Title: [243574] branches/safari-607-branch/Source/WebCore
Revision
243574
Author
[email protected]
Date
2019-03-27 16:43:43 -0700 (Wed, 27 Mar 2019)

Log Message

Cherry-pick r242921. rdar://problem/49308071

    [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:

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

Modified Paths

Diff

Modified: branches/safari-607-branch/Source/WebCore/ChangeLog (243573 => 243574)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-03-27 23:43:41 UTC (rev 243573)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-03-27 23:43:43 UTC (rev 243574)
@@ -1,5 +1,51 @@
 2019-03-27  Alan Coon  <[email protected]>
 
+        Cherry-pick r242921. rdar://problem/49308071
+
+    [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:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242921 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-27  Alan Coon  <[email protected]>
+
         Cherry-pick r242919. rdar://problem/49307949
 
     Use RenderBox::previousSiblingBox/nextSiblingBox in RenderMultiColumnFlow

Modified: branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.cpp (243573 => 243574)


--- branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.cpp	2019-03-27 23:43:41 UTC (rev 243573)
+++ branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.cpp	2019-03-27 23:43:43 UTC (rev 243574)
@@ -1122,7 +1122,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
@@ -1210,7 +1210,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;
     }
@@ -1218,7 +1218,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));
@@ -1343,7 +1343,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.
@@ -1382,12 +1382,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();
@@ -1534,7 +1534,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;
     }
 }
@@ -1650,7 +1650,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;
         }
@@ -1733,7 +1733,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);
 }
 
@@ -1740,7 +1740,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);
 }
 
@@ -1747,7 +1747,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;
@@ -1767,7 +1767,7 @@
 
 bool RenderListMarker::isInside() const
 {
-    return m_listItem.notInList() || style().listStylePosition() == ListStylePosition::Inside;
+    return m_listItem->notInList() || style().listStylePosition() == ListStylePosition::Inside;
 }
 
 FloatRect RenderListMarker::getRelativeMarkerRect()
@@ -1877,7 +1877,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: branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.h (243573 => 243574)


--- branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.h	2019-03-27 23:43:41 UTC (rev 243573)
+++ branches/safari-607-branch/Source/WebCore/rendering/RenderListMarker.h	2019-03-27 23:43:43 UTC (rev 243574)
@@ -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