Bug 1246764 - Part 4: Rename mask flag and function name of xxxBasicShape to xxxBasicShapeOrPath. r=jwatt
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 17 Aug 2018 15:48:02 -0700
changeset 491116 fff761953caf5e8bf979636ad58b5b6cdad83f98
parent 491115 bcdbd9f8b52d4d76b554581132c94cc2b46b0a69
child 491117 21b885b5fc62ce75eb92b9412ea2e0eba1287e7d
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1246764
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1246764 - Part 4: Rename mask flag and function name of xxxBasicShape to xxxBasicShapeOrPath. r=jwatt This flag and function name are used for both basic shapes and path function, so rename it. For now, we treat path() and other basic-shapes as the different object (i.e. StyleSVGPath and StyleBasicShape), so I rename these functions and mask flag. Differential Revision: https://phabricator.services.mozilla.com/D3636
layout/generic/nsFrame.cpp
layout/svg/nsCSSClipPathInstance.cpp
layout/svg/nsCSSClipPathInstance.h
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGUtils.cpp
layout/svg/nsSVGUtils.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2708,18 +2708,18 @@ ComputeClipForMaskItem(nsDisplayListBuil
   gfxPoint devPixelOffsetToUserSpace = nsLayoutUtils::PointToGfxPoint(
       offsetToUserSpace, devPixelRatio);
   gfxMatrix cssToDevMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(aMaskedFrame);
 
   nsPoint toReferenceFrame;
   aBuilder->FindReferenceFrameFor(aMaskedFrame, &toReferenceFrame);
 
   Maybe<gfxRect> combinedClip;
-  if (maskUsage.shouldApplyBasicShape) {
-    Rect result = nsCSSClipPathInstance::GetBoundingRectForBasicShapeClip(
+  if (maskUsage.shouldApplyBasicShapeOrPath) {
+    Rect result = nsCSSClipPathInstance::GetBoundingRectForBasicShapeOrPathClip(
         aMaskedFrame, svgReset->mClipPath);
     combinedClip = Some(ThebesRect(result));
   } else if (maskUsage.shouldApplyClipPath) {
     gfxRect result = nsSVGUtils::GetBBox(aMaskedFrame,
         nsSVGUtils::eBBoxIncludeClipped |
         nsSVGUtils::eBBoxIncludeFill |
         nsSVGUtils::eBBoxIncludeMarkers |
         nsSVGUtils::eBBoxIncludeStroke |
--- a/layout/svg/nsCSSClipPathInstance.cpp
+++ b/layout/svg/nsCSSClipPathInstance.cpp
@@ -21,18 +21,18 @@
 #include "nsSVGUtils.h"
 #include "nsSVGViewBox.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 /* static*/ void
-nsCSSClipPathInstance::ApplyBasicShapeClip(gfxContext& aContext,
-                                           nsIFrame* aFrame)
+nsCSSClipPathInstance::ApplyBasicShapeOrPathClip(gfxContext& aContext,
+                                                 nsIFrame* aFrame)
 {
   auto& clipPathStyle = aFrame->StyleSVGReset()->mClipPath;
 
 #ifdef DEBUG
   StyleShapeSourceType type = clipPathStyle.GetType();
   MOZ_ASSERT(type == StyleShapeSourceType::Shape ||
              type == StyleShapeSourceType::Box ||
              type == StyleShapeSourceType::Path,
@@ -43,18 +43,18 @@ nsCSSClipPathInstance::ApplyBasicShapeCl
 
   aContext.NewPath();
   RefPtr<Path> path = instance.CreateClipPath(aContext.GetDrawTarget());
   aContext.SetPath(path);
   aContext.Clip();
 }
 
 /* static*/ bool
-nsCSSClipPathInstance::HitTestBasicShapeClip(nsIFrame* aFrame,
-                                             const gfxPoint& aPoint)
+nsCSSClipPathInstance::HitTestBasicShapeOrPathClip(nsIFrame* aFrame,
+                                                   const gfxPoint& aPoint)
 {
   auto& clipPathStyle = aFrame->StyleSVGReset()->mClipPath;
   StyleShapeSourceType type = clipPathStyle.GetType();
   MOZ_ASSERT(type != StyleShapeSourceType::None, "unexpected none value");
   // In the future nsCSSClipPathInstance may handle <clipPath> references as
   // well. For the time being return early.
   if (type == StyleShapeSourceType::URL) {
     return false;
@@ -66,17 +66,17 @@ nsCSSClipPathInstance::HitTestBasicShape
     gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget();
   RefPtr<Path> path = instance.CreateClipPath(drawTarget);
   float pixelRatio = float(AppUnitsPerCSSPixel()) /
                      aFrame->PresContext()->AppUnitsPerDevPixel();
   return path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix());
 }
 
 /* static */ Rect
-nsCSSClipPathInstance::GetBoundingRectForBasicShapeClip(
+nsCSSClipPathInstance::GetBoundingRectForBasicShapeOrPathClip(
   nsIFrame* aFrame,
   const StyleShapeSource& aClipPathStyle)
 {
   MOZ_ASSERT(aClipPathStyle.GetType() == StyleShapeSourceType::Shape ||
              aClipPathStyle.GetType() == StyleShapeSourceType::Box ||
              aClipPathStyle.GetType() == StyleShapeSourceType::Path);
 
   nsCSSClipPathInstance instance(aFrame, aClipPathStyle);
--- a/layout/svg/nsCSSClipPathInstance.h
+++ b/layout/svg/nsCSSClipPathInstance.h
@@ -18,23 +18,23 @@ namespace mozilla {
 
 class nsCSSClipPathInstance
 {
   typedef mozilla::gfx::DrawTarget DrawTarget;
   typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::Rect Rect;
 
 public:
-  static void ApplyBasicShapeClip(gfxContext& aContext,
-                                  nsIFrame* aFrame);
+  static void ApplyBasicShapeOrPathClip(gfxContext& aContext,
+                                        nsIFrame* aFrame);
   // aPoint is in CSS pixels.
-  static bool HitTestBasicShapeClip(nsIFrame* aFrame,
-                                    const gfxPoint& aPoint);
+  static bool HitTestBasicShapeOrPathClip(nsIFrame* aFrame,
+                                          const gfxPoint& aPoint);
 
-  static Rect GetBoundingRectForBasicShapeClip(
+  static Rect GetBoundingRectForBasicShapeOrPathClip(
     nsIFrame* aFrame,
     const StyleShapeSource& aClipPathStyle);
 
 private:
   explicit nsCSSClipPathInstance(nsIFrame* aFrame,
                                  const StyleShapeSource aClipPathStyle)
     : mTargetFrame(aFrame)
     , mClipPathStyle(aClipPathStyle)
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -804,23 +804,23 @@ nsSVGIntegrationUtils::PaintMask(const P
     ctx.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, maskUsage.opacity);
     autoPop.SetContext(&ctx);
   }
 
   gfxContextMatrixAutoSaveRestore matSR;
 
   // Paint clip-path-basic-shape onto ctx
   gfxContextAutoSaveRestore basicShapeSR;
-  if (maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.shouldApplyBasicShapeOrPath) {
     matSR.SetContext(&ctx);
 
     MoveContextOriginToUserSpace(firstFrame, aParams);
 
     basicShapeSR.SetContext(&ctx);
-    nsCSSClipPathInstance::ApplyBasicShapeClip(ctx, frame);
+    nsCSSClipPathInstance::ApplyBasicShapeOrPathClip(ctx, frame);
     if (!maskUsage.shouldGenerateMaskLayer) {
       // Only have basic-shape clip-path effect. Fill clipped region by
       // opaque white.
       ctx.SetColor(Color(1.0, 1.0, 1.0, 1.0));
       ctx.Fill();
 
       return true;
     }
@@ -992,27 +992,27 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
                                       maskSurface, maskTransform);
       }
     }
   }
 
   /* If this frame has only a trivial clipPath, set up cairo's clipping now so
    * we can just do normal painting and get it clipped appropriately.
    */
-  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShapeOrPath) {
     gfxContextMatrixAutoSaveRestore matSR(&context);
 
     MoveContextOriginToUserSpace(firstFrame, aParams);
 
     MOZ_ASSERT(!maskUsage.shouldApplyClipPath ||
-               !maskUsage.shouldApplyBasicShape);
+               !maskUsage.shouldApplyBasicShapeOrPath);
     if (maskUsage.shouldApplyClipPath) {
       clipPathFrame->ApplyClipPath(context, frame, cssPxToDevPxMatrix);
     } else {
-      nsCSSClipPathInstance::ApplyBasicShapeClip(context, frame);
+      nsCSSClipPathInstance::ApplyBasicShapeOrPathClip(context, frame);
     }
   }
 
   /* Paint the child */
   context.SetMatrix(matrixAutoSaveRestore.Matrix());
   BasicLayerManager* basic = aParams.layerManager->AsBasicLayerManager();
   RefPtr<gfxContext> oldCtx = basic->GetTarget();
   basic->SetTarget(&context);
@@ -1031,26 +1031,26 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
     Color overlayColor(0.0f, 0.0f, 0.0f, 0.8f);
     if (maskUsage.shouldGenerateMaskLayer) {
       overlayColor.r = 1.0f; // red represents css positioned mask.
     }
     if (maskUsage.shouldApplyClipPath ||
         maskUsage.shouldGenerateClipMaskLayer) {
       overlayColor.g = 1.0f; // green represents clip-path:<clip-source>.
     }
-    if (maskUsage.shouldApplyBasicShape) {
+    if (maskUsage.shouldApplyBasicShapeOrPath) {
       overlayColor.b = 1.0f; // blue represents
                              // clip-path:<basic-shape>||<geometry-box>.
     }
 
     context.SetColor(overlayColor);
     context.Fill();
   }
 
-  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShapeOrPath) {
     context.PopClip();
   }
 
   if (shouldPushMask) {
     context.PopGroupAndBlend();
   }
 
 }
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -519,21 +519,22 @@ nsSVGUtils::DetermineMaskUsage(nsIFrame*
         } else {
           aUsage.shouldGenerateClipMaskLayer = true;
         }
       }
       break;
     case StyleShapeSourceType::Shape:
     case StyleShapeSourceType::Box:
     case StyleShapeSourceType::Path:
-      aUsage.shouldApplyBasicShape = true;
+      aUsage.shouldApplyBasicShapeOrPath = true;
       break;
     case StyleShapeSourceType::None:
       MOZ_ASSERT(!aUsage.shouldGenerateClipMaskLayer &&
-                 !aUsage.shouldApplyClipPath && !aUsage.shouldApplyBasicShape);
+                 !aUsage.shouldApplyClipPath &&
+                 !aUsage.shouldApplyBasicShapeOrPath);
       break;
     default:
       MOZ_ASSERT_UNREACHABLE("Unsupported clip-path type.");
       break;
   }
 }
 
 class MixModeBlender {
@@ -803,21 +804,21 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
                                     maskFrame ? 1.0 : maskUsage.opacity,
                                     maskSurface, maskTransform);
     }
   }
 
   /* If this frame has only a trivial clipPath, set up cairo's clipping now so
    * we can just do normal painting and get it clipped appropriately.
    */
