Bug 1273250 - Expand the visible rect of fixed background display items instead of special-casing them in FrameLayerBuilder. r=mstange draft
authorBotond Ballo <botond@mozilla.com>
Mon, 16 May 2016 17:14:29 -0400
changeset 367610 5da55ed6ec733ff10c2c855c95bf4109fdbbe4b5
parent 367609 22ef189053bd80e3f8faaa10fb239031f8010587
child 367611 b561f8721d91c930bced7664f11a331552b97a5e
push id18289
push userbballo@mozilla.com
push dateMon, 16 May 2016 23:53:34 +0000
reviewersmstange
bugs1273250
milestone49.0a1
Bug 1273250 - Expand the visible rect of fixed background display items instead of special-casing them in FrameLayerBuilder. r=mstange MozReview-Commit-ID: DT3Mh8ordzQ
layout/base/FrameLayerBuilder.cpp
layout/base/nsDisplayList.cpp
--- a/layout/base/FrameLayerBuilder.cpp
+++ b/layout/base/FrameLayerBuilder.cpp
@@ -3931,26 +3931,21 @@ ContainerState::ProcessDisplayItems(nsDi
           }
         }
       }
     }
     ((nsRect&)mAccumulatedChildBounds).UnionRect(mAccumulatedChildBounds, bounds);
 #endif
 
     nsIntRect itemVisibleRect = itemDrawRect;
-    if (!shouldFixToViewport) {
-      // We haven't computed visibility at this point, so item->GetVisibleRect()
-      // is just the dirty rect that item was initialized with. We intersect it
-      // with the clipped item bounds to get a tighter visible rect.
-      // However, we don't do this for fixed background images, because their
-      // clips can move asynchronously so we want the layer to contain the
-      // whole bounds of the display item.
-      itemVisibleRect = itemVisibleRect.Intersect(
-        ScaleToOutsidePixels(item->GetVisibleRect(), false));
-    }
+    // We haven't computed visibility at this point, so item->GetVisibleRect()
+    // is just the dirty rect that item was initialized with. We intersect it
+    // with the clipped item bounds to get a tighter visible rect.
+    itemVisibleRect = itemVisibleRect.Intersect(
+      ScaleToOutsidePixels(item->GetVisibleRect(), false));
 
     if (maxLayers != -1 && layerCount >= maxLayers) {
       forceInactive = true;
     }
 
     // Assign the item to a layer
     if (layerState == LAYER_ACTIVE_FORCE ||
         (layerState == LAYER_INACTIVE && !mManager->IsWidgetLayerManager()) ||
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -2388,16 +2388,23 @@ nsDisplayBackgroundImage::nsDisplayBackg
     nsCSSRendering::PrepareImageLayer(presContext, mFrame, flags,
                                       mBackgroundRect, mBackgroundRect, layer,
                                       &isTransformedFixed);
   mShouldTreatAsFixed = ComputeShouldTreatAsFixed(isTransformedFixed);
 
   mBounds = GetBoundsInternal(aBuilder);
   if (ShouldFixToViewport(aBuilder)) {
     mAnimatedGeometryRoot = aBuilder->FindAnimatedGeometryRootFor(this);
+
+    // Expand the item's visible rect to cover the entire bounds, limited to the
+    // viewport rect. This is necessary because the background's clip can move
+    // asynchronously.
+    if (Maybe<nsRect> viewportRect = GetViewportRectRelativeToReferenceFrame(aBuilder, mFrame)) {
+      mVisibleRect = mBounds.Intersect(*viewportRect);
+    }
   }
 
   mFillRect = state.mFillArea;
   mDestRect = state.mDestArea;
 
   nsImageRenderer* imageRenderer = &state.mImageRenderer;
   // We only care about images here, not gradients.
   if (imageRenderer->IsRasterImage()) {