Bug 1303623 - Part4. Rendering changes. r=heycam draft
authorEthan Lin <ethlin@mozilla.com>
Wed, 19 Oct 2016 15:49:57 +0800
changeset 445788 d673e85e8f4941fd8e1dd926b58bf36cf5c2ffc4
parent 445787 c0e596ce7af964b2f16fd50109bc6d6098f87676
child 445789 f33d8e17b8a06ca81f69ac34229ccf4754b614fe
push id37609
push userbmo:cku@mozilla.com
push dateWed, 30 Nov 2016 08:03:11 +0000
reviewersheycam
bugs1303623
milestone53.0a1
Bug 1303623 - Part4. Rendering changes. r=heycam MozReview-Commit-ID: AXKoabclfz9
layout/painting/nsCSSRendering.cpp
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1909,19 +1909,28 @@ nsCSSRendering::GetImageLayerClip(const 
   // Compute the outermost boundary of the area that might be painted.
   // Same coordinate space as aBorderArea.
   Sides skipSides = aForFrame->GetSkipSides();
   nsRect clipBorderArea =
     ::BoxDecorationRectForBorder(aForFrame, aBorderArea, skipSides, &aBorder);
 
   bool haveRoundedCorners = GetRadii(aForFrame, aBorder, aBorderArea,
                                      clipBorderArea, aClipState->mRadii);
-
   uint8_t backgroundClip = aLayer.mClip;
 
+  // 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 (backgroundClip == NS_STYLE_IMAGELAYER_CLIP_FILL ||
+      backgroundClip == NS_STYLE_IMAGELAYER_CLIP_STROKE ||
+      backgroundClip == NS_STYLE_IMAGELAYER_CLIP_VIEW ||
+      backgroundClip == NS_STYLE_IMAGELAYER_CLIP_NO_CLIP) {
+    backgroundClip = NS_STYLE_IMAGELAYER_CLIP_BORDER;
+  }
+
   bool isSolidBorder =
       aWillPaintBorder && IsOpaqueBorder(aBorder);
   if (isSolidBorder && backgroundClip == NS_STYLE_IMAGELAYER_CLIP_BORDER) {
     // If we have rounded corners, we need to inflate the background
     // drawing area a bit to avoid seams between the border and
     // background.
     backgroundClip = haveRoundedCorners ?
       NS_STYLE_IMAGELAYER_CLIP_MOZ_ALMOST_PADDING : NS_STYLE_IMAGELAYER_CLIP_PADDING;
@@ -3377,39 +3386,50 @@ 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;
 
+  uint8_t 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 == NS_STYLE_IMAGELAYER_ORIGIN_FILL ||
+      backgroundOrigin == NS_STYLE_IMAGELAYER_ORIGIN_STROKE ||
+      backgroundOrigin == NS_STYLE_IMAGELAYER_ORIGIN_VIEW) {
+    backgroundOrigin = NS_STYLE_IMAGELAYER_ORIGIN_BORDER;
+  }
+
   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()
         // For the dir=rtl case:
         + scrollableFrame->GetScrollRange().TopLeft(),
       scrollableFrame->GetScrolledRect().Size());
     // The ScrolledRect’s size does not include the borders or scrollbars,
     // reverse the handling of background-origin
     // compared to the common case below.
-    if (aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_BORDER) {
+    if (backgroundOrigin == NS_STYLE_IMAGELAYER_ORIGIN_BORDER) {
       nsMargin border = geometryFrame->GetUsedBorder();
       border.ApplySkipSides(geometryFrame->GetSkipSides());
       bgPositioningArea.Inflate(border);
       bgPositioningArea.Inflate(scrollableFrame->GetActualScrollbarSizes());
-    } else if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
+    } else if (backgroundOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
       nsMargin padding = geometryFrame->GetUsedPadding();
       padding.ApplySkipSides(geometryFrame->GetSkipSides());
       bgPositioningArea.Deflate(padding);
-      NS_ASSERTION(aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
+      NS_ASSERTION(backgroundOrigin == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
                    "unknown background-origin value");
     }
     *aAttachedToFrame = aForFrame;
     return bgPositioningArea;
   }
 
   if (MOZ_UNLIKELY(frameType == nsGkAtoms::canvasFrame)) {
     geometryFrame = aForFrame->PrincipalChildList().FirstChild();
@@ -3426,19 +3446,19 @@ nsCSSRendering::ComputeImageLayerPositio
 
   // 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
   // NS_STYLE_IMAGELAYER_ORIGIN_MARGIN instead of
   // NS_STYLE_IMAGELAYER_ORIGIN_BORDER.
   if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_BORDER && geometryFrame) {
     nsMargin border = geometryFrame->GetUsedBorder();
-    if (aLayer.mOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
+    if (backgroundOrigin != NS_STYLE_IMAGELAYER_ORIGIN_PADDING) {
       border += geometryFrame->GetUsedPadding();
-      NS_ASSERTION(aLayer.mOrigin == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
+      NS_ASSERTION(backgroundOrigin == NS_STYLE_IMAGELAYER_ORIGIN_CONTENT,
                    "unknown background-origin value");
     }
     bgPositioningArea.Deflate(border);
   }
 
   nsIFrame* attachedToFrame = aForFrame;
   if (NS_STYLE_IMAGELAYER_ATTACHMENT_FIXED == aLayer.mAttachment) {
     // If it's a fixed background attachment, then the image is placed