| Index: Source/core/layout/LayoutBoxModelObject.cpp
|
| diff --git a/Source/core/layout/LayoutBoxModelObject.cpp b/Source/core/layout/LayoutBoxModelObject.cpp
|
| index a1c4e4474400ed203df6ee7e345912cc5a26177a..ce05ee9f53e9ba2256d32ad05a54e00dfc855111 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();
|
| + }
|
| + }
|
| + }
|
| +
|
| 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
|
|
|