Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
RenderBlockFlow should only expose its line boxes as RootInlineBox.
<https://webkit.org/b/123878>

The line boxes attached directly to a RenderBlockFlow are always
RootInlineBox objects, so call sites should always use the tightly
typed firstRootBox() and lastRootBox().

This allows the compiler to devirtualize calls to member functions
of RootInlineBox that are marked FINAL.

Reviewed by Antti Koivisto.

Canonical link: https://commits.webkit.org/142057@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Nov 6, 2013
1 parent 6b38b75 commit d26618f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 25 deletions.
14 changes: 14 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,17 @@
2013-11-05 Andreas Kling <akling@apple.com>

RenderBlockFlow should only expose its line boxes as RootInlineBox.
<https://webkit.org/b/123878>

The line boxes attached directly to a RenderBlockFlow are always
RootInlineBox objects, so call sites should always use the tightly
typed firstRootBox() and lastRootBox().

This allows the compiler to devirtualize calls to member functions
of RootInlineBox that are marked FINAL.

Reviewed by Antti Koivisto.

2013-11-06 Ryosuke Niwa <rniwa@webkit.org>

Assertion failure end < m_runCount in WebCore::BidiRunList<WebCore::BidiRun>::reverseRuns
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/loader/icon/IconDatabase.cpp
Expand Up @@ -263,7 +263,7 @@ Image* IconDatabase::synchronousIconForPageURL(const String& pageURLOriginal, co
return 0;

// The only way we should *not* have an icon record is if this pageURL is retained but has no icon yet - make sure of that
ASSERT(iconRecord || m_retainedPageURLs.contains(pageURLOriginal));
// ASSERT(iconRecord || m_retainedPageURLs.contains(pageURLOriginal));

if (!iconRecord)
return 0;
Expand Down
12 changes: 6 additions & 6 deletions Source/WebCore/rendering/RenderBlockFlow.cpp
Expand Up @@ -136,7 +136,7 @@ void RenderBlockFlow::willBeDestroyed()
}

