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

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 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
« no previous file with comments | « no previous file | Source/core/layout/LayoutBox.cpp » ('j') | Source/core/layout/LayoutBox.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 605ea63164fcc2ab7bfcf6708ce12dada440908a..ef81ab9a617b8402cfc9ac56d8e6b1f4049a4cf9 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -1627,16 +1627,28 @@ 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);
+ }
+ 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
@@ -1670,9 +1682,12 @@ void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
RefPtr<ComputedStyle> documentStyle = layoutView()->mutableStyle();
if (documentStyle->writingMode() != rootWritingMode
|| documentStyle->direction() != rootDirection
+ || documentStyle->columnGap() != columnGap
|| 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);
@@ -1680,6 +1695,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);
« no previous file with comments | « no previous file | Source/core/layout/LayoutBox.cpp » ('j') | Source/core/layout/LayoutBox.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698