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

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

Issue 2264663002: Paint solid color backgrounds which are equivalent to locally attached into scrolling contents layer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scrollcontent-paint-bg
Patch Set: Add test and only skip local equivalence if outline enters padding-box Created 4 years, 4 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/LayoutBoxModelObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
index 6c6ec933ce0598843aae45578a2128c3483ef273..a757f5e362f632e2d3b2cd70e1061308f658b884 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -33,6 +33,7 @@
#include "core/layout/LayoutFlexibleBox.h"
#include "core/layout/LayoutGeometryMap.h"
#include "core/layout/LayoutInline.h"
+#include "core/layout/LayoutTheme.h"
#include "core/layout/LayoutView.h"
#include "core/layout/compositing/CompositedLayerMapping.h"
#include "core/layout/compositing/PaintLayerCompositor.h"
@@ -115,6 +116,64 @@ bool LayoutBoxModelObject::usesCompositedScrolling() const
return hasOverflowClip() && hasLayer() && layer()->getScrollableArea()->usesCompositedScrolling();
}
+bool LayoutBoxModelObject::hasLocalEquivalentBackground() const
+{
+ int minBorderWidth = std::min(style()->borderTopWidth(),
+ std::min(style()->borderLeftWidth(),
+ std::min(style()->borderRightWidth(), style()->borderBottomWidth())));
+ bool outlineOverlapsPaddingBox = style()->outlineOffset() < -minBorderWidth;
+ bool hasCustomScrollbars = false;
+ // TODO(flackr): Detect opaque custom scrollbars which would cover up a border-box
+ // background.
+ if (PaintLayerScrollableArea* scrollableArea = getScrollableArea()) {
+ if ((scrollableArea->horizontalScrollbar() && scrollableArea->horizontalScrollbar()->isCustomScrollbar())
+ || (scrollableArea->verticalScrollbar() && scrollableArea->verticalScrollbar()->isCustomScrollbar())) {
+ hasCustomScrollbars = true;
+ }
+ }
+
+ const FillLayer* layer = &(style()->backgroundLayers());
+ for (; layer; layer = layer->next()) {
+ if (layer->attachment() == LocalBackgroundAttachment)
+ continue;
+
+ // If the outline draws inside the border, it intends to draw on top of the scroller's background,
+ // however because it is painted into a layer behind the scrolling contents layer we avoid auto
+ // promoting in this case to avoid obscuring the outline.
+ // TODO(flackr): Outlines should be drawn on top of the scrolling contents layer so that
+ // they cannot be covered up by composited scrolling contents.
+ if (outlineOverlapsPaddingBox)
+ return false;
+
+ // Solid color layers with an effective background clip of the padding box can be treated
+ // as local.
+ if (!layer->image() && !layer->next() && resolveColor(CSSPropertyBackgroundColor).alpha() > 0) {
+ EFillBox clip = layer->clip();
+ if (clip == PaddingFillBox)
+ continue;
+ // A border box can be treated as a padding box if the border is opaque or there is
+ // no border and we don't have custom scrollbars.
+ if (clip == BorderFillBox && !hasCustomScrollbars
+ && (style()->borderTopWidth() == 0 || !resolveColor(CSSPropertyBorderTopColor).hasAlpha())
+ && (style()->borderLeftWidth() == 0 || !resolveColor(CSSPropertyBorderLeftColor).hasAlpha())
+ && (style()->borderRightWidth() == 0 || !resolveColor(CSSPropertyBorderRightColor).hasAlpha())
+ && (style()->borderBottomWidth() == 0 || !resolveColor(CSSPropertyBorderBottomColor).hasAlpha())) {
+ continue;
+ }
+ // A content fill box can be treated as a padding fill box if there is no padding.
+ if (clip == ContentFillBox
+ && style()->paddingTop().isZero()
+ && style()->paddingLeft().isZero()
+ && style()->paddingRight().isZero()
+ && style()->paddingBottom().isZero()) {
+ continue;
+ }
+ }
+ return false;
+ }
+ return true;
+}
+
LayoutBoxModelObject::~LayoutBoxModelObject()
{
// Our layer should have been destroyed and cleared by now
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBoxModelObject.h ('k') | third_party/WebKit/Source/core/layout/LayoutTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698