tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 6bd1f87b31e358b29a43e1f9b2c575f7472f7a7a
parent 265b8c2f2cb421c09811cc6d33af444d767a16cf
Author: longsonr <longsonr@gmail.com>
Date:   Wed,  7 Jan 2026 18:52:31 +0000

Bug 2008957 - Convert ISVGDisplayFrame::SVGChangedFlags to an enum class r=firefox-svg-reviewers,dholbert

Differential Revision: https://phabricator.services.mozilla.com/D278147

Diffstat:
Mdom/svg/SVGSVGElement.cpp | 2+-
Mlayout/svg/ISVGDisplayableFrame.h | 20+++++++++++---------
Mlayout/svg/ISVGSVGFrame.h | 8+++++---
Mlayout/svg/SVGClipPathFrame.cpp | 2+-
Mlayout/svg/SVGContainerFrame.cpp | 9+++++----
Mlayout/svg/SVGContainerFrame.h | 2+-
Mlayout/svg/SVGForeignObjectFrame.cpp | 9+++++----
Mlayout/svg/SVGForeignObjectFrame.h | 2+-
Mlayout/svg/SVGGFrame.cpp | 2+-
Mlayout/svg/SVGGeometryFrame.cpp | 12+++++++-----
Mlayout/svg/SVGGeometryFrame.h | 2+-
Mlayout/svg/SVGImageFrame.cpp | 5+++--
Mlayout/svg/SVGImageFrame.h | 2+-
Mlayout/svg/SVGMarkerFrame.cpp | 3++-
Mlayout/svg/SVGMaskFrame.cpp | 3++-
Mlayout/svg/SVGOuterSVGFrame.cpp | 42+++++++++++++++++++++---------------------
Mlayout/svg/SVGOuterSVGFrame.h | 2+-
Mlayout/svg/SVGPatternFrame.cpp | 3++-
Mlayout/svg/SVGTextFrame.cpp | 9+++++----
Mlayout/svg/SVGTextFrame.h | 2+-
Mlayout/svg/SVGUseFrame.cpp | 9+++++----
Mlayout/svg/SVGUseFrame.h | 2+-
Mlayout/svg/SVGUtils.cpp | 3++-
Mlayout/svg/SVGUtils.h | 4+++-
Mlayout/svg/SVGViewportFrame.cpp | 30+++++++++++++++++-------------
Mlayout/svg/SVGViewportFrame.h | 4++--
26 files changed, 107 insertions(+), 86 deletions(-)

diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp @@ -490,7 +490,7 @@ void SVGSVGElement::InvalidateTransformNotifyFrame() { // might fail this check if we've failed conditional processing if (ISVGSVGFrame* svgframe = do_QueryFrame(GetPrimaryFrame())) { svgframe->NotifyViewportOrTransformChanged( - ISVGDisplayableFrame::TRANSFORM_CHANGED); + ISVGDisplayableFrame::ChangeFlags::TransformChanged); } } diff --git a/layout/svg/ISVGDisplayableFrame.h b/layout/svg/ISVGDisplayableFrame.h @@ -10,6 +10,7 @@ #include "gfxMatrix.h" #include "gfxPoint.h" #include "gfxRect.h" +#include "mozilla/EnumSet.h" #include "mozilla/gfx/MatrixFwd.h" #include "nsQueryFrame.h" #include "nsRect.h" @@ -95,28 +96,29 @@ class ISVGDisplayableFrame : public nsQueryFrame { // Flags to pass to NotifySVGChange: // - // TRANSFORM_CHANGED: + // TransformChanged: // the current transform matrix for this frame has changed - // COORD_CONTEXT_CHANGED: + // CoordContextChanged: // the dimensions of this frame's coordinate context has changed (percentage // lengths must be reevaluated) - // FULL_ZOOM_CHANGED: + // FullZoomChanged: // the page's zoom level has changed - enum SVGChangedFlags { - TRANSFORM_CHANGED = 0x01, - COORD_CONTEXT_CHANGED = 0x02, - FULL_ZOOM_CHANGED = 0x04 + enum class ChangeFlags { + TransformChanged, + CoordContextChanged, + FullZoomChanged }; + /** * This is called on a frame when there has been a change to one of its - * ancestors that might affect the frame too. SVGChangedFlags are passed + * ancestors that might affect the frame too. ChangeFlags are passed * to indicate what changed. * * Implementations do not need to invalidate, since the caller will * invalidate the entire area of the ancestor that changed. However, they * may need to update their bounds. */ - virtual void NotifySVGChanged(uint32_t aFlags) = 0; + virtual void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) = 0; /** * Get this frame's contribution to the rect returned by a GetBBox() call diff --git a/layout/svg/ISVGSVGFrame.h b/layout/svg/ISVGSVGFrame.h @@ -7,6 +7,7 @@ #ifndef LAYOUT_SVG_ISVGSVGFRAME_H_ #define LAYOUT_SVG_ISVGSVGFRAME_H_ +#include "mozilla/ISVGDisplayableFrame.h" #include "nsQueryFrame.h" namespace mozilla { @@ -19,10 +20,11 @@ class ISVGSVGFrame { * Called when non-attribute changes have caused the element's width/height * or its for-children transform to change, and to get the element to notify * its children appropriately. aFlags must be set to - * ISVGDisplayableFrame::COORD_CONTEXT_CHANGED and/or - * ISVGDisplayableFrame::TRANSFORM_CHANGED. + * ISVGDisplayableFrame::ChangeFlags::CoordContextChanged and/or + * ISVGDisplayableFrame::ChangeFlags::TransformChanged. */ - virtual void NotifyViewportOrTransformChanged(uint32_t aFlags) = 0; + virtual void NotifyViewportOrTransformChanged( + EnumSet<ISVGDisplayableFrame::ChangeFlags> aFlags) = 0; }; } // namespace mozilla diff --git a/layout/svg/SVGClipPathFrame.cpp b/layout/svg/SVGClipPathFrame.cpp @@ -172,7 +172,7 @@ void SVGClipPathFrame::PaintFrameIntoMask(nsIFrame* aFrame, } // The CTM of each frame referencing us can be different. - frame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); + frame->NotifySVGChanged(ISVGDisplayableFrame::ChangeFlags::TransformChanged); // Children of this clipPath may themselves be clipped. SVGClipPathFrame* clipPathThatClipsChild; diff --git a/layout/svg/SVGContainerFrame.cpp b/layout/svg/SVGContainerFrame.cpp @@ -381,15 +381,16 @@ void SVGDisplayContainerFrame::DidSetComputedStyle(ComputedStyle* aOldStyle) { } if (StyleDisplay()->CalcTransformPropertyDifference( *aOldStyle->StyleDisplay())) { - NotifySVGChanged(TRANSFORM_CHANGED); + NotifySVGChanged(ChangeFlags::TransformChanged); } } -void SVGDisplayContainerFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGDisplayContainerFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); - if (aFlags & TRANSFORM_CHANGED) { + if (aFlags.contains(ChangeFlags::TransformChanged)) { // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; } diff --git a/layout/svg/SVGContainerFrame.h b/layout/svg/SVGContainerFrame.h @@ -133,7 +133,7 @@ class SVGDisplayContainerFrame : public SVGContainerFrame, imgDrawingParams& aImgParams) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, uint32_t aFlags) override; bool IsDisplayContainer() override { return true; } diff --git a/layout/svg/SVGForeignObjectFrame.cpp b/layout/svg/SVGForeignObjectFrame.cpp @@ -280,15 +280,16 @@ void SVGForeignObjectFrame::ReflowSVG() { NS_FRAME_HAS_DIRTY_CHILDREN); } -void SVGForeignObjectFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGForeignObjectFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); bool needNewBounds = false; // i.e. mRect or ink overflow rect bool needReflow = false; bool needNewCanvasTM = false; - if (aFlags & COORD_CONTEXT_CHANGED) { + if (aFlags.contains(ChangeFlags::CoordContextChanged)) { // Coordinate context changes affect mCanvasTM if we have a // percentage 'x' or 'y' if (StyleSVGReset()->mX.HasPercent() || StyleSVGReset()->mY.HasPercent()) { @@ -306,7 +307,7 @@ void SVGForeignObjectFrame::NotifySVGChanged(uint32_t aFlags) { } } - if (aFlags & TRANSFORM_CHANGED) { + if (aFlags.contains(ChangeFlags::TransformChanged)) { if (mCanvasTM && mCanvasTM->IsSingular()) { needNewBounds = true; // old bounds are bogus } diff --git a/layout/svg/SVGForeignObjectFrame.h b/layout/svg/SVGForeignObjectFrame.h @@ -62,7 +62,7 @@ class SVGForeignObjectFrame final : public nsContainerFrame, imgDrawingParams& aImgParams) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, uint32_t aFlags) override; bool IsDisplayContainer() override { return true; } diff --git a/layout/svg/SVGGFrame.cpp b/layout/svg/SVGGFrame.cpp @@ -49,7 +49,7 @@ nsresult SVGGFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute, // Also note that SVGTransformableElement::GetAttributeChangeHint will // return nsChangeHint_UpdateOverflow for "transform" attribute changes // and cause DoApplyRenderingChangeToTree to make the SchedulePaint call. - NotifySVGChanged(TRANSFORM_CHANGED); + NotifySVGChanged(ChangeFlags::TransformChanged); } return NS_OK; diff --git a/layout/svg/SVGGeometryFrame.cpp b/layout/svg/SVGGeometryFrame.cpp @@ -116,7 +116,7 @@ void SVGGeometryFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { if (StyleDisplay()->CalcTransformPropertyDifference( *aOldComputedStyle->StyleDisplay())) { - NotifySVGChanged(TRANSFORM_CHANGED); + NotifySVGChanged(ChangeFlags::TransformChanged); } if (element->IsGeometryChangedViaCSS(*Style(), *aOldComputedStyle) || @@ -309,8 +309,9 @@ void SVGGeometryFrame::ReflowSVG() { } } -void SVGGeometryFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGGeometryFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); // Changes to our ancestors may affect how we render when we are rendered as @@ -326,7 +327,7 @@ void SVGGeometryFrame::NotifySVGChanged(uint32_t aFlags) { // overflow rects or not, and we sometimes deliberately include stroke // when it's not visible. See the complexities of GetBBoxContribution. - if (aFlags & COORD_CONTEXT_CHANGED) { + if (aFlags.contains(ChangeFlags::CoordContextChanged)) { auto* geom = static_cast<SVGGeometryElement*>(GetContent()); // Stroke currently contributes to our mRect, which is why we have to take // account of stroke-width here. Note that we do not need to take account @@ -342,7 +343,8 @@ void SVGGeometryFrame::NotifySVGChanged(uint32_t aFlags) { } } - if ((aFlags & TRANSFORM_CHANGED) && StyleSVGReset()->HasNonScalingStroke()) { + if (aFlags.contains(ChangeFlags::TransformChanged) && + StyleSVGReset()->HasNonScalingStroke()) { // Stroke currently contributes to our mRect, and our stroke depends on // the transform to our outer-<svg> if |vector-effect:non-scaling-stroke|. SVGUtils::ScheduleReflowSVG(this); diff --git a/layout/svg/SVGGeometryFrame.h b/layout/svg/SVGGeometryFrame.h @@ -91,7 +91,7 @@ class SVGGeometryFrame final : public nsIFrame, public ISVGDisplayableFrame { imgDrawingParams& aImgParams) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, uint32_t aFlags) override; bool IsDisplayContainer() override { return false; } diff --git a/layout/svg/SVGImageFrame.cpp b/layout/svg/SVGImageFrame.cpp @@ -826,8 +826,9 @@ bool SVGImageFrame::IgnoreHitTest() const { return true; } -void SVGImageFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGImageFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); } diff --git a/layout/svg/SVGImageFrame.h b/layout/svg/SVGImageFrame.h @@ -63,7 +63,7 @@ class SVGImageFrame final : public nsIFrame, imgDrawingParams& aImgParams) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, uint32_t aFlags) override; bool IsDisplayContainer() override { return false; } diff --git a/layout/svg/SVGMarkerFrame.cpp b/layout/svg/SVGMarkerFrame.cpp @@ -133,7 +133,8 @@ void SVGMarkerFrame::PaintMark(gfxContext& aContext, nsIFrame* kid = GetAnonymousChildFrame(this); ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); // The CTM of each frame referencing us may be different. - SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); + SVGFrame->NotifySVGChanged( + ISVGDisplayableFrame::ChangeFlags::TransformChanged); auto contextPaint = MakeRefPtr<SVGContextPaintImpl>(); contextPaint->Init(aContext.GetDrawTarget(), aToMarkedFrameUserSpace * aContext.CurrentMatrixDouble(), diff --git a/layout/svg/SVGMaskFrame.cpp b/layout/svg/SVGMaskFrame.cpp @@ -89,7 +89,8 @@ already_AddRefed<SourceSurface> SVGMaskFrame::GetMaskForMaskedFrame( // The CTM of each frame referencing us can be different ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { - SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); + SVGFrame->NotifySVGChanged( + ISVGDisplayableFrame::ChangeFlags::TransformChanged); m = SVGUtils::GetTransformMatrixInUserSpace(kid) * m; } diff --git a/layout/svg/SVGOuterSVGFrame.cpp b/layout/svg/SVGOuterSVGFrame.cpp @@ -374,7 +374,7 @@ void SVGOuterSVGFrame::Reflow(nsPresContext* aPresContext, nsPresContext::AppUnitsToFloatCSSPixels(aReflowInput.ComputedWidth()), nsPresContext::AppUnitsToFloatCSSPixels(aReflowInput.ComputedHeight())); - uint32_t changeBits = 0; + EnumSet<ChangeFlags> changeBits; if (newViewportSize != svgElem->GetViewportSize()) { // When our viewport size changes, we may need to update the overflow rects // of our child frames. This is the case if: @@ -403,17 +403,17 @@ void SVGOuterSVGFrame::Reflow(nsPresContext* aPresContext, child->MarkSubtreeDirty(); } } - changeBits |= COORD_CONTEXT_CHANGED; + changeBits += ChangeFlags::CoordContextChanged; svgElem->SetViewportSize(newViewportSize); } if (mIsRootContent && !mIsInIframe) { const auto oldZoom = mFullZoom; mFullZoom = ComputeFullZoom(); if (oldZoom != mFullZoom) { - changeBits |= FULL_ZOOM_CHANGED; + changeBits += ChangeFlags::FullZoomChanged; } } - if (changeBits && !HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { + if (!changeBits.isEmpty() && !HasAnyStateBits(NS_FRAME_FIRST_REFLOW)) { NotifyViewportOrTransformChanged(changeBits); } @@ -513,8 +513,9 @@ nsresult SVGOuterSVGFrame::AttributeChanged(int32_t aNameSpaceID, SVGUtils::NotifyChildrenOfSVGChange( PrincipalChildList().FirstChild(), aAttribute == nsGkAtoms::viewBox - ? TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED - : TRANSFORM_CHANGED); + ? EnumSet<ChangeFlags>(ChangeFlags::TransformChanged, + ChangeFlags::CoordContextChanged) + : ChangeFlags::TransformChanged); if (aAttribute != nsGkAtoms::transform) { static_cast<SVGSVGElement*>(GetContent()) @@ -577,44 +578,43 @@ void SVGOuterSVGFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, //---------------------------------------------------------------------- // ISVGSVGFrame methods: -void SVGOuterSVGFrame::NotifyViewportOrTransformChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags && !(aFlags & ~(COORD_CONTEXT_CHANGED | TRANSFORM_CHANGED | - FULL_ZOOM_CHANGED)), - "Unexpected aFlags value"); - +void SVGOuterSVGFrame::NotifyViewportOrTransformChanged( + EnumSet<ChangeFlags> aFlags) { auto* content = static_cast<SVGSVGElement*>(GetContent()); - if (aFlags & COORD_CONTEXT_CHANGED) { + if (aFlags.contains(ChangeFlags::CoordContextChanged)) { 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. - aFlags = TRANSFORM_CHANGED; + aFlags = ChangeFlags::TransformChanged; } else if (content->ShouldSynthesizeViewBox()) { // In the case of a synthesized viewBox, the synthetic viewBox's rect // changes as the viewport changes. As a result we need to maintain the // COORD_CONTEXT_CHANGED flag. - aFlags |= TRANSFORM_CHANGED; + aFlags += ChangeFlags::TransformChanged; } else if (mCanvasTM && mCanvasTM->IsSingular()) { // A width/height of zero will result in us having a singular mCanvasTM // even when we don't have a viewBox. So we also want to recompute our // mCanvasTM for this width/height change even though we don't have a // viewBox. - aFlags |= TRANSFORM_CHANGED; + aFlags += ChangeFlags::TransformChanged; } } - bool haveNonFulLZoomTransformChange = (aFlags & TRANSFORM_CHANGED); + bool haveNonFullZoomTransformChange = + aFlags.contains(ChangeFlags::TransformChanged); - if (aFlags & FULL_ZOOM_CHANGED) { - // Convert FULL_ZOOM_CHANGED to TRANSFORM_CHANGED: - aFlags = (aFlags & ~FULL_ZOOM_CHANGED) | TRANSFORM_CHANGED; + if (aFlags.contains(ChangeFlags::FullZoomChanged)) { + // Convert FullZoomChanged to TransformChanged. + aFlags -= ChangeFlags::FullZoomChanged; + aFlags += ChangeFlags::TransformChanged; } - if (aFlags & TRANSFORM_CHANGED) { + if (aFlags.contains(ChangeFlags::TransformChanged)) { // Make sure our canvas transform matrix gets (lazily) recalculated: mCanvasTM = nullptr; - if (haveNonFulLZoomTransformChange && + if (haveNonFullZoomTransformChange && !HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { uint32_t flags = HasAnyStateBits(NS_FRAME_IN_REFLOW) ? SVGSVGElement::eDuringReflow diff --git a/layout/svg/SVGOuterSVGFrame.h b/layout/svg/SVGOuterSVGFrame.h @@ -99,7 +99,7 @@ class SVGOuterSVGFrame final : public SVGDisplayContainerFrame, void AppendDirectlyOwnedAnonBoxes(nsTArray<OwnedAnonBox>& aResult) override; // ISVGSVGFrame interface: - void NotifyViewportOrTransformChanged(uint32_t aFlags) override; + void NotifyViewportOrTransformChanged(EnumSet<ChangeFlags> aFlags) override; // ISVGDisplayableFrame methods: void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, diff --git a/layout/svg/SVGPatternFrame.cpp b/layout/svg/SVGPatternFrame.cpp @@ -239,7 +239,8 @@ void SVGPatternFrame::PaintChildren(DrawTarget* aDrawTarget, // The CTM of each frame referencing us can be different ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { - SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); + SVGFrame->NotifySVGChanged( + ISVGDisplayableFrame::ChangeFlags::TransformChanged); tm = SVGUtils::GetTransformMatrixInUserSpace(kid) * tm; } diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp @@ -3053,18 +3053,19 @@ void SVGTextFrame::FindCloserFrameForSelection( //---------------------------------------------------------------------- // ISVGDisplayableFrame methods -void SVGTextFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGTextFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); bool needNewBounds = false; bool needGlyphMetricsUpdate = false; - if ((aFlags & COORD_CONTEXT_CHANGED) && + if (aFlags.contains(ChangeFlags::CoordContextChanged) && HasAnyStateBits(NS_STATE_SVG_POSITIONING_MAY_USE_PERCENTAGES)) { needGlyphMetricsUpdate = true; } - if (aFlags & TRANSFORM_CHANGED) { + if (aFlags.contains(ChangeFlags::TransformChanged)) { if (mCanvasTM && mCanvasTM->IsSingular()) { // We won't have calculated the glyph positions correctly. needNewBounds = true; diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h @@ -226,7 +226,7 @@ class SVGTextFrame final : public SVGDisplayContainerFrame { const nsPoint& aPoint, FrameWithDistance* aCurrentBestFrame) override; // ISVGDisplayableFrame interface: - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, imgDrawingParams& aImgParams) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; diff --git a/layout/svg/SVGUseFrame.cpp b/layout/svg/SVGUseFrame.cpp @@ -55,7 +55,7 @@ void SVGUseFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) { // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; SVGUtils::ScheduleReflowSVG(this); - SVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); + SVGUtils::NotifyChildrenOfSVGChange(this, ChangeFlags::TransformChanged); } } @@ -105,12 +105,13 @@ void SVGUseFrame::ReflowSVG() { SVGGFrame::ReflowSVG(); } -void SVGUseFrame::NotifySVGChanged(uint32_t aFlags) { - if (aFlags & COORD_CONTEXT_CHANGED && !(aFlags & TRANSFORM_CHANGED)) { +void SVGUseFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + if (aFlags.contains(ChangeFlags::CoordContextChanged) && + !aFlags.contains(ChangeFlags::TransformChanged)) { // Coordinate context changes affect mCanvasTM if we have a // percentage 'x' or 'y' if (StyleSVGReset()->mX.HasPercent() || StyleSVGReset()->mY.HasPercent()) { - aFlags |= TRANSFORM_CHANGED; + aFlags += ChangeFlags::TransformChanged; // Ancestor changes can't affect how we render from the perspective of // any rendering observers that we may have, so we don't need to // invalidate them. We also don't need to invalidate ourself, since our diff --git a/layout/svg/SVGUseFrame.h b/layout/svg/SVGUseFrame.h @@ -51,7 +51,7 @@ class SVGUseFrame final : public SVGGFrame { // ISVGDisplayableFrame interface: void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; private: bool mHasValidDimensions; diff --git a/layout/svg/SVGUtils.cpp b/layout/svg/SVGUtils.cpp @@ -360,7 +360,8 @@ bool SVGUtils::GetParentSVGTransforms(const nsIFrame* aFrame, return false; } -void SVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) { +void SVGUtils::NotifyChildrenOfSVGChange( + nsIFrame* aFrame, EnumSet<ISVGDisplayableFrame::ChangeFlags> aFlags) { for (nsIFrame* kid : aFrame->PrincipalChildList()) { ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { diff --git a/layout/svg/SVGUtils.h b/layout/svg/SVGUtils.h @@ -18,6 +18,7 @@ #include "gfxMatrix.h" #include "gfxPoint.h" #include "gfxRect.h" +#include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/gfx/Rect.h" #include "nsCOMPtr.h" #include "nsChangeHint.h" @@ -260,7 +261,8 @@ class SVGUtils final { * Notify the descendants of aFrame of a change to one of their ancestors * that might affect them. */ - static void NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags); + static void NotifyChildrenOfSVGChange( + nsIFrame* aFrame, EnumSet<ISVGDisplayableFrame::ChangeFlags> aFlags); /* * Convert a surface size to an integer for use by thebes diff --git a/layout/svg/SVGViewportFrame.cpp b/layout/svg/SVGViewportFrame.cpp @@ -73,11 +73,12 @@ void SVGViewportFrame::ReflowSVG() { SVGDisplayContainerFrame::ReflowSVG(); } -void SVGViewportFrame::NotifySVGChanged(uint32_t aFlags) { - MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED), +void SVGViewportFrame::NotifySVGChanged(EnumSet<ChangeFlags> aFlags) { + MOZ_ASSERT(aFlags.contains(ChangeFlags::TransformChanged) || + aFlags.contains(ChangeFlags::CoordContextChanged), "Invalidation logic may need adjusting"); - if (aFlags & COORD_CONTEXT_CHANGED) { + if (aFlags.contains(ChangeFlags::CoordContextChanged)) { SVGViewportElement* svg = static_cast<SVGViewportElement*>(GetContent()); bool xOrYIsPercentage = @@ -101,19 +102,19 @@ void SVGViewportFrame::NotifySVGChanged(uint32_t aFlags) { // percentage 'x' or 'y', or if we have a percentage 'width' or 'height' AND // a 'viewBox'. - if (!(aFlags & TRANSFORM_CHANGED) && + if (!aFlags.contains(ChangeFlags::TransformChanged) && (xOrYIsPercentage || (widthOrHeightIsPercentage && svg->HasViewBox()))) { - aFlags |= TRANSFORM_CHANGED; + aFlags += ChangeFlags::TransformChanged; } 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: - aFlags &= ~COORD_CONTEXT_CHANGED; + aFlags -= ChangeFlags::CoordContextChanged; - if (!aFlags) { + if (aFlags.isEmpty()) { return; // No notification flags left } } @@ -180,12 +181,13 @@ nsresult SVGViewportFrame::AttributeChanged(int32_t aNameSpaceID, // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; content->ChildrenOnlyTransformChanged(); - SVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); + SVGUtils::NotifyChildrenOfSVGChange(this, + ChangeFlags::TransformChanged); } else { - uint32_t flags = COORD_CONTEXT_CHANGED; + EnumSet<ChangeFlags> flags(ChangeFlags::CoordContextChanged); if (mCanvasTM && mCanvasTM->IsSingular()) { mCanvasTM = nullptr; - flags |= TRANSFORM_CHANGED; + flags += ChangeFlags::TransformChanged; } SVGUtils::NotifyChildrenOfSVGChange(this, flags); } @@ -198,8 +200,9 @@ nsresult SVGViewportFrame::AttributeChanged(int32_t aNameSpaceID, SVGUtils::NotifyChildrenOfSVGChange( this, aAttribute == nsGkAtoms::viewBox - ? TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED - : TRANSFORM_CHANGED); + ? EnumSet<ChangeFlags>(ChangeFlags::TransformChanged, + ChangeFlags::CoordContextChanged) + : ChangeFlags::TransformChanged); if (aAttribute == nsGkAtoms::x || aAttribute == nsGkAtoms::y) { nsLayoutUtils::PostRestyleEvent( @@ -229,7 +232,8 @@ nsIFrame* SVGViewportFrame::GetFrameForPoint(const gfxPoint& aPoint) { //---------------------------------------------------------------------- // ISVGSVGFrame methods: -void SVGViewportFrame::NotifyViewportOrTransformChanged(uint32_t aFlags) { +void SVGViewportFrame::NotifyViewportOrTransformChanged( + EnumSet<ChangeFlags> aFlags) { // The dimensions of inner-<svg> frames are purely defined by their "width" // and "height" attributes, and transform changes can only occur as a result // of changes to their "width", "height", "viewBox" or "preserveAspectRatio" diff --git a/layout/svg/SVGViewportFrame.h b/layout/svg/SVGViewportFrame.h @@ -33,7 +33,7 @@ class SVGViewportFrame : public SVGDisplayContainerFrame, public ISVGSVGFrame { void PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, imgDrawingParams& aImgParams) override; void ReflowSVG() override; - void NotifySVGChanged(uint32_t aFlags) override; + void NotifySVGChanged(EnumSet<ChangeFlags> aFlags) override; SVGBBox GetBBoxContribution(const Matrix& aToBBoxUserspace, uint32_t aFlags) override; nsIFrame* GetFrameForPoint(const gfxPoint& aPoint) override; @@ -42,7 +42,7 @@ class SVGViewportFrame : public SVGDisplayContainerFrame, public ISVGSVGFrame { bool HasChildrenOnlyTransform(Matrix* aTransform) const override; // ISVGSVGFrame interface: - void NotifyViewportOrTransformChanged(uint32_t aFlags) override; + void NotifyViewportOrTransformChanged(EnumSet<ChangeFlags> aFlags) override; }; } // namespace mozilla