Skip to content

Commit aa8b54b

Browse files
committed
[1249] Fix body background rendering
1 parent 6fdcf6c commit aa8b54b

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

Source/WebCore/rendering/RenderBox.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,11 @@ void RenderBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& pai
16551655
bool RenderBox::paintsOwnBackground() const
16561656
{
16571657
if (isBody()) {
1658+
// If the body element is composited, then it needs to paint its own background, otherwise it won't be
1659+
// painted at all. See https://bugs.webkit.org/show_bug.cgi?id=266478.
1660+
if (isComposited())
1661+
return true;
1662+
16581663
// The <body> only paints its background if the root element has defined a background independent of the body,
16591664
// or if the <body>'s parent is not the document element's renderer (e.g. inside SVG foreignObject).
16601665
auto documentElementRenderer = document().documentElement()->renderer();
@@ -2041,22 +2046,14 @@ bool RenderBox::repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer
20412046
if (layer->image() && image == layer->image()->data() && (layer->image()->isLoaded() || layer->image()->canRender(this, style().effectiveZoom()))) {
20422047
// Now that we know this image is being used, compute the renderer and the rect if we haven't already.
20432048
bool drawingRootBackground = drawingBackground && (isDocumentElementRenderer() || (isBody() && !document().documentElement()->renderer()->hasBackground()));
2044-
if (!layerRenderer) {
2045-
if (drawingRootBackground) {
2046-
layerRenderer = &view();
20472049

2048-
LayoutUnit rw = downcast<RenderView>(*layerRenderer).frameView().contentsWidth();
2049-
LayoutUnit rh = downcast<RenderView>(*layerRenderer).frameView().contentsHeight();
2050+
// There are 2 cases here that need explanation when we're drawing the root background.
2051+
// * If this is the DocumentElementRenderer, then we use it as renderer.
2052+
// * If this is the body element, its background image can be painted by itself (if paintsOwnBackground is false) or
2053+
// by the DocumentElementRenderer. In both cases setting this instance as the renderer does the appropriate job.
2054+
layerRenderer = this;
2055+
rendererRect = borderBoxRect();
20502056

2051-
rendererRect = LayoutRect(-layerRenderer->marginLeft(),
2052-
-layerRenderer->marginTop(),
2053-
std::max(layerRenderer->width() + layerRenderer->horizontalMarginExtent() + layerRenderer->borderLeft() + layerRenderer->borderRight(), rw),
2054-
std::max(layerRenderer->height() + layerRenderer->verticalMarginExtent() + layerRenderer->borderTop() + layerRenderer->borderBottom(), rh));
2055-
} else {
2056-
layerRenderer = this;
2057-
rendererRect = borderBoxRect();
2058-
}
2059-
}
20602057
// FIXME: Figure out how to pass absolute position to calculateBackgroundImageGeometry (for pixel snapping)
20612058
BackgroundImageGeometry geometry = layerRenderer->calculateBackgroundImageGeometry(nullptr, *layer, LayoutPoint(), rendererRect);
20622059
if (geometry.hasNonLocalGeometry()) {

0 commit comments

Comments
 (0)