Title: [224632] trunk/Source/WebCore
Revision
224632
Author
za...@apple.com
Date
2017-11-09 10:21:58 -0800 (Thu, 09 Nov 2017)

Log Message

[LayoutState cleanup] LayouState::m_lineGrid should be a weak pointer
https://bugs.webkit.org/show_bug.cgi?id=179484
<rdar://problem/35442725>

Reviewed by Darin Adler.

Covered by existing tests.

* rendering/LayoutState.cpp:
(WebCore::LayoutState::propagateLineGridInfo):
(WebCore::LayoutState::establishLineGrid):
* rendering/LayoutState.h:
(WebCore::LayoutState::lineGrid const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224631 => 224632)


--- trunk/Source/WebCore/ChangeLog	2017-11-09 17:36:11 UTC (rev 224631)
+++ trunk/Source/WebCore/ChangeLog	2017-11-09 18:21:58 UTC (rev 224632)
@@ -1,5 +1,21 @@
 2017-11-09  Zalan Bujtas  <za...@apple.com>
 
+        [LayoutState cleanup] LayouState::m_lineGrid should be a weak pointer
+        https://bugs.webkit.org/show_bug.cgi?id=179484
+        <rdar://problem/35442725>
+
+        Reviewed by Darin Adler.
+
+        Covered by existing tests.
+
+        * rendering/LayoutState.cpp:
+        (WebCore::LayoutState::propagateLineGridInfo):
+        (WebCore::LayoutState::establishLineGrid):
+        * rendering/LayoutState.h:
+        (WebCore::LayoutState::lineGrid const):
+
+2017-11-09  Zalan Bujtas  <za...@apple.com>
+
         [LayoutState cleanup] Add pagination parameter to subtree LayoutState
         https://bugs.webkit.org/show_bug.cgi?id=179465
         <rdar://problem/35434096>

Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224631 => 224632)


--- trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 17:36:11 UTC (rev 224631)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp	2017-11-09 18:21:58 UTC (rev 224632)
@@ -31,6 +31,7 @@
 #include "RenderLayer.h"
 #include "RenderMultiColumnFlow.h"
 #include "RenderView.h"
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
 
@@ -223,7 +224,7 @@
     if (renderer.isUnsplittableForPagination())
         return;
 
-    m_lineGrid = ancestor.lineGrid();
+    m_lineGrid = makeWeakPtr(ancestor.lineGrid());
     m_lineGridOffset = ancestor.lineGridOffset();
     m_lineGridPaginationOrigin = ancestor.lineGridPaginationOrigin();
 }
@@ -234,16 +235,16 @@
     if (m_lineGrid) {
         if (m_lineGrid->style().lineGrid() == renderer.style().lineGrid())
             return;
-        RenderBlockFlow* currentGrid = m_lineGrid;
+        auto* currentGrid = m_lineGrid.get();
         for (int i = layoutStateStack.size() - 1; i <= 0; --i) {
             auto& currentState = *layoutStateStack[i].get();
             if (currentState.m_lineGrid == currentGrid)
                 continue;
-            currentGrid = currentState.m_lineGrid;
+            currentGrid = currentState.lineGrid();
             if (!currentGrid)
                 break;
             if (currentGrid->style().lineGrid() == renderer.style().lineGrid()) {
-                m_lineGrid = currentGrid;
+                m_lineGrid = makeWeakPtr(currentGrid);
                 m_lineGridOffset = currentState.m_lineGridOffset;
                 return;
             }
@@ -251,7 +252,7 @@
     }
     
     // We didn't find an already-established grid with this identifier. Our render object establishes the grid.
-    m_lineGrid = &renderer;
+    m_lineGrid = makeWeakPtr(renderer);
     m_lineGridOffset = m_layoutOffset;
 }
 

Modified: trunk/Source/WebCore/rendering/LayoutState.h (224631 => 224632)


--- trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 17:36:11 UTC (rev 224631)
+++ trunk/Source/WebCore/rendering/LayoutState.h	2017-11-09 18:21:58 UTC (rev 224632)
@@ -66,7 +66,7 @@
     LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
     bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
 
-    RenderBlockFlow* lineGrid() const { return m_lineGrid; }
+    RenderBlockFlow* lineGrid() const { return m_lineGrid.get(); }
     LayoutSize lineGridOffset() const { return m_lineGridOffset; }
     LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; }
 
@@ -108,7 +108,7 @@
     bool m_layoutDeltaYSaturated : 1;
 #endif
     // The current line grid that we're snapping to and the offset of the start of the grid.
-    RenderBlockFlow* m_lineGrid { nullptr };
+    WeakPtr<RenderBlockFlow> m_lineGrid;
 
     // FIXME: Distinguish between the layout clip rect and the paint clip rect which may be larger,
     // e.g., because of composited scrolling.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to