Skip to content

Commit

Permalink
Merge r242921 - [WeakPtr] RenderListMarker::m_listItem should be a We…
Browse files Browse the repository at this point in the history
…akPtr

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:
  • Loading branch information
alanbaradlay authored and carlosgcampos committed Apr 8, 2019
1 parent 91bcf08 commit 34b9407
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
21 changes: 21 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,24 @@
2019-03-13 Zalan Bujtas <zalan@apple.com>

[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 Zalan Bujtas <zalan@apple.com>

Use RenderBox::previousSiblingBox/nextSiblingBox in RenderMultiColumnFlow
Expand Down
28 changes: 14 additions & 14 deletions Source/WebCore/rendering/RenderListMarker.cpp
Expand Up @@ -1121,7 +1121,7 @@ String listMarkerText(ListStyleType type, int value)

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
Expand Down Expand Up @@ -1209,15 +1209,15 @@ void RenderListMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
if (selectionState() != SelectionNone) {
LayoutRect selRect = localSelectionRect();
selRect.moveBy(boxOrigin);
context.fillRect(snappedIntRect(selRect), m_listItem.selectionBackgroundColor());
context.fillRect(snappedIntRect(selRect), m_listItem->selectionBackgroundColor());
}
return;
}

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));
Expand Down Expand Up @@ -1342,7 +1342,7 @@ void RenderListMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
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.
Expand Down Expand Up @@ -1381,12 +1381,12 @@ void RenderListMarker::layout()
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();
Expand Down Expand Up @@ -1533,7 +1533,7 @@ void RenderListMarker::updateContent()
case ListStyleType::UpperNorwegian:
case ListStyleType::UpperRoman:
case ListStyleType::Urdu:
m_text = listMarkerText(type, m_listItem.value());
m_text = listMarkerText(type, m_listItem->value());
break;
}
}
Expand Down Expand Up @@ -1649,7 +1649,7 @@ void RenderListMarker::computePreferredLogicalWidths()
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;
}
Expand Down Expand Up @@ -1732,21 +1732,21 @@ void RenderListMarker::updateMargins()
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);
}

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);
}

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;
Expand All @@ -1766,7 +1766,7 @@ String RenderListMarker::suffix() const

bool RenderListMarker::isInside() const
{
return m_listItem.notInList() || style().listStylePosition() == ListStylePosition::Inside;
return m_listItem->notInList() || style().listStylePosition() == ListStylePosition::Inside;
}

FloatRect RenderListMarker::getRelativeMarkerRect()
Expand Down Expand Up @@ -1876,7 +1876,7 @@ FloatRect RenderListMarker::getRelativeMarkerRect()
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());
}
Expand Down
6 changes: 1 addition & 5 deletions Source/WebCore/rendering/RenderListMarker.h
Expand Up @@ -47,10 +47,6 @@ class RenderListMarker final : public RenderBox {

void updateMarginsAndContent();

#if !ASSERT_DISABLED
RenderListItem& listItem() const { return m_listItem; }
#endif

private:
void willBeDestroyed() override;

Expand Down Expand Up @@ -90,7 +86,7 @@ class RenderListMarker final : public RenderBox {

String m_text;
RefPtr<StyleImage> m_image;
RenderListItem& m_listItem;
WeakPtr<RenderListItem> m_listItem;
LayoutUnit m_lineOffsetForListItem;
};

Expand Down

0 comments on commit 34b9407

Please sign in to comment.