Chromium Code Reviews| Index: Source/core/layout/LayoutBoxModelObject.cpp |
| diff --git a/Source/core/layout/LayoutBoxModelObject.cpp b/Source/core/layout/LayoutBoxModelObject.cpp |
| index 5bb26441ea1591e11bd3296f507e504cb8768f8c..64b65fc6746bf67d62b01e0f4b1fc0e9c7f99c3c 100644 |
| --- a/Source/core/layout/LayoutBoxModelObject.cpp |
| +++ b/Source/core/layout/LayoutBoxModelObject.cpp |
| @@ -26,6 +26,8 @@ |
| #include "config.h" |
| #include "core/layout/LayoutBoxModelObject.h" |
| +#include "core/dom/NodeComputedStyle.h" |
| +#include "core/html/HTMLBodyElement.h" |
| #include "core/layout/ImageQualityController.h" |
| #include "core/layout/LayoutBlock.h" |
| #include "core/layout/LayoutFlowThread.h" |
| @@ -249,6 +251,19 @@ void LayoutBoxModelObject::styleDidChange(StyleDifference diff, const ComputedSt |
| invalidateDisplayItemClientForNonCompositingDescendants(); |
| } |
| + if (isDocumentElement()) { |
|
chrishtr
2015/06/08 20:30:58
Please add a comment.
trchen
2015/06/08 22:46:55
Done.
|
| + HTMLBodyElement* body = document().firstBodyElement(); |
| + LayoutObject* bodyLayout = body ? body->layoutObject() : nullptr; |
| + if (bodyLayout && bodyLayout->isBoxModelObject()) { |
| + bool newStoleBodyBackground = toLayoutBoxModelObject(bodyLayout)->backgroundStolenForBeingBody(style()); |
| + bool oldStoleBodyBackground = oldStyle && toLayoutBoxModelObject(bodyLayout)->backgroundStolenForBeingBody(oldStyle); |
| + if (newStoleBodyBackground != oldStoleBodyBackground |
| + && bodyLayout->style() && bodyLayout->style()->hasBackground()) { |
| + bodyLayout->setShouldDoFullPaintInvalidation(); |
| + } |
| + } |
| + } |
| + |
| if (FrameView *frameView = view()->frameView()) { |
| bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition(); |
| bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); |
| @@ -939,4 +954,27 @@ void LayoutBoxModelObject::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject |
| } |
| } |
| +bool LayoutBoxModelObject::backgroundStolenForBeingBody(const ComputedStyle* rootElementStyle) const |
| +{ |
| + // http://www.w3.org/TR/css3-background/#body-background |
| + // If the root element is <html> with no background, and a <body> child element exists, |
| + // the root element steals the first <body> child element's background. |
| + if (!isBody()) |
| + return false; |
| + |
| + Element* rootElement = document().documentElement(); |
| + if (!isHTMLHtmlElement(rootElement)) |
| + return false; |
| + |
| + if (!rootElementStyle) |
| + rootElementStyle = rootElement->ensureComputedStyle(); |
| + if (rootElementStyle->hasBackground()) |
| + return false; |
| + |
| + if (node() != document().firstBodyElement()) |
| + return false; |
| + |
| + return true; |
| +} |
| + |
| } // namespace blink |