Bug 1273250 - Expand the visible rect of fixed background display items instead of special-casing them in FrameLayerBuilder. r=mstange
MozReview-Commit-ID: DT3Mh8ordzQ
--- 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()) {