Bug 1647525 - Use HasAnyStateBits() in nsSVGUtils r=emilio draft
authorKagami Sascha Rosylight <saschanaz@outlook.com>
Sat, 27 Jun 2020 13:51:28 +0000
changeset 3009949 894da12c00d41a7be292d62e725834d1a6b63f56
parent 3009948 9f434a788c55a2cfc026d6f157d11d26e6c9b026
child 3009950 4d40484476fd1738da9ade4a798b8c380746b1ba
push id561043
push userreviewbot
push dateSat, 27 Jun 2020 13:52:06 +0000
treeherdertry@52cabdbb40ab [default view] [failures only]
reviewersemilio
bugs1647525
milestone79.0a1
Bug 1647525 - Use HasAnyStateBits() in nsSVGUtils r=emilio Summary: Differential Revision: https://phabricator.services.mozilla.com/D81221 Depends on D81220 Test Plan: Reviewers: emilio Subscribers: Bug #: 1647525 Differential Diff: PHID-DIFF-3mlnyv5ikx5b5ogmvvd3
layout/svg/nsSVGUtils.cpp
layout/svg/nsSVGUtils.h
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -109,17 +109,17 @@ bool SVGAutoRenderState::IsPaintingToWin
   if (state) {
     return static_cast<SVGAutoRenderState*>(state)->mPaintingToWindow;
   }
   return false;
 }
 
 nsRect nsSVGUtils::GetPostFilterVisualOverflowRect(
     nsIFrame* aFrame, const nsRect& aPreFilterRect) {
-  MOZ_ASSERT(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT,
+  MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT),
              "Called on invalid frame type");
 
   // Note: we do not return here for eHasNoRefs since we must still handle any
   // CSS filter functions.
   // TODO: We currently pass nullptr instead of an nsTArray* here, but we
   // actually should get the filter frames and then pass them into
   // GetPostFilterBounds below!  See bug 1494263.
   // TODO: we should really return an empty rect for eHasRefsSomeInvalid since
