Title: [242921] trunk/Source/WebCore
Revision
242921
Author
[email protected]
Date
2019-03-13 16:46:05 -0700 (Wed, 13 Mar 2019)

Log Message

[WeakPtr] RenderListMarker::m_listItem should be a WeakPtr
https://bugs.webkit.org/show_bug.cgi?id=195704
<rdar://problem/48486278>

Reviewed by Simon Fraser.

* rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::RenderListMarker):
(WebCore::RenderListMarker::paint):
(WebCore::RenderListMarker::layout):
(WebCore::RenderListMarker::updateContent):
(WebCore::RenderListMarker::computePreferredLogicalWidths):
(WebCore::RenderListMarker::lineHeight const):
(WebCore::RenderListMarker::baselinePosition const):
(WebCore::RenderListMarker::suffix const):
(WebCore::RenderListMarker::isInside const):
(WebCore::RenderListMarker::getRelativeMarkerRect):
* rendering/RenderListMarker.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (242920 => 242921)


--- trunk/Source/WebCore/ChangeLog	2019-03-13 23:37:32 UTC (rev 242920)
+++ trunk/Source/WebCore/ChangeLog	2019-03-13 23:46:05 UTC (rev 242921)
@@ -1,3 +1,24 @@
+2019-03-13  Zalan Bujtas  <[email protected]>
+
+        [WeakPtr] RenderListMarker::m_listItem should be a WeakPtr
+        https://bugs.webkit.org/show_bug.cgi?id=195704
+        <rdar://problem/48486278>
+
+        Reviewed by Simon Fraser.
+
+        * rendering/RenderListMarker.cpp:
+        (WebCore::RenderListMarker::RenderListMarker):
+        (WebCore::RenderListMarker::paint):
+        (WebCore::RenderListMarker::layout):
+        (WebCore::RenderListMarker::updateContent):
+        (WebCore::RenderListMarker::computePreferredLogicalWidths):
+        (WebCore::RenderListMarker::lineHeight const):
+        (WebCore::RenderListMarker::baselinePosition const):
+        (WebCore::RenderListMarker::suffix const):
+        (WebCore::RenderListMarker::isInside const):
+        (WebCore::RenderListMarker::getRelativeMarkerRect):
+        * rendering/RenderListMarker.h:
+
 2019-03-13  Dean Jackson  <[email protected]>
 
         Block all plugins smaller than 5x5px

Modified: trunk/Source/WebCore/rendering/RenderListMarker.cpp (242920 => 242921)


--- trunk/Source/WebCore/rendering/RenderListMarker.cpp	2019-03-13 23:37:32 UTC (rev 242920)
+++ trunk/Source/WebCore/rendering/RenderListMarker.cpp	2019-03-13 23:46:05 UTC (rev 242921)
@@ -1121,7 +1121,7 @@
 
 RenderListMarker::RenderListMarker(RenderListItem& listItem, RenderStyle&& style)
     : RenderBox(listItem.document(), WTFMove(style), 0)
-    , m_listItem(listItem)
+    , m_listItem(makeWeakPtr(listItem))
 {
     // init RenderObject attributes
     setInline(true);   // our object is Inline
@@ -1209,7 +1209,7 @@
         if (selectionState() != SelectionNone) {
             LayoutRect selRect = localSelectionRect();
             selRect.moveBy(boxOrigin);
-            context.fillRect(snappedIntRect(selRect), m_listItem.selectionBackgroundColor());
+            context.fillRect(snappedIntRect(selRect), m_listItem->selectionBackgroundColor());
         }
         return;
     }
@@ -1217,7 +1217,7 @@
     if (selectionState() != SelectionNone) {
         LayoutRect selRect = localSelectionRect();
         selRect.moveBy(boxOrigin);
-        context.fillRect(snappedIntRect(selRect), m_listItem.selectionBackgroundColor());
+        context.fillRect(snappedIntRect(selRect), m_listItem->selectionBackgroundColor());
     }
 
     const Color color(style().visitedDependentColorWithColorFilter(CSSPropertyColor));
@@ -1342,7 +1342,7 @@
     if (type == ListStyleType::Asterisks || type == ListStyleType::Footnotes)
         context.drawText(font, textRun, textOrigin);
     else {
-        const UChar suffix = listMarkerSuffix(type, m_listItem.value());
+        const UChar suffix = listMarkerSuffix(type, m_listItem->value());
 
         // Text is not arbitrary. We can judge whether it's RTL from the first character,
         // and we only need to handle the direction U_RIGHT_TO_LEFT for now.
@@ -1381,12 +1381,12 @@
     ASSERT(needsLayout());
 
     LayoutUnit blockOffset;
-    for (auto* ancestor = parentBox(); ancestor && ancestor != &m_listItem; ancestor = ancestor->parentBox())
+    for (auto* ancestor = parentBox(); ancestor && ancestor != m_listItem.get(); ancestor = ancestor->parentBox())
         blockOffset += ancestor->logicalTop();
     if (style().isLeftToRightDirection())
-        m_lineOffsetForListItem = m_listItem.logicalLeftOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
+        m_lineOffsetForListItem = m_listItem->logicalLeftOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
     else
-        m_lineOffsetForListItem = m_listItem.logicalRightOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
+        m_lineOffsetForListItem = m_listItem->logicalRightOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
  
     if (isImage()) {
         updateMarginsAndContent();
@@ -1533,7 +1533,7 @@
     case ListStyleType::UpperNorwegian:
     case ListStyleType::UpperRoman:
     case ListStyleType::Urdu:
-        m_text = listMarkerText(type, m_listItem.value());
+        m_text = listMarkerText(type, m_listItem->value());
         break;
     }
 }
@@ -1649,7 +1649,7 @@
         else {
             TextRun run = RenderBlock::constructTextRun(m_text, style());
             LayoutUnit itemWidth = font.width(run);
-            UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
+            UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
             LayoutUnit suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
             logicalWidth = itemWidth + suffixSpaceWidth;
         }
@@ -1732,7 +1732,7 @@
 LayoutUnit RenderListMarker::lineHeight(bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
 {
     if (!isImage())
-        return m_listItem.lineHeight(firstLine, direction, PositionOfInteriorLineBoxes);
+        return m_listItem->lineHeight(firstLine, direction, PositionOfInteriorLineBoxes);
     return RenderBox::lineHeight(firstLine, direction, linePositionMode);
 }
 
@@ -1739,7 +1739,7 @@
 int RenderListMarker::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
 {
     if (!isImage())
-        return m_listItem.baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes);
+        return m_listItem->baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes);
     return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
 }
 
@@ -1746,7 +1746,7 @@
 String RenderListMarker::suffix() const
 {
     ListStyleType type = style().listStyleType();
-    const UChar suffix = listMarkerSuffix(type, m_listItem.value());
+    const UChar suffix = listMarkerSuffix(type, m_listItem->value());
 
     if (suffix == ' ')
         return " "_str;
@@ -1766,7 +1766,7 @@
 
 bool RenderListMarker::isInside() const
 {
-    return m_listItem.notInList() || style().listStylePosition() == ListStylePosition::Inside;
+    return m_listItem->notInList() || style().listStylePosition() == ListStylePosition::Inside;
 }
 
 FloatRect RenderListMarker::getRelativeMarkerRect()
@@ -1876,7 +1876,7 @@
         const FontCascade& font = style().fontCascade();
         TextRun run = RenderBlock::constructTextRun(m_text, style());
         float itemWidth = font.width(run);
-        UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
+        UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
         float suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
         relativeRect = FloatRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height());
     }

Modified: trunk/Source/WebCore/rendering/RenderListMarker.h (242920 => 242921)


--- trunk/Source/WebCore/rendering/RenderListMarker.h	2019-03-13 23:37:32 UTC (rev 242920)
+++ trunk/Source/WebCore/rendering/RenderListMarker.h	2019-03-13 23:46:05 UTC (rev 242921)
@@ -47,10 +47,6 @@
 
     void updateMarginsAndContent();
 
-#if !ASSERT_DISABLED
-    RenderListItem& listItem() const { return m_listItem; }
-#endif
-
 private:
     void willBeDestroyed() override;
 
@@ -90,7 +86,7 @@
 
     String m_text;
     RefPtr<StyleImage> m_image;
-    RenderListItem& m_listItem;
+    WeakPtr<RenderListItem> m_listItem;
     LayoutUnit m_lineOffsetForListItem;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to