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

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

Issue 2511893002: Paint solid color background into both scrolling contents layer and graphics layer. (Closed)
Patch Set: Created 4 years, 1 month 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 34be08968d9df991c67e4d51e6c74b68e868ab94..17ba956ea0b99716c94b80b12a256258f7eefb1e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp
@@ -111,7 +111,7 @@ bool LayoutBoxModelObject::usesCompositedScrolling() const {
layer()->getScrollableArea()->usesCompositedScrolling();
}
-bool LayoutBoxModelObject::hasLocalEquivalentBackground() const {
+BackgroundPaintLocation LayoutBoxModelObject::backgroundPaintLocation() const {
int minBorderWidth = std::min(
style()->borderTopWidth(),
std::min(
@@ -133,14 +133,17 @@ bool LayoutBoxModelObject::hasLocalEquivalentBackground() const {
// TODO(flackr): When we correctly clip the scrolling contents layer we can
// paint locally equivalent backgrounds into it. https://crbug.com/645957
if (!style()->hasAutoClip())
- return false;
+ return BackgroundPaintInGraphicsLayer;
// TODO(flackr): Remove this when box shadows are still painted correctly when
// painting into the composited scrolling contents layer.
// https://crbug.com/646464
if (style()->boxShadow())
- return false;
+ return BackgroundPaintInGraphicsLayer;
+ // Assume optimistically that the background can be painted in the scrolling
+ // contents until we find otherwise.
+ BackgroundPaintLocation paintLocation = BackgroundPaintInScrollingContents;
const FillLayer* layer = &(style()->backgroundLayers());
for (; layer; layer = layer->next()) {
if (layer->attachment() == LocalBackgroundAttachment)
@@ -153,7 +156,7 @@ bool LayoutBoxModelObject::hasLocalEquivalentBackground() const {
// 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;
+ return BackgroundPaintInGraphicsLayer;
// Solid color layers with an effective background clip of the padding box
// can be treated as local.
@@ -164,15 +167,25 @@ bool LayoutBoxModelObject::hasLocalEquivalentBackground() const {
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())) {
+ if (clip == BorderFillBox) {
+ if (!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;
+ }
+ // If we have an opaque background color only, we can safely paint it
+ // into both the scrolling contents layer and the graphics layer to
+ // preserve LCD text.
+ if (layer == (&style()->backgroundLayers()) &&
chrishtr 2016/11/17 20:55:39 What if there are later layers in the iteration th
flackr 2016/11/17 23:38:00 The background color is always the last layer, the
+ resolveColor(CSSPropertyBackgroundColor).alpha() < 255)
+ return BackgroundPaintInGraphicsLayer;
+ paintLocation |= BackgroundPaintInGraphicsLayer;
continue;
}
// A content fill box can be treated as a padding fill box if there is no
@@ -183,9 +196,9 @@ bool LayoutBoxModelObject::hasLocalEquivalentBackground() const {
continue;
}
}
- return false;
+ return BackgroundPaintInGraphicsLayer;
}
- return true;
+ return paintLocation;
}
LayoutBoxModelObject::~LayoutBoxModelObject() {

Powered by Google App Engine
This is Rietveld 408576698