Title: [231245] trunk/Source/WebCore
Revision
231245
Author
[email protected]
Date
2018-05-02 11:18:10 -0700 (Wed, 02 May 2018)

Log Message

Use WeakPtr in GridCell
https://bugs.webkit.org/show_bug.cgi?id=185180
<rdar://problem/39432165>

Reviewed by Antti Koivisto.

Since GridCell does not own the renderers, it should
construct weak pointers.

Unable to create a reliably reproducible test case.

* rendering/Grid.cpp:
(WebCore::Grid::insert):
(WebCore::GridIterator::nextGridItem):
* rendering/Grid.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::firstLineBaseline const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (231244 => 231245)


--- trunk/Source/WebCore/ChangeLog	2018-05-02 18:05:08 UTC (rev 231244)
+++ trunk/Source/WebCore/ChangeLog	2018-05-02 18:18:10 UTC (rev 231245)
@@ -1,3 +1,23 @@
+2018-05-02  Zalan Bujtas <[email protected]>
+
+        Use WeakPtr in GridCell
+        https://bugs.webkit.org/show_bug.cgi?id=185180
+        <rdar://problem/39432165>
+
+        Reviewed by Antti Koivisto.
+
+        Since GridCell does not own the renderers, it should
+        construct weak pointers.
+
+        Unable to create a reliably reproducible test case.
+
+        * rendering/Grid.cpp:
+        (WebCore::Grid::insert):
+        (WebCore::GridIterator::nextGridItem):
+        * rendering/Grid.h:
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::firstLineBaseline const):
+
 2018-05-02  Eric Carlson  <[email protected]>
 
         [iOS] Provide audio route information when invoking AirPlay picker

Modified: trunk/Source/WebCore/rendering/Grid.cpp (231244 => 231245)


--- trunk/Source/WebCore/rendering/Grid.cpp	2018-05-02 18:05:08 UTC (rev 231244)
+++ trunk/Source/WebCore/rendering/Grid.cpp	2018-05-02 18:18:10 UTC (rev 231245)
@@ -68,7 +68,7 @@
 
     for (auto row : area.rows) {
         for (auto column : area.columns)
-            m_grid[row][column].append(&child);
+            m_grid[row][column].append(makeWeakPtr(child));
     }
 
     setGridItemArea(child, area);
@@ -189,7 +189,7 @@
     for (; varyingTrackIndex < endOfVaryingTrackIndex; ++varyingTrackIndex) {
         const auto& children = m_grid[m_rowIndex][m_columnIndex];
         if (m_childIndex < children.size())
-            return children[m_childIndex++];
+            return children[m_childIndex++].get();
 
         m_childIndex = 0;
     }

Modified: trunk/Source/WebCore/rendering/Grid.h (231244 => 231245)


--- trunk/Source/WebCore/rendering/Grid.h	2018-05-02 18:05:08 UTC (rev 231244)
+++ trunk/Source/WebCore/rendering/Grid.h	2018-05-02 18:18:10 UTC (rev 231245)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-typedef Vector<RenderBox*, 1> GridCell;
+typedef Vector<WeakPtr<RenderBox>, 1> GridCell;
 typedef Vector<Vector<GridCell>> GridAsMatrix;
 typedef ListHashSet<size_t> OrderedTrackIndexSet;
 

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (231244 => 231245)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2018-05-02 18:05:08 UTC (rev 231244)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2018-05-02 18:18:10 UTC (rev 231245)
@@ -1176,15 +1176,16 @@
     // Finding the first grid item in grid order.
     unsigned numColumns = m_grid.numTracks(ForColumns);
     for (size_t column = 0; column < numColumns; column++) {
-        for (const auto* child : m_grid.cell(0, column)) {
+        for (auto& child : m_grid.cell(0, column)) {
+            ASSERT(child.get());
             // If an item participates in baseline alignment, we select such item.
             if (isInlineBaselineAlignedChild(*child)) {
                 // FIXME: self-baseline and content-baseline alignment not implemented yet.
-                baselineChild = child;
+                baselineChild = child.get();
                 break;
             }
             if (!baselineChild)
-                baselineChild = child;
+                baselineChild = child.get();
         }
     }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to