Bug 1166301 - If APZ is enabled, only clip fixed background images to the viewport area. r=mattwoodrow

--HG--
extra : rebase_source : 9f10834ee3fe429d4afb52bce643411f385f1f1a
extra : source : 7cee3d3e42a562996fdfc602145712d21b1d91ca
This commit is contained in:
Botond Ballo 2015-09-02 15:27:41 -04:00
parent 66ecf4ccdd
commit 52a154ac58
2 changed files with 18 additions and 2 deletions

View File

@ -2349,6 +2349,13 @@ nsDisplayBackgroundImage::IsSingleFixedPositionImage(nsDisplayListBuilder* aBuil
return true;
}
bool
nsDisplayBackgroundImage::IsNonEmptyFixedImage() const
{
return mBackgroundStyle->mLayers[mLayer].mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
!mBackgroundStyle->mLayers[mLayer].mImage.IsEmpty();
}
bool
nsDisplayBackgroundImage::ShouldFixToViewport(LayerManager* aManager)
{
@ -2360,8 +2367,7 @@ nsDisplayBackgroundImage::ShouldFixToViewport(LayerManager* aManager)
// Put background-attachment:fixed background images in their own
// compositing layer.
return mBackgroundStyle->mLayers[mLayer].mAttachment == NS_STYLE_BG_ATTACHMENT_FIXED &&
!mBackgroundStyle->mLayers[mLayer].mImage.IsEmpty();
return IsNonEmptyFixedImage();
}
bool
@ -2777,6 +2783,15 @@ nsDisplayBackgroundImage::GetBoundsInternal(nsDisplayListBuilder* aBuilder) {
if (mFrame->GetType() == nsGkAtoms::canvasFrame) {
nsCanvasFrame* frame = static_cast<nsCanvasFrame*>(mFrame);
clipRect = frame->CanvasArea() + ToReferenceFrame();
} else if (nsLayoutUtils::UsesAsyncScrolling(mFrame) && IsNonEmptyFixedImage()) {
// If this is a background-attachment:fixed image, and APZ is enabled,
// async scrolling could reveal additional areas of the image, so don't
// clip it beyond clipping to the document's viewport.
nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
nsRect rootRect = rootFrame->GetRectRelativeToSelf();
if (nsLayoutUtils::TransformRect(rootFrame, mFrame, rootRect) == nsLayoutUtils::TRANSFORM_SUCCEEDED) {
clipRect = rootRect + aBuilder->ToReferenceFrame(mFrame);
}
}
const nsStyleBackground::Layer& layer = mBackgroundStyle->mLayers[mLayer];
return nsCSSRendering::GetBackgroundLayerRect(presContext, mFrame,

View File

@ -2403,6 +2403,7 @@ protected:
bool IsSingleFixedPositionImage(nsDisplayListBuilder* aBuilder,
const nsRect& aClipRect,
gfxRect* aDestRect);
bool IsNonEmptyFixedImage() const;
nsRect GetBoundsInternal(nsDisplayListBuilder* aBuilder);
void PaintInternal(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx,