Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(620)

Unified Diff: Source/core/dom/Document.cpp

Issue 1145993002: Refactor root element background painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert to patchset 10 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 582f900a5af515086f2eb2c6b5a9b5a57e19353b..282e04f85df08b945f65ee9d40f69577d87f9718 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1612,13 +1612,34 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
rootDirection = bodyStyle->direction();
}
- RefPtr<ComputedStyle> overflowStyle;
+ const ComputedStyle* backgroundStyle = documentElementStyle.get();
+ // http://www.w3.org/TR/css3-background/#body-background
+ // <html> root element with no background steals background from its first <body> child.
+ // Also see LayoutBoxModelObject::backgroundStolenForBeingBody()
+ if (isHTMLHtmlElement(documentElement()) && isHTMLBodyElement(body) && !backgroundStyle->hasBackground())
+ backgroundStyle = bodyStyle.get();
+ Color backgroundColor = backgroundStyle->visitedDependentColor(CSSPropertyBackgroundColor);
+ FillLayer backgroundLayers = backgroundStyle->backgroundLayers();
+ for (auto currentLayer = &backgroundLayers; currentLayer; currentLayer = currentLayer->next()) {
+ // http://www.w3.org/TR/css3-background/#root-background
+ // The root element background always have painting area of the whole canvas.
+ currentLayer->setClip(BorderFillBox);
+
+ // The root element doesn't scroll. It always propagates its layout overflow
+ // to the viewport. Positioning background against either box is equivalent to
+ // positioning against the scrolled box of the viewport.
+ if (currentLayer->attachment() == ScrollBackgroundAttachment)
+ currentLayer->setAttachment(LocalBackgroundAttachment);
+ }
+ EImageRendering imageRendering = backgroundStyle->imageRendering();
+
+ const ComputedStyle* overflowStyle = nullptr;
if (Element* element = viewportDefiningElement(documentElementStyle.get())) {
if (element == body) {
- overflowStyle = bodyStyle;
+ overflowStyle = bodyStyle.get();
} else {
ASSERT(element == documentElement());
- overflowStyle = documentElementStyle;
+ overflowStyle = documentElementStyle.get();
}
}
@@ -1655,6 +1676,9 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
if (documentStyle->writingMode() != rootWritingMode
|| documentStyle->direction() != rootDirection
+ || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor
chrishtr 2015/06/05 23:54:18 How do you know this list is complete? Is it exhau
trchen 2015/06/06 05:30:02 I think so. Everything in css3-background is cover
+ || documentStyle->backgroundLayers() != backgroundLayers
+ || documentStyle->imageRendering() != imageRendering
|| documentStyle->overflowX() != overflowX
|| documentStyle->overflowY() != overflowY
|| documentStyle->columnGap() != columnGap
@@ -1662,9 +1686,12 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle);
newStyle->setWritingMode(rootWritingMode);
newStyle->setDirection(rootDirection);
- newStyle->setColumnGap(columnGap);
+ newStyle->setBackgroundColor(backgroundColor);
+ newStyle->accessBackgroundLayers() = backgroundLayers;
+ newStyle->setImageRendering(imageRendering);
newStyle->setOverflowX(overflowX);
newStyle->setOverflowY(overflowY);
+ newStyle->setColumnGap(columnGap);
newStyle->setScrollBlocksOn(scrollBlocksOn);
layoutView()->setStyle(newStyle);
setupFontBuilder(*newStyle);

Powered by Google App Engine
This is Rietveld 408576698