diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index dccc0319722e..7aae6b1ba7ce 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -7720,6 +7720,8 @@ nsDisplayText::nsDisplayText(nsDisplayListBuilder* aBuilder, mBounds = mFrame->InkOverflowRectRelativeToSelf() + ToReferenceFrame(); // Bug 748228 mBounds.Inflate(mFrame->PresContext()->AppUnitsPerDevPixel()); + mVisibleRect = aBuilder->GetVisibleRect() + + aBuilder->GetCurrentFrameOffsetToReferenceFrame(); } bool nsDisplayText::CanApplyOpacity(WebRenderLayerManager* aManager, @@ -7743,7 +7745,10 @@ bool nsDisplayText::CanApplyOpacity(WebRenderLayerManager* aManager, void nsDisplayText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { AUTO_PROFILER_LABEL("nsDisplayText::Paint", GRAPHICS); - RenderToContext(aCtx, aBuilder); + // We don't pass mVisibleRect here, since this can be called from within + // the WebRender fallback painting path, and we don't want to issue + // recorded commands that are dependent on the visible/building rect. + RenderToContext(aCtx, aBuilder, GetPaintRect(aBuilder, aCtx)); } bool nsDisplayText::CreateWebRenderCommands( @@ -7793,7 +7798,7 @@ bool nsDisplayText::CreateWebRenderCommands( // ::selected and ::inctive-selected pseudo-selectors. So don't do this // optimization if we have shadows or a selection. if (!(f->IsSelected() || f->StyleText()->HasTextShadow())) { - nsRect visible = GetPaintRect(); + nsRect visible = mVisibleRect; visible.Inflate(3 * appUnitsPerDevPixel); bounds = bounds.Intersect(visible); } @@ -7803,7 +7808,7 @@ bool nsDisplayText::CreateWebRenderCommands( aBuilder.StartGroup(this); - RenderToContext(textDrawer, aDisplayListBuilder, + RenderToContext(textDrawer, aDisplayListBuilder, mVisibleRect, aBuilder.GetInheritedOpacity(), true); const bool result = textDrawer->GetTextDrawer()->Finish(); @@ -7818,7 +7823,8 @@ bool nsDisplayText::CreateWebRenderCommands( void nsDisplayText::RenderToContext(gfxContext* aCtx, nsDisplayListBuilder* aBuilder, - float aOpacity, bool aIsRecording) { + const nsRect& aVisibleRect, float aOpacity, + bool aIsRecording) { nsTextFrame* f = static_cast(mFrame); // Add 1 pixel of dirty area around mVisibleRect to allow us to paint @@ -7827,7 +7833,7 @@ void nsDisplayText::RenderToContext(gfxContext* aCtx, // extents. auto A2D = mFrame->PresContext()->AppUnitsPerDevPixel(); LayoutDeviceRect extraVisible = - LayoutDeviceRect::FromAppUnits(GetPaintRect(), A2D); + LayoutDeviceRect::FromAppUnits(aVisibleRect, A2D); extraVisible.Inflate(1); gfxRect pixelVisible(extraVisible.x, extraVisible.y, extraVisible.width, diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index d6748ac52862..6d53e1bd8ef0 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -6640,7 +6640,8 @@ class nsDisplayText final : public nsPaintedDisplayItem { nsRegion* aInvalidRegion) const final; void RenderToContext(gfxContext* aCtx, nsDisplayListBuilder* aBuilder, - float aOpacity = 1.0f, bool aIsRecording = false); + const nsRect& aVisibleRect, float aOpacity = 1.0f, + bool aIsRecording = false); bool CanApplyOpacity(WebRenderLayerManager* aManager, nsDisplayListBuilder* aBuilder) const final; @@ -6685,6 +6686,7 @@ class nsDisplayText final : public nsPaintedDisplayItem { private: nsRect mBounds; + nsRect mVisibleRect; // Lengths measured from the visual inline start and end sides // (i.e. left and right respectively in horizontal writing modes, diff --git a/layout/xul/nsTextBoxFrame.cpp b/layout/xul/nsTextBoxFrame.cpp index 7af40fcd912c..9970d2f72c12 100644 --- a/layout/xul/nsTextBoxFrame.cpp +++ b/layout/xul/nsTextBoxFrame.cpp @@ -266,7 +266,8 @@ void nsDisplayXULTextBox::Paint(nsDisplayListBuilder* aBuilder, // Paint the text shadow before doing any foreground stuff nsRect drawRect = static_cast(mFrame)->mTextDrawRect + ToReferenceFrame(); - nsLayoutUtils::PaintTextShadow(mFrame, aCtx, drawRect, GetPaintRect(), + nsLayoutUtils::PaintTextShadow(mFrame, aCtx, drawRect, + GetPaintRect(aBuilder, aCtx), mFrame->StyleText()->mColor.ToColor(), PaintTextShadowCallback, (void*)this); @@ -276,7 +277,8 @@ void nsDisplayXULTextBox::Paint(nsDisplayListBuilder* aBuilder, void nsDisplayXULTextBox::PaintTextToContext(gfxContext* aCtx, nsPoint aOffset, const nscolor* aColor) { static_cast(mFrame)->PaintTitle( - *aCtx, GetPaintRect(), ToReferenceFrame() + aOffset, aColor); + *aCtx, mFrame->InkOverflowRectRelativeToSelf() + ToReferenceFrame(), + ToReferenceFrame() + aOffset, aColor); } bool nsDisplayXULTextBox::CreateWebRenderCommands(