summaryrefslogtreecommitdiffstats
path: root/layout/base/nsCSSRendering.h
diff options
context:
space:
mode:
authorAndy <webmaster@RealityRipple.com>2020-07-31 13:01:18 -0700
committerMoonchild <moonchild@palemoon.org>2020-08-07 21:27:29 +0000
commit3266e0976ff055aefa49b664966229bbb89d1009 (patch)
tree41603b23ec1667a191fe0714d72a2d2649d77125 /layout/base/nsCSSRendering.h
parent4433519ae8b7e1cc14e217c3e20d8bca3f9cf2f2 (diff)
downloadUXP-3266e0976ff055aefa49b664966229bbb89d1009.tar
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.gz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.lz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.xz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.zip
Issue #1619 - Convert Intrinsic Ratio to Float
https://bugzilla.mozilla.org/show_bug.cgi?id=1547792 Aspect Ratio handling simplified by using floating point integers: - Multiplication of value (or inverse value) to a known side for Scaling - No unequal equal values such as "4/3" vs "8/6" vs "20/15" - Truly "Empty" aspect ratios, even if one dimension is not 0
Diffstat (limited to 'layout/base/nsCSSRendering.h')
-rw-r--r--layout/base/nsCSSRendering.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h
index 791e9656e..8ebeb7537 100644
--- a/layout/base/nsCSSRendering.h
+++ b/layout/base/nsCSSRendering.h
@@ -17,6 +17,7 @@
#include "nsLayoutUtils.h"
#include "nsStyleStruct.h"
#include "nsIFrame.h"
+#include "mozilla/AspectRatio.h"
class gfxDrawable;
class nsStyleContext;
@@ -41,8 +42,7 @@ class ImageContainer;
struct CSSSizeOrRatio
{
CSSSizeOrRatio()
- : mRatio(0, 0)
- , mHasWidth(false)
+ : mHasWidth(false)
, mHasHeight(false) {}
bool CanComputeConcreteSize() const
@@ -50,12 +50,12 @@ struct CSSSizeOrRatio
return mHasWidth + mHasHeight + HasRatio() >= 2;
}
bool IsConcrete() const { return mHasWidth && mHasHeight; }
- bool HasRatio() const { return mRatio.width > 0 && mRatio.height > 0; }
+ bool HasRatio() const { return !!mRatio; }
bool IsEmpty() const
{
return (mHasWidth && mWidth <= 0) ||
(mHasHeight && mHeight <= 0) ||
- mRatio.width <= 0 || mRatio.height <= 0;
+ !mRatio;
}
// CanComputeConcreteSize must return true when ComputeConcreteSize is
@@ -67,7 +67,7 @@ struct CSSSizeOrRatio
mWidth = aWidth;
mHasWidth = true;
if (mHasHeight) {
- mRatio = nsSize(mWidth, mHeight);
+ mRatio = AspectRatio::FromSize(mWidth, mHeight);
}
}
void SetHeight(nscoord aHeight)
@@ -75,7 +75,7 @@ struct CSSSizeOrRatio
mHeight = aHeight;
mHasHeight = true;
if (mHasWidth) {
- mRatio = nsSize(mWidth, mHeight);
+ mRatio = AspectRatio::FromSize(mWidth, mHeight);
}
}
void SetSize(const nsSize& aSize)
@@ -84,16 +84,16 @@ struct CSSSizeOrRatio
mHeight = aSize.height;
mHasWidth = true;
mHasHeight = true;
- mRatio = aSize;
+ mRatio = AspectRatio::FromSize(mWidth, mHeight);
}
- void SetRatio(const nsSize& aRatio)
+ void SetRatio(const AspectRatio& aRatio)
{
MOZ_ASSERT(!mHasWidth || !mHasHeight,
"Probably shouldn't be setting a ratio if we have a concrete size");
mRatio = aRatio;
}
- nsSize mRatio;
+ AspectRatio mRatio;
nscoord mWidth;
nscoord mHeight;
bool mHasWidth;
@@ -184,11 +184,9 @@ public:
/**
* Compute the size of the rendered image using either the 'cover' or
* 'contain' constraints (aFitType).
- * aIntrinsicRatio may be an invalid ratio, that is one or both of its
- * dimensions can be less than or equal to zero.
*/
static nsSize ComputeConstrainedSize(const nsSize& aConstrainingSize,
- const nsSize& aIntrinsicRatio,
+ const mozilla::AspectRatio& aIntrinsicRatio,
FitType aFitType);
/**
* Compute the size of the rendered image (the concrete size) where no cover/