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

Side by Side Diff: third_party/WebKit/Source/core/paint/BoxPaintInvalidator.cpp

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/BoxPaintInvalidator.h" 5 #include "core/paint/BoxPaintInvalidator.h"
6 6
7 #include "core/frame/Settings.h" 7 #include "core/frame/Settings.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/paint/ObjectPaintInvalidator.h" 9 #include "core/paint/ObjectPaintInvalidator.h"
10 #include "core/paint/PaintInvalidator.h" 10 #include "core/paint/PaintInvalidator.h"
(...skipping 26 matching lines...) Expand all
37 bool hasBoxDecorations = m_box.styleRef().hasBoxDecorations(); 37 bool hasBoxDecorations = m_box.styleRef().hasBoxDecorations();
38 if (!m_box.styleRef().hasBackground() && !hasBoxDecorations) 38 if (!m_box.styleRef().hasBackground() && !hasBoxDecorations)
39 return result; 39 return result;
40 40
41 const LayoutRect& oldBounds = m_context.oldBounds; 41 const LayoutRect& oldBounds = m_context.oldBounds;
42 const LayoutRect& newBounds = m_context.newBounds; 42 const LayoutRect& newBounds = m_context.newBounds;
43 43
44 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size()); 44 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size());
45 LayoutSize newBorderBoxSize = m_box.size(); 45 LayoutSize newBorderBoxSize = m_box.size();
46 46
47 // If border m_box size didn't change, ObjectPaintInvalidatorWithContext::incr ementallyInvalidatePaint() is good. 47 // If border m_box size didn't change,
48 // ObjectPaintInvalidatorWithContext::incrementallyInvalidatePaint() is good.
48 if (oldBorderBoxSize == newBorderBoxSize) 49 if (oldBorderBoxSize == newBorderBoxSize)
49 return result; 50 return result;
50 51
51 // If size of the paint invalidation rect equals to size of border box, 52 // If size of the paint invalidation rect equals to size of border box,
52 // ObjectPaintInvalidatorWithContext::incrementallyInvalidatePaint() 53 // ObjectPaintInvalidatorWithContext::incrementallyInvalidatePaint()
53 // is good for boxes having background without box decorations. 54 // is good for boxes having background without box decorations.
54 DCHECK( 55 DCHECK(
55 oldBounds.location() == 56 oldBounds.location() ==
56 newBounds.location()); // Otherwise we won't do incremental invalidation. 57 newBounds.location()); // Otherwise we won't do incremental invalidation.
57 if (!hasBoxDecorations && m_context.newLocation == newBounds.location() && 58 if (!hasBoxDecorations && m_context.newLocation == newBounds.location() &&
58 oldBorderBoxSize == oldBounds.size() && 59 oldBorderBoxSize == oldBounds.size() &&
59 newBorderBoxSize == newBounds.size()) 60 newBorderBoxSize == newBounds.size())
60 return result; 61 return result;
61 62
62 // Invalidate the right delta part and the right border of the old or new m_bo x which has smaller width. 63 // Invalidate the right delta part and the right border of the old or new
64 // m_box which has smaller width.
63 if (LayoutUnit deltaWidth = 65 if (LayoutUnit deltaWidth =
64 (oldBorderBoxSize.width() - newBorderBoxSize.width()).abs()) { 66 (oldBorderBoxSize.width() - newBorderBoxSize.width()).abs()) {
65 LayoutUnit smallerWidth = 67 LayoutUnit smallerWidth =
66 std::min(oldBorderBoxSize.width(), newBorderBoxSize.width()); 68 std::min(oldBorderBoxSize.width(), newBorderBoxSize.width());
67 LayoutUnit borderTopRightRadiusWidth = valueForLength( 69 LayoutUnit borderTopRightRadiusWidth = valueForLength(
68 m_box.styleRef().borderTopRightRadius().width(), smallerWidth); 70 m_box.styleRef().borderTopRightRadius().width(), smallerWidth);
69 LayoutUnit borderBottomRightRadiusWidth = valueForLength( 71 LayoutUnit borderBottomRightRadiusWidth = valueForLength(
70 m_box.styleRef().borderBottomRightRadius().width(), smallerWidth); 72 m_box.styleRef().borderBottomRightRadius().width(), smallerWidth);
71 LayoutUnit borderWidth = std::max( 73 LayoutUnit borderWidth = std::max(
72 LayoutUnit(m_box.borderRight()), 74 LayoutUnit(m_box.borderRight()),
73 std::max(borderTopRightRadiusWidth, borderBottomRightRadiusWidth)); 75 std::max(borderTopRightRadiusWidth, borderBottomRightRadiusWidth));
74 LayoutRect rightDeltaRect( 76 LayoutRect rightDeltaRect(
75 m_context.newLocation.x() + smallerWidth - borderWidth, 77 m_context.newLocation.x() + smallerWidth - borderWidth,
76 m_context.newLocation.y(), deltaWidth + borderWidth, 78 m_context.newLocation.y(), deltaWidth + borderWidth,
77 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height())); 79 std::max(oldBorderBoxSize.height(), newBorderBoxSize.height()));
78 invalidatePaintRectClippedByOldAndNewBounds(rightDeltaRect); 80 invalidatePaintRectClippedByOldAndNewBounds(rightDeltaRect);
79 } 81 }
80 82
81 // Invalidate the bottom delta part and the bottom border of the old or new m_ box which has smaller height. 83 // Invalidate the bottom delta part and the bottom border of the old or new
84 // m_box which has smaller height.
82 if (LayoutUnit deltaHeight = 85 if (LayoutUnit deltaHeight =
83 (oldBorderBoxSize.height() - newBorderBoxSize.height()).abs()) { 86 (oldBorderBoxSize.height() - newBorderBoxSize.height()).abs()) {
84 LayoutUnit smallerHeight = 87 LayoutUnit smallerHeight =
85 std::min(oldBorderBoxSize.height(), newBorderBoxSize.height()); 88 std::min(oldBorderBoxSize.height(), newBorderBoxSize.height());
86 LayoutUnit borderBottomLeftRadiusHeight = valueForLength( 89 LayoutUnit borderBottomLeftRadiusHeight = valueForLength(
87 m_box.styleRef().borderBottomLeftRadius().height(), smallerHeight); 90 m_box.styleRef().borderBottomLeftRadius().height(), smallerHeight);
88 LayoutUnit borderBottomRightRadiusHeight = valueForLength( 91 LayoutUnit borderBottomRightRadiusHeight = valueForLength(
89 m_box.styleRef().borderBottomRightRadius().height(), smallerHeight); 92 m_box.styleRef().borderBottomRightRadius().height(), smallerHeight);
90 LayoutUnit borderHeight = std::max( 93 LayoutUnit borderHeight = std::max(
91 LayoutUnit(m_box.borderBottom()), 94 LayoutUnit(m_box.borderBottom()),
(...skipping 17 matching lines...) Expand all
109 ObjectPaintInvalidator objectPaintInvalidator(m_box); 112 ObjectPaintInvalidator objectPaintInvalidator(m_box);
110 LayoutRect rectClippedByOldBounds = intersection(rect, m_context.oldBounds); 113 LayoutRect rectClippedByOldBounds = intersection(rect, m_context.oldBounds);
111 LayoutRect rectClippedByNewBounds = intersection(rect, m_context.newBounds); 114 LayoutRect rectClippedByNewBounds = intersection(rect, m_context.newBounds);
112 // Invalidate only once if the clipped rects equal. 115 // Invalidate only once if the clipped rects equal.
113 if (rectClippedByOldBounds == rectClippedByNewBounds) { 116 if (rectClippedByOldBounds == rectClippedByNewBounds) {
114 objectPaintInvalidator.invalidatePaintUsingContainer( 117 objectPaintInvalidator.invalidatePaintUsingContainer(
115 *m_context.paintInvalidationContainer, rectClippedByOldBounds, 118 *m_context.paintInvalidationContainer, rectClippedByOldBounds,
116 PaintInvalidationIncremental); 119 PaintInvalidationIncremental);
117 return; 120 return;
118 } 121 }
119 // Invalidate the bigger one if one contains another. Otherwise invalidate bot h. 122 // Invalidate the bigger one if one contains another. Otherwise invalidate
123 // both.
120 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds)) 124 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds))
121 objectPaintInvalidator.invalidatePaintUsingContainer( 125 objectPaintInvalidator.invalidatePaintUsingContainer(
122 *m_context.paintInvalidationContainer, rectClippedByOldBounds, 126 *m_context.paintInvalidationContainer, rectClippedByOldBounds,
123 PaintInvalidationIncremental); 127 PaintInvalidationIncremental);
124 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds)) 128 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds))
125 objectPaintInvalidator.invalidatePaintUsingContainer( 129 objectPaintInvalidator.invalidatePaintUsingContainer(
126 *m_context.paintInvalidationContainer, rectClippedByNewBounds, 130 *m_context.paintInvalidationContainer, rectClippedByNewBounds,
127 PaintInvalidationIncremental); 131 PaintInvalidationIncremental);
128 } 132 }
129 133
130 PaintInvalidationReason BoxPaintInvalidator::computePaintInvalidationReason() { 134 PaintInvalidationReason BoxPaintInvalidator::computePaintInvalidationReason() {
131 PaintInvalidationReason reason = 135 PaintInvalidationReason reason =
132 ObjectPaintInvalidatorWithContext(m_box, m_context) 136 ObjectPaintInvalidatorWithContext(m_box, m_context)
133 .computePaintInvalidationReason(); 137 .computePaintInvalidationReason();
134 138
135 if (isImmediateFullPaintInvalidationReason(reason) || 139 if (isImmediateFullPaintInvalidationReason(reason) ||
136 reason == PaintInvalidationNone) 140 reason == PaintInvalidationNone)
137 return reason; 141 return reason;
138 142
139 if (m_box.mayNeedPaintInvalidationAnimatedBackgroundImage() && 143 if (m_box.mayNeedPaintInvalidationAnimatedBackgroundImage() &&
140 !m_box.backgroundIsKnownToBeObscured()) 144 !m_box.backgroundIsKnownToBeObscured())
141 reason = PaintInvalidationDelayedFull; 145 reason = PaintInvalidationDelayedFull;
142 146
143 // If the current paint invalidation reason is PaintInvalidationDelayedFull, t hen this paint invalidation can delayed if the 147 // If the current paint invalidation reason is PaintInvalidationDelayedFull,
144 // LayoutBox in question is not on-screen. The logic to decide whether this is appropriate exists at the site of the original 148 // then this paint invalidation can delayed if the LayoutBox in question is
145 // paint invalidation that chose PaintInvalidationDelayedFull. 149 // not on-screen. The logic to decide whether this is appropriate exists at
150 // the site of the original paint invalidation that chose
151 // PaintInvalidationDelayedFull.
146 if (reason == PaintInvalidationDelayedFull) { 152 if (reason == PaintInvalidationDelayedFull) {
147 // Do regular full paint invalidation if the object is onscreen. 153 // Do regular full paint invalidation if the object is onscreen.
148 return m_box.intersectsVisibleViewport() ? PaintInvalidationFull 154 return m_box.intersectsVisibleViewport() ? PaintInvalidationFull
149 : PaintInvalidationDelayedFull; 155 : PaintInvalidationDelayedFull;
150 } 156 }
151 157
152 if (m_box.isLayoutView()) { 158 if (m_box.isLayoutView()) {
153 const LayoutView& layoutView = toLayoutView(m_box); 159 const LayoutView& layoutView = toLayoutView(m_box);
154 // In normal compositing mode, root background doesn't need to be invalidate d for 160 // In normal compositing mode, root background doesn't need to be
155 // box changes, because the background always covers the whole document rect 161 // invalidated for box changes, because the background always covers the
156 // and clipping is done by compositor()->m_containerLayer. Also the scrollba rs 162 // whole document rect and clipping is done by
157 // are always composited. There are no other box decoration on the LayoutVie w thus 163 // compositor()->m_containerLayer. Also the scrollbars are always
158 // we can safely exit here. 164 // composited. There are no other box decoration on the LayoutView thus we
165 // can safely exit here.
159 if (layoutView.usesCompositing() && 166 if (layoutView.usesCompositing() &&
160 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 167 !RuntimeEnabledFeatures::rootLayerScrollingEnabled())
161 return reason; 168 return reason;
162 } 169 }
163 170
164 // If the transform is not identity or translation, incremental invalidation i s not applicable 171 // If the transform is not identity or translation, incremental invalidation
165 // because the difference between oldBounds and newBounds doesn't cover all ar ea needing invalidation. 172 // is not applicable because the difference between oldBounds and newBounds
166 // FIXME: Should also consider ancestor transforms since paintInvalidationCont ainer. crbug.com/426111. 173 // doesn't cover all area needing invalidation.
174 // FIXME: Should also consider ancestor transforms since
175 // paintInvalidationContainer. crbug.com/426111.
167 if (reason == PaintInvalidationIncremental && 176 if (reason == PaintInvalidationIncremental &&
168 m_context.oldBounds != m_context.newBounds && 177 m_context.oldBounds != m_context.newBounds &&
169 m_context.paintInvalidationContainer != m_box && m_box.hasLayer() && 178 m_context.paintInvalidationContainer != m_box && m_box.hasLayer() &&
170 m_box.layer()->transform() && 179 m_box.layer()->transform() &&
171 !m_box.layer()->transform()->isIdentityOrTranslation()) 180 !m_box.layer()->transform()->isIdentityOrTranslation())
172 return PaintInvalidationBoundsChange; 181 return PaintInvalidationBoundsChange;
173 182
174 const ComputedStyle& style = m_box.styleRef(); 183 const ComputedStyle& style = m_box.styleRef();
175 if (style.backgroundLayers().thisOrNextLayersUseContentBox() || 184 if (style.backgroundLayers().thisOrNextLayersUseContentBox() ||
176 style.maskLayers().thisOrNextLayersUseContentBox() || 185 style.maskLayers().thisOrNextLayersUseContentBox() ||
177 style.boxSizing() == BoxSizingBorderBox) { 186 style.boxSizing() == BoxSizingBorderBox) {
178 if (previousBoxSizesMap().get(&m_box).contentBoxRect != 187 if (previousBoxSizesMap().get(&m_box).contentBoxRect !=
179 m_box.contentBoxRect()) 188 m_box.contentBoxRect())
180 return PaintInvalidationContentBoxChange; 189 return PaintInvalidationContentBoxChange;
181 } 190 }
182 191
183 if (!style.hasBackground() && !style.hasBoxDecorations()) { 192 if (!style.hasBackground() && !style.hasBoxDecorations()) {
184 // We could let incremental invalidation cover non-composited scrollbars, bu t just 193 // We could let incremental invalidation cover non-composited scrollbars,
185 // do a full invalidation because incremental invalidation will go away with slimming paint. 194 // but just do a full invalidation because incremental invalidation will go
195 // away with slimming paint.
186 if (reason == PaintInvalidationIncremental && 196 if (reason == PaintInvalidationIncremental &&
187 m_context.oldBounds != m_context.newBounds && 197 m_context.oldBounds != m_context.newBounds &&
188 m_box.hasNonCompositedScrollbars()) 198 m_box.hasNonCompositedScrollbars())
189 return PaintInvalidationBorderBoxChange; 199 return PaintInvalidationBorderBoxChange;
190 return reason; 200 return reason;
191 } 201 }
192 202
193 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) { 203 if (style.backgroundLayers().thisOrNextLayersHaveLocalAttachment()) {
194 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect != 204 if (previousBoxSizesMap().get(&m_box).layoutOverflowRect !=
195 m_box.layoutOverflowRect()) 205 m_box.layoutOverflowRect())
196 return PaintInvalidationLayoutOverflowBoxChange; 206 return PaintInvalidationLayoutOverflowBoxChange;
197 } 207 }
198 208
199 LayoutSize oldBorderBoxSize = 209 LayoutSize oldBorderBoxSize =
200 computePreviousBorderBoxSize(m_context.oldBounds.size()); 210 computePreviousBorderBoxSize(m_context.oldBounds.size());
201 LayoutSize newBorderBoxSize = m_box.size(); 211 LayoutSize newBorderBoxSize = m_box.size();
202 212
203 if (oldBorderBoxSize == newBorderBoxSize) 213 if (oldBorderBoxSize == newBorderBoxSize)
204 return reason; 214 return reason;
205 215
206 // See another hasNonCompositedScrollbars() callsite above. 216 // See another hasNonCompositedScrollbars() callsite above.
207 if (m_box.hasNonCompositedScrollbars()) 217 if (m_box.hasNonCompositedScrollbars())
208 return PaintInvalidationBorderBoxChange; 218 return PaintInvalidationBorderBoxChange;
209 219
210 if (style.hasVisualOverflowingEffect() || style.hasAppearance() || 220 if (style.hasVisualOverflowingEffect() || style.hasAppearance() ||
211 style.hasFilterInducingProperty() || style.resize() != RESIZE_NONE) 221 style.hasFilterInducingProperty() || style.resize() != RESIZE_NONE)
212 return PaintInvalidationBorderBoxChange; 222 return PaintInvalidationBorderBoxChange;
213 223
214 if (style.hasBorderRadius()) { 224 if (style.hasBorderRadius()) {
215 // If a border-radius exists and width/height is smaller than radius width/h eight, 225 // If a border-radius exists and width/height is smaller than radius
216 // we need to fully invalidate to cover the changed radius. 226 // width/height, we need to fully invalidate to cover the changed radius.
217 FloatRoundedRect oldRoundedRect = style.getRoundedBorderFor( 227 FloatRoundedRect oldRoundedRect = style.getRoundedBorderFor(
218 LayoutRect(LayoutPoint(0, 0), oldBorderBoxSize)); 228 LayoutRect(LayoutPoint(0, 0), oldBorderBoxSize));
219 FloatRoundedRect newRoundedRect = style.getRoundedBorderFor( 229 FloatRoundedRect newRoundedRect = style.getRoundedBorderFor(
220 LayoutRect(LayoutPoint(0, 0), newBorderBoxSize)); 230 LayoutRect(LayoutPoint(0, 0), newBorderBoxSize));
221 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii()) 231 if (oldRoundedRect.getRadii() != newRoundedRect.getRadii())
222 return PaintInvalidationBorderBoxChange; 232 return PaintInvalidationBorderBoxChange;
223 } 233 }
224 234
225 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && 235 if (oldBorderBoxSize.width() != newBorderBoxSize.width() &&
226 m_box.mustInvalidateBackgroundOrBorderPaintOnWidthChange()) 236 m_box.mustInvalidateBackgroundOrBorderPaintOnWidthChange())
227 return PaintInvalidationBorderBoxChange; 237 return PaintInvalidationBorderBoxChange;
228 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && 238 if (oldBorderBoxSize.height() != newBorderBoxSize.height() &&
229 m_box.mustInvalidateBackgroundOrBorderPaintOnHeightChange()) 239 m_box.mustInvalidateBackgroundOrBorderPaintOnHeightChange())
230 return PaintInvalidationBorderBoxChange; 240 return PaintInvalidationBorderBoxChange;
231 241
232 return reason; 242 return reason;
233 } 243 }
234 244
235 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() { 245 PaintInvalidationReason BoxPaintInvalidator::invalidatePaintIfNeeded() {
236 PaintInvalidationReason reason = computePaintInvalidationReason(); 246 PaintInvalidationReason reason = computePaintInvalidationReason();
237 if (reason == PaintInvalidationIncremental) { 247 if (reason == PaintInvalidationIncremental) {
238 if (incrementallyInvalidatePaint()) { 248 if (incrementallyInvalidatePaint()) {
239 m_context.paintingLayer->setNeedsRepaint(); 249 m_context.paintingLayer->setNeedsRepaint();
240 m_box.invalidateDisplayItemClients(reason); 250 m_box.invalidateDisplayItemClients(reason);
241 } else { 251 } else {
242 reason = PaintInvalidationNone; 252 reason = PaintInvalidationNone;
243 } 253 }
244 // Though we have done our own version of incremental invalidation, we still need to call 254 // Though we have done our own version of incremental invalidation, we still
245 // ObjectPaintInvalidator with PaintInvalidationNone to do any other require d operations. 255 // need to call ObjectPaintInvalidator with PaintInvalidationNone to do any
256 // other required operations.
246 reason = std::max( 257 reason = std::max(
247 reason, 258 reason,
248 ObjectPaintInvalidatorWithContext(m_box, m_context) 259 ObjectPaintInvalidatorWithContext(m_box, m_context)
249 .invalidatePaintIfNeededWithComputedReason(PaintInvalidationNone)); 260 .invalidatePaintIfNeededWithComputedReason(PaintInvalidationNone));
250 } else { 261 } else {
251 reason = ObjectPaintInvalidatorWithContext(m_box, m_context) 262 reason = ObjectPaintInvalidatorWithContext(m_box, m_context)
252 .invalidatePaintIfNeededWithComputedReason(reason); 263 .invalidatePaintIfNeededWithComputedReason(reason);
253 } 264 }
254 265
255 if (PaintLayerScrollableArea* area = m_box.getScrollableArea()) 266 if (PaintLayerScrollableArea* area = m_box.getScrollableArea())
256 area->invalidatePaintOfScrollControlsIfNeeded(m_context); 267 area->invalidatePaintOfScrollControlsIfNeeded(m_context);
257 268
258 // This is for the next invalidatePaintIfNeeded so must be at the end. 269 // This is for the next invalidatePaintIfNeeded so must be at the end.
259 savePreviousBoxSizesIfNeeded(); 270 savePreviousBoxSizesIfNeeded();
260 271
261 return reason; 272 return reason;
262 } 273 }
263 274
264 bool BoxPaintInvalidator::needsToSavePreviousBoxSizes() { 275 bool BoxPaintInvalidator::needsToSavePreviousBoxSizes() {
265 LayoutSize paintInvalidationSize = m_context.newBounds.size(); 276 LayoutSize paintInvalidationSize = m_context.newBounds.size();
266 // Don't save old box sizes if the paint rect is empty because we'll 277 // Don't save old box sizes if the paint rect is empty because we'll
267 // full invalidate once the paint rect becomes non-empty. 278 // full invalidate once the paint rect becomes non-empty.
268 if (paintInvalidationSize.isEmpty()) 279 if (paintInvalidationSize.isEmpty())
269 return false; 280 return false;
270 281
271 const ComputedStyle& style = m_box.styleRef(); 282 const ComputedStyle& style = m_box.styleRef();
272 283
273 // If we use border-box sizing we need to track changes in the size of the con tent box. 284 // If we use border-box sizing we need to track changes in the size of the
285 // content box.
274 if (style.boxSizing() == BoxSizingBorderBox) 286 if (style.boxSizing() == BoxSizingBorderBox)
275 return true; 287 return true;
276 288
277 // We need the old box sizes only when the box has background, decorations, or masks. 289 // We need the old box sizes only when the box has background, decorations, or
290 // masks.
278 // Main LayoutView paints base background, thus interested in box size. 291 // Main LayoutView paints base background, thus interested in box size.
279 if (!m_box.isLayoutView() && !style.hasBackground() && 292 if (!m_box.isLayoutView() && !style.hasBackground() &&
280 !style.hasBoxDecorations() && !style.hasMask()) 293 !style.hasBoxDecorations() && !style.hasMask())
281 return false; 294 return false;
282 295
283 // No need to save old border box size if we can use size of the old paint 296 // No need to save old border box size if we can use size of the old paint
284 // rect as the old border box size in the next invalidation. 297 // rect as the old border box size in the next invalidation.
285 if (paintInvalidationSize != m_box.size()) 298 if (paintInvalidationSize != m_box.size())
286 return true; 299 return true;
287 300
288 // Background and mask layers can depend on other boxes than border box. See c rbug.com/490533 301 // Background and mask layers can depend on other boxes than border box. See
302 // crbug.com/490533
289 if (style.backgroundLayers().thisOrNextLayersUseContentBox() || 303 if (style.backgroundLayers().thisOrNextLayersUseContentBox() ||
290 style.backgroundLayers().thisOrNextLayersHaveLocalAttachment() || 304 style.backgroundLayers().thisOrNextLayersHaveLocalAttachment() ||
291 style.maskLayers().thisOrNextLayersUseContentBox()) 305 style.maskLayers().thisOrNextLayersUseContentBox())
292 return true; 306 return true;
293 307
294 return false; 308 return false;
295 } 309 }
296 310
297 void BoxPaintInvalidator::savePreviousBoxSizesIfNeeded() { 311 void BoxPaintInvalidator::savePreviousBoxSizesIfNeeded() {
298 if (!needsToSavePreviousBoxSizes()) { 312 if (!needsToSavePreviousBoxSizes()) {
299 previousBoxSizesMap().remove(&m_box); 313 previousBoxSizesMap().remove(&m_box);
300 return; 314 return;
301 } 315 }
302 316
303 PreviousBoxSizes sizes = {m_box.size(), m_box.contentBoxRect(), 317 PreviousBoxSizes sizes = {m_box.size(), m_box.contentBoxRect(),
304 m_box.layoutOverflowRect()}; 318 m_box.layoutOverflowRect()};
305 previousBoxSizesMap().set(&m_box, sizes); 319 previousBoxSizesMap().set(&m_box, sizes);
306 } 320 }
307 321
308 LayoutSize BoxPaintInvalidator::computePreviousBorderBoxSize( 322 LayoutSize BoxPaintInvalidator::computePreviousBorderBoxSize(
309 const LayoutSize& previousBoundsSize) { 323 const LayoutSize& previousBoundsSize) {
310 // PreviousBorderBoxSize is only valid when there is background or box decorat ions. 324 // PreviousBorderBoxSize is only valid when there is background or box
325 // decorations.
311 DCHECK(m_box.styleRef().hasBackground() || 326 DCHECK(m_box.styleRef().hasBackground() ||
312 m_box.styleRef().hasBoxDecorations()); 327 m_box.styleRef().hasBoxDecorations());
313 328
314 auto it = previousBoxSizesMap().find(&m_box); 329 auto it = previousBoxSizesMap().find(&m_box);
315 if (it != previousBoxSizesMap().end()) 330 if (it != previousBoxSizesMap().end())
316 return it->value.borderBoxSize; 331 return it->value.borderBoxSize;
317 332
318 // We didn't save the old border box size because it was the same as the size of oldBounds. 333 // We didn't save the old border box size because it was the same as the size
334 // of oldBounds.
319 return previousBoundsSize; 335 return previousBoundsSize;
320 } 336 }
321 337
322 } // namespace blink 338 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/BoxDecorationData.cpp ('k') | third_party/WebKit/Source/core/paint/BoxPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698