@@ -158,54 +158,53 @@ void nsSVGUtils::ScheduleReflowSVG(nsIFr
   NS_ASSERTION(!OuterSVGIsCallingReflowSVG(aFrame),
                "Do not call under nsSVGDisplayableFrame::ReflowSVG!");
 
   // We don't call SVGObserverUtils::InvalidateRenderingObservers here because
   // we should only be called under InvalidateAndScheduleReflowSVG (which
   // calls InvalidateBounds) or nsSVGDisplayContainerFrame::InsertFrames
   // (at which point the frame has no observers).
 
-  if (aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
+  if (aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
     return;
   }
 
-  if (aFrame->GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_FIRST_REFLOW)) {
+  if (aFrame->HasAnyStateBits(NS_FRAME_IS_DIRTY | NS_FRAME_FIRST_REFLOW)) {
     // Nothing to do if we're already dirty, or if the outer-<svg>
     // hasn't yet had its initial reflow.
     return;
   }
 
   nsSVGOuterSVGFrame* outerSVGFrame = nullptr;
 
   // We must not add dirty bits to the nsSVGOuterSVGFrame or else
   // PresShell::FrameNeedsReflow won't work when we pass it in below.
   if (aFrame->IsSVGOuterSVGFrame()) {
     outerSVGFrame = static_cast<nsSVGOuterSVGFrame*>(aFrame);
   } else {
     aFrame->MarkSubtreeDirty();
 
     nsIFrame* f = aFrame->GetParent();
     while (f && !f->IsSVGOuterSVGFrame()) {
-      if (f->GetStateBits() &
-          (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) {
+      if (f->HasAnyStateBits(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) {
         return;
       }
       f->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
       f = f->GetParent();
       MOZ_ASSERT(f->IsFrameOfType(nsIFrame::eSVG),
                  "IsSVGOuterSVGFrame check above not valid!");
     }
 
     outerSVGFrame = static_cast<nsSVGOuterSVGFrame*>(f);
 
     MOZ_ASSERT(outerSVGFrame && outerSVGFrame->IsSVGOuterSVGFrame(),
                "Did not find nsSVGOuterSVGFrame!");
   }
 
-  if (outerSVGFrame->GetStateBits() & NS_FRAME_IN_REFLOW) {
+  if (outerSVGFrame->HasAnyStateBits(NS_FRAME_IN_REFLOW)) {
     // We're currently under an nsSVGOuterSVGFrame::Reflow call so there is no
     // need to call PresShell::FrameNeedsReflow, since we have an
     // nsSVGOuterSVGFrame::DidReflow call pending.
     return;
   }
 
   nsFrameState dirtyBit =
       (outerSVGFrame == aFrame ? NS_FRAME_IS_DIRTY
@@ -298,17 +297,17 @@ nsIFrame* nsSVGUtils::GetOuterSVGFrameAn
   if (!svg) {
     return nullptr;
   }
   nsSVGOuterSVGFrame* outer = GetOuterSVGFrame(aFrame);
   if (outer == svg) {
     return nullptr;
   }
 
-  if (aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) {
+  if (aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
     *aRect = nsRect(0, 0, 0, 0);
   } else {
     uint32_t flags =
         nsSVGUtils::eForGetClientRects | nsSVGUtils::eBBoxIncludeFill |
         nsSVGUtils::eBBoxIncludeStroke | nsSVGUtils::eBBoxIncludeMarkers;
 
     auto ctm = nsLayoutUtils::GetTransformToAncestor(RelativeTo{aFrame},
                                                      RelativeTo{outer});
@@ -535,17 +534,17 @@ class MixModeBlender {
 
   IntRect ComputeClipExtsInDeviceSpace(const gfxMatrix& aTransform) {
     // These are used if we require a temporary surface for a custom blend
     // mode. Clip the source context first, so that we can generate a smaller
     // temporary surface. (Since we will clip this context in
     // SetupContextMatrix, a pair of save/restore is needed.)
     gfxContextAutoSaveRestore saver(mSourceCtx);
 
-    if (!(mFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
+    if (!mFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
       // aFrame has a valid visual overflow rect, so clip to it before calling
       // PushGroup() to minimize the size of the surfaces we'll composite:
       gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(mSourceCtx);
       mSourceCtx->Multiply(aTransform);
       nsRect overflowRect = mFrame->GetVisualOverflowRectRelativeToSelf();
       if (mFrame->IsSVGGeometryFrameOrSubclass() ||
           nsSVGUtils::IsInSVGTextSubtree(mFrame)) {
         // Unlike containers, leaf frames do not include GetPosition() in
@@ -574,17 +573,17 @@ class MixModeBlender {
   IntPoint mTargetOffset;
 };
 
 void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext,
                                        const gfxMatrix& aTransform,
                                        imgDrawingParams& aImgParams,
                                        const nsIntRect* aDirtyRect) {
   NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() ||
-                   (aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY) ||
+                   aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) ||
                    aFrame->PresContext()->Document()->IsSVGGlyphsDocument(),
                "If display lists are enabled, only painting of non-display "
                "SVG should take this code path");
 
   nsSVGDisplayableFrame* svgFrame = do_QueryFrame(aFrame);
   if (!svgFrame) {
     return;
   }
@@ -596,17 +595,17 @@ void nsSVGUtils::PaintFrameWithEffects(n
   }
 
   const nsIContent* content = aFrame->GetContent();
   if (content->IsSVGElement() &&
       !static_cast<const SVGElement*>(content)->HasValidDimensions()) {
     return;
   }
 
-  if (aDirtyRect && !(aFrame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
+  if (aDirtyRect && !aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) {
     // Here we convert aFrame's paint bounds to outer-<svg> device space,
     // compare it to aDirtyRect, and return early if they don't intersect.
     // We don't do this optimization for nondisplay SVG since nondisplay
     // SVG doesn't maintain bounds/overflow rects.
     nsRect overflowRect = aFrame->GetVisualOverflowRectRelativeToSelf();
     if (aFrame->IsSVGGeometryFrameOrSubclass() ||
         nsSVGUtils::IsInSVGTextSubtree(aFrame)) {
       // Unlike containers, leaf frames do not include GetPosition() in
@@ -987,17 +986,17 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aF
       while (!ancestor->IsSVGTextFrame()) {
         ancestor = ancestor->GetParent();
       }
     }
     aFrame = ancestor;
   }
 
   nsSVGDisplayableFrame* svg = do_QueryFrame(aFrame);
-  const bool hasSVGLayout = aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT;
+  const bool hasSVGLayout = aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT);
   if (hasSVGLayout && !svg) {
     // An SVG frame, but not one that can be displayed directly (for
     // example, nsGradientFrame). These can't contribute to the bbox.
     return gfxRect();
   }
 
   const bool isOuterSVG = svg && !hasSVGLayout;
   MOZ_ASSERT(!isOuterSVG || aFrame->IsSVGOuterSVGFrame());
@@ -1111,17 +1110,17 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aF
     // cache the result for future calls, since calculation can be expensive:
     aFrame->SetProperty(ObjectBoundingBoxProperty(), new gfxRect(bbox));
   }
 
   return bbox;
 }
 
 gfxPoint nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) {
-  if (!(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
+  if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) {
     // The user space for non-SVG frames is defined as the bounding box of the
     // frame's border-box rects over all continuations.
     return gfxPoint();
   }
 
   // Leaf frames apply their own offset inside their user space.
   if (aFrame->IsSVGGeometryFrameOrSubclass() ||
       nsSVGUtils::IsInSVGTextSubtree(aFrame)) {
@@ -1175,17 +1174,17 @@ gfxRect nsSVGUtils::GetRelativeRect(uint
     SVGElement* svgElement = static_cast<SVGElement*>(content);
     return GetRelativeRect(aUnits, aXYWH, aBBox, SVGElementMetrics(svgElement));
   }
   return GetRelativeRect(aUnits, aXYWH, aBBox,
                          NonSVGFrameUserSpaceMetrics(aFrame));
 }
 
 bool nsSVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) {
-  if (!(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) {
+  if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) {
     return false;
   }
   LayoutFrameType type = aFrame->Type();
   if (type != LayoutFrameType::SVGImage &&
       type != LayoutFrameType::SVGGeometry) {
     return false;
   }
   if (aFrame->StyleEffects()->HasFilters()) {
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -583,17 +583,17 @@ class nsSVGUtils {
    * units. This method provides a transform matrix to multiply onto a
    * gfxContext's current transform to convert the context's current units from
    * its usual dev pixels to SVG user units/CSS px to keep the SVG code happy.
    */
   static gfxMatrix GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame);
 
   static bool IsInSVGTextSubtree(const nsIFrame* aFrame) {
     // Returns true if the frame is an SVGTextFrame or one of its descendants.
-    return aFrame->GetStateBits() & NS_FRAME_IS_SVG_TEXT;
+    return aFrame->HasAnyStateBits(NS_FRAME_IS_SVG_TEXT);
   }
 
   /**
    * It is a replacement of
    * SVGElement::PrependLocalTransformsTo(eUserSpaceToParent).
    * If no CSS transform is involved, they should behave exactly the same;
    * if there are CSS transforms, this one will take them into account
    * while SVGElement::PrependLocalTransformsTo won't.