-  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShapeOrPath) {
     if (maskUsage.shouldApplyClipPath) {
       clipPathFrame->ApplyClipPath(aContext, aFrame, aTransform);
     } else {
-      nsCSSClipPathInstance::ApplyBasicShapeClip(aContext, aFrame);
+      nsCSSClipPathInstance::ApplyBasicShapeOrPathClip(aContext, aFrame);
     }
   }
 
   /* Paint the child */
   if (effectProperties.HasValidFilter()) {
     nsRegion* dirtyRegion = nullptr;
     nsRegion tmpDirtyRegion;
     if (aDirtyRect) {
@@ -852,17 +853,17 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
 
     SVGPaintCallback paintCallback;
     nsFilterInstance::PaintFilteredFrame(aFrame, target, &paintCallback,
                                          dirtyRegion, aImgParams);
   } else {
      svgFrame->PaintSVG(*target, aTransform, aImgParams, aDirtyRect);
   }
 
-  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShape) {
+  if (maskUsage.shouldApplyClipPath || maskUsage.shouldApplyBasicShapeOrPath) {
     aContext.PopClip();
   }
 
   if (shouldPushMask) {
     target->PopGroupAndBlend();
   }
 
   if (blender.ShouldCreateDrawTargetForBlend()) {
@@ -874,17 +875,17 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
 bool
 nsSVGUtils::HitTestClip(nsIFrame *aFrame, const gfxPoint &aPoint)
 {
   SVGObserverUtils::EffectProperties props =
     SVGObserverUtils::GetEffectProperties(aFrame);
   if (!props.mClipPath) {
     const nsStyleSVGReset *style = aFrame->StyleSVGReset();
     if (style->HasClipPath()) {
-      return nsCSSClipPathInstance::HitTestBasicShapeClip(aFrame, aPoint);
+      return nsCSSClipPathInstance::HitTestBasicShapeOrPathClip(aFrame, aPoint);
     }
     return true;
   }
 
   if (props.HasInvalidClipPath()) {
     // clipPath is not a valid resource, so nothing gets painted, so
     // hit-testing must fail.
     return false;
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -601,29 +601,32 @@ public:
   static nsRect ToCanvasBounds(const gfxRect &aUserspaceRect,
                                const gfxMatrix &aToCanvas,
                                const nsPresContext *presContext);
 
   struct MaskUsage {
     bool shouldGenerateMaskLayer;
     bool shouldGenerateClipMaskLayer;
     bool shouldApplyClipPath;
-    bool shouldApplyBasicShape;
+    bool shouldApplyBasicShapeOrPath;
     float opacity;
 
     MaskUsage()
-      : shouldGenerateMaskLayer(false), shouldGenerateClipMaskLayer(false),
-        shouldApplyClipPath(false), shouldApplyBasicShape(false), opacity(0.0)
+      : shouldGenerateMaskLayer(false)
+      , shouldGenerateClipMaskLayer(false)
+      , shouldApplyClipPath(false)
+      , shouldApplyBasicShapeOrPath(false)
+      , opacity(0.0)
     { }
 
     bool shouldDoSomething() {
       return shouldGenerateMaskLayer
           || shouldGenerateClipMaskLayer
           || shouldApplyClipPath
-          || shouldApplyBasicShape
+          || shouldApplyBasicShapeOrPath
           || opacity != 1.0;
     }
   };
 
   static void DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity,
                                  MaskUsage& aUsage);
 
   static float ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity);