Chromium Code Reviews| 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, |