Free up some bits in RenderObject by moving rarely used bits into a side table
[WebKit-https.git] / Source / WebCore / rendering / RenderObject.cpp
index bfbf9e7..3472961 100644 (file)
@@ -130,6 +130,7 @@ RenderObject::~RenderObject()
     renderObjectCounter.decrement();
 #endif
     view().didDestroyRenderer();
+    ASSERT(!hasRareData());
 }
 
 RenderTheme& RenderObject::theme() const
@@ -1903,6 +1904,7 @@ void RenderObject::willBeDestroyed()
     }
 
     clearLayoutRootIfNeeded();
+    removeRareData();
 }
 
 void RenderObject::insertedIntoTree()
@@ -2495,6 +2497,44 @@ void RenderObject::calculateBorderStyleColor(const EBorderStyle& style, const Bo
     }
 }
 
+void RenderObject::setIsDragging(bool isDragging)
+{
+    if (isDragging || hasRareData())
+        ensureRareData().setIsDragging(isDragging);
+}
+
+void RenderObject::setHasReflection(bool hasReflection)
+{
+    if (hasReflection || hasRareData())
+        ensureRareData().setHasReflection(hasReflection);
+}
+
+RenderObject::RareDataHash& RenderObject::rareDataMap()
+{
+    static NeverDestroyed<RareDataHash> map;
+    return map;
+}
+
+RenderObject::RenderObjectRareData RenderObject::rareData() const
+{
+    if (!hasRareData())
+        return RenderObjectRareData();
+
+    return rareDataMap().get(this);
+}
+
+RenderObject::RenderObjectRareData& RenderObject::ensureRareData()
+{
+    setHasRareData(true);
+    return rareDataMap().add(this, RenderObjectRareData()).iterator->value;
+}
+
+void RenderObject::removeRareData()
+{
+    rareDataMap().remove(this);
+    setHasRareData(false);
+}
+
 } // namespace WebCore
 
 #if ENABLE(TREE_DEBUGGING)