⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 242921 in webkit


Ignore:
Timestamp:
Mar 13, 2019, 4:46:05 PM (7 years ago)
Author:
Alan Bujtas
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:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242920 r242921  
     12019-03-13  Zalan Bujtas  <zalan@apple.com>
     2
     3        [WeakPtr] RenderListMarker::m_listItem should be a WeakPtr
     4        https://bugs.webkit.org/show_bug.cgi?id=195704
     5        <rdar://problem/48486278>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * rendering/RenderListMarker.cpp:
     10        (WebCore::RenderListMarker::RenderListMarker):
     11        (WebCore::RenderListMarker::paint):
     12        (WebCore::RenderListMarker::layout):
     13        (WebCore::RenderListMarker::updateContent):
     14        (WebCore::RenderListMarker::computePreferredLogicalWidths):
     15        (WebCore::RenderListMarker::lineHeight const):
     16        (WebCore::RenderListMarker::baselinePosition const):
     17        (WebCore::RenderListMarker::suffix const):
     18        (WebCore::RenderListMarker::isInside const):
     19        (WebCore::RenderListMarker::getRelativeMarkerRect):
     20        * rendering/RenderListMarker.h:
     21
    1222019-03-13  Dean Jackson  <dino@apple.com>
    223
  • trunk/Source/WebCore/rendering/RenderListMarker.cpp

    r240641 r242921  
    11221122RenderListMarker::RenderListMarker(RenderListItem& listItem, RenderStyle&& style)
    11231123    : RenderBox(listItem.document(), WTFMove(style), 0)
    1124     , m_listItem(listItem)
     1124    , m_listItem(makeWeakPtr(listItem))
    11251125{
    11261126    // init RenderObject attributes
     
    12101210            LayoutRect selRect = localSelectionRect();
    12111211            selRect.moveBy(boxOrigin);
    1212             context.fillRect(snappedIntRect(selRect), m_listItem.selectionBackgroundColor());
     1212            context.fillRect(snappedIntRect(selRect), m_listItem->selectionBackgroundColor());
    12131213        }
    12141214        return;
     
    12181218        LayoutRect selRect = localSelectionRect();
    12191219        selRect.moveBy(boxOrigin);
    1220         context.fillRect(snappedIntRect(selRect), m_listItem.selectionBackgroundColor());
     1220        context.fillRect(snappedIntRect(selRect), m_listItem->selectionBackgroundColor());
    12211221    }
    12221222
     
    13431343        context.drawText(font, textRun, textOrigin);
    13441344    else {
    1345         const UChar suffix = listMarkerSuffix(type, m_listItem.value());
     1345        const UChar suffix = listMarkerSuffix(type, m_listItem->value());
    13461346
    13471347        // Text is not arbitrary. We can judge whether it's RTL from the first character,
     
    13821382
    13831383    LayoutUnit blockOffset;
    1384     for (auto* ancestor = parentBox(); ancestor && ancestor != &m_listItem; ancestor = ancestor->parentBox())
     1384    for (auto* ancestor = parentBox(); ancestor && ancestor != m_listItem.get(); ancestor = ancestor->parentBox())
    13851385        blockOffset += ancestor->logicalTop();
    13861386    if (style().isLeftToRightDirection())
    1387         m_lineOffsetForListItem = m_listItem.logicalLeftOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
     1387        m_lineOffsetForListItem = m_listItem->logicalLeftOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
    13881388    else
    1389         m_lineOffsetForListItem = m_listItem.logicalRightOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
     1389        m_lineOffsetForListItem = m_listItem->logicalRightOffsetForLine(blockOffset, DoNotIndentText, 0_lu);
    13901390 
    13911391    if (isImage()) {
     
    15341534    case ListStyleType::UpperRoman:
    15351535    case ListStyleType::Urdu:
    1536         m_text = listMarkerText(type, m_listItem.value());
     1536        m_text = listMarkerText(type, m_listItem->value());
    15371537        break;
    15381538    }
     
    16501650            TextRun run = RenderBlock::constructTextRun(m_text, style());
    16511651            LayoutUnit itemWidth = font.width(run);
    1652             UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
     1652            UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
    16531653            LayoutUnit suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
    16541654            logicalWidth = itemWidth + suffixSpaceWidth;
     
    17331733{
    17341734    if (!isImage())
    1735         return m_listItem.lineHeight(firstLine, direction, PositionOfInteriorLineBoxes);
     1735        return m_listItem->lineHeight(firstLine, direction, PositionOfInteriorLineBoxes);
    17361736    return RenderBox::lineHeight(firstLine, direction, linePositionMode);
    17371737}
     
    17401740{
    17411741    if (!isImage())
    1742         return m_listItem.baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes);
     1742        return m_listItem->baselinePosition(baselineType, firstLine, direction, PositionOfInteriorLineBoxes);
    17431743    return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
    17441744}
     
    17471747{
    17481748    ListStyleType type = style().listStyleType();
    1749     const UChar suffix = listMarkerSuffix(type, m_listItem.value());
     1749    const UChar suffix = listMarkerSuffix(type, m_listItem->value());
    17501750
    17511751    if (suffix == ' ')
     
    17671767bool RenderListMarker::isInside() const
    17681768{
    1769     return m_listItem.notInList() || style().listStylePosition() == ListStylePosition::Inside;
     1769    return m_listItem->notInList() || style().listStylePosition() == ListStylePosition::Inside;
    17701770}
    17711771
     
    18771877        TextRun run = RenderBlock::constructTextRun(m_text, style());
    18781878        float itemWidth = font.width(run);
    1879         UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
     1879        UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
    18801880        float suffixSpaceWidth = font.width(RenderBlock::constructTextRun(suffixSpace, 2, style()));
    18811881        relativeRect = FloatRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height());
  • trunk/Source/WebCore/rendering/RenderListMarker.h

    r232178 r242921  
    4848    void updateMarginsAndContent();
    4949
    50 #if !ASSERT_DISABLED
    51     RenderListItem& listItem() const { return m_listItem; }
    52 #endif
    53 
    5450private:
    5551    void willBeDestroyed() override;
     
    9187    String m_text;
    9288    RefPtr<StyleImage> m_image;
    93     RenderListItem& m_listItem;
     89    WeakPtr<RenderListItem> m_listItem;
    9490    LayoutUnit m_lineOffsetForListItem;
    9591};
Note: See TracChangeset for help on using the changeset viewer.