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

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

Issue 2476813002: Move LayoutObject::m_previousPosition... into a global map in ObjectPaintInvalidator (Closed)
Patch Set: doc 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 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/ObjectPaintInvalidator.h" 5 #include "core/paint/ObjectPaintInvalidator.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
9 #include "core/layout/LayoutBlockFlow.h" 9 #include "core/layout/LayoutBlockFlow.h"
10 #include "core/layout/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 static void setPreviousSelectionVisualRect(const LayoutObject& object, 28 static void setPreviousSelectionVisualRect(const LayoutObject& object,
29 const LayoutRect& rect) { 29 const LayoutRect& rect) {
30 if (rect.isEmpty()) 30 if (rect.isEmpty())
31 selectionVisualRectMap().remove(&object); 31 selectionVisualRectMap().remove(&object);
32 else 32 else
33 selectionVisualRectMap().set(&object, rect); 33 selectionVisualRectMap().set(&object, rect);
34 } 34 }
35 35
36 typedef HashMap<const LayoutObject*, LayoutPoint> LocationInBackingMap;
37 static LocationInBackingMap& locationInBackingMap() {
38 DEFINE_STATIC_LOCAL(LocationInBackingMap, map, ());
39 return map;
40 }
41
36 void ObjectPaintInvalidator::objectWillBeDestroyed(const LayoutObject& object) { 42 void ObjectPaintInvalidator::objectWillBeDestroyed(const LayoutObject& object) {
43 // TODO(wangxianzhu): Use the same mechanism as for locatinInBackingMap().
37 selectionVisualRectMap().remove(&object); 44 selectionVisualRectMap().remove(&object);
45
46 DCHECK(object.hasPreviousLocationInBacking() ==
47 locationInBackingMap().contains(&object));
48 if (object.hasPreviousLocationInBacking())
49 locationInBackingMap().remove(&object);
38 } 50 }
39 51
40 // TODO(trchen): Use std::function<void, LayoutObject&> when available. 52 // TODO(trchen): Use std::function<void, LayoutObject&> when available.
41 template <typename LayoutObjectTraversalFunctor> 53 template <typename LayoutObjectTraversalFunctor>
42 void traverseNonCompositingDescendantsInPaintOrder( 54 void traverseNonCompositingDescendantsInPaintOrder(
43 const LayoutObject&, 55 const LayoutObject&,
44 const LayoutObjectTraversalFunctor&); 56 const LayoutObjectTraversalFunctor&);
45 57
46 template <typename LayoutObjectTraversalFunctor> 58 template <typename LayoutObjectTraversalFunctor>
47 void traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContai ner( 59 void traverseNonCompositingDescendantsBelongingToAncestorPaintInvalidationContai ner(
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 m_object.invalidateDisplayItemClients(PaintInvalidationRectangle); 375 m_object.invalidateDisplayItemClients(PaintInvalidationRectangle);
364 376
365 return dirtyRectOnBacking; 377 return dirtyRectOnBacking;
366 } 378 }
367 379
368 void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() { 380 void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() {
369 if (PaintLayer* paintingLayer = m_object.paintingLayer()) 381 if (PaintLayer* paintingLayer = m_object.paintingLayer())
370 paintingLayer->setNeedsRepaint(); 382 paintingLayer->setNeedsRepaint();
371 } 383 }
372 384
385 LayoutPoint ObjectPaintInvalidator::previousLocationInBacking() const {
386 DCHECK(m_object.hasPreviousLocationInBacking() ==
387 locationInBackingMap().contains(&m_object));
388 return m_object.hasPreviousLocationInBacking()
389 ? locationInBackingMap().get(&m_object)
390 : m_object.previousVisualRect().location();
391 }
392
393 void ObjectPaintInvalidator::setPreviousLocationInBacking(
394 const LayoutPoint& location) {
395 DCHECK(m_object.hasPreviousLocationInBacking() ==
396 locationInBackingMap().contains(&m_object));
397 if (location == m_object.previousVisualRect().location()) {
398 if (m_object.hasPreviousLocationInBacking()) {
399 locationInBackingMap().remove(&m_object);
400 m_object.getMutableForPainting().setHasPreviousLocationInBacking(false);
401 }
402 } else {
403 locationInBackingMap().set(&m_object, location);
404 m_object.getMutableForPainting().setHasPreviousLocationInBacking(true);
405 }
406 }
407
373 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint( 408 void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint(
374 PaintInvalidationReason reason, 409 PaintInvalidationReason reason,
375 const LayoutRect& oldVisualRect, 410 const LayoutRect& oldVisualRect,
376 const LayoutRect& newVisualRect) { 411 const LayoutRect& newVisualRect) {
377 // The following logic avoids invalidating twice if one set of bounds contains 412 // The following logic avoids invalidating twice if one set of bounds contains
378 // the other. 413 // the other.
379 if (!newVisualRect.contains(oldVisualRect)) { 414 if (!newVisualRect.contains(oldVisualRect)) {
380 LayoutRect invalidationRect = oldVisualRect; 415 LayoutRect invalidationRect = oldVisualRect;
381 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer, 416 invalidatePaintUsingContainer(*m_context.paintInvalidationContainer,
382 invalidationRect, reason); 417 invalidationRect, reason);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 552
518 m_context.paintingLayer->setNeedsRepaint(); 553 m_context.paintingLayer->setNeedsRepaint();
519 m_object.invalidateDisplayItemClients(reason); 554 m_object.invalidateDisplayItemClients(reason);
520 return reason; 555 return reason;
521 } 556 }
522 557
523 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts() 558 DisablePaintInvalidationStateAsserts::DisablePaintInvalidationStateAsserts()
524 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {} 559 : m_disabler(&gDisablePaintInvalidationStateAsserts, true) {}
525 560
526 } // namespace blink 561 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.h ('k') | third_party/WebKit/Source/core/paint/PaintInvalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698