Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| index 33ebe5d70e5514d82cfa6dbdc943c3469146d4cd..445c40c5becce72c87841d44957e43f561c6fc1b 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -74,6 +74,7 @@ |
| #include "core/layout/compositing/PaintLayerCompositor.h" |
| #include "core/page/AutoscrollController.h" |
| #include "core/page/Page.h" |
| +#include "core/paint/ObjectPaintProperties.h" |
| #include "core/paint/ObjectPainter.h" |
| #include "core/paint/PaintInfo.h" |
| #include "core/paint/PaintLayer.h" |
| @@ -148,6 +149,16 @@ bool LayoutObject::s_affectsParentBlock = false; |
| typedef HashMap<const LayoutObject*, LayoutRect> SelectionPaintInvalidationMap; |
| static SelectionPaintInvalidationMap* selectionPaintInvalidationMap = nullptr; |
| +// The pointer to paint properties is implemented as a global hash map temporarily, |
| +// to avoid memory regression during the transition towards SPv2. |
| +typedef HashMap<const LayoutObject*, OwnPtr<ObjectPaintProperties>> ObjectPaintPropertiesMap; |
| +static ObjectPaintPropertiesMap& objectPaintPropertiesMap() |
| +{ |
| + DEFINE_STATIC_LOCAL(ObjectPaintPropertiesMap, |
| +staticObjectPaintPropertiesMap, ()); |
|
pdr.
2015/10/21 21:02:45
Oops, I think this fell off the line before it.
trchen
2015/10/21 22:21:14
Done.
|
| + return staticObjectPaintPropertiesMap; |
| +} |
| + |
| void* LayoutObject::operator new(size_t sz) |
| { |
| ASSERT(isMainThread()); |
| @@ -2513,6 +2524,9 @@ void LayoutObject::willBeDestroyed() |
| if (selectionPaintInvalidationMap) |
| selectionPaintInvalidationMap->remove(this); |
| + if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| + clearObjectPaintProperties(); |
| + |
| clearLayoutRootIfNeeded(); |
| if (m_style) { |
| @@ -3458,6 +3472,26 @@ void LayoutObject::setIsBackgroundAttachmentFixedObject(bool isBackgroundAttachm |
| frameView()->removeBackgroundAttachmentFixedObject(this); |
| } |
| +ObjectPaintProperties* LayoutObject::objectPaintProperties() const |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| + return objectPaintPropertiesMap().get(this); |
| +} |
| + |
| +ObjectPaintProperties& LayoutObject::ensureObjectPaintProperties() |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| + if (ObjectPaintProperties* properties = objectPaintProperties()) |
| + return *properties; |
| + return *objectPaintPropertiesMap().set(this, ObjectPaintProperties::create()).storedValue->value.get(); |
| +} |
| + |
| +void LayoutObject::clearObjectPaintProperties() |
| +{ |
| + ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| + objectPaintPropertiesMap().remove(this); |
| +} |
| + |
| } // namespace blink |
| #ifndef NDEBUG |