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

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: rebase & revise expectation Created 5 years, 7 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 a9c37fc3fdf0091bc437c81ad03d425e11523a14..e673c38f716b682b90370c688121c8bb84957817 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1612,16 +1612,34 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
rootDirection = bodyStyle->direction();
}
- RefPtr<ComputedStyle> overflowStyle;
+ 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();
}
}
+ const ComputedStyle* backgroundStyle = documentElementStyle.get();
+ 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();
+
// Resolved rem units are stored in the matched properties cache so we need to make sure to
// invalidate the cache if the documentElement needed to reattach or the font size changed
// and then trigger a full document recalc. We also need to clear it here since the
@@ -1655,9 +1673,12 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
if (documentStyle->writingMode() != rootWritingMode
|| documentStyle->direction() != rootDirection
+ || documentStyle->columnGap() != columnGap
Xianzhu 2015/06/02 23:34:35 Better to keep the same order when calculating, ch
trchen 2015/06/03 00:06:59 Acknowledged.
|| documentStyle->overflowX() != overflowX
|| documentStyle->overflowY() != overflowY
- || documentStyle->columnGap() != columnGap
+ || documentStyle->visitedDependentColor(CSSPropertyBackgroundColor) != backgroundColor
+ || documentStyle->backgroundLayers() != backgroundLayers
+ || documentStyle->imageRendering() != imageRendering
|| documentStyle->scrollBlocksOn() != scrollBlocksOn) {
RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*documentStyle);
newStyle->setWritingMode(rootWritingMode);
@@ -1665,6 +1686,9 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
newStyle->setColumnGap(columnGap);
newStyle->setOverflowX(overflowX);
newStyle->setOverflowY(overflowY);
+ newStyle->setBackgroundColor(backgroundColor);
+ newStyle->accessBackgroundLayers() = backgroundLayers;
+ newStyle->setImageRendering(imageRendering);
newStyle->setScrollBlocksOn(scrollBlocksOn);
layoutView()->setStyle(newStyle);
setupFontBuilder(*newStyle);

Powered by Google App Engine
This is Rietveld 408576698