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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
diff --git a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
index 5dac2b6796a97570578b3be9562eb3e3e32904dc..8da60adff69277ad1642617b892d8d33f8709110 100644
--- a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
@@ -33,8 +33,20 @@ static void setPreviousSelectionVisualRect(const LayoutObject& object,
selectionVisualRectMap().set(&object, rect);
}
+typedef HashMap<const LayoutObject*, LayoutPoint> LocationInBackingMap;
+static LocationInBackingMap& locationInBackingMap() {
+ DEFINE_STATIC_LOCAL(LocationInBackingMap, map, ());
+ return map;
+}
+
void ObjectPaintInvalidator::objectWillBeDestroyed(const LayoutObject& object) {
+ // TODO(wangxianzhu): Use the same mechanism as for locatinInBackingMap().
selectionVisualRectMap().remove(&object);
+
+ DCHECK(object.hasPreviousLocationInBacking() ==
+ locationInBackingMap().contains(&object));
+ if (object.hasPreviousLocationInBacking())
+ locationInBackingMap().remove(&object);
}
// TODO(trchen): Use std::function<void, LayoutObject&> when available.
@@ -370,6 +382,29 @@ void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() {
paintingLayer->setNeedsRepaint();
}
+LayoutPoint ObjectPaintInvalidator::previousLocationInBacking() const {
+ DCHECK(m_object.hasPreviousLocationInBacking() ==
+ locationInBackingMap().contains(&m_object));
+ return m_object.hasPreviousLocationInBacking()
+ ? locationInBackingMap().get(&m_object)
+ : m_object.previousVisualRect().location();
+}
+
+void ObjectPaintInvalidator::setPreviousLocationInBacking(
+ const LayoutPoint& location) {
+ DCHECK(m_object.hasPreviousLocationInBacking() ==
+ locationInBackingMap().contains(&m_object));
+ if (location == m_object.previousVisualRect().location()) {
+ if (m_object.hasPreviousLocationInBacking()) {
+ locationInBackingMap().remove(&m_object);
+ m_object.getMutableForPainting().setHasPreviousLocationInBacking(false);
+ }
+ } else {
+ locationInBackingMap().set(&m_object, location);
+ m_object.getMutableForPainting().setHasPreviousLocationInBacking(true);
+ }
+}
+
void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint(
PaintInvalidationReason reason,
const LayoutRect& oldVisualRect,
« 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