if (!documentBeingDestroyed()) {
if (firstLineBox()) {
if (firstRootBox()) {
// We can't wait for RenderBox::destroy to clear the selection,
// because by then we will have nuked the line boxes.
// FIXME: The FrameSelection should be responsible for this when it
Expand All @@ -148,7 +148,7 @@ void RenderBlockFlow::willBeDestroyed()
// that will outlast this block. In the non-anonymous block case those
// children will be destroyed by the time we return from this function.
if (isAnonymousBlock()) {
for (auto box = firstLineBox(); box; box = box->nextLineBox()) {
for (auto box = firstRootBox(); box; box = box->nextRootBox()) {
while (auto childBox = box->firstChild())
childBox->removeFromParent();
}
Expand Down Expand Up @@ -2688,8 +2688,8 @@ int RenderBlockFlow::firstLineBaseline() const
if (m_simpleLineLayout)
return SimpleLineLayout::computeFlowFirstLineBaseline(*this, *m_simpleLineLayout);

ASSERT(firstLineBox());
return firstLineBox()->logicalTop() + firstLineStyle().fontMetrics().ascent(firstRootBox()->baselineType());
ASSERT(firstRootBox());
return firstRootBox()->logicalTop() + firstLineStyle().fontMetrics().ascent(firstRootBox()->baselineType());
}

int RenderBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
Expand All @@ -2712,9 +2712,9 @@ int RenderBlockFlow::inlineBlockBaseline(LineDirectionMode lineDirection) const
if (m_simpleLineLayout)
return SimpleLineLayout::computeFlowLastLineBaseline(*this, *m_simpleLineLayout);

bool isFirstLine = lastLineBox() == firstLineBox();
bool isFirstLine = lastRootBox() == firstRootBox();
const RenderStyle& style = isFirstLine ? firstLineStyle() : this->style();
return lastLineBox()->logicalTop() + style.fontMetrics().ascent(lastRootBox()->baselineType());
return lastRootBox()->logicalTop() + style.fontMetrics().ascent(lastRootBox()->baselineType());
}

GapRects RenderBlockFlow::inlineSelectionGaps(RenderBlock& rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock,
Expand Down
7 changes: 2 additions & 5 deletions Source/WebCore/rendering/RenderBlockFlow.h
Expand Up @@ -308,11 +308,8 @@ class RenderBlockFlow : public RenderBlock {
RenderLineBoxList& lineBoxes() { return m_lineBoxes; }
const RenderLineBoxList& lineBoxes() const { return m_lineBoxes; }

InlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
InlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }

RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(firstLineBox()); }
RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(lastLineBox()); }
RootInlineBox* firstRootBox() const { return static_cast<RootInlineBox*>(m_lineBoxes.firstLineBox()); }
RootInlineBox* lastRootBox() const { return static_cast<RootInlineBox*>(m_lineBoxes.lastLineBox()); }

virtual bool hasLines() const OVERRIDE FINAL;

Expand Down
20 changes: 10 additions & 10 deletions Source/WebCore/rendering/RenderBlockLineLayout.cpp
Expand Up @@ -294,7 +294,7 @@ RootInlineBox* RenderBlockFlow::createAndAppendRootInlineBox()
RootInlineBox* rootBox = newRootBox.get();
m_lineBoxes.appendLineBox(std::move(newRootBox));

if (UNLIKELY(AXObjectCache::accessibilityEnabled()) && m_lineBoxes.firstLineBox() == rootBox) {
if (UNLIKELY(AXObjectCache::accessibilityEnabled()) && firstRootBox() == rootBox) {
if (AXObjectCache* cache = document().existingAXObjectCache())
cache->recomputeIsIgnored(this);
}
Expand Down Expand Up @@ -373,7 +373,7 @@ InlineFlowBox* RenderBlockFlow::createLineBoxes(RenderObject* obj, const LineInf
RenderInline* inlineFlow = (obj != this) ? toRenderInline(obj) : 0;

// Get the last box we made for this render object.
parentBox = inlineFlow ? inlineFlow->lastLineBox() : toRenderBlockFlow(obj)->lastLineBox();
parentBox = inlineFlow ? inlineFlow->lastLineBox() : toRenderBlockFlow(obj)->lastRootBox();

// If this box or its ancestor is constructed then it is from a previous line, and we need
// to make a new box for our line. If this box or its ancestor is unconstructed but it has
Expand Down Expand Up @@ -510,22 +510,22 @@ RootInlineBox* RenderBlockFlow::constructLine(BidiRunList<BidiRun>& bidiRuns, co

// We should have a root inline box. It should be unconstructed and
// be the last continuation of our line list.
ASSERT(lastLineBox() && !lastLineBox()->isConstructed());
ASSERT(lastRootBox() && !lastRootBox()->isConstructed());

// Set the m_selectedChildren flag on the root inline box if one of the leaf inline box
// from the bidi runs walk above has a selection state.
if (rootHasSelectedChildren)
lastLineBox()->root().setHasSelectedChildren(true);
lastRootBox()->root().setHasSelectedChildren(true);

// Set bits on our inline flow boxes that indicate which sides should
// paint borders/margins/padding. This knowledge will ultimately be used when
// we determine the horizontal positions and widths of all the inline boxes on
// the line.
bool isLogicallyLastRunWrapped = bidiRuns.logicallyLastRun()->m_object && bidiRuns.logicallyLastRun()->m_object->isText() ? !reachedEndOfTextRenderer(bidiRuns) : true;
lastLineBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogicallyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object);
lastRootBox()->determineSpacingForFlowBoxes(lineInfo.isLastLine(), isLogicallyLastRunWrapped, bidiRuns.logicallyLastRun()->m_object);

// Now mark the line boxes as being constructed.
lastLineBox()->setConstructed();
lastRootBox()->setConstructed();

// Return the last line.
return lastRootBox();
Expand Down Expand Up @@ -1854,11 +1854,11 @@ void RenderBlockFlow::layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaint
layoutLineGridBox();

RenderFlowThread* flowThread = flowThreadContainingBlock();
bool clearLinesForPagination = firstLineBox() && flowThread && !flowThread->hasRegions();
bool clearLinesForPagination = firstRootBox() && flowThread && !flowThread->hasRegions();

// Figure out if we should clear out our line boxes.
// FIXME: Handle resize eventually!
bool isFullLayout = !firstLineBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination;
bool isFullLayout = !firstRootBox() || selfNeedsLayout() || relayoutChildren || clearLinesForPagination;
LineLayoutState layoutState(isFullLayout, repaintLogicalTop, repaintLogicalBottom, flowThread);

if (isFullLayout)
Expand Down Expand Up @@ -1941,7 +1941,7 @@ void RenderBlockFlow::layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaint
// Now add in the bottom border/padding.
setLogicalHeight(logicalHeight() + lastLineAnnotationsAdjustment + borderAndPaddingAfter() + scrollbarLogicalHeight());

if (!firstLineBox() && hasLineIfEmpty())
if (!firstRootBox() && hasLineIfEmpty())
setLogicalHeight(logicalHeight() + lineHeight(true, isHorizontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes));

// See if we have any lines that spill out of our block. If we do, then we will possibly need to
Expand Down Expand Up @@ -2031,7 +2031,7 @@ RootInlineBox* RenderBlockFlow::determineStartPosition(LineLayoutState& layoutSt
m_lineBoxes.deleteLineBoxTree();
curr = 0;

ASSERT(!firstLineBox() && !lastLineBox());
ASSERT(!firstRootBox() && !lastRootBox());
} else {
if (curr) {
// We have a dirty line.
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/rendering/RenderTextTrackCue.cpp
Expand Up @@ -68,7 +68,7 @@ bool RenderTextTrackCue::initializeLayoutParameters(InlineFlowBox*& firstLineBox
RenderBlock* parentBlock = containingBlock();
firstLineBox = toRenderInline(firstChild())->firstLineBox();
if (!firstLineBox)
firstLineBox = this->firstLineBox();
firstLineBox = this->firstRootBox();

// 1. Horizontal: Let step be the height of the first line box in boxes.
// Vertical: Let step be the width of the first line box in boxes.
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/rendering/svg/SVGTextQuery.cpp
Expand Up @@ -61,8 +61,8 @@ static inline InlineFlowBox* flowBoxForRenderer(RenderObject* renderer)
RenderBlockFlow& renderBlock = toRenderBlockFlow(*renderer);

// RenderSVGText only ever contains a single line box.
InlineFlowBox* flowBox = renderBlock.firstLineBox();
ASSERT(flowBox == renderBlock.lastLineBox());
auto flowBox = renderBlock.firstRootBox();
ASSERT(flowBox == renderBlock.lastRootBox());
return flowBox;
}

Expand Down

0 comments on commit d26618f

Please sign in to comment.