diff --git a/dom/svg/SVGAnimatedViewBox.cpp b/dom/svg/SVGAnimatedViewBox.cpp index 1c4ffef3d7fb..119e125904e7 100644 --- a/dom/svg/SVGAnimatedViewBox.cpp +++ b/dom/svg/SVGAnimatedViewBox.cpp @@ -19,9 +19,9 @@ namespace mozilla { #define NUM_VIEWBOX_COMPONENTS 4 -/* Implementation of SVGViewBoxRect methods */ +/* Implementation of SVGViewBox methods */ -bool SVGViewBoxRect::operator==(const SVGViewBoxRect& aOther) const { +bool SVGViewBox::operator==(const SVGViewBox& aOther) const { if (&aOther == this) return true; return (none && aOther.none) || @@ -30,8 +30,7 @@ bool SVGViewBoxRect::operator==(const SVGViewBoxRect& aOther) const { } /* static */ -nsresult SVGViewBoxRect::FromString(const nsAString& aStr, - SVGViewBoxRect* aViewBox) { +nsresult SVGViewBox::FromString(const nsAString& aStr, SVGViewBox* aViewBox) { if (aStr.EqualsLiteral("none")) { aViewBox->none = true; return NS_OK; @@ -107,7 +106,7 @@ void SVGAnimatedViewBox::Init() { bool SVGAnimatedViewBox::HasRect() const { // Check mAnimVal if we have one; otherwise, check mBaseVal if we have one; // otherwise, just return false (we clearly do not have a rect). - const SVGViewBoxRect* rect = mAnimVal; + const SVGViewBox* rect = mAnimVal; if (!rect) { if (!mHasBaseVal) { // no anim val, no base val --> no viewbox rect @@ -119,11 +118,11 @@ bool SVGAnimatedViewBox::HasRect() const { return !rect->none && rect->width >= 0 && rect->height >= 0; } -void SVGAnimatedViewBox::SetAnimValue(const SVGViewBoxRect& aRect, +void SVGAnimatedViewBox::SetAnimValue(const SVGViewBox& aRect, SVGElement* aSVGElement) { if (!mAnimVal) { // it's okay if allocation fails - and no point in reporting that - mAnimVal = new SVGViewBoxRect(aRect); + mAnimVal = new SVGViewBox(aRect); } else { if (aRect == *mAnimVal) { return; @@ -133,7 +132,7 @@ void SVGAnimatedViewBox::SetAnimValue(const SVGViewBoxRect& aRect, aSVGElement->DidAnimateViewBox(); } -void SVGAnimatedViewBox::SetBaseValue(const SVGViewBoxRect& aRect, +void SVGAnimatedViewBox::SetBaseValue(const SVGViewBox& aRect, SVGElement* aSVGElement) { if (!mHasBaseVal || mBaseVal == aRect) { // This method is used to set a single x, y, width @@ -158,9 +157,9 @@ void SVGAnimatedViewBox::SetBaseValue(const SVGViewBoxRect& aRect, nsresult SVGAnimatedViewBox::SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement, bool aDoSetAttr) { - SVGViewBoxRect viewBox; + SVGViewBox viewBox; - nsresult rv = SVGViewBoxRect::FromString(aValue, &viewBox); + nsresult rv = SVGViewBox::FromString(aValue, &viewBox); if (NS_FAILED(rv)) { return rv; } @@ -247,26 +246,26 @@ SVGAnimatedViewBox::DOMAnimVal::~DOMAnimVal() { } void SVGAnimatedViewBox::DOMBaseVal::SetX(float aX, ErrorResult& aRv) { - SVGViewBoxRect rect = mVal->GetBaseValue(); + SVGViewBox rect = mVal->GetBaseValue(); rect.x = aX; mVal->SetBaseValue(rect, mSVGElement); } void SVGAnimatedViewBox::DOMBaseVal::SetY(float aY, ErrorResult& aRv) { - SVGViewBoxRect rect = mVal->GetBaseValue(); + SVGViewBox rect = mVal->GetBaseValue(); rect.y = aY; mVal->SetBaseValue(rect, mSVGElement); } void SVGAnimatedViewBox::DOMBaseVal::SetWidth(float aWidth, ErrorResult& aRv) { - SVGViewBoxRect rect = mVal->GetBaseValue(); + SVGViewBox rect = mVal->GetBaseValue(); rect.width = aWidth; mVal->SetBaseValue(rect, mSVGElement); } void SVGAnimatedViewBox::DOMBaseVal::SetHeight(float aHeight, ErrorResult& aRv) { - SVGViewBoxRect rect = mVal->GetBaseValue(); + SVGViewBox rect = mVal->GetBaseValue(); rect.height = aHeight; mVal->SetBaseValue(rect, mSVGElement); } @@ -278,13 +277,13 @@ UniquePtr SVGAnimatedViewBox::ToSMILAttr(SVGElement* aSVGElement) { nsresult SVGAnimatedViewBox::SMILViewBox ::ValueFromString( const nsAString& aStr, const SVGAnimationElement* /*aSrcElement*/, SMILValue& aValue, bool& aPreventCachingOfSandwich) const { - SVGViewBoxRect viewBox; - nsresult res = SVGViewBoxRect::FromString(aStr, &viewBox); + SVGViewBox viewBox; + nsresult res = SVGViewBox::FromString(aStr, &viewBox); if (NS_FAILED(res)) { return res; } SMILValue val(&SVGViewBoxSMILType::sSingleton); - *static_cast(val.mU.mPtr) = viewBox; + *static_cast(val.mU.mPtr) = viewBox; aValue = std::move(val); aPreventCachingOfSandwich = false; @@ -293,7 +292,7 @@ nsresult SVGAnimatedViewBox::SMILViewBox ::ValueFromString( SMILValue SVGAnimatedViewBox::SMILViewBox::GetBaseValue() const { SMILValue val(&SVGViewBoxSMILType::sSingleton); - *static_cast(val.mU.mPtr) = mVal->mBaseVal; + *static_cast(val.mU.mPtr) = mVal->mBaseVal; return val; } @@ -309,7 +308,7 @@ nsresult SVGAnimatedViewBox::SMILViewBox::SetAnimValue( NS_ASSERTION(aValue.mType == &SVGViewBoxSMILType::sSingleton, "Unexpected type to assign animated value"); if (aValue.mType == &SVGViewBoxSMILType::sSingleton) { - SVGViewBoxRect& vb = *static_cast(aValue.mU.mPtr); + SVGViewBox& vb = *static_cast(aValue.mU.mPtr); mVal->SetAnimValue(vb, mSVGElement); } return NS_OK; diff --git a/dom/svg/SVGAnimatedViewBox.h b/dom/svg/SVGAnimatedViewBox.h index 681b0c7c6e02..6eb50ea267af 100644 --- a/dom/svg/SVGAnimatedViewBox.h +++ b/dom/svg/SVGAnimatedViewBox.h @@ -26,23 +26,23 @@ class SVGAnimationElement; class SVGElement; } // namespace dom -struct SVGViewBoxRect { +struct SVGViewBox { float x, y; float width, height; bool none; - SVGViewBoxRect() : x(0.0), y(0.0), width(0.0), height(0.0), none(true) {} - SVGViewBoxRect(float aX, float aY, float aWidth, float aHeight) + SVGViewBox() : x(0.0), y(0.0), width(0.0), height(0.0), none(true) {} + SVGViewBox(float aX, float aY, float aWidth, float aHeight) : x(aX), y(aY), width(aWidth), height(aHeight), none(false) {} - SVGViewBoxRect(const SVGViewBoxRect& rhs) + SVGViewBox(const SVGViewBox& rhs) : x(rhs.x), y(rhs.y), width(rhs.width), height(rhs.height), none(rhs.none) {} - bool operator==(const SVGViewBoxRect& aOther) const; + bool operator==(const SVGViewBox& aOther) const; - static nsresult FromString(const nsAString& aStr, SVGViewBoxRect* aViewBox); + static nsresult FromString(const nsAString& aStr, SVGViewBox* aViewBox); }; class SVGAnimatedViewBox { @@ -66,18 +66,18 @@ class SVGAnimatedViewBox { */ bool IsExplicitlySet() const { if (mAnimVal || mHasBaseVal) { - const SVGViewBoxRect& rect = GetAnimValue(); + const SVGViewBox& rect = GetAnimValue(); return rect.none || (rect.width >= 0 && rect.height >= 0); } return false; } - const SVGViewBoxRect& GetBaseValue() const { return mBaseVal; } - void SetBaseValue(const SVGViewBoxRect& aRect, SVGElement* aSVGElement); - const SVGViewBoxRect& GetAnimValue() const { + const SVGViewBox& GetBaseValue() const { return mBaseVal; } + void SetBaseValue(const SVGViewBox& aRect, SVGElement* aSVGElement); + const SVGViewBox& GetAnimValue() const { return mAnimVal ? *mAnimVal : mBaseVal; } - void SetAnimValue(const SVGViewBoxRect& aRect, SVGElement* aSVGElement); + void SetAnimValue(const SVGViewBox& aRect, SVGElement* aSVGElement); nsresult SetBaseValueString(const nsAString& aValue, SVGElement* aSVGElement, bool aDoSetAttr); @@ -95,8 +95,8 @@ class SVGAnimatedViewBox { mozilla::UniquePtr ToSMILAttr(SVGElement* aSVGElement); private: - SVGViewBoxRect mBaseVal; - nsAutoPtr mAnimVal; + SVGViewBox mBaseVal; + nsAutoPtr mAnimVal; bool mHasBaseVal; public: diff --git a/dom/svg/SVGElement.cpp b/dom/svg/SVGElement.cpp index 737f82d9dd63..ba22350aacb9 100644 --- a/dom/svg/SVGElement.cpp +++ b/dom/svg/SVGElement.cpp @@ -173,20 +173,20 @@ nsresult SVGElement::Init() { enumInfo.Reset(i); } - SVGAnimatedOrient* orient = GetOrient(); + SVGAnimatedOrient* orient = GetAnimatedOrient(); if (orient) { orient->Init(); } - SVGAnimatedViewBox* viewBox = GetViewBox(); + SVGAnimatedViewBox* viewBox = GetAnimatedViewBox(); if (viewBox) { viewBox->Init(); } SVGAnimatedPreserveAspectRatio* preserveAspectRatio = - GetPreserveAspectRatio(); + GetAnimatedPreserveAspectRatio(); if (preserveAspectRatio) { preserveAspectRatio->Init(); @@ -532,7 +532,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, if (!foundMatch) { // Check for orient attribute if (aAttribute == nsGkAtoms::orient) { - SVGAnimatedOrient* orient = GetOrient(); + SVGAnimatedOrient* orient = GetAnimatedOrient(); if (orient) { rv = orient->SetBaseValueString(aValue, this, false); if (NS_FAILED(rv)) { @@ -545,7 +545,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, } // Check for viewBox attribute } else if (aAttribute == nsGkAtoms::viewBox) { - SVGAnimatedViewBox* viewBox = GetViewBox(); + SVGAnimatedViewBox* viewBox = GetAnimatedViewBox(); if (viewBox) { rv = viewBox->SetBaseValueString(aValue, this, false); if (NS_FAILED(rv)) { @@ -559,7 +559,7 @@ bool SVGElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, // Check for preserveAspectRatio attribute } else if (aAttribute == nsGkAtoms::preserveAspectRatio) { SVGAnimatedPreserveAspectRatio* preserveAspectRatio = - GetPreserveAspectRatio(); + GetAnimatedPreserveAspectRatio(); if (preserveAspectRatio) { rv = preserveAspectRatio->SetBaseValueString(aValue, this, false); if (NS_FAILED(rv)) { @@ -768,7 +768,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName, // Check if this is an orient attribute going away if (aName == nsGkAtoms::orient) { - SVGAnimatedOrient* orient = GetOrient(); + SVGAnimatedOrient* orient = GetAnimatedOrient(); if (orient) { MaybeSerializeAttrBeforeRemoval(aName, aNotify); orient->Init(); @@ -778,7 +778,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName, // Check if this is a viewBox attribute going away if (aName == nsGkAtoms::viewBox) { - SVGAnimatedViewBox* viewBox = GetViewBox(); + SVGAnimatedViewBox* viewBox = GetAnimatedViewBox(); if (viewBox) { MaybeSerializeAttrBeforeRemoval(aName, aNotify); viewBox->Init(); @@ -789,7 +789,7 @@ void SVGElement::UnsetAttrInternal(int32_t aNamespaceID, nsAtom* aName, // Check if this is a preserveAspectRatio attribute going away if (aName == nsGkAtoms::preserveAspectRatio) { SVGAnimatedPreserveAspectRatio* preserveAspectRatio = - GetPreserveAspectRatio(); + GetAnimatedPreserveAspectRatio(); if (preserveAspectRatio) { MaybeSerializeAttrBeforeRemoval(aName, aNotify); preserveAspectRatio->Init(); @@ -1885,14 +1885,14 @@ void SVGElement::DidAnimateEnum(uint8_t aAttrEnum) { } } -SVGAnimatedOrient* SVGElement::GetOrient() { return nullptr; } +SVGAnimatedOrient* SVGElement::GetAnimatedOrient() { return nullptr; } nsAttrValue SVGElement::WillChangeOrient() { return WillChangeValue(nsGkAtoms::orient); } void SVGElement::DidChangeOrient(const nsAttrValue& aEmptyOrOldValue) { - SVGAnimatedOrient* orient = GetOrient(); + SVGAnimatedOrient* orient = GetAnimatedOrient(); NS_ASSERTION(orient, "DidChangeOrient on element with no orient attrib"); @@ -1911,14 +1911,14 @@ void SVGElement::DidAnimateOrient() { } } -SVGAnimatedViewBox* SVGElement::GetViewBox() { return nullptr; } +SVGAnimatedViewBox* SVGElement::GetAnimatedViewBox() { return nullptr; } nsAttrValue SVGElement::WillChangeViewBox() { return WillChangeValue(nsGkAtoms::viewBox); } void SVGElement::DidChangeViewBox(const nsAttrValue& aEmptyOrOldValue) { - SVGAnimatedViewBox* viewBox = GetViewBox(); + SVGAnimatedViewBox* viewBox = GetAnimatedViewBox(); NS_ASSERTION(viewBox, "DidChangeViewBox on element with no viewBox attrib"); @@ -1937,7 +1937,7 @@ void SVGElement::DidAnimateViewBox() { } } -SVGAnimatedPreserveAspectRatio* SVGElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* SVGElement::GetAnimatedPreserveAspectRatio() { return nullptr; } @@ -1948,7 +1948,7 @@ nsAttrValue SVGElement::WillChangePreserveAspectRatio() { void SVGElement::DidChangePreserveAspectRatio( const nsAttrValue& aEmptyOrOldValue) { SVGAnimatedPreserveAspectRatio* preserveAspectRatio = - GetPreserveAspectRatio(); + GetAnimatedPreserveAspectRatio(); NS_ASSERTION(preserveAspectRatio, "DidChangePreserveAspectRatio on element with no " @@ -2222,20 +2222,20 @@ UniquePtr SVGElement::GetAnimatedAttr(int32_t aNamespaceID, // orient: if (aName == nsGkAtoms::orient) { - SVGAnimatedOrient* orient = GetOrient(); + SVGAnimatedOrient* orient = GetAnimatedOrient(); return orient ? orient->ToSMILAttr(this) : nullptr; } // viewBox: if (aName == nsGkAtoms::viewBox) { - SVGAnimatedViewBox* viewBox = GetViewBox(); + SVGAnimatedViewBox* viewBox = GetAnimatedViewBox(); return viewBox ? viewBox->ToSMILAttr(this) : nullptr; } // preserveAspectRatio: if (aName == nsGkAtoms::preserveAspectRatio) { SVGAnimatedPreserveAspectRatio* preserveAspectRatio = - GetPreserveAspectRatio(); + GetAnimatedPreserveAspectRatio(); return preserveAspectRatio ? preserveAspectRatio->ToSMILAttr(this) : nullptr; } diff --git a/dom/svg/SVGElement.h b/dom/svg/SVGElement.h index ed258cf5dbc1..b5f29baca253 100644 --- a/dom/svg/SVGElement.h +++ b/dom/svg/SVGElement.h @@ -567,9 +567,9 @@ class SVGElement : public SVGElementBase // nsIContent virtual EnumAttributesInfo GetEnumInfo(); // We assume all orients, viewboxes and preserveAspectRatios are alike // so we don't need to wrap the class - virtual SVGAnimatedOrient* GetOrient(); - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio(); - virtual SVGAnimatedViewBox* GetViewBox(); + virtual SVGAnimatedOrient* GetAnimatedOrient(); + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio(); + virtual SVGAnimatedViewBox* GetAnimatedViewBox(); virtual NumberListAttributesInfo GetNumberListInfo(); virtual LengthListAttributesInfo GetLengthListInfo(); virtual StringAttributesInfo GetStringInfo(); diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index 8b87c61c46a6..b487917f9930 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -284,7 +284,8 @@ SVGFEImageElement::PreserveAspectRatio() { return mPreserveAspectRatio.ToDOMAnimatedPreserveAspectRatio(this); } -SVGAnimatedPreserveAspectRatio* SVGFEImageElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGFEImageElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } diff --git a/dom/svg/SVGFEImageElement.h b/dom/svg/SVGFEImageElement.h index 7a10990c76a3..c88a71cb2e8d 100644 --- a/dom/svg/SVGFEImageElement.h +++ b/dom/svg/SVGFEImageElement.h @@ -88,7 +88,8 @@ class SVGFEImageElement final : public SVGFEImageElementBase, protected: virtual bool ProducesSRGB() override { return true; } - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; virtual StringAttributesInfo GetStringInfo() override; // Override for nsImageLoadingContent. diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index 8d64e5c54892..0bbab6cb3049 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -279,7 +279,8 @@ SVGElement::LengthAttributesInfo SVGImageElement::GetLengthInfo() { ArrayLength(sLengthInfo)); } -SVGAnimatedPreserveAspectRatio* SVGImageElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGImageElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } diff --git a/dom/svg/SVGImageElement.h b/dom/svg/SVGImageElement.h index ca6ff67d20c7..ed48fd794f8f 100644 --- a/dom/svg/SVGImageElement.h +++ b/dom/svg/SVGImageElement.h @@ -99,7 +99,8 @@ class SVGImageElement : public SVGImageElementBase, nsresult LoadSVGImage(bool aForce, bool aNotify); virtual LengthAttributesInfo GetLengthInfo() override; - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; virtual StringAttributesInfo GetStringInfo() override; // Override for nsImageLoadingContent. diff --git a/dom/svg/SVGMarkerElement.cpp b/dom/svg/SVGMarkerElement.cpp index 2c65cceeb759..ba5347e393c2 100644 --- a/dom/svg/SVGMarkerElement.cpp +++ b/dom/svg/SVGMarkerElement.cpp @@ -165,11 +165,12 @@ SVGElement::EnumAttributesInfo SVGMarkerElement::GetEnumInfo() { return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo)); } -SVGAnimatedOrient* SVGMarkerElement::GetOrient() { return &mOrient; } +SVGAnimatedOrient* SVGMarkerElement::GetAnimatedOrient() { return &mOrient; } -SVGAnimatedViewBox* SVGMarkerElement::GetViewBox() { return &mViewBox; } +SVGAnimatedViewBox* SVGMarkerElement::GetAnimatedViewBox() { return &mViewBox; } -SVGAnimatedPreserveAspectRatio* SVGMarkerElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGMarkerElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } @@ -200,13 +201,13 @@ gfx::Matrix SVGMarkerElement::GetMarkerTransform(float aStrokeWidth, -sin(angle) * scale, cos(angle) * scale, aMark.x, aMark.y); } -SVGViewBoxRect SVGMarkerElement::GetViewBoxRect() { +SVGViewBox SVGMarkerElement::GetViewBox() { if (mViewBox.HasRect()) { return mViewBox.GetAnimValue(); } - return SVGViewBoxRect( - 0, 0, mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx), - mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx)); + return SVGViewBox(0, 0, + mLengthAttributes[MARKERWIDTH].GetAnimValue(mCoordCtx), + mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx)); } gfx::Matrix SVGMarkerElement::GetViewBoxTransform() { @@ -216,7 +217,7 @@ gfx::Matrix SVGMarkerElement::GetViewBoxTransform() { float viewportHeight = mLengthAttributes[MARKERHEIGHT].GetAnimValue(mCoordCtx); - SVGViewBoxRect viewbox = GetViewBoxRect(); + SVGViewBox viewbox = GetViewBox(); MOZ_ASSERT(viewbox.width > 0.0f && viewbox.height > 0.0f, "Rendering should be disabled"); diff --git a/dom/svg/SVGMarkerElement.h b/dom/svg/SVGMarkerElement.h index 36a7a067df5c..9f72fb6c3898 100644 --- a/dom/svg/SVGMarkerElement.h +++ b/dom/svg/SVGMarkerElement.h @@ -56,7 +56,7 @@ class SVGMarkerElement : public SVGMarkerElementBase { // public helpers gfx::Matrix GetMarkerTransform(float aStrokeWidth, const SVGMark& aMark); - SVGViewBoxRect GetViewBoxRect(); + SVGViewBox GetViewBox(); gfx::Matrix GetViewBoxTransform(); virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; @@ -79,9 +79,10 @@ class SVGMarkerElement : public SVGMarkerElementBase { virtual LengthAttributesInfo GetLengthInfo() override; virtual EnumAttributesInfo GetEnumInfo() override; - virtual SVGAnimatedOrient* GetOrient() override; - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; - virtual SVGAnimatedViewBox* GetViewBox() override; + virtual SVGAnimatedOrient* GetAnimatedOrient() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; + virtual SVGAnimatedViewBox* GetAnimatedViewBox() override; enum { REFX, REFY, MARKERWIDTH, MARKERHEIGHT }; SVGAnimatedLength mLengthAttributes[4]; diff --git a/dom/svg/SVGPatternElement.cpp b/dom/svg/SVGPatternElement.cpp index 8835c97c8d2f..36b2c6859953 100644 --- a/dom/svg/SVGPatternElement.cpp +++ b/dom/svg/SVGPatternElement.cpp @@ -162,9 +162,12 @@ SVGElement::EnumAttributesInfo SVGPatternElement::GetEnumInfo() { return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo)); } -SVGAnimatedViewBox* SVGPatternElement::GetViewBox() { return &mViewBox; } +SVGAnimatedViewBox* SVGPatternElement::GetAnimatedViewBox() { + return &mViewBox; +} -SVGAnimatedPreserveAspectRatio* SVGPatternElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGPatternElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } diff --git a/dom/svg/SVGPatternElement.h b/dom/svg/SVGPatternElement.h index b93fc5557f2a..03e92de70a0e 100644 --- a/dom/svg/SVGPatternElement.h +++ b/dom/svg/SVGPatternElement.h @@ -73,8 +73,9 @@ class SVGPatternElement final : public SVGPatternElementBase { virtual LengthAttributesInfo GetLengthInfo() override; virtual EnumAttributesInfo GetEnumInfo() override; virtual StringAttributesInfo GetStringInfo() override; - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; - virtual SVGAnimatedViewBox* GetViewBox() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; + virtual SVGAnimatedViewBox* GetAnimatedViewBox() override; enum { ATTR_X, ATTR_Y, ATTR_WIDTH, ATTR_HEIGHT }; SVGAnimatedLength mLengthAttributes[4]; diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp index 901b02ce9b44..b341d30d3b49 100644 --- a/dom/svg/SVGSVGElement.cpp +++ b/dom/svg/SVGSVGElement.cpp @@ -524,15 +524,15 @@ void SVGSVGElement::SetImageOverridePreserveAspectRatio( MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(), "should only override preserveAspectRatio in images"); - bool hasViewBoxRect = HasViewBoxRect(); - if (!hasViewBoxRect && ShouldSynthesizeViewBox()) { + bool hasViewBox = HasViewBox(); + if (!hasViewBox && ShouldSynthesizeViewBox()) { // My non- clients will have been painting me with a synthesized // viewBox, but my client that's about to paint me now does NOT // want that. Need to tell ourselves to flush our transform. mImageNeedsTransformInvalidation = true; } - if (!hasViewBoxRect) { + if (!hasViewBox) { return; // preserveAspectRatio irrelevant (only matters if we have viewBox) } @@ -545,7 +545,7 @@ void SVGSVGElement::ClearImageOverridePreserveAspectRatio() { MOZ_ASSERT(OwnerDoc()->IsBeingUsedAsImage(), "should only override image preserveAspectRatio in images"); - if (!HasViewBoxRect() && ShouldSynthesizeViewBox()) { + if (!HasViewBox() && ShouldSynthesizeViewBox()) { // My non- clients will want to paint me with a synthesized // viewBox, but my client that just painted me did NOT // use that. Need to tell ourselves to flush our transform. @@ -603,9 +603,9 @@ SVGPreserveAspectRatio SVGSVGElement::GetPreserveAspectRatioWithOverride() SVGViewElement* viewElement = GetCurrentViewElement(); - // This check is equivalent to "!HasViewBoxRect() && + // This check is equivalent to "!HasViewBox() && // ShouldSynthesizeViewBox()". We're just holding onto the viewElement that - // HasViewBoxRect() would look up, so that we don't have to look it up again + // HasViewBox() would look up, so that we don't have to look it up again // later. if (!((viewElement && viewElement->mViewBox.HasRect()) || (mSVGView && mSVGView->mViewBox.HasRect()) || mViewBox.HasRect()) && diff --git a/dom/svg/SVGViewBoxSMILType.cpp b/dom/svg/SVGViewBoxSMILType.cpp index 754b13100f98..669cc35a5d8b 100644 --- a/dom/svg/SVGViewBoxSMILType.cpp +++ b/dom/svg/SVGViewBoxSMILType.cpp @@ -19,13 +19,13 @@ SVGViewBoxSMILType SVGViewBoxSMILType::sSingleton; void SVGViewBoxSMILType::Init(SMILValue& aValue) const { MOZ_ASSERT(aValue.IsNull(), "Unexpected value type"); - aValue.mU.mPtr = new SVGViewBoxRect(); + aValue.mU.mPtr = new SVGViewBox(); aValue.mType = this; } void SVGViewBoxSMILType::Destroy(SMILValue& aValue) const { MOZ_ASSERT(aValue.mType == this, "Unexpected SMIL value"); - delete static_cast(aValue.mU.mPtr); + delete static_cast(aValue.mU.mPtr); aValue.mU.mPtr = nullptr; aValue.mType = SMILNullType::Singleton(); } @@ -35,8 +35,8 @@ nsresult SVGViewBoxSMILType::Assign(SMILValue& aDest, MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types"); MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL value"); - const SVGViewBoxRect* src = static_cast(aSrc.mU.mPtr); - SVGViewBoxRect* dst = static_cast(aDest.mU.mPtr); + const SVGViewBox* src = static_cast(aSrc.mU.mPtr); + SVGViewBox* dst = static_cast(aDest.mU.mPtr); *dst = *src; return NS_OK; } @@ -46,9 +46,8 @@ bool SVGViewBoxSMILType::IsEqual(const SMILValue& aLeft, MOZ_ASSERT(aLeft.mType == aRight.mType, "Incompatible SMIL types"); MOZ_ASSERT(aLeft.mType == this, "Unexpected type for SMIL value"); - const SVGViewBoxRect* leftBox = - static_cast(aLeft.mU.mPtr); - const SVGViewBoxRect* rightBox = static_cast(aRight.mU.mPtr); + const SVGViewBox* leftBox = static_cast(aLeft.mU.mPtr); + const SVGViewBox* rightBox = static_cast(aRight.mU.mPtr); return *leftBox == *rightBox; } @@ -70,9 +69,8 @@ nsresult SVGViewBoxSMILType::ComputeDistance(const SMILValue& aFrom, MOZ_ASSERT(aFrom.mType == aTo.mType, "Trying to compare different types"); MOZ_ASSERT(aFrom.mType == this, "Unexpected source type"); - const SVGViewBoxRect* from = - static_cast(aFrom.mU.mPtr); - const SVGViewBoxRect* to = static_cast(aTo.mU.mPtr); + const SVGViewBox* from = static_cast(aFrom.mU.mPtr); + const SVGViewBox* to = static_cast(aTo.mU.mPtr); if (from->none || to->none) { return NS_ERROR_FAILURE; @@ -104,16 +102,14 @@ nsresult SVGViewBoxSMILType::Interpolate(const SMILValue& aStartVal, MOZ_ASSERT(aStartVal.mType == this, "Unexpected types for interpolation"); MOZ_ASSERT(aResult.mType == this, "Unexpected result type"); - const SVGViewBoxRect* start = - static_cast(aStartVal.mU.mPtr); - const SVGViewBoxRect* end = - static_cast(aEndVal.mU.mPtr); + const SVGViewBox* start = static_cast(aStartVal.mU.mPtr); + const SVGViewBox* end = static_cast(aEndVal.mU.mPtr); if (start->none || end->none) { return NS_ERROR_FAILURE; } - SVGViewBoxRect* current = static_cast(aResult.mU.mPtr); + SVGViewBox* current = static_cast(aResult.mU.mPtr); float x = (start->x + (end->x - start->x) * aUnitDistance); float y = (start->y + (end->y - start->y) * aUnitDistance); @@ -121,7 +117,7 @@ nsresult SVGViewBoxSMILType::Interpolate(const SMILValue& aStartVal, float height = (start->height + (end->height - start->height) * aUnitDistance); - *current = SVGViewBoxRect(x, y, width, height); + *current = SVGViewBox(x, y, width, height); return NS_OK; } diff --git a/dom/svg/SVGViewElement.cpp b/dom/svg/SVGViewElement.cpp index aec1bcde006c..c992596918a9 100644 --- a/dom/svg/SVGViewElement.cpp +++ b/dom/svg/SVGViewElement.cpp @@ -67,9 +67,10 @@ SVGElement::EnumAttributesInfo SVGViewElement::GetEnumInfo() { return EnumAttributesInfo(mEnumAttributes, sEnumInfo, ArrayLength(sEnumInfo)); } -SVGAnimatedViewBox* SVGViewElement::GetViewBox() { return &mViewBox; } +SVGAnimatedViewBox* SVGViewElement::GetAnimatedViewBox() { return &mViewBox; } -SVGAnimatedPreserveAspectRatio* SVGViewElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGViewElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } diff --git a/dom/svg/SVGViewElement.h b/dom/svg/SVGViewElement.h index 94db68155694..b8881d09221d 100644 --- a/dom/svg/SVGViewElement.h +++ b/dom/svg/SVGViewElement.h @@ -58,8 +58,9 @@ class SVGViewElement : public SVGViewElementBase { static SVGEnumMapping sZoomAndPanMap[]; static EnumInfo sEnumInfo[1]; - virtual SVGAnimatedViewBox* GetViewBox() override; - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; + virtual SVGAnimatedViewBox* GetAnimatedViewBox() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; SVGAnimatedViewBox mViewBox; SVGAnimatedPreserveAspectRatio mPreserveAspectRatio; diff --git a/dom/svg/SVGViewportElement.cpp b/dom/svg/SVGViewportElement.cpp index d9a48b301212..eca0f2206dcd 100644 --- a/dom/svg/SVGViewportElement.cpp +++ b/dom/svg/SVGViewportElement.cpp @@ -185,8 +185,7 @@ gfx::Matrix SVGViewportElement::GetViewBoxTransform() const { return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular } - SVGViewBoxRect viewBox = - GetViewBoxWithSynthesis(viewportWidth, viewportHeight); + SVGViewBox viewBox = GetViewBoxWithSynthesis(viewportWidth, viewportHeight); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { return gfx::Matrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular @@ -200,9 +199,9 @@ gfx::Matrix SVGViewportElement::GetViewBoxTransform() const { // SVGViewportElement float SVGViewportElement::GetLength(uint8_t aCtxType) { - const SVGViewBoxRect* viewbox = GetViewBoxInternal().HasRect() - ? &GetViewBoxInternal().GetAnimValue() - : nullptr; + const SVGViewBox* viewbox = GetViewBoxInternal().HasRect() + ? &GetViewBoxInternal().GetAnimValue() + : nullptr; float h = 0.0f, w = 0.0f; bool shouldComputeWidth = @@ -310,14 +309,17 @@ bool SVGViewportElement::HasValidDimensions() const { mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0)); } -SVGAnimatedViewBox* SVGViewportElement::GetViewBox() { return &mViewBox; } +SVGAnimatedViewBox* SVGViewportElement::GetAnimatedViewBox() { + return &mViewBox; +} -SVGAnimatedPreserveAspectRatio* SVGViewportElement::GetPreserveAspectRatio() { +SVGAnimatedPreserveAspectRatio* +SVGViewportElement::GetAnimatedPreserveAspectRatio() { return &mPreserveAspectRatio; } bool SVGViewportElement::ShouldSynthesizeViewBox() const { - MOZ_ASSERT(!HasViewBoxRect(), "Should only be called if we lack a viewBox"); + MOZ_ASSERT(!HasViewBox(), "Should only be called if we lack a viewBox"); return IsRoot() && OwnerDoc()->IsBeingUsedAsImage(); } @@ -325,7 +327,7 @@ bool SVGViewportElement::ShouldSynthesizeViewBox() const { //---------------------------------------------------------------------- // implementation helpers -SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis( +SVGViewBox SVGViewportElement::GetViewBoxWithSynthesis( float aViewportWidth, float aViewportHeight) const { if (GetViewBoxInternal().HasRect()) { return GetViewBoxInternal().GetAnimValue(); @@ -334,7 +336,7 @@ SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis( if (ShouldSynthesizeViewBox()) { // Special case -- fake a viewBox, using height & width attrs. // (Use |this| as context, since if we get here, we're outermost .) - return SVGViewBoxRect( + return SVGViewBox( 0, 0, ComputeSynthesizedViewBoxDimension(mLengthAttributes[ATTR_WIDTH], mViewportWidth, this), @@ -344,7 +346,7 @@ SVGViewBoxRect SVGViewportElement::GetViewBoxWithSynthesis( // No viewBox attribute, so we shouldn't auto-scale. This is equivalent // to having a viewBox that exactly matches our viewport size. - return SVGViewBoxRect(0, 0, aViewportWidth, aViewportHeight); + return SVGViewBox(0, 0, aViewportWidth, aViewportHeight); } SVGElement::LengthAttributesInfo SVGViewportElement::GetLengthInfo() { diff --git a/dom/svg/SVGViewportElement.h b/dom/svg/SVGViewportElement.h index aeb9dd1ab370..c8b31b9c3c5a 100644 --- a/dom/svg/SVGViewportElement.h +++ b/dom/svg/SVGViewportElement.h @@ -79,19 +79,19 @@ class SVGViewportElement : public SVGGraphicsElement { * Note also that this method does not pay attention to whether the width or * height values of the viewBox rect are positive! */ - bool HasViewBoxRect() const { return GetViewBoxInternal().HasRect(); } + bool HasViewBox() const { return GetViewBoxInternal().HasRect(); } /** * Returns true if we should synthesize a viewBox for ourselves (that is, if * we're the root element in an image document, and we're not currently being * painted for an element). * - * Only call this method if HasViewBoxRect() returns false. + * Only call this method if HasViewBox() returns false. */ bool ShouldSynthesizeViewBox() const; bool HasViewBoxOrSyntheticViewBox() const { - return HasViewBoxRect() || ShouldSynthesizeViewBox(); + return HasViewBox() || ShouldSynthesizeViewBox(); } bool HasChildrenOnlyTransform() const { return mHasChildrenOnlyTransform; } @@ -126,7 +126,7 @@ class SVGViewportElement : public SVGGraphicsElement { // WebIDL already_AddRefed ViewBox(); already_AddRefed PreserveAspectRatio(); - virtual SVGAnimatedViewBox* GetViewBox() override; + virtual SVGAnimatedViewBox* GetAnimatedViewBox() override; protected: // implementation helpers: @@ -162,8 +162,8 @@ class SVGViewportElement : public SVGGraphicsElement { * viewBox, if appropriate, or else a viewBox matching the dimensions of the * SVG viewport. */ - SVGViewBoxRect GetViewBoxWithSynthesis(float aViewportWidth, - float aViewportHeight) const; + SVGViewBox GetViewBoxWithSynthesis(float aViewportWidth, + float aViewportHeight) const; /** * Retrieve the value of currentScale and currentTranslate. @@ -176,7 +176,8 @@ class SVGViewportElement : public SVGGraphicsElement { static LengthInfo sLengthInfo[4]; virtual LengthAttributesInfo GetLengthInfo() override; - virtual SVGAnimatedPreserveAspectRatio* GetPreserveAspectRatio() override; + virtual SVGAnimatedPreserveAspectRatio* GetAnimatedPreserveAspectRatio() + override; virtual const SVGAnimatedViewBox& GetViewBoxInternal() const { return mViewBox; diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index e52c93d5d88f..d6836ab52f07 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -9589,14 +9589,15 @@ static nsRect ComputeSVGReferenceRect(nsIFrame* aFrame, SVGViewportElement* svgElement = element->GetCtx(); MOZ_ASSERT(svgElement); - if (svgElement && svgElement->HasViewBoxRect()) { + if (svgElement && svgElement->HasViewBox()) { // If a `viewBox` attribute is specified for the SVG viewport creating // element: // 1. The reference box is positioned at the origin of the coordinate // system established by the `viewBox` attribute. // 2. The dimension of the reference box is set to the width and height // values of the `viewBox` attribute. - const SVGViewBoxRect& value = svgElement->GetViewBox()->GetAnimValue(); + const SVGViewBox& value = + svgElement->GetAnimatedViewBox()->GetAnimValue(); r = nsRect(nsPresContext::CSSPixelsToAppUnits(value.x), nsPresContext::CSSPixelsToAppUnits(value.y), nsPresContext::CSSPixelsToAppUnits(value.width), diff --git a/layout/svg/nsSVGMarkerFrame.cpp b/layout/svg/nsSVGMarkerFrame.cpp index a743c4ca2465..a4ed63484d60 100644 --- a/layout/svg/nsSVGMarkerFrame.cpp +++ b/layout/svg/nsSVGMarkerFrame.cpp @@ -105,7 +105,7 @@ void nsSVGMarkerFrame::PaintMark(gfxContext& aContext, return; } - const SVGViewBoxRect viewBox = marker->GetViewBoxRect(); + const SVGViewBox viewBox = marker->GetViewBox(); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { // We must disable rendering if the viewBox width or height are zero. @@ -154,7 +154,7 @@ SVGBBox nsSVGMarkerFrame::GetMarkBBoxContribution( return bbox; } - const SVGViewBoxRect viewBox = content->GetViewBoxRect(); + const SVGViewBox viewBox = content->GetViewBox(); if (viewBox.width <= 0.0f || viewBox.height <= 0.0f) { return bbox; diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp index 1675f8a56745..da2ad0620d01 100644 --- a/layout/svg/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/nsSVGOuterSVGFrame.cpp @@ -257,7 +257,7 @@ nsSize nsSVGOuterSVGFrame::GetIntrinsicRatio() { } SVGViewElement* viewElement = content->GetCurrentViewElement(); - const SVGViewBoxRect* viewbox = nullptr; + const SVGViewBox* viewbox = nullptr; // The logic here should match HasViewBox(). if (viewElement && viewElement->mViewBox.HasRect()) { @@ -781,7 +781,7 @@ void nsSVGOuterSVGFrame::NotifyViewportOrTransformChanged(uint32_t aFlags) { SVGSVGElement* content = static_cast(GetContent()); if (aFlags & COORD_CONTEXT_CHANGED) { - if (content->HasViewBoxRect()) { + if (content->HasViewBox()) { // Percentage lengths on children resolve against the viewBox rect so we // don't need to notify them of the viewport change, but the viewBox // transform will have changed, so we need to notify them of that instead. diff --git a/layout/svg/nsSVGPatternFrame.cpp b/layout/svg/nsSVGPatternFrame.cpp index c28a419864de..a9a5c50fb770 100644 --- a/layout/svg/nsSVGPatternFrame.cpp +++ b/layout/svg/nsSVGPatternFrame.cpp @@ -636,9 +636,9 @@ gfxMatrix nsSVGPatternFrame::ConstructCTM(const SVGAnimatedViewBox &aViewBox, if (!aViewBox.IsExplicitlySet()) { return gfxMatrix(scaleX, 0.0, 0.0, scaleY, 0.0, 0.0); } - const SVGViewBoxRect viewBoxRect = aViewBox.GetAnimValue(); + const SVGViewBox viewBox = aViewBox.GetAnimValue(); - if (viewBoxRect.height <= 0.0f || viewBoxRect.width <= 0.0f) { + if (viewBox.height <= 0.0f || viewBox.width <= 0.0f) { return gfxMatrix(0.0, 0.0, 0.0, 0.0, 0.0, 0.0); // singular } @@ -664,9 +664,8 @@ gfxMatrix nsSVGPatternFrame::ConstructCTM(const SVGAnimatedViewBox &aViewBox, } Matrix tm = SVGContentUtils::GetViewBoxTransform( - viewportWidth * scaleX, viewportHeight * scaleY, viewBoxRect.x, - viewBoxRect.y, viewBoxRect.width, viewBoxRect.height, - GetPreserveAspectRatio()); + viewportWidth * scaleX, viewportHeight * scaleY, viewBox.x, viewBox.y, + viewBox.width, viewBox.height, GetPreserveAspectRatio()); return ThebesMatrix(tm); } diff --git a/layout/svg/nsSVGViewportFrame.cpp b/layout/svg/nsSVGViewportFrame.cpp index 16f5ac4b18b2..a0c8cdf0fd04 100644 --- a/layout/svg/nsSVGViewportFrame.cpp +++ b/layout/svg/nsSVGViewportFrame.cpp @@ -102,11 +102,11 @@ void nsSVGViewportFrame::NotifySVGChanged(uint32_t aFlags) { if (!(aFlags & TRANSFORM_CHANGED) && (xOrYIsPercentage || - (widthOrHeightIsPercentage && svg->HasViewBoxRect()))) { + (widthOrHeightIsPercentage && svg->HasViewBox()))) { aFlags |= TRANSFORM_CHANGED; } - if (svg->HasViewBoxRect() || !widthOrHeightIsPercentage) { + if (svg->HasViewBox() || !widthOrHeightIsPercentage) { // Remove COORD_CONTEXT_CHANGED, since we establish the coordinate // context for our descendants and this notification won't change its // dimensions: