OLD | NEW |
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 LayoutBoxModelObject::LayoutBoxModelObject(ContainerNode* node) | 106 LayoutBoxModelObject::LayoutBoxModelObject(ContainerNode* node) |
107 : LayoutObject(node) {} | 107 : LayoutObject(node) {} |
108 | 108 |
109 bool LayoutBoxModelObject::usesCompositedScrolling() const { | 109 bool LayoutBoxModelObject::usesCompositedScrolling() const { |
110 return hasOverflowClip() && hasLayer() && | 110 return hasOverflowClip() && hasLayer() && |
111 layer()->getScrollableArea()->usesCompositedScrolling(); | 111 layer()->getScrollableArea()->usesCompositedScrolling(); |
112 } | 112 } |
113 | 113 |
114 bool LayoutBoxModelObject::hasLocalEquivalentBackground() const { | 114 BackgroundPaintLocation LayoutBoxModelObject::backgroundPaintLocation() const { |
115 bool hasCustomScrollbars = false; | 115 bool hasCustomScrollbars = false; |
116 // TODO(flackr): Detect opaque custom scrollbars which would cover up a | 116 // TODO(flackr): Detect opaque custom scrollbars which would cover up a |
117 // border-box background. | 117 // border-box background. |
118 if (PaintLayerScrollableArea* scrollableArea = getScrollableArea()) { | 118 if (PaintLayerScrollableArea* scrollableArea = getScrollableArea()) { |
119 if ((scrollableArea->horizontalScrollbar() && | 119 if ((scrollableArea->horizontalScrollbar() && |
120 scrollableArea->horizontalScrollbar()->isCustomScrollbar()) || | 120 scrollableArea->horizontalScrollbar()->isCustomScrollbar()) || |
121 (scrollableArea->verticalScrollbar() && | 121 (scrollableArea->verticalScrollbar() && |
122 scrollableArea->verticalScrollbar()->isCustomScrollbar())) { | 122 scrollableArea->verticalScrollbar()->isCustomScrollbar())) { |
123 hasCustomScrollbars = true; | 123 hasCustomScrollbars = true; |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 // TODO(flackr): When we correctly clip the scrolling contents layer we can | 127 // TODO(flackr): When we correctly clip the scrolling contents layer we can |
128 // paint locally equivalent backgrounds into it. https://crbug.com/645957 | 128 // paint locally equivalent backgrounds into it. https://crbug.com/645957 |
129 if (!style()->hasAutoClip()) | 129 if (!style()->hasAutoClip()) |
130 return false; | 130 return BackgroundPaintInGraphicsLayer; |
131 | 131 |
132 // TODO(flackr): Remove this when box shadows are still painted correctly when | 132 // TODO(flackr): Remove this when box shadows are still painted correctly when |
133 // painting into the composited scrolling contents layer. | 133 // painting into the composited scrolling contents layer. |
134 // https://crbug.com/646464 | 134 // https://crbug.com/646464 |
135 if (style()->boxShadow()) | 135 if (style()->boxShadow()) |
136 return false; | 136 return BackgroundPaintInGraphicsLayer; |
137 | 137 |
| 138 // Assume optimistically that the background can be painted in the scrolling |
| 139 // contents until we find otherwise. |
| 140 BackgroundPaintLocation paintLocation = BackgroundPaintInScrollingContents; |
138 const FillLayer* layer = &(style()->backgroundLayers()); | 141 const FillLayer* layer = &(style()->backgroundLayers()); |
139 for (; layer; layer = layer->next()) { | 142 for (; layer; layer = layer->next()) { |
140 if (layer->attachment() == LocalBackgroundAttachment) | 143 if (layer->attachment() == LocalBackgroundAttachment) |
141 continue; | 144 continue; |
142 | 145 |
143 // Solid color layers with an effective background clip of the padding box | 146 // Solid color layers with an effective background clip of the padding box |
144 // can be treated as local. | 147 // can be treated as local. |
145 if (!layer->image() && !layer->next() && | 148 if (!layer->image() && !layer->next() && |
146 resolveColor(CSSPropertyBackgroundColor).alpha() > 0) { | 149 resolveColor(CSSPropertyBackgroundColor).alpha() > 0) { |
147 EFillBox clip = layer->clip(); | 150 EFillBox clip = layer->clip(); |
148 if (clip == PaddingFillBox) | 151 if (clip == PaddingFillBox) |
149 continue; | 152 continue; |
150 // A border box can be treated as a padding box if the border is opaque or | 153 // A border box can be treated as a padding box if the border is opaque or |
151 // there is no border and we don't have custom scrollbars. | 154 // there is no border and we don't have custom scrollbars. |
152 if (clip == BorderFillBox && !hasCustomScrollbars && | 155 if (clip == BorderFillBox) { |
153 (style()->borderTopWidth() == 0 || | 156 if (!hasCustomScrollbars && |
154 !resolveColor(CSSPropertyBorderTopColor).hasAlpha()) && | 157 (style()->borderTopWidth() == 0 || |
155 (style()->borderLeftWidth() == 0 || | 158 !resolveColor(CSSPropertyBorderTopColor).hasAlpha()) && |
156 !resolveColor(CSSPropertyBorderLeftColor).hasAlpha()) && | 159 (style()->borderLeftWidth() == 0 || |
157 (style()->borderRightWidth() == 0 || | 160 !resolveColor(CSSPropertyBorderLeftColor).hasAlpha()) && |
158 !resolveColor(CSSPropertyBorderRightColor).hasAlpha()) && | 161 (style()->borderRightWidth() == 0 || |
159 (style()->borderBottomWidth() == 0 || | 162 !resolveColor(CSSPropertyBorderRightColor).hasAlpha()) && |
160 !resolveColor(CSSPropertyBorderBottomColor).hasAlpha())) { | 163 (style()->borderBottomWidth() == 0 || |
| 164 !resolveColor(CSSPropertyBorderBottomColor).hasAlpha())) { |
| 165 continue; |
| 166 } |
| 167 // If we have an opaque background color only, we can safely paint it |
| 168 // into both the scrolling contents layer and the graphics layer to |
| 169 // preserve LCD text. |
| 170 if (layer == (&style()->backgroundLayers()) && |
| 171 resolveColor(CSSPropertyBackgroundColor).alpha() < 255) |
| 172 return BackgroundPaintInGraphicsLayer; |
| 173 paintLocation |= BackgroundPaintInGraphicsLayer; |
161 continue; | 174 continue; |
162 } | 175 } |
163 // A content fill box can be treated as a padding fill box if there is no | 176 // A content fill box can be treated as a padding fill box if there is no |
164 // padding. | 177 // padding. |
165 if (clip == ContentFillBox && style()->paddingTop().isZero() && | 178 if (clip == ContentFillBox && style()->paddingTop().isZero() && |
166 style()->paddingLeft().isZero() && style()->paddingRight().isZero() && | 179 style()->paddingLeft().isZero() && style()->paddingRight().isZero() && |
167 style()->paddingBottom().isZero()) { | 180 style()->paddingBottom().isZero()) { |
168 continue; | 181 continue; |
169 } | 182 } |
170 } | 183 } |
171 return false; | 184 return BackgroundPaintInGraphicsLayer; |
172 } | 185 } |
173 return true; | 186 return paintLocation; |
174 } | 187 } |
175 | 188 |
176 LayoutBoxModelObject::~LayoutBoxModelObject() { | 189 LayoutBoxModelObject::~LayoutBoxModelObject() { |
177 // Our layer should have been destroyed and cleared by now | 190 // Our layer should have been destroyed and cleared by now |
178 ASSERT(!hasLayer()); | 191 ASSERT(!hasLayer()); |
179 ASSERT(!m_layer); | 192 ASSERT(!m_layer); |
180 } | 193 } |
181 | 194 |
182 void LayoutBoxModelObject::willBeDestroyed() { | 195 void LayoutBoxModelObject::willBeDestroyed() { |
183 ImageQualityController::remove(*this); | 196 ImageQualityController::remove(*this); |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 if (rootElementStyle->hasBackground()) | 1327 if (rootElementStyle->hasBackground()) |
1315 return false; | 1328 return false; |
1316 | 1329 |
1317 if (node() != document().firstBodyElement()) | 1330 if (node() != document().firstBodyElement()) |
1318 return false; | 1331 return false; |
1319 | 1332 |
1320 return true; | 1333 return true; |
1321 } | 1334 } |
1322 | 1335 |
1323 } // namespace blink | 1336 } // namespace blink |
OLD | NEW |