Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0637bedae75eb3bea1f33827d6a576c193134371
https://github.com/WebKit/WebKit/commit/0637bedae75eb3bea1f33827d6a576c193134371
Author: Kiet Ho <[email protected]>
Date: 2026-07-02 (Thu, 02 Jul 2026)
Changed paths:
A LayoutTests/fast/body-propagation/background-color/009-expected.html
A LayoutTests/fast/body-propagation/background-color/009.html
A LayoutTests/fast/body-propagation/background-color/010-expected.html
A LayoutTests/fast/body-propagation/background-color/010.html
M Source/WebCore/rendering/BackgroundPainter.cpp
M Source/WebCore/rendering/RenderView.cpp
Log Message:
-----------
Background of composited root element is not re-painted when background of
<body> changes
rdar://177975964
https://bugs.webkit.org/show_bug.cgi?id=315512
Reviewed by Simon Fraser and Alan Baradlay.
Per CSS Backgrounds spec [1], the background of <body> is used as the
background of the root
element (e.g <html>). When the background of <body> changes,
RenderBox::styleWillChange handles
this by repainting the RenderView:
void RenderBox::styleWillChange(Style::Difference diff, const
Style::ComputedStyle& newStyle)
{
s_hadNonVisibleOverflow = hasNonVisibleOverflow();
const Style::ComputedStyle* oldStyle = hasInitializedStyle() ? &style() :
nullptr;
if (oldStyle) {
if (diff >= Style::DifferenceResult::Repaint &&
(isDocumentElementRenderer() || isBody())) {
----> view().repaintRootContents();
if (Style::hasEntirelyFixedBackground(oldStyle->backgroundLayers())
!= Style::hasEntirelyFixedBackground(newStyle.backgroundLayers()))
view().compositor().rootLayerConfigurationChanged();
}
[...]
}
But this only repaints the RenderView, not the root. It might just so happen to
re-paint
its contents because the repaint region of RenderView covers it. BUT, if it's
composited
(e.g an element is fixed-positioned and has negative z-index, forcing creation
of background
and content layers), then its layers doesn't get repainted. This may include
the background
layer, which is the document's background.
Fix this by making RenderView::repaintRootContents repaint the root layer too if
it's composited.
[1]: https://drafts.csswg.org/css-backgrounds/#body-background
Tests: fast/body-propagation/background-color/009.html
fast/body-propagation/background-color/010.html
* LayoutTests/fast/body-propagation/background-color/009-expected.html: Added.
* LayoutTests/fast/body-propagation/background-color/009.html: Added.
* LayoutTests/fast/body-propagation/background-color/010-expected.html: Added.
* LayoutTests/fast/body-propagation/background-color/010.html: Added.
- Add tests that change the background color of <body> in two ways: by
modifying the
style directly, and by changing the light/dark appearance. Unfortunately
the tests
rely on testRunner.dontForceRepaint(), so they can't be upstreamed to WPT.
* Source/WebCore/rendering/BackgroundPainter.cpp:
(WebCore::BackgroundPainter::paintsOwnBackground):
* Source/WebCore/rendering/RenderView.cpp:
(WebCore::RenderView::repaintRootContents):
Canonical link: https://commits.webkit.org/316415@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications