Skip to content


Browse files Browse the repository at this point in the history
Prevent background propagation on <html> with any containment

Reviewed by Simon Fraser.

This patch ensures that we don't paint the root (initial contain block) background unless there's a renderer from where the background color could be propagated. This should include cases when containment rules prevent the background color from being painted on the canvas (initial contains block). This is not to be confused with either rootFillsViewport or rootObscuresBackground logic (they both have a slightly different meaning; -where with shouldPropagateBackgroundPaintingToInitialContainingBlock, we still paint the ICB background, but we use the default color instead.)

* Source/WebCore/rendering/RenderView.cpp:

Canonical link:
  • Loading branch information
alanbaradlay committed Aug 2, 2022
1 parent 28422ee commit 320ad14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/WebCore/rendering/RenderView.cpp
Expand Up @@ -396,12 +396,14 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)

bool rootFillsViewport = false;
bool rootObscuresBackground = false;
auto shouldPropagateBackgroundPaintingToInitialContainingBlock = true;
Element* documentElement = document().documentElement();
if (RenderElement* rootRenderer = documentElement ? documentElement->renderer() : nullptr) {
// The document element's renderer is currently forced to be a block, but may not always be.
auto* rootBox = dynamicDowncast<RenderBox>(*rootRenderer);
rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox->width() >= width() && rootBox->height() >= height();
rootObscuresBackground = rendererObscuresBackground(*rootRenderer);
shouldPropagateBackgroundPaintingToInitialContainingBlock = !!rendererForRootBackground();

Expand All @@ -423,7 +425,7 @@ void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
frameView().setCannotBlitToWindow(); // The parent must show behind the child.
else {
const Color& documentBackgroundColor = frameView().documentBackgroundColor();
const Color& backgroundColor = (settings().backgroundShouldExtendBeyondPage() && documentBackgroundColor.isValid()) ? documentBackgroundColor : frameView().baseBackgroundColor();
const Color& backgroundColor = (shouldPropagateBackgroundPaintingToInitialContainingBlock && settings().backgroundShouldExtendBeyondPage() && documentBackgroundColor.isValid()) ? documentBackgroundColor : frameView().baseBackgroundColor();
if (backgroundColor.isVisible()) {
CompositeOperator previousOperator = paintInfo.context().compositeOperation();
Expand Down

0 comments on commit 320ad14

Please sign in to comment.