diff options
Diffstat (limited to 'layout/base/nsCSSRendering.h')
-rw-r--r-- | layout/base/nsCSSRendering.h | 22 |
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/ |