RenderBlockRareData::m_enclosingFragmentedFlow should be WeakPtr
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jan 2018 17:28:54 +0000 (17:28 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jan 2018 17:28:54 +0000 (17:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182045
<rdar://problem/36334787>

Reviewed by Zalan Bujtas.

For safety.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::cachedEnclosingFragmentedFlow const):
(WebCore::RenderBlock::updateCachedEnclosingFragmentedFlow const):
(WebCore::RenderBlock::locateEnclosingFragmentedFlow const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227525 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp

index 9c93ff4..a09e640 100644 (file)
@@ -1,3 +1,18 @@
+2018-01-24  Antti Koivisto  <antti@apple.com>
+
+        RenderBlockRareData::m_enclosingFragmentedFlow should be WeakPtr
+        https://bugs.webkit.org/show_bug.cgi?id=182045
+        <rdar://problem/36334787>
+
+        Reviewed by Zalan Bujtas.
+
+        For safety.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::cachedEnclosingFragmentedFlow const):
+        (WebCore::RenderBlock::updateCachedEnclosingFragmentedFlow const):
+        (WebCore::RenderBlock::locateEnclosingFragmentedFlow const):
+
 2018-01-23  Dean Jackson  <dino@apple.com>
 
         REGRESSION (r222961?): sRGB images shown in WebGL are over-saturated on a wide gamut monitor
 2018-01-23  Dean Jackson  <dino@apple.com>
 
         REGRESSION (r222961?): sRGB images shown in WebGL are over-saturated on a wide gamut monitor
index d1a3bc8..f85e275 100644 (file)
@@ -254,7 +254,7 @@ public:
     LayoutUnit m_pageLogicalOffset;
     LayoutUnit m_intrinsicBorderForFieldset;
     
     LayoutUnit m_pageLogicalOffset;
     LayoutUnit m_intrinsicBorderForFieldset;
     
-    std::optional<RenderFragmentedFlow*> m_enclosingFragmentedFlow;
+    std::optional<WeakPtr<RenderFragmentedFlow>> m_enclosingFragmentedFlow;
 };
 
 typedef HashMap<const RenderBlock*, std::unique_ptr<RenderBlockRareData>> RenderBlockRareDataMap;
 };
 
 typedef HashMap<const RenderBlock*, std::unique_ptr<RenderBlockRareData>> RenderBlockRareDataMap;
@@ -2833,7 +2833,7 @@ RenderFragmentedFlow* RenderBlock::cachedEnclosingFragmentedFlow() const
     if (!rareData || !rareData->m_enclosingFragmentedFlow)
         return nullptr;
 
     if (!rareData || !rareData->m_enclosingFragmentedFlow)
         return nullptr;
 
-    return rareData->m_enclosingFragmentedFlow.value();
+    return rareData->m_enclosingFragmentedFlow.value().get();
 }
 
 bool RenderBlock::cachedEnclosingFragmentedFlowNeedsUpdate() const
 }
 
 bool RenderBlock::cachedEnclosingFragmentedFlowNeedsUpdate() const
@@ -2855,7 +2855,7 @@ void RenderBlock::setCachedEnclosingFragmentedFlowNeedsUpdate()
 RenderFragmentedFlow* RenderBlock::updateCachedEnclosingFragmentedFlow(RenderFragmentedFlow* fragmentedFlow) const
 {
     RenderBlockRareData& rareData = ensureBlockRareData(*this);
 RenderFragmentedFlow* RenderBlock::updateCachedEnclosingFragmentedFlow(RenderFragmentedFlow* fragmentedFlow) const
 {
     RenderBlockRareData& rareData = ensureBlockRareData(*this);
-    rareData.m_enclosingFragmentedFlow = fragmentedFlow;
+    rareData.m_enclosingFragmentedFlow = makeWeakPtr(fragmentedFlow);
 
     return fragmentedFlow;
 }
 
     return fragmentedFlow;
 }
@@ -2867,7 +2867,7 @@ RenderFragmentedFlow* RenderBlock::locateEnclosingFragmentedFlow() const
         return updateCachedEnclosingFragmentedFlow(RenderBox::locateEnclosingFragmentedFlow());
 
     ASSERT(rareData->m_enclosingFragmentedFlow.value() == RenderBox::locateEnclosingFragmentedFlow());
         return updateCachedEnclosingFragmentedFlow(RenderBox::locateEnclosingFragmentedFlow());
 
     ASSERT(rareData->m_enclosingFragmentedFlow.value() == RenderBox::locateEnclosingFragmentedFlow());
-    return rareData->m_enclosingFragmentedFlow.value();
+    return rareData->m_enclosingFragmentedFlow.value().get();
 }
 
 void RenderBlock::resetEnclosingFragmentedFlowAndChildInfoIncludingDescendants(RenderFragmentedFlow*)
 }
 
 void RenderBlock::resetEnclosingFragmentedFlowAndChildInfoIncludingDescendants(RenderFragmentedFlow*)