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

Unified Diff: Source/core/layout/LayoutBox.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
Index: Source/core/layout/LayoutBox.cpp
diff --git a/Source/core/layout/LayoutBox.cpp b/Source/core/layout/LayoutBox.cpp
index 3fe7409b4b57cf3135ad63f77991de306704d548..6f948014a58612494bf2697b93aa38c48623670a 100644
--- a/Source/core/layout/LayoutBox.cpp
+++ b/Source/core/layout/LayoutBox.cpp
@@ -89,17 +89,6 @@ static OverrideSizeMap* gExtraBlockOffsetMap = 0;
static const int autoscrollBeltSize = 20;
static const unsigned backgroundObscurationTestMaxDepth = 4;
-static bool skipBodyBackground(const LayoutBox* bodyElementLayoutObject)
-{
- ASSERT(bodyElementLayoutObject->isBody());
- // The <body> only paints its background if the root element has defined a background independent of the body,
- // or if the <body>'s parent is not the document element's layoutObject (e.g. inside SVG foreignObject).
- LayoutObject* documentElementLayoutObject = bodyElementLayoutObject->document().documentElement()->layoutObject();
- return documentElementLayoutObject
- && !documentElementLayoutObject->hasBackground()
- && (documentElementLayoutObject == bodyElementLayoutObject->parent());
-}
-
LayoutBox::LayoutBox(ContainerNode* node)
: LayoutBoxModelObject(node)
, m_intrinsicContentLogicalHeight(-1)
@@ -1188,7 +1177,7 @@ bool LayoutBox::getBackgroundPaintedExtent(LayoutRect& paintedExtent)
bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
{
- if (isBody() && skipBodyBackground(this))
+ if (backgroundStolenForBeingBody())
return false;
Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
@@ -1329,7 +1318,7 @@ void LayoutBox::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOf
void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
{
- if (!parent())
+ if (!parent() && !isLayoutView())
return;
// TODO(chrishtr): support PaintInvalidationDelayedFull for animated border images.
@@ -1354,29 +1343,15 @@ void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*)
bool LayoutBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const FillLayer& layers, bool drawingBackground)
Xianzhu 2015/05/20 16:14:44 BTW this function can be renamed to 'invalidatePai
{
- Vector<LayoutObject*> layerLayoutObjects;
-
- // A background of the body or document must extend to the total visible size of the document. This means the union of the
- // view and document bounds, since it can be the case that the view is larger than the document and vice-versa.
- // http://dev.w3.org/csswg/css-backgrounds/#the-background
- if (drawingBackground && (isDocumentElement() || (isBody() && !document().documentElement()->layoutObject()->hasBackground()))) {
- layerLayoutObjects.append(document().documentElement()->layoutObject());
- layerLayoutObjects.append(view());
- if (view()->frameView())
- view()->frameView()->setNeedsFullPaintInvalidation();
- } else {
- layerLayoutObjects.append(this);
- }
+ if (drawingBackground && (isDocumentElement() || backgroundStolenForBeingBody()))
+ return false;
for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->next()) {
- if (curLayer->image() && image == curLayer->image()->data() && curLayer->image()->canRender(*this, style()->effectiveZoom())) {
- for (LayoutObject* layerLayoutObject : layerLayoutObjects) {
- // For now, only support delayed paint invalidation for animated background images.
- bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->image()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->maybeAnimated();
- if (maybeAnimated && drawingBackground)
- layerLayoutObject->setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
- else
- layerLayoutObject->setShouldDoFullPaintInvalidation(PaintInvalidationFull);
- }
+ if (curLayer->image() && image == curLayer->image()->data()) {
+ bool maybeAnimated = curLayer->image()->cachedImage() && curLayer->image()->cachedImage()->image() && curLayer->image()->cachedImage()->image()->maybeAnimated();
+ if (maybeAnimated && drawingBackground)
+ setShouldDoFullPaintInvalidation(PaintInvalidationDelayedFull);
+ else
+ setShouldDoFullPaintInvalidation();
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698