Bug 1311270 - Part 6. Handle mask-origin.
authorcku <cku@mozilla.com>
Thu, 24 Nov 2016 02:52:44 +0800
changeset 372173 1b0ac433a1003c581c31120fbf2d511d89a27aa6
parent 372172 6509a168badfb0ee4e6de42f23be7b8209cd5242
child 372174 d83d4dd9f36a9e758d3f860dc96fe6a294a1e099
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1311270
milestone53.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 1311270 - Part 6. Handle mask-origin. MozReview-Commit-ID: EGuK4TIy7wp
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -3463,26 +3463,41 @@ nsCSSRendering::ComputeImageLayerPositio
                                                  const nsStyleImageLayers::Layer& aLayer,
                                                  nsIFrame** aAttachedToFrame,
                                                  bool* aOutIsTransformedFixed)
 {
   // Compute background origin area relative to aBorderArea now as we may need
   // it to compute the effective image size for a CSS gradient.
   nsRect bgPositioningArea;
 
-  StyleGeometryBox backgroundOrigin = aLayer.mOrigin;
-
-  // XXX TODO: bug 1303623 only implements the parser of fill-box|stroke-box|view-box|no-clip.
-  // So we need to fallback to default value when rendering. We should remove this
-  // in bug 1311270.
-  if (backgroundOrigin == StyleGeometryBox::Fill ||
-      backgroundOrigin == StyleGeometryBox::Stroke ||
-      backgroundOrigin == StyleGeometryBox::View) {
-    backgroundOrigin = StyleGeometryBox::Border;
-  }
+  StyleGeometryBox backgroundOrigin =
+    ComputeBoxValue(aForFrame, aLayer.mOrigin);
+
+  if (IsSVGStyleGeometryBox(backgroundOrigin)) {
+    MOZ_ASSERT(aForFrame->IsFrameOfType(nsIFrame::eSVG) &&
+               (aForFrame->GetType() != nsGkAtoms::svgOuterSVGFrame));
+    *aAttachedToFrame = aForFrame;
+
+    bgPositioningArea =
+      nsLayoutUtils::ComputeGeometryBox(aForFrame, backgroundOrigin);
+
+    nsPoint toStrokeBoxOffset = nsPoint(0, 0);
+    if (backgroundOrigin != StyleGeometryBox::Stroke) {
+      nsRect strokeBox =
+        nsLayoutUtils::ComputeGeometryBox(aForFrame,
+                                          StyleGeometryBox::Stroke);
+      toStrokeBoxOffset = bgPositioningArea.TopLeft() - strokeBox.TopLeft();
+    }
+
+    // For SVG frames, the return value is relative to the stroke box
+    return nsRect(toStrokeBoxOffset, bgPositioningArea.Size());
+  }
+
+  MOZ_ASSERT(!aForFrame->IsFrameOfType(nsIFrame::eSVG) ||
+             aForFrame->GetType() == nsGkAtoms::svgOuterSVGFrame);
 
   nsIAtom* frameType = aForFrame->GetType();
   nsIFrame* geometryFrame = aForFrame;
   if (MOZ_UNLIKELY(frameType == nsGkAtoms::scrollFrame &&
                    NS_STYLE_IMAGELAYER_ATTACHMENT_LOCAL == aLayer.mAttachment)) {
     nsIScrollableFrame* scrollableFrame = do_QueryFrame(aForFrame);
     bgPositioningArea = nsRect(
       scrollableFrame->GetScrolledFrame()->GetPosition()
@@ -3518,19 +3533,16 @@ nsCSSRendering::ComputeImageLayerPositio
       bgPositioningArea = geometryFrame->GetRect();
     }
   } else {
     bgPositioningArea = nsRect(nsPoint(0,0), aBorderArea.Size());
   }
 
   // Background images are tiled over the 'background-clip' area
   // but the origin of the tiling is based on the 'background-origin' area
-  // XXX: Bug 1303623 will bring in new origin value, we should iterate from
-  // StyleGeometryBox::Margin instead of
-  // StyleGeometryBox::Border.
   if (backgroundOrigin != StyleGeometryBox::Border && geometryFrame) {
     nsMargin border = geometryFrame->GetUsedBorder();
     if (backgroundOrigin != StyleGeometryBox::Padding) {
       border += geometryFrame->GetUsedPadding();
       NS_ASSERTION(backgroundOrigin == StyleGeometryBox::Content,
                    "unknown background-origin value");
     }
     bgPositioningArea.Deflate(border);