Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CTTE] RenderListMarker is always anonymous and owned by RenderListItem.
<https://webkit.org/b/121274>

Reviewed by Anders Carlsson.

Store a RenderListItem& instead of a pointer in RenderListMarker.
Deleted the element() function since list markers are always anonymous.

Canonical link: https://commits.webkit.org/139227@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155670 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Sep 13, 2013
1 parent d55d6c2 commit a0d20b4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
10 changes: 10 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
2013-09-12 Andreas Kling <akling@apple.com>

[CTTE] RenderListMarker is always anonymous and owned by RenderListItem.
<https://webkit.org/b/121274>

Reviewed by Anders Carlsson.

Store a RenderListItem& instead of a pointer in RenderListMarker.
Deleted the element() function since list markers are always anonymous.

2013-09-12 Andreas Kling <akling@apple.com>

[CTTE] RenderListBox's element is always a HTMLSelectElement.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderListItem.cpp
Expand Up @@ -62,7 +62,7 @@ void RenderListItem::styleDidChange(StyleDifference diff, const RenderStyle* old
// up (e.g., in some deeply nested line box). See CSS3 spec.
newStyle->inheritFrom(style());
if (!m_marker)
m_marker = RenderListMarker::createAnonymous(this);
m_marker = RenderListMarker::createAnonymous(*this);
m_marker->setStyle(newStyle.release());
} else if (m_marker) {
m_marker->destroy();
Expand Down
26 changes: 13 additions & 13 deletions Source/WebCore/rendering/RenderListMarker.cpp
Expand Up @@ -1053,9 +1053,9 @@ String listMarkerText(EListStyleType type, int value)
return "";
}

RenderListMarker::RenderListMarker(RenderListItem* item)
RenderListMarker::RenderListMarker(RenderListItem& listItem)
: RenderBox(0)
, m_listItem(item)
, m_listItem(listItem)
{
// init RenderObject attributes
setInline(true); // our object is Inline
Expand All @@ -1068,10 +1068,10 @@ RenderListMarker::~RenderListMarker()
m_image->removeClient(this);
}

RenderListMarker* RenderListMarker::createAnonymous(RenderListItem* item)
RenderListMarker* RenderListMarker::createAnonymous(RenderListItem& listItem)
{
Document& document = item->document();
RenderListMarker* renderer = new (document.renderArena()) RenderListMarker(item);
Document& document = listItem.document();
RenderListMarker* renderer = new (document.renderArena()) RenderListMarker(listItem);
renderer->setDocumentForAnonymous(&document);
return renderer;
}
Expand Down Expand Up @@ -1303,7 +1303,7 @@ void RenderListMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
textRun.setText(reversedText.characters(), length);
}

const UChar suffix = listMarkerSuffix(type, m_listItem->value());
const UChar suffix = listMarkerSuffix(type, m_listItem.value());
if (style()->isLeftToRightDirection()) {
int width = font.width(textRun);
context->drawText(font, textRun, textOrigin);
Expand Down Expand Up @@ -1467,7 +1467,7 @@ void RenderListMarker::updateContent()
case UpperNorwegian:
case UpperRoman:
case Urdu:
m_text = listMarkerText(type, m_listItem->value());
m_text = listMarkerText(type, m_listItem.value());
break;
}
}
Expand Down Expand Up @@ -1580,7 +1580,7 @@ void RenderListMarker::computePreferredLogicalWidths()
logicalWidth = 0;
else {
LayoutUnit itemWidth = font.width(m_text);
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
LayoutUnit suffixSpaceWidth = font.width(RenderBlock::constructTextRun(this, font, suffixSpace, 2, style()));
logicalWidth = itemWidth + suffixSpaceWidth;
}
Expand Down Expand Up @@ -1663,21 +1663,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
{
EListStyleType type = style()->listStyleType();
const UChar suffix = listMarkerSuffix(type, m_listItem->value());
const UChar suffix = listMarkerSuffix(type, m_listItem.value());

if (suffix == ' ')
return String(" ");
Expand All @@ -1697,7 +1697,7 @@ String RenderListMarker::suffix() const

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

IntRect RenderListMarker::getRelativeMarkerRect()
Expand Down Expand Up @@ -1805,7 +1805,7 @@ IntRect RenderListMarker::getRelativeMarkerRect()
return IntRect();
const Font& font = style()->font();
int itemWidth = font.width(m_text);
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem->value()), ' ' };
UChar suffixSpace[2] = { listMarkerSuffix(type, m_listItem.value()), ' ' };
int suffixSpaceWidth = font.width(RenderBlock::constructTextRun(this, font, suffixSpace, 2, style()));
relativeRect = IntRect(0, 0, itemWidth + suffixSpaceWidth, font.fontMetrics().height());
}
Expand Down
8 changes: 5 additions & 3 deletions Source/WebCore/rendering/RenderListMarker.h
Expand Up @@ -35,7 +35,7 @@ String listMarkerText(EListStyleType, int value);
// The RenderListMarker always has to be a child of a RenderListItem.
class RenderListMarker FINAL : public RenderBox {
public:
static RenderListMarker* createAnonymous(RenderListItem*);
static RenderListMarker* createAnonymous(RenderListItem&);

virtual ~RenderListMarker();

Expand All @@ -47,7 +47,9 @@ class RenderListMarker FINAL : public RenderBox {
void updateMarginsAndContent();

private:
RenderListMarker(RenderListItem*);
void element() const WTF_DELETED_FUNCTION;

explicit RenderListMarker(RenderListItem&);

virtual const char* renderName() const { return "RenderListMarker"; }
virtual void computePreferredLogicalWidths() OVERRIDE;
Expand Down Expand Up @@ -83,7 +85,7 @@ class RenderListMarker FINAL : public RenderBox {

String m_text;
RefPtr<StyleImage> m_image;
RenderListItem* m_listItem;
RenderListItem& m_listItem;
};

inline RenderListMarker& toRenderListMarker(RenderObject& object)
Expand Down

0 comments on commit a0d20b4

Please sign in to comment.