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

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: - 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..9af86fea838e11e5b70ec8c6eed7bb275bbc0100 100644
--- a/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
+++ b/third_party/WebKit/Source/core/paint/ObjectPaintInvalidator.cpp
@@ -33,8 +33,15 @@ 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) {
selectionVisualRectMap().remove(&object);
+ locationInBackingMap().remove(&object);
}
// TODO(trchen): Use std::function<void, LayoutObject&> when available.
@@ -370,6 +377,25 @@ void ObjectPaintInvalidator::slowSetPaintingLayerNeedsRepaint() {
paintingLayer->setNeedsRepaint();
}
+LayoutPoint ObjectPaintInvalidator::previousLocationInBacking() const {
+ // TODO(wangxianzhu): Use a bit in LayoutObject to indicate whether the object
+ // has previous location in the map to avoid unnecessary map lookup.
+ auto it = locationInBackingMap().find(&m_object);
chrishtr 2016/11/04 18:20:07 This lookup will be slow. How slow? I think you s
Xianzhu 2016/11/04 19:11:03 Done.
+ if (it == locationInBackingMap().end())
+ return m_object.previousVisualRect().location();
+ return it->value;
+}
+
+void ObjectPaintInvalidator::setPreviousLocationInBacking(
+ const LayoutPoint& location) {
+ // TODO(wangxianzhu): Use a bit in LayoutObject to indicate whether the object
+ // has previous location in the map to avoid unnecessary map lookup.
+ if (location == m_object.previousVisualRect().location())
+ locationInBackingMap().remove(&m_object);
+ else
+ locationInBackingMap().set(&m_object, location);
+}
+
void ObjectPaintInvalidatorWithContext::fullyInvalidatePaint(
PaintInvalidationReason reason,
const LayoutRect& oldVisualRect,

Powered by Google App Engine
This is Rietveld 408576698