Chromium Code Reviews| Index: Source/core/layout/LayoutBoxModelObject.cpp |
| diff --git a/Source/core/layout/LayoutBoxModelObject.cpp b/Source/core/layout/LayoutBoxModelObject.cpp |
| index b82d053b67fbd5e03673e2ab8e59a7425c382031..efe68d6021a2147880885698deb5e22592141255 100644 |
| --- a/Source/core/layout/LayoutBoxModelObject.cpp |
| +++ b/Source/core/layout/LayoutBoxModelObject.cpp |
| @@ -26,6 +26,7 @@ |
| #include "config.h" |
| #include "core/layout/LayoutBoxModelObject.h" |
| +#include "core/dom/NodeComputedStyle.h" |
| #include "core/layout/ImageQualityController.h" |
| #include "core/layout/LayoutBlock.h" |
| #include "core/layout/LayoutFlowThread.h" |
| @@ -249,6 +250,21 @@ void LayoutBoxModelObject::styleDidChange(StyleDifference diff, const ComputedSt |
| invalidateDisplayItemClientForNonCompositingDescendants(); |
| } |
| + if (isDocumentElement() && isHTMLHtmlElement(node())) { |
| + // Refers to backgroundStolenForBeingBody(). |
| + bool newStyleHasBackground = style()->hasBackground(); |
| + bool oldStyleHasBackground = oldStyle && oldStyle->hasBackground(); |
| + if (newStyleHasBackground != oldStyleHasBackground) { |
| + Element* body = document().body(); |
| + LayoutObject* bodyLayout = isHTMLBodyElement(body) ? body->layoutObject() : nullptr; |
| + if (bodyLayout) { |
| + const ComputedStyle* bodyStyle = bodyLayout->style(); |
| + if (bodyStyle && bodyStyle->hasBackground()) |
| + bodyLayout-> setShouldDoFullPaintInvalidation(); |
|
Xianzhu
2015/06/02 23:34:35
s/-> /->/
trchen
2015/06/03 00:06:59
Acknowledged.
|
| + } |
| + } |
| + } |
| + |
| if (FrameView *frameView = view()->frameView()) { |
| bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition(); |
| bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition(); |
| @@ -709,6 +725,11 @@ bool LayoutBoxModelObject::boxShadowShouldBeAppliedToBackground(BackgroundBleedA |
| if (backgroundColor.hasAlpha()) |
| return false; |
| + // TODO(trchen): Mask layers are painted with the same code path as background layers. |
| + // We shouldn't paint shadow to the mask by accident. |
| + if (style()->maskImage()) |
| + return false; |
| + |
| const FillLayer* lastBackgroundLayer = &style()->backgroundLayers(); |
| for (const FillLayer* next = lastBackgroundLayer->next(); next; next = lastBackgroundLayer->next()) |
| lastBackgroundLayer = next; |
| @@ -944,4 +965,22 @@ void LayoutBoxModelObject::moveChildrenTo(LayoutBoxModelObject* toBoxModelObject |
| } |
| } |
| +bool LayoutBoxModelObject::backgroundStolenForBeingBody() 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) || rootElement->ensureComputedStyle()->hasBackground()) |
| + return false; |
| + |
| + if (node() != document().body()) |
| + return false; |
| + |
| + return true; |
| +} |
| + |
| } // namespace blink |