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

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

Issue 2699463004: Fix gradient background invalidation when HTML size changes (Closed)
Patch Set: Refactor Created 3 years, 10 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/layout/compositing/CompositedLayerMapping.h" 9 #include "core/layout/compositing/CompositedLayerMapping.h"
10 #include "core/paint/ObjectPaintInvalidator.h" 10 #include "core/paint/ObjectPaintInvalidator.h"
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 area->invalidatePaintOfScrollControlsIfNeeded(m_context); 305 area->invalidatePaintOfScrollControlsIfNeeded(m_context);
306 306
307 // This is for the next invalidatePaintIfNeeded so must be at the end. 307 // This is for the next invalidatePaintIfNeeded so must be at the end.
308 savePreviousBoxGeometriesIfNeeded(); 308 savePreviousBoxGeometriesIfNeeded();
309 309
310 return reason; 310 return reason;
311 } 311 }
312 312
313 bool BoxPaintInvalidator::needsToSavePreviousBoxGeometries() { 313 bool BoxPaintInvalidator::needsToSavePreviousBoxGeometries() {
314 LayoutSize paintInvalidationSize = m_context.newVisualRect.size(); 314 LayoutSize paintInvalidationSize = m_context.newVisualRect.size();
315 // Don't save old box Geometries if the paint rect is empty because we'll
316 // full invalidate once the paint rect becomes non-empty.
317 if (paintInvalidationSize.isEmpty())
318 return false;
319 315
320 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize()) 316 // The shortcuts doesn't apply to HTML element. ViewPaintInvalidator needs to
321 return false; 317 // know its previous border box size.
chrishtr 2017/02/16 21:11:14 Even if empty? I wonder in which case.
Xianzhu 2017/02/16 22:01:58 The size of HTML element affects viewport backgrou
318 if (!m_box.node() || !m_box.node()->isHTMLElement()) {
319 // Don't save old box Geometries if the paint rect is empty because we'll
320 // full invalidate once the paint rect becomes non-empty.
chrishtr 2017/02/16 21:11:14 drive-by nit: s/full/fully/. also "geometries" ins
Xianzhu 2017/02/16 22:01:58 Done.
321 if (paintInvalidationSize.isEmpty())
322 return false;
323
324 if (m_box.paintedOutputOfObjectHasNoEffectRegardlessOfSize())
325 return false;
326 }
322 327
323 const ComputedStyle& style = m_box.styleRef(); 328 const ComputedStyle& style = m_box.styleRef();
324 329
325 // If we use border-box sizing we need to track changes in the size of the 330 // If we use border-box sizing we need to track changes in the size of the
326 // content box. 331 // content box.
327 if (style.boxSizing() == EBoxSizing::kBorderBox) 332 if (style.boxSizing() == EBoxSizing::kBorderBox)
328 return true; 333 return true;
329 334
330 // No need to save old border box size if we can use size of the old paint 335 // No need to save old border box size if we can use size of the old paint
331 // rect as the old border box size in the next invalidation. 336 // rect as the old border box size in the next invalidation.
(...skipping 21 matching lines...) Expand all
353 } 358 }
354 return; 359 return;
355 } 360 }
356 361
357 PreviousBoxGeometries geometries = {m_box.size(), m_box.contentBoxRect(), 362 PreviousBoxGeometries geometries = {m_box.size(), m_box.contentBoxRect(),
358 m_box.layoutOverflowRect()}; 363 m_box.layoutOverflowRect()};
359 previousBoxGeometriesMap().set(&m_box, geometries); 364 previousBoxGeometriesMap().set(&m_box, geometries);
360 m_box.getMutableForPainting().setHasPreviousBoxGeometries(true); 365 m_box.getMutableForPainting().setHasPreviousBoxGeometries(true);
361 } 366 }
362 367
368 static LayoutSize previousBorderBoxSizeInternal(const LayoutBox& box,
369 const LayoutSize& defaultSize) {
370 DCHECK(box.hasPreviousBoxGeometries() ==
371 previousBoxGeometriesMap().contains(&box));
372 if (box.hasPreviousBoxGeometries())
373 return previousBoxGeometriesMap().get(&box).borderBoxSize;
374 return defaultSize;
375 }
376
377 LayoutSize BoxPaintInvalidator::previousBorderBoxSize(const LayoutBox& box) {
378 return previousBorderBoxSizeInternal(box, box.visualRect().size());
379 }
380
363 LayoutSize BoxPaintInvalidator::previousBorderBoxSize() { 381 LayoutSize BoxPaintInvalidator::previousBorderBoxSize() {
364 DCHECK(m_box.hasPreviousBoxGeometries() == 382 return previousBorderBoxSizeInternal(m_box, m_context.oldVisualRect.size());
chrishtr 2017/02/16 21:11:14 Wh oldVisualRect() here but visualRect() in the ot
Xianzhu 2017/02/16 22:01:58 Added comments: // This is used during paint inval
365 previousBoxGeometriesMap().contains(&m_box));
366 if (m_box.hasPreviousBoxGeometries())
367 return previousBoxGeometriesMap().get(&m_box).borderBoxSize;
368
369 // We didn't save the old border box size because it was the same as the size
370 // of oldVisualRect.
371 return m_context.oldVisualRect.size();
372 } 383 }
373 384
374 LayoutRect BoxPaintInvalidator::previousContentBoxRect() { 385 LayoutRect BoxPaintInvalidator::previousContentBoxRect() {
375 DCHECK(m_box.hasPreviousBoxGeometries() == 386 DCHECK(m_box.hasPreviousBoxGeometries() ==
376 previousBoxGeometriesMap().contains(&m_box)); 387 previousBoxGeometriesMap().contains(&m_box));
377 return m_box.hasPreviousBoxGeometries() 388 return m_box.hasPreviousBoxGeometries()
378 ? previousBoxGeometriesMap().get(&m_box).contentBoxRect 389 ? previousBoxGeometriesMap().get(&m_box).contentBoxRect
379 : LayoutRect(); 390 : LayoutRect();
380 } 391 }
381 392
382 LayoutRect BoxPaintInvalidator::previousLayoutOverflowRect() { 393 LayoutRect BoxPaintInvalidator::previousLayoutOverflowRect() {
383 DCHECK(m_box.hasPreviousBoxGeometries() == 394 DCHECK(m_box.hasPreviousBoxGeometries() ==
384 previousBoxGeometriesMap().contains(&m_box)); 395 previousBoxGeometriesMap().contains(&m_box));
385 return m_box.hasPreviousBoxGeometries() 396 return m_box.hasPreviousBoxGeometries()
386 ? previousBoxGeometriesMap().get(&m_box).layoutOverflowRect 397 ? previousBoxGeometriesMap().get(&m_box).layoutOverflowRect
387 : LayoutRect(); 398 : LayoutRect();
388 } 399 }
389 400
390 } // namespace blink 401 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698