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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 2068723002: Paint local attachment backgrounds into composited scrolling contents layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve opaque layer detection and fix non-composited border painting bug in layout tests. Created 4 years, 5 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: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 246ccabb2e3a81e661dac034b68b9c451e15b57f..0cfbb374950d74f1d459ac342b00b0fed8cf98ff 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -727,6 +727,51 @@ LayoutRect LayoutBox::backgroundClipRect() const
return LayoutRect();
}
+LayoutRect LayoutBox::opaqueBackgroundClipRect() const
+{
+ EFillBox backgroundClip = TextFillBox;
+ // Find the largest opaque background clip rect.
+ // TODO(flackr): Unify with the above method.
+ if (const FillLayer* current = &(style()->backgroundLayers())) {
+ do {
+ const FillLayer* cur = current;
+ current = current->next();
+ if (cur->blendMode() != WebBlendModeNormal || cur->composite() != CompositeSourceOver)
+ continue;
+ // Check if the image or color has alpha.
+ if (const StyleImage* image = cur->image()) {
+ if (!image->knownToBeOpaque(*this))
+ continue;
+ } else {
+ Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
+ if (backgroundColor.hasAlpha())
+ continue;
+ }
+ EFillBox currentClip = cur->clip();
+ // Adjust clip if attachment is local.
+ if (currentClip == BorderFillBox && cur->attachment() == LocalBackgroundAttachment)
+ currentClip = PaddingFillBox;
+ // TODO(flackr): Expose and use clipMax method from FillLayer.cpp.
+ if (currentClip < backgroundClip)
+ backgroundClip = currentClip;
+ } while (current);
+ }
+ switch (backgroundClip) {
+ case BorderFillBox:
+ return borderBoxRect();
+ break;
+ case PaddingFillBox:
+ return paddingBoxRect();
+ break;
+ case ContentFillBox:
+ return contentBoxRect();
+ break;
+ default:
+ break;
+ }
+ return LayoutRect();
+}
+
void LayoutBox::addOutlineRects(Vector<LayoutRect>& rects, const LayoutPoint& additionalOffset, IncludeBlockVisualOverflowOrNot) const
{
rects.append(LayoutRect(additionalOffset, size()));
@@ -1395,10 +1440,6 @@ bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
if (isDocumentElement() || backgroundStolenForBeingBody())
return false;
- Color backgroundColor = resolveColor(CSSPropertyBackgroundColor);
- if (backgroundColor.hasAlpha())
- return false;
-
// If the element has appearance, it might be painted by theme.
// We cannot be sure if theme paints the background opaque.
// In this case it is safe to not assume opaqueness.
@@ -1412,10 +1453,9 @@ bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
return false;
if (hasClipPath())
return false;
- // FIXME: The background color clip is defined by the last layer.
- if (style()->backgroundLayers().next())
+ if (style()->hasBlendMode())
return false;
- return backgroundClipRect().contains(localRect);
+ return opaqueBackgroundClipRect().contains(localRect);
}
static bool isCandidateForOpaquenessTest(const LayoutBox& childBox)

Powered by Google App Engine
This is Rietveld 408576698