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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
7 * Copyright (C) 2010 Google Inc. All rights reserved. 7 * Copyright (C) 2010 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 15 matching lines...) Expand all
26 #include "core/layout/LayoutBoxModelObject.h" 26 #include "core/layout/LayoutBoxModelObject.h"
27 27
28 #include "core/frame/FrameView.h" 28 #include "core/frame/FrameView.h"
29 #include "core/frame/LocalFrame.h" 29 #include "core/frame/LocalFrame.h"
30 #include "core/html/HTMLBodyElement.h" 30 #include "core/html/HTMLBodyElement.h"
31 #include "core/layout/ImageQualityController.h" 31 #include "core/layout/ImageQualityController.h"
32 #include "core/layout/LayoutBlock.h" 32 #include "core/layout/LayoutBlock.h"
33 #include "core/layout/LayoutFlexibleBox.h" 33 #include "core/layout/LayoutFlexibleBox.h"
34 #include "core/layout/LayoutGeometryMap.h" 34 #include "core/layout/LayoutGeometryMap.h"
35 #include "core/layout/LayoutInline.h" 35 #include "core/layout/LayoutInline.h"
36 #include "core/layout/LayoutTheme.h"
36 #include "core/layout/LayoutView.h" 37 #include "core/layout/LayoutView.h"
37 #include "core/layout/compositing/CompositedLayerMapping.h" 38 #include "core/layout/compositing/CompositedLayerMapping.h"
38 #include "core/layout/compositing/PaintLayerCompositor.h" 39 #include "core/layout/compositing/PaintLayerCompositor.h"
39 #include "core/paint/ObjectPaintInvalidator.h" 40 #include "core/paint/ObjectPaintInvalidator.h"
40 #include "core/paint/PaintLayer.h" 41 #include "core/paint/PaintLayer.h"
41 #include "core/style/ShadowList.h" 42 #include "core/style/ShadowList.h"
42 #include "platform/LengthFunctions.h" 43 #include "platform/LengthFunctions.h"
43 #include "wtf/PtrUtil.h" 44 #include "wtf/PtrUtil.h"
44 45
45 namespace blink { 46 namespace blink {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 LayoutBoxModelObject::LayoutBoxModelObject(ContainerNode* node) 109 LayoutBoxModelObject::LayoutBoxModelObject(ContainerNode* node)
109 : LayoutObject(node) 110 : LayoutObject(node)
110 { 111 {
111 } 112 }
112 113
113 bool LayoutBoxModelObject::usesCompositedScrolling() const 114 bool LayoutBoxModelObject::usesCompositedScrolling() const
114 { 115 {
115 return hasOverflowClip() && hasLayer() && layer()->getScrollableArea()->uses CompositedScrolling(); 116 return hasOverflowClip() && hasLayer() && layer()->getScrollableArea()->uses CompositedScrolling();
116 } 117 }
117 118
119 bool LayoutBoxModelObject::hasLocalEquivalentBackground() const
120 {
121 int minBorderWidth = std::min(style()->borderTopWidth(),
122 std::min(style()->borderLeftWidth(),
123 std::min(style()->borderRightWidth(), style()->borderBottomWidth())) );
124 bool outlineOverlapsPaddingBox = style()->outlineOffset() < -minBorderWidth;
125 bool hasCustomScrollbars = false;
126 // TODO(flackr): Detect opaque custom scrollbars which would cover up a bord er-box
127 // background.
128 if (PaintLayerScrollableArea* scrollableArea = getScrollableArea()) {
129 if ((scrollableArea->horizontalScrollbar() && scrollableArea->horizontal Scrollbar()->isCustomScrollbar())
130 || (scrollableArea->verticalScrollbar() && scrollableArea->verticalS crollbar()->isCustomScrollbar())) {
131 hasCustomScrollbars = true;
132 }
133 }
134
135 const FillLayer* layer = &(style()->backgroundLayers());
136 for (; layer; layer = layer->next()) {
137 if (layer->attachment() == LocalBackgroundAttachment)
138 continue;
139
140 // If the outline draws inside the border, it intends to draw on top of the scroller's background,
141 // however because it is painted into a layer behind the scrolling conte nts layer we avoid auto
142 // promoting in this case to avoid obscuring the outline.
143 // TODO(flackr): Outlines should be drawn on top of the scrolling conten ts layer so that
144 // they cannot be covered up by composited scrolling contents.
145 if (outlineOverlapsPaddingBox)
146 return false;
147
148 // Solid color layers with an effective background clip of the padding b ox can be treated
149 // as local.
150 if (!layer->image() && !layer->next() && resolveColor(CSSPropertyBackgro undColor).alpha() > 0) {
151 EFillBox clip = layer->clip();
152 if (clip == PaddingFillBox)
153 continue;
154 // A border box can be treated as a padding box if the border is opa que or there is
155 // no border and we don't have custom scrollbars.
156 if (clip == BorderFillBox && !hasCustomScrollbars
157 && (style()->borderTopWidth() == 0 || !resolveColor(CSSPropertyB orderTopColor).hasAlpha())
158 && (style()->borderLeftWidth() == 0 || !resolveColor(CSSProperty BorderLeftColor).hasAlpha())
159 && (style()->borderRightWidth() == 0 || !resolveColor(CSSPropert yBorderRightColor).hasAlpha())
160 && (style()->borderBottomWidth() == 0 || !resolveColor(CSSProper tyBorderBottomColor).hasAlpha())) {
161 continue;
162 }
163 // A content fill box can be treated as a padding fill box if there is no padding.
164 if (clip == ContentFillBox
165 && style()->paddingTop().isZero()
166 && style()->paddingLeft().isZero()
167 && style()->paddingRight().isZero()
168 && style()->paddingBottom().isZero()) {
169 continue;
170 }
171 }
172 return false;
173 }
174 return true;
175 }
176
118 LayoutBoxModelObject::~LayoutBoxModelObject() 177 LayoutBoxModelObject::~LayoutBoxModelObject()
119 { 178 {
120 // Our layer should have been destroyed and cleared by now 179 // Our layer should have been destroyed and cleared by now
121 ASSERT(!hasLayer()); 180 ASSERT(!hasLayer());
122 ASSERT(!m_layer); 181 ASSERT(!m_layer);
123 } 182 }
124 183
125 void LayoutBoxModelObject::willBeDestroyed() 184 void LayoutBoxModelObject::willBeDestroyed()
126 { 185 {
127 ImageQualityController::remove(*this); 186 ImageQualityController::remove(*this);
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 if (rootElementStyle->hasBackground()) 1170 if (rootElementStyle->hasBackground())
1112 return false; 1171 return false;
1113 1172
1114 if (node() != document().firstBodyElement()) 1173 if (node() != document().firstBodyElement())
1115 return false; 1174 return false;
1116 1175
1117 return true; 1176 return true;
1118 } 1177 }
1119 1178
1120 } // namespace blink 1179 } // namespace blink
OLDNEW
« 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