Source/WebCore/ChangeLog

 12013-09-08 Andreas Kling <akling@apple.com>
 2
 3 InlineBox::root() should return a reference.
 4 <https://webkit.org/b/121014>
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 There is always a root inline box, so make root() return a reference.
 9 Also make some effort to cache the result in a local at call sites.
 10
1112013-09-08 Anders Carlsson <andersca@apple.com>
212
313 Move WTF::notFound to Vector.h and delete NotFound.h

Source/WebCore/dom/ContainerNode.cpp

@@bool ContainerNode::getUpperLeftCorner(FloatPoint& point) const
915915 } else if ((o->isText() && !o->isBR()) || o->isReplaced()) {
916916 point = FloatPoint();
917917 if (o->isText() && toRenderText(o)->firstTextBox()) {
918  point.move(toRenderText(o)->linesBoundingBox().x(), toRenderText(o)->firstTextBox()->root()->lineTop());
 918 point.move(toRenderText(o)->linesBoundingBox().x(), toRenderText(o)->firstTextBox()->root().lineTop());
919919 } else if (o->isBox()) {
920920 RenderBox* box = toRenderBox(o);
921921 point.moveBy(box->location());

Source/WebCore/dom/Position.cpp

@@bool Position::rendersInDifferentPosition(const Position &pos) const
10601060 return false;
10611061 }
10621062
1063  if (b1->root() != b2->root()) {
 1063 if (&b1->root() != &b2->root()) {
10641064 return true;
10651065 }
10661066

Source/WebCore/editing/RenderedPosition.h

@@public:
4949 bool isEquivalent(const RenderedPosition&) const;
5050
5151 bool isNull() const { return !m_renderer; }
52  RootInlineBox* rootBox() { return m_inlineBox ? m_inlineBox->root() : 0; }
 52 RootInlineBox* rootBox() { return m_inlineBox ? &m_inlineBox->root() : 0; }
5353
5454 unsigned char bidiLevelOnLeft() const;
5555 unsigned char bidiLevelOnRight() const;

Source/WebCore/editing/VisiblePosition.cpp

@@Position VisiblePosition::leftVisuallyDistinctCandidate() const
154154 InlineBox* boxOnLeft;
155155 int offsetOnLeft;
156156 positionOnLeft.getInlineBoxAndOffset(m_affinity, primaryDirection, boxOnLeft, offsetOnLeft);
157  if (boxOnLeft && boxOnLeft->root() == box->root())
 157 if (boxOnLeft && &boxOnLeft->root() == &box->root())
158158 return Position();
159159 return positionOnLeft;
160160 }

@@Position VisiblePosition::leftVisuallyDistinctCandidate() const
174174 if (box->direction() == primaryDirection) {
175175 if (!prevBox) {
176176 InlineBox* logicalStart = 0;
177  if (primaryDirection == LTR ? box->root()->getLogicalStartBoxWithNode(logicalStart) : box->root()->getLogicalEndBoxWithNode(logicalStart)) {
 177 if (primaryDirection == LTR ? box->root().getLogicalStartBoxWithNode(logicalStart) : box->root().getLogicalEndBoxWithNode(logicalStart)) {
178178 box = logicalStart;
179179 renderer = &box->renderer();
180180 offset = primaryDirection == LTR ? box->caretMinOffset() : box->caretMaxOffset();

@@Position VisiblePosition::rightVisuallyDistinctCandidate() const
319319 InlineBox* boxOnRight;
320320 int offsetOnRight;
321321 positionOnRight.getInlineBoxAndOffset(m_affinity, primaryDirection, boxOnRight, offsetOnRight);
322  if (boxOnRight && boxOnRight->root() == box->root())
 322 if (boxOnRight && &boxOnRight->root() == &box->root())
323323 return Position();
324324 return positionOnRight;
325325 }

@@Position VisiblePosition::rightVisuallyDistinctCandidate() const
339339 if (box->direction() == primaryDirection) {
340340 if (!nextBox) {
341341 InlineBox* logicalEnd = 0;
342  if (primaryDirection == LTR ? box->root()->getLogicalEndBoxWithNode(logicalEnd) : box->root()->getLogicalStartBoxWithNode(logicalEnd)) {
 342 if (primaryDirection == LTR ? box->root().getLogicalEndBoxWithNode(logicalEnd) : box->root().getLogicalStartBoxWithNode(logicalEnd)) {
343343 box = logicalEnd;
344344 renderer = &box->renderer();
345345 offset = primaryDirection == LTR ? box->caretMaxOffset() : box->caretMinOffset();

Source/WebCore/editing/VisibleUnits.cpp

@@static const InlineTextBox* logicallyPreviousBox(const VisiblePosition& visibleP
205205{
206206 const InlineBox* startBox = textBox;
207207
208  const InlineTextBox* previousBox = leafBoxes.previousTextBox(startBox->root(), textBox);
 208 const InlineTextBox* previousBox = leafBoxes.previousTextBox(&startBox->root(), textBox);
209209 if (previousBox)
210210 return previousBox;
211211
212  previousBox = leafBoxes.previousTextBox(startBox->root()->prevRootBox(), 0);
 212 previousBox = leafBoxes.previousTextBox(startBox->root().prevRootBox(), 0);
213213 if (previousBox)
214214 return previousBox;
215215

@@static const InlineTextBox* logicallyNextBox(const VisiblePosition& visiblePosit
246246{
247247 const InlineBox* startBox = textBox;
248248
249  const InlineTextBox* nextBox = leafBoxes.nextTextBox(startBox->root(), textBox);
 249 const InlineTextBox* nextBox = leafBoxes.nextTextBox(&startBox->root(), textBox);
250250 if (nextBox)
251251 return nextBox;
252252
253  nextBox = leafBoxes.nextTextBox(startBox->root()->nextRootBox(), 0);
 253 nextBox = leafBoxes.nextTextBox(startBox->root().nextRootBox(), 0);
254254 if (nextBox)
255255 return nextBox;
256256

@@VisiblePosition previousLinePosition(const VisiblePosition &visiblePosition, int
931931 int ignoredCaretOffset;
932932 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset);
933933 if (box) {
934  root = box->root()->prevRootBox();
 934 root = box->root().prevRootBox();
935935 // We want to skip zero height boxes.
936936 // This could happen in case it is a TrailingFloatsRootInlineBox.
937937 if (!root || !root->logicalHeight() || !root->firstLeafChild())

@@VisiblePosition nextLinePosition(const VisiblePosition &visiblePosition, int lin
986986 int ignoredCaretOffset;
987987 visiblePosition.getInlineBoxAndOffset(box, ignoredCaretOffset);
988988 if (box) {
989  root = box->root()->nextRootBox();
 989 root = box->root().nextRootBox();
990990 // We want to skip zero height boxes.
991991 // This could happen in case it is a TrailingFloatsRootInlineBox.
992992 if (!root || !root->logicalHeight() || !root->firstLeafChild())

Source/WebCore/rendering/EllipsisBox.cpp

@@IntRect EllipsisBox::selectionRect()
104104{
105105 RenderStyle* style = renderer().style(isFirstLineStyle());
106106 const Font& font = style->font();
 107 const RootInlineBox& rootBox = root();
107108 // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
108  return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHeightAdjustedForPrecedingBlock()));
 109 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock()), rootBox.selectionHeightAdjustedForPrecedingBlock()));
109110}
110111
111112void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, RenderStyle* style, const Font& font)

@@void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
120121 if (textColor == c)
121122 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
122123
123  GraphicsContextStateSaver stateSaver(*context);
124  LayoutUnit top = root()->selectionTop();
125  LayoutUnit h = root()->selectionHeight();
 124 const RootInlineBox& rootBox = root();
 125 LayoutUnit top = rootBox.selectionTop();
 126 LayoutUnit h = rootBox.selectionHeight();
126127 FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
127128 alignSelectionRectToDevicePixels(clipRect);
 129
 130 GraphicsContextStateSaver stateSaver(*context);
128131 context->clip(clipRect);
129132 // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
130133 context->drawHighlightForText(font, RenderBlock::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style->colorSpace());

Source/WebCore/rendering/InlineBox.cpp

@@bool InlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
250250 return m_renderer.hitTest(request, result, locationInContainer, childPoint);
251251}
252252
253 const RootInlineBox* InlineBox::root() const
 253const RootInlineBox& InlineBox::root() const
254254{
255255 if (m_parent)
256256 return m_parent->root();
257257 ASSERT(isRootInlineBox());
258  return static_cast<const RootInlineBox*>(this);
 258 return static_cast<const RootInlineBox&>(*this);
259259}
260260
261 RootInlineBox* InlineBox::root()
 261RootInlineBox& InlineBox::root()
262262{
263263 if (m_parent)
264264 return m_parent->root();
265265 ASSERT(isRootInlineBox());
266  return static_cast<RootInlineBox*>(this);
 266 return static_cast<RootInlineBox&>(*this);
267267}
268268
269269bool InlineBox::nextOnLineExists() const

@@FloatPoint InlineBox::locationIncludingFlipping()
351351{
352352 if (!m_renderer.style()->isFlippedBlocksWritingMode())
353353 return FloatPoint(x(), y());
354  RenderBlock& block = root()->block();
 354 RenderBlock& block = root().block();
355355 if (block.style()->isHorizontalWritingMode())
356356 return FloatPoint(x(), block.height() - height() - y());
357357 else

@@void InlineBox::flipForWritingMode(FloatRect& rect)
362362{
363363 if (!m_renderer.style()->isFlippedBlocksWritingMode())
364364 return;
365  root()->block().flipForWritingMode(rect);
 365 root().block().flipForWritingMode(rect);
366366}
367367
368368FloatPoint InlineBox::flipForWritingMode(const FloatPoint& point)
369369{
370370 if (!m_renderer.style()->isFlippedBlocksWritingMode())
371371 return point;
372  return root()->block().flipForWritingMode(point);
 372 return root().block().flipForWritingMode(point);
373373}
374374
375375void InlineBox::flipForWritingMode(LayoutRect& rect)
376376{
377377 if (!m_renderer.style()->isFlippedBlocksWritingMode())
378378 return;
379  root()->block().flipForWritingMode(rect);
 379 root().block().flipForWritingMode(rect);
380380}
381381
382382LayoutPoint InlineBox::flipForWritingMode(const LayoutPoint& point)
383383{
384384 if (!m_renderer.style()->isFlippedBlocksWritingMode())
385385 return point;
386  return root()->block().flipForWritingMode(point);
 386 return root().block().flipForWritingMode(point);
387387}
388388
389389} // namespace WebCore

Source/WebCore/rendering/InlineBox.h

@@public:
190190 }
191191 void setParent(InlineFlowBox* par) { m_parent = par; }
192192
193  const RootInlineBox* root() const;
194  RootInlineBox* root();
 193 const RootInlineBox& root() const;
 194 RootInlineBox& root();
195195
196196 // x() is the left side of the box in the containing block's coordinate system.
197197 void setX(float x) { m_topLeft.setX(x); }

Source/WebCore/rendering/InlineFlowBox.cpp

@@void InlineFlowBox::removeChild(InlineBox* child)
185185 if (!isDirty())
186186 dirtyLineBoxes();
187187
188  root()->childRemoved(child);
 188 root().childRemoved(child);
189189
190190 if (child == m_firstChild)
191191 m_firstChild = child->nextOnLine();

@@float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, Inlin
408408 // Our offset that we cache needs to be from the edge of the right border box and
409409 // not the left border box. We have to subtract |x| from the width of the block
410410 // (which can be obtained from the root line box).
411  curr->setLogicalLeft(root()->block().logicalWidth() - logicalLeft);
 411 curr->setLogicalLeft(root().block().logicalWidth() - logicalLeft);
412412 continue; // The positioned object has no effect on the width.
413413 }
414414 if (curr->renderer().isRenderInline()) {

@@bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
10561056
10571057 // Do not hittest content beyond the ellipsis box.
10581058 if (isRootInlineBox() && hasEllipsisBox()) {
1059  const EllipsisBox* ellipsisBox = root()->ellipsisBox();
 1059 const EllipsisBox* ellipsisBox = root().ellipsisBox();
10601060 LayoutRect boundsRect(roundedFrameRect());
10611061
10621062 if (isHorizontal())

@@bool InlineFlowBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
10801080 // Constrain our hit testing to the line top and bottom if necessary.
10811081 bool noQuirksMode = renderer().document().inNoQuirksMode();
10821082 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
1083  RootInlineBox* rootBox = root();
 1083 RootInlineBox& rootBox = root();
10841084 LayoutUnit& top = isHorizontal() ? minY : minX;
10851085 LayoutUnit& logicalHeight = isHorizontal() ? height : width;
1086  LayoutUnit bottom = min(rootBox->lineBottom(), top + logicalHeight);
1087  top = max(rootBox->lineTop(), top);
 1086 LayoutUnit bottom = min(rootBox.lineBottom(), top + logicalHeight);
 1087 top = max(rootBox.lineTop(), top);
10881088 logicalHeight = bottom - top;
10891089 }
10901090

@@void InlineFlowBox::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const
12501250{
12511251 bool noQuirksMode = renderer().document().inNoQuirksMode();
12521252 if (!noQuirksMode && !hasTextChildren() && !(descendantsHaveSameLineHeightAndBaseline() && hasTextDescendants())) {
1253  const RootInlineBox* rootBox = root();
 1253 const RootInlineBox& rootBox = root();
12541254 LayoutUnit logicalTop = isHorizontal() ? rect.y() : rect.x();
12551255 LayoutUnit logicalHeight = isHorizontal() ? rect.height() : rect.width();
1256  LayoutUnit bottom = min(rootBox->lineBottom(), logicalTop + logicalHeight);
1257  logicalTop = max(rootBox->lineTop(), logicalTop);
 1256 LayoutUnit bottom = min(rootBox.lineBottom(), logicalTop + logicalHeight);
 1257 logicalTop = max(rootBox.lineTop(), logicalTop);
12581258 logicalHeight = bottom - logicalTop;
12591259 if (isHorizontal()) {
12601260 rect.setY(logicalTop);

Source/WebCore/rendering/InlineTextBox.cpp

@@LayoutUnit InlineTextBox::lineHeight() const
118118
119119LayoutUnit InlineTextBox::selectionTop()
120120{
121  return root()->selectionTop();
 121 return root().selectionTop();
122122}
123123
124124LayoutUnit InlineTextBox::selectionBottom()
125125{
126  return root()->selectionBottom();
 126 return root().selectionBottom();
127127}
128128
129129LayoutUnit InlineTextBox::selectionHeight()
130130{
131  return root()->selectionHeight();
 131 return root().selectionHeight();
132132}
133133
134134bool InlineTextBox::isSelected(int startPos, int endPos) const

@@RenderObject::SelectionState InlineTextBox::selectionState()
163163 }
164164
165165 // If there are ellipsis following, make sure their selection is updated.
166  if (m_truncation != cNoTruncation && root()->ellipsisBox()) {
167  EllipsisBox* ellipsis = root()->ellipsisBox();
 166 if (m_truncation != cNoTruncation && root().ellipsisBox()) {
 167 EllipsisBox* ellipsis = root().ellipsisBox();
168168 if (state != RenderObject::SelectionNone) {
169169 int start, end;
170170 selectionStartEnd(start, end);

@@void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
903903 if (respectHyphen)
904904 ePos = textRun.length();
905905
906  LayoutUnit selectionBottom = root()->selectionBottom();
907  LayoutUnit selectionTop = root()->selectionTopAdjustedForPrecedingBlock();
 906 const RootInlineBox& rootBox = root();
 907 LayoutUnit selectionBottom = rootBox.selectionBottom();
 908 LayoutUnit selectionTop = rootBox.selectionTopAdjustedForPrecedingBlock();
908909
909910 int deltaY = roundToInt(textRenderer.style()->isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop);
910911 int selHeight = max(0, roundToInt(selectionBottom - selectionTop));

@@void InlineTextBox::paintCustomHighlight(const LayoutPoint& paintOffset, const A
947948 if (!page)
948949 return;
949950
950  RootInlineBox* r = root();
951  FloatRect rootRect(paintOffset.x() + r->x(), paintOffset.y() + selectionTop(), r->logicalWidth(), selectionHeight());
 951 const RootInlineBox& rootBox = root();
 952 FloatRect rootRect(paintOffset.x() + rootBox.x(), paintOffset.y() + selectionTop(), rootBox.logicalWidth(), selectionHeight());
952953 FloatRect textRect(paintOffset.x() + x(), rootRect.y(), logicalWidth(), rootRect.height());
953954
954955 page->chrome().client().paintCustomHighlight(renderer().node(), type, textRect, rootRect, true, false);

@@static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
997998 return fontMetrics.ascent() + gap; // Position underline near the alphabetic baseline.
998999 case TextUnderlinePositionUnder: {
9991000 // Position underline relative to the under edge of the lowest element's content box.
1000  const float offset = inlineTextBox->root()->maxLogicalTop() - inlineTextBox->logicalTop();
 1001 const float offset = inlineTextBox->root().maxLogicalTop() - inlineTextBox->logicalTop();
10011002 if (offset > 0)
10021003 return inlineTextBox->logicalHeight() + gap + offset;
10031004 return inlineTextBox->logicalHeight() + gap;

@@float InlineTextBox::textPos() const
15341535 // from the containing block edge in its measurement. textPos() should be consistent so the text are rendered in the same width.
15351536 if (logicalLeft() == 0)
15361537 return 0;
1537  return logicalLeft() - root()->logicalLeft();
 1538 return logicalLeft() - root().logicalLeft();
15381539}
15391540
15401541int InlineTextBox::offsetForPosition(float lineOffset, bool includePartialGlyphs) const

Source/WebCore/rendering/RenderBlock.cpp

@@void RenderBlock::simplifiedNormalFlowLayout()
28152815 RenderObject* o = walker.current();
28162816 if (!o->isOutOfFlowPositioned() && (o->isReplaced() || o->isFloating())) {
28172817 o->layoutIfNeeded();
2818  if (toRenderBox(o)->inlineBoxWrapper()) {
2819  RootInlineBox* box = toRenderBox(o)->inlineBoxWrapper()->root();
2820  lineBoxes.add(box);
2821  }
 2818 if (toRenderBox(o)->inlineBoxWrapper())
 2819 lineBoxes.add(&toRenderBox(o)->inlineBoxWrapper()->root());
28222820 } else if (o->isText() || (o->isRenderInline() && !walker.atEndOfInline()))
28232821 o->setNeedsLayout(false);
28242822 }

@@VisiblePosition RenderBlock::positionForPointWithInlineChildren(const LayoutPoin
55455543 }
55465544
55475545 // pass the box a top position that is inside it
5548  LayoutPoint point(pointInLogicalContents.x(), closestBox->root()->blockDirectionPointInLine());
 5546 LayoutPoint point(pointInLogicalContents.x(), closestBox->root().blockDirectionPointInLine());
55495547 if (!isHorizontalWritingMode())
55505548 point = point.transposedPoint();
55515549 if (closestBox->renderer().isReplaced())

Source/WebCore/rendering/RenderBlockLineLayout.cpp

@@RootInlineBox* RenderBlock::constructLine(BidiRunList<BidiRun>& bidiRuns, const
719719 // Set the m_selectedChildren flag on the root inline box if one of the leaf inline box
720720 // from the bidi runs walk above has a selection state.
721721 if (rootHasSelectedChildren)
722  lastLineBox()->root()->setHasSelectedChildren(true);
 722 lastLineBox()->root().setHasSelectedChildren(true);
723723
724724 // Set bits on our inline flow boxes that indicate which sides should
725725 // paint borders/margins/padding. This knowledge will ultimately be used when

Source/WebCore/rendering/RenderBox.cpp

@@void RenderBox::paintCustomHighlight(const LayoutPoint& paintOffset, const Atomi
15901590 return;
15911591
15921592 InlineBox* boxWrap = inlineBoxWrapper();
1593  RootInlineBox* r = boxWrap ? boxWrap->root() : 0;
 1593 RootInlineBox* r = boxWrap ? &boxWrap->root() : 0;
15941594 if (r) {
15951595 FloatRect rootRect(paintOffset.x() + r->x(), paintOffset.y() + r->selectionTop(), r->logicalWidth(), r->selectionHeight());
15961596 FloatRect imageRect(paintOffset.x() + x(), rootRect.y(), width(), rootRect.height());

@@void RenderBox::positionLineBox(InlineBox* box)
19731973 // The value is cached in the xPos of the box. We only need this value if
19741974 // our object was inline originally, since otherwise it would have ended up underneath
19751975 // the inlines.
1976  RootInlineBox* root = box->root();
1977  root->block().setStaticInlinePositionForChild(this, root->lineTopWithLeading(), roundedLayoutUnit(box->logicalLeft()));
 1976 RootInlineBox& rootBox = box->root();
 1977 rootBox.block().setStaticInlinePositionForChild(this, rootBox.lineTopWithLeading(), roundedLayoutUnit(box->logicalLeft()));
19781978 if (style()->hasStaticInlinePosition(box->isHorizontal()))
19791979 setChildNeedsLayout(true, MarkOnlyThis); // Just go ahead and mark the positioned object as needing layout, so it will update its position properly.
19801980 } else {

@@LayoutRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit
40304030 rect.move(LayoutSize(width() - caretWidth, 0));
40314031
40324032 if (box) {
4033  RootInlineBox* rootBox = box->root();
4034  LayoutUnit top = rootBox->lineTop();
 4033 const RootInlineBox& rootBox = box->root();
 4034 LayoutUnit top = rootBox.lineTop();
40354035 rect.setY(top);
4036  rect.setHeight(rootBox->lineBottom() - top);
 4036 rect.setHeight(rootBox.lineBottom() - top);
40374037 }
40384038
40394039 // If height of box is smaller than font height, use the latter one,

Source/WebCore/rendering/RenderBoxModelObject.cpp

@@void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, co
711711 // InlineTextBoxes that they should just add their contents to the clip.
712712 PaintInfo info(maskImageContext, maskRect, PaintPhaseTextClip, PaintBehaviorForceBlackText, 0, paintInfo.renderRegion);
713713 if (box) {
714  RootInlineBox* root = box->root();
715  box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), root->lineTop(), root->lineBottom());
 714 const RootInlineBox& rootBox = box->root();
 715 box->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), rootBox.lineTop(), rootBox.lineBottom());
716716 } else {
717717 LayoutSize localOffset = isBox() ? toRenderBox(this)->locationOffset() : LayoutSize();
718718 paint(info, scrolledPaintRect.location() - localOffset);

Source/WebCore/rendering/RenderInline.cpp

@@void RenderInline::generateCulledLineBoxRects(GeneratorContext& yield, const Ren
564564 if (curr->isBox()) {
565565 RenderBox* currBox = toRenderBox(curr);
566566 if (currBox->inlineBoxWrapper()) {
567  RootInlineBox* rootBox = currBox->inlineBoxWrapper()->root();
568  int logicalTop = rootBox->logicalTop() + (rootBox->renderer().style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent());
569  int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
 567 const RootInlineBox& rootBox = currBox->inlineBoxWrapper()->root();
 568 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
 569 int logicalHeight = container->style(rootBox.isFirstLineStyle())->font().fontMetrics().height();
570570 if (isHorizontal)
571571 yield(FloatRect(currBox->inlineBoxWrapper()->x() - currBox->marginLeft(), logicalTop, currBox->width() + currBox->marginWidth(), logicalHeight));
572572 else

@@void RenderInline::generateCulledLineBoxRects(GeneratorContext& yield, const Ren
579579 currInline->generateCulledLineBoxRects(yield, container);
580580 else {
581581 for (InlineFlowBox* childLine = currInline->firstLineBox(); childLine; childLine = childLine->nextLineBox()) {
582  RootInlineBox* rootBox = childLine->root();
583  int logicalTop = rootBox->logicalTop() + (rootBox->renderer().style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent());
584  int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
 582 const RootInlineBox& rootBox = childLine->root();
 583 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
 584 int logicalHeight = container->style(rootBox.isFirstLineStyle())->font().fontMetrics().height();
585585 if (isHorizontal)
586586 yield(FloatRect(childLine->x() - childLine->marginLogicalLeft(),
587587 logicalTop,

@@void RenderInline::generateCulledLineBoxRects(GeneratorContext& yield, const Ren
597597 } else if (curr->isText()) {
598598 RenderText* currText = toRenderText(curr);
599599 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox()) {
600  RootInlineBox* rootBox = childText->root();
601  int logicalTop = rootBox->logicalTop() + (rootBox->renderer().style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox->isFirstLineStyle())->font().fontMetrics().ascent());
602  int logicalHeight = container->style(rootBox->isFirstLineStyle())->font().fontMetrics().height();
 600 const RootInlineBox& rootBox = childText->root();
 601 int logicalTop = rootBox.logicalTop() + (rootBox.renderer().style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent() - container->style(rootBox.isFirstLineStyle())->font().fontMetrics().ascent());
 602 int logicalHeight = container->style(rootBox.isFirstLineStyle())->font().fontMetrics().height();
603603 if (isHorizontal)
604604 yield(FloatRect(childText->x(), logicalTop, childText->logicalWidth(), logicalHeight));
605605 else

@@LayoutRect RenderInline::linesVisualOverflowBoundingBox() const
990990 logicalRightSide = max(logicalRightSide, curr->logicalRightVisualOverflow());
991991 }
992992
993  RootInlineBox* firstRootBox = firstLineBox()->root();
994  RootInlineBox* lastRootBox = lastLineBox()->root();
 993 const RootInlineBox& firstRootBox = firstLineBox()->root();
 994 const RootInlineBox& lastRootBox = lastLineBox()->root();
995995
996  LayoutUnit logicalTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox->lineTop());
 996 LayoutUnit logicalTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox.lineTop());
997997 LayoutUnit logicalWidth = logicalRightSide - logicalLeftSide;
998  LayoutUnit logicalHeight = lastLineBox()->logicalBottomVisualOverflow(lastRootBox->lineBottom()) - logicalTop;
 998 LayoutUnit logicalHeight = lastLineBox()->logicalBottomVisualOverflow(lastRootBox.lineBottom()) - logicalTop;
999999
10001000 LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);
10011001 if (!style()->isHorizontalWritingMode())

@@void RenderInline::dirtyLineBoxes(bool fullLayout)
12851285 if (curr->isBox() && !curr->needsLayout()) {
12861286 RenderBox* currBox = toRenderBox(curr);
12871287 if (currBox->inlineBoxWrapper())
1288  currBox->inlineBoxWrapper()->root()->markDirty();
 1288 currBox->inlineBoxWrapper()->root().markDirty();
12891289 } else if (!curr->selfNeedsLayout()) {
12901290 if (curr->isRenderInline()) {
12911291 RenderInline* currInline = toRenderInline(curr);
12921292 for (InlineFlowBox* childLine = currInline->firstLineBox(); childLine; childLine = childLine->nextLineBox())
1293  childLine->root()->markDirty();
 1293 childLine->root().markDirty();
12941294 } else if (curr->isText()) {
12951295 RenderText* currText = toRenderText(curr);
12961296 for (InlineTextBox* childText = currText->firstTextBox(); childText; childText = childText->nextTextBox())
1297  childText->root()->markDirty();
 1297 childText->root().markDirty();
12981298 }
12991299 }
13001300 }

@@void RenderInline::paintOutline(PaintInfo& paintInfo, const LayoutPoint& paintOf
14351435
14361436 rects.append(LayoutRect());
14371437 for (InlineFlowBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
1438  RootInlineBox* root = curr->root();
1439  LayoutUnit top = max<LayoutUnit>(root->lineTop(), curr->logicalTop());
1440  LayoutUnit bottom = min<LayoutUnit>(root->lineBottom(), curr->logicalBottom());
 1438 const RootInlineBox& rootBox = curr->root();
 1439 LayoutUnit top = max<LayoutUnit>(rootBox.lineTop(), curr->logicalTop());
 1440 LayoutUnit bottom = min<LayoutUnit>(rootBox.lineBottom(), curr->logicalBottom());
14411441 rects.append(LayoutRect(curr->x(), top, curr->logicalWidth(), bottom - top));
14421442 }
14431443 rects.append(LayoutRect());

Source/WebCore/rendering/RenderLineBoxList.cpp

@@bool RenderLineBoxList::anyLineIntersectsRect(RenderBoxModelObject* renderer, co
177177 // intersect. This is a quick short-circuit that we can take to avoid walking any lines.
178178 // FIXME: This check is flawed in the following extremely obscure way:
179179 // if some line in the middle has a huge overflow, it might actually extend below the last line.
180  RootInlineBox* firstRootBox = firstLineBox()->root();
181  RootInlineBox* lastRootBox = lastLineBox()->root();
182  LayoutUnit firstLineTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox->lineTop());
 180 const RootInlineBox& firstRootBox = firstLineBox()->root();
 181 const RootInlineBox& lastRootBox = lastLineBox()->root();
 182 LayoutUnit firstLineTop = firstLineBox()->logicalTopVisualOverflow(firstRootBox.lineTop());
183183 if (usePrintRect && !firstLineBox()->parent())
184  firstLineTop = min(firstLineTop, firstLineBox()->root()->lineTop());
185  LayoutUnit lastLineBottom = lastLineBox()->logicalBottomVisualOverflow(lastRootBox->lineBottom());
 184 firstLineTop = min(firstLineTop, firstRootBox.lineTop());
 185 LayoutUnit lastLineBottom = lastLineBox()->logicalBottomVisualOverflow(lastRootBox.lineBottom());
186186 if (usePrintRect && !lastLineBox()->parent())
187  lastLineBottom = max(lastLineBottom, lastLineBox()->root()->lineBottom());
 187 lastLineBottom = max(lastLineBottom, lastRootBox.lineBottom());
188188 LayoutUnit logicalTop = firstLineTop - outlineSize;
189189 LayoutUnit logicalBottom = outlineSize + lastLineBottom;
190190

@@bool RenderLineBoxList::anyLineIntersectsRect(RenderBoxModelObject* renderer, co
193193
194194bool RenderLineBoxList::lineIntersectsDirtyRect(RenderBoxModelObject* renderer, InlineFlowBox* box, const PaintInfo& paintInfo, const LayoutPoint& offset) const
195195{
196  RootInlineBox* root = box->root();
197  LayoutUnit logicalTop = min<LayoutUnit>(box->logicalTopVisualOverflow(root->lineTop()), root->selectionTop()) - renderer->maximalOutlineSize(paintInfo.phase);
198  LayoutUnit logicalBottom = box->logicalBottomVisualOverflow(root->lineBottom()) + renderer->maximalOutlineSize(paintInfo.phase);
 196 const RootInlineBox& rootBox = box->root();
 197 LayoutUnit logicalTop = min<LayoutUnit>(box->logicalTopVisualOverflow(rootBox.lineTop()), rootBox.selectionTop()) - renderer->maximalOutlineSize(paintInfo.phase);
 198 LayoutUnit logicalBottom = box->logicalBottomVisualOverflow(rootBox.lineBottom()) + renderer->maximalOutlineSize(paintInfo.phase);
199199
200200 return rangeIntersectsRect(renderer, logicalTop, logicalBottom, paintInfo.rect, offset);
201201}

@@void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintIn
234234 // FIXME: This is the deprecated pagination model that is still needed
235235 // for embedded views inside AppKit. AppKit is incapable of paginating vertical
236236 // text pages, so we don't have to deal with vertical lines at all here.
237  RootInlineBox* root = curr->root();
238  LayoutUnit topForPaginationCheck = curr->logicalTopVisualOverflow(root->lineTop());
 237 const RootInlineBox& rootBox = curr->root();
 238 LayoutUnit topForPaginationCheck = curr->logicalTopVisualOverflow(rootBox.lineTop());
239239 LayoutUnit bottomForPaginationCheck = curr->logicalLeftVisualOverflow();
240240 if (!curr->parent()) {
241241 // We're a root box. Use lineTop and lineBottom as well here.
242  topForPaginationCheck = min(topForPaginationCheck, root->lineTop());
243  bottomForPaginationCheck = max(bottomForPaginationCheck, root->lineBottom());
 242 topForPaginationCheck = min(topForPaginationCheck, rootBox.lineTop());
 243 bottomForPaginationCheck = max(bottomForPaginationCheck, rootBox.lineBottom());
244244 }
245245 if (bottomForPaginationCheck - topForPaginationCheck <= v.printRect().height()) {
246246 if (paintOffset.y() + bottomForPaginationCheck > v.printRect().maxY()) {
247  if (RootInlineBox* nextRootBox = curr->root()->nextRootBox())
 247 if (RootInlineBox* nextRootBox = rootBox.nextRootBox())
248248 bottomForPaginationCheck = min(bottomForPaginationCheck, min<LayoutUnit>(nextRootBox->logicalTopVisualOverflow(), nextRootBox->lineTop()));
249249 }
250250 if (paintOffset.y() + bottomForPaginationCheck > v.printRect().maxY()) {

@@void RenderLineBoxList::paint(RenderBoxModelObject* renderer, PaintInfo& paintIn
258258 }
259259
260260 if (lineIntersectsDirtyRect(renderer, curr, info, paintOffset)) {
261  RootInlineBox* root = curr->root();
262  curr->paint(info, paintOffset, root->lineTop(), root->lineBottom());
 261 const RootInlineBox& rootBox = curr->root();
 262 curr->paint(info, paintOffset, rootBox.lineTop(), rootBox.lineBottom());
263263 }
264264 }
265265

@@bool RenderLineBoxList::hitTest(RenderBoxModelObject* renderer, const HitTestReq
296296 // them further. Note that boxes can easily overlap, so we can't make any assumptions
297297 // based off positions of our first line box or our last line box.
298298 for (InlineFlowBox* curr = lastLineBox(); curr; curr = curr->prevLineBox()) {
299  RootInlineBox* root = curr->root();
300  if (rangeIntersectsRect(renderer, curr->logicalTopVisualOverflow(root->lineTop()), curr->logicalBottomVisualOverflow(root->lineBottom()), rect, accumulatedOffset)) {
301  bool inside = curr->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, root->lineTop(), root->lineBottom());
 299 const RootInlineBox& rootBox = curr->root();
 300 if (rangeIntersectsRect(renderer, curr->logicalTopVisualOverflow(rootBox.lineTop()), curr->logicalBottomVisualOverflow(rootBox.lineBottom()), rect, accumulatedOffset)) {
 301 bool inside = curr->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, rootBox.lineTop(), rootBox.lineBottom());
302302 if (inside) {
303303 renderer->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
304304 return true;

@@void RenderLineBoxList::dirtyLinesFromChangedChild(RenderObject* container, Rend
340340 if (curr->isReplaced()) {
341341 InlineBox* wrapper = toRenderBox(curr)->inlineBoxWrapper();
342342 if (wrapper)
343  box = wrapper->root();
 343 box = &wrapper->root();
344344 } else if (curr->isText()) {
345345 InlineTextBox* textBox = toRenderText(curr)->lastTextBox();
346346 if (textBox)
347  box = textBox->root();
 347 box = &textBox->root();
348348 } else if (curr->isRenderInline()) {
349349 InlineBox* lastSiblingBox = toRenderInline(curr)->lastLineBoxIncludingCulling();
350350 if (lastSiblingBox)
351  box = lastSiblingBox->root();
 351 box = &lastSiblingBox->root();
352352 }
353353
354354 if (box)

@@void RenderLineBoxList::dirtyLinesFromChangedChild(RenderObject* container, Rend
367367 }
368368 return;
369369 }
370  box = firstBox->root();
 370 box = &firstBox->root();
371371 }
372372
373373 // If we found a line box, then dirty it.

Source/WebCore/rendering/RenderListItem.cpp

@@void RenderListItem::positionListMarker()
341341
342342 bool adjustOverflow = false;
343343 LayoutUnit markerLogicalLeft;
344  RootInlineBox* root = m_marker->inlineBoxWrapper()->root();
345344 bool hitSelfPaintingLayer = false;
346345
347  RootInlineBox* rootBox = m_marker->inlineBoxWrapper()->root();
348  LayoutUnit lineTop = rootBox->lineTop();
349  LayoutUnit lineBottom = rootBox->lineBottom();
 346 const RootInlineBox& rootBox = m_marker->inlineBoxWrapper()->root();
 347 LayoutUnit lineTop = rootBox.lineTop();
 348 LayoutUnit lineBottom = rootBox.lineBottom();
350349
351350 // FIXME: Need to account for relative positioning in the layout overflow.
352351 if (style()->isLeftToRightDirection()) {

@@void RenderListItem::positionListMarker()
359358 if (markerLogicalLeft < newLogicalVisualOverflowRect.x() && !hitSelfPaintingLayer) {
360359 newLogicalVisualOverflowRect.setWidth(newLogicalVisualOverflowRect.maxX() - markerLogicalLeft);
361360 newLogicalVisualOverflowRect.setX(markerLogicalLeft);
362  if (box == root)
 361 if (box == &rootBox)
363362 adjustOverflow = true;
364363 }
365364 if (markerLogicalLeft < newLogicalLayoutOverflowRect.x()) {
366365 newLogicalLayoutOverflowRect.setWidth(newLogicalLayoutOverflowRect.maxX() - markerLogicalLeft);
367366 newLogicalLayoutOverflowRect.setX(markerLogicalLeft);
368  if (box == root)
 367 if (box == &rootBox)
369368 adjustOverflow = true;
370369 }
371370 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, newLogicalVisualOverflowRect, lineTop, lineBottom);

@@void RenderListItem::positionListMarker()
381380 LayoutRect newLogicalLayoutOverflowRect = box->logicalLayoutOverflowRect(lineTop, lineBottom);
382381 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalVisualOverflowRect.maxX() && !hitSelfPaintingLayer) {
383382 newLogicalVisualOverflowRect.setWidth(markerLogicalLeft + m_marker->logicalWidth() - newLogicalVisualOverflowRect.x());
384  if (box == root)
 383 if (box == &rootBox)
385384 adjustOverflow = true;
386385 }
387386 if (markerLogicalLeft + m_marker->logicalWidth() > newLogicalLayoutOverflowRect.maxX()) {
388387 newLogicalLayoutOverflowRect.setWidth(markerLogicalLeft + m_marker->logicalWidth() - newLogicalLayoutOverflowRect.x());
389  if (box == root)
 388 if (box == &rootBox)
390389 adjustOverflow = true;
391390 }
392391 box->setOverflowFromLogicalRects(newLogicalLayoutOverflowRect, newLogicalVisualOverflowRect, lineTop, lineBottom);

Source/WebCore/rendering/RenderListMarker.cpp

@@LayoutRect RenderListMarker::localSelectionRect()
11141114 InlineBox* box = inlineBoxWrapper();
11151115 if (!box)
11161116 return LayoutRect(LayoutPoint(), size());
1117  RootInlineBox* root = m_inlineBoxWrapper->root();
1118  LayoutUnit newLogicalTop = root->block().style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
1119  if (root->block().style()->isHorizontalWritingMode())
1120  return LayoutRect(0, newLogicalTop, width(), root->selectionHeight());
1121  return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height());
 1117 const RootInlineBox& rootBox = m_inlineBoxWrapper->root();
 1118 LayoutUnit newLogicalTop = rootBox.block().style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - rootBox.selectionBottom() : rootBox.selectionTop() - m_inlineBoxWrapper->logicalTop();
 1119 if (rootBox.block().style()->isHorizontalWritingMode())
 1120 return LayoutRect(0, newLogicalTop, width(), rootBox.selectionHeight());
 1121 return LayoutRect(newLogicalTop, 0, rootBox.selectionHeight(), height());
11221122}
11231123
11241124void RenderListMarker::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)

@@void RenderListMarker::setSelectionState(SelectionState state)
18241824 RenderBox::setSelectionState(state);
18251825
18261826 if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
1827  if (RootInlineBox* root = m_inlineBoxWrapper->root())
1828  root->setHasSelectedChildren(state != SelectionNone);
 1827 m_inlineBoxWrapper->root().setHasSelectedChildren(state != SelectionNone);
18291828}
18301829
18311830LayoutRect RenderListMarker::selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent)

@@LayoutRect RenderListMarker::selectionRectForRepaint(const RenderLayerModelObjec
18351834 if (selectionState() == SelectionNone || !inlineBoxWrapper())
18361835 return LayoutRect();
18371836
1838  RootInlineBox* root = inlineBoxWrapper()->root();
1839  LayoutRect rect(0, root->selectionTop() - y(), width(), root->selectionHeight());
 1837 RootInlineBox& rootBox = inlineBoxWrapper()->root();
 1838 LayoutRect rect(0, rootBox.selectionTop() - y(), width(), rootBox.selectionHeight());
18401839
18411840 if (clipToVisibleContent)
18421841 computeRectForRepaint(repaintContainer, rect);

Source/WebCore/rendering/RenderReplaced.cpp

@@bool RenderReplaced::shouldPaint(PaintInfo& paintInfo, const LayoutPoint& paintO
189189 LayoutUnit top = adjustedPaintOffset.y() + visualOverflowRect().y();
190190 LayoutUnit bottom = adjustedPaintOffset.y() + visualOverflowRect().maxY();
191191 if (isSelected() && m_inlineBoxWrapper) {
192  LayoutUnit selTop = paintOffset.y() + m_inlineBoxWrapper->root()->selectionTop();
193  LayoutUnit selBottom = paintOffset.y() + selTop + m_inlineBoxWrapper->root()->selectionHeight();
 192 const RootInlineBox& rootBox = m_inlineBoxWrapper->root();
 193 LayoutUnit selTop = paintOffset.y() + rootBox.selectionTop();
 194 LayoutUnit selBottom = paintOffset.y() + selTop + rootBox.selectionHeight();
194195 top = min(selTop, top);
195196 bottom = max(selBottom, bottom);
196197 }

@@VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point)
490491{
491492 // FIXME: This code is buggy if the replaced element is relative positioned.
492493 InlineBox* box = inlineBoxWrapper();
493  RootInlineBox* rootBox = box ? box->root() : 0;
 494 const RootInlineBox* rootBox = box ? &box->root() : 0;
494495
495496 LayoutUnit top = rootBox ? rootBox->selectionTop() : logicalTop();
496497 LayoutUnit bottom = rootBox ? rootBox->selectionBottom() : logicalBottom();

@@LayoutRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
538539 // We're a block-level replaced element. Just return our own dimensions.
539540 return LayoutRect(LayoutPoint(), size());
540541
541  RootInlineBox* root = m_inlineBoxWrapper->root();
542  LayoutUnit newLogicalTop = root->block().style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - root->selectionBottom() : root->selectionTop() - m_inlineBoxWrapper->logicalTop();
543  if (root->block().style()->isHorizontalWritingMode())
544  return LayoutRect(0, newLogicalTop, width(), root->selectionHeight());
545  return LayoutRect(newLogicalTop, 0, root->selectionHeight(), height());
 542 const RootInlineBox& rootBox = m_inlineBoxWrapper->root();
 543 LayoutUnit newLogicalTop = rootBox.block().style()->isFlippedBlocksWritingMode() ? m_inlineBoxWrapper->logicalBottom() - rootBox.selectionBottom() : rootBox.selectionTop() - m_inlineBoxWrapper->logicalTop();
 544 if (rootBox.block().style()->isHorizontalWritingMode())
 545 return LayoutRect(0, newLogicalTop, width(), rootBox.selectionHeight());
 546 return LayoutRect(newLogicalTop, 0, rootBox.selectionHeight(), height());
546547}
547548
548549void RenderReplaced::setSelectionState(SelectionState state)

@@void RenderReplaced::setSelectionState(SelectionState state)
551552 RenderBox::setSelectionState(state);
552553
553554 if (m_inlineBoxWrapper && canUpdateSelectionOnRootLineBoxes())
554  if (RootInlineBox* root = m_inlineBoxWrapper->root())
555  root->setHasSelectedChildren(isSelected());
 555 m_inlineBoxWrapper->root().setHasSelectedChildren(isSelected());
556556}
557557
558558bool RenderReplaced::isSelected() const

Source/WebCore/rendering/RenderText.cpp

@@void RenderText::removeAndDestroyTextBoxes()
226226 if (!documentBeingDestroyed()) {
227227 if (firstTextBox()) {
228228 if (isBR()) {
229  RootInlineBox* next = firstTextBox()->root()->nextRootBox();
 229 RootInlineBox* next = firstTextBox()->root().nextRootBox();
230230 if (next)
231231 next->markDirty();
232232 }

@@static IntRect ellipsisRectForBox(InlineTextBox* box, unsigned startPos, unsigne
390390 return IntRect();
391391
392392 IntRect rect;
393  if (EllipsisBox* ellipsis = box->root()->ellipsisBox()) {
 393 if (EllipsisBox* ellipsis = box->root().ellipsisBox()) {
394394 int ellipsisStartPosition = max<int>(startPos - box->start(), 0);
395395 int ellipsisEndPosition = min<int>(endPos - box->start(), box->len());
396396

@@VisiblePosition RenderText::positionForPoint(const LayoutPoint& point)
624624 if (box->isLineBreak() && !box->prevLeafChild() && box->nextLeafChild() && !box->nextLeafChild()->isLineBreak())
625625 box = box->nextTextBox();
626626
627  RootInlineBox* rootBox = box->root();
628  LayoutUnit top = min(rootBox->selectionTop(), rootBox->lineTop());
 627 const RootInlineBox& rootBox = box->root();
 628 LayoutUnit top = min(rootBox.selectionTop(), rootBox.lineTop());
629629 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
630  LayoutUnit bottom = rootBox->selectionBottom();
631  if (rootBox->nextRootBox())
632  bottom = min(bottom, rootBox->nextRootBox()->lineTop());
 630 LayoutUnit bottom = rootBox.selectionBottom();
 631 if (rootBox.nextRootBox())
 632 bottom = min(bottom, rootBox.nextRootBox()->lineTop());
633633
634634 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockDirection == bottom)) {
635635 ShouldAffinityBeDownstream shouldAffinityBeDownstream;

@@LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
659659
660660 InlineTextBox* box = toInlineTextBox(inlineBox);
661661
662  int height = box->root()->selectionHeight();
663  int top = box->root()->selectionTop();
 662 const RootInlineBox& rootBox = box->root();
 663 int height = rootBox.selectionHeight();
 664 int top = rootBox.selectionTop();
664665
665666 // Go ahead and round left to snap it to the nearest pixel.
666667 float left = box->positionForOffset(caretOffset);

@@LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
672673
673674 left = roundf(left);
674675
675  float rootLeft = box->root()->logicalLeft();
676  float rootRight = box->root()->logicalRight();
 676 float rootLeft = rootBox.logicalLeft();
 677 float rootRight = rootBox.logicalRight();
677678
678679 // FIXME: should we use the width of the root inline box or the
679680 // width of the containing block for this?
680681 if (extraWidthToEndOfLine)
681  *extraWidthToEndOfLine = (box->root()->logicalWidth() + rootLeft) - (left + 1);
 682 *extraWidthToEndOfLine = (rootBox.logicalWidth() + rootLeft) - (left + 1);
682683
683684 RenderBlock* cb = containingBlock();
684685 RenderStyle* cbStyle = cb->style();

@@void RenderText::setSelectionState(SelectionState state)
12421243 startPos = 0;
12431244
12441245 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1245  if (box->isSelected(startPos, endPos)) {
1246  RootInlineBox* root = box->root();
1247  if (root)
1248  root->setHasSelectedChildren(true);
1249  }
 1246 if (box->isSelected(startPos, endPos))
 1247 box->root().setHasSelectedChildren(true);
12501248 }
12511249 } else {
12521250 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
1253  RootInlineBox* root = box->root();
1254  if (root)
1255  root->setHasSelectedChildren(state == SelectionInside);
 1251 box->root().setHasSelectedChildren(state == SelectionInside);
12561252 }
12571253 }
12581254 }

@@void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset,
12881284 // Text run is entirely after the affected range.
12891285 if (curr->start() > end) {
12901286 curr->offsetRun(delta);
1291  RootInlineBox* root = curr->root();
 1287 RootInlineBox& rootBox = curr->root();
12921288 if (!firstRootBox) {
1293  firstRootBox = root;
 1289 firstRootBox = &rootBox;
12941290 if (!dirtiedLines) {
12951291 // The affected area was in between two runs. Go ahead and mark the root box of
12961292 // the run after the affected area as dirty.

@@void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset,
12981294 dirtiedLines = true;
12991295 }
13001296 }
1301  lastRootBox = root;
 1297 lastRootBox = &rootBox;
13021298 } else if (curr->end() >= offset && curr->end() <= end) {
13031299 // Text run overlaps with the left end of the affected range.
13041300 curr->dirtyLineBoxes();

@@void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset,
13241320 firstRootBox = prev;
13251321 } else if (lastTextBox()) {
13261322 ASSERT(!lastRootBox);
1327  firstRootBox = lastTextBox()->root();
 1323 firstRootBox = &lastTextBox()->root();
13281324 firstRootBox->markDirty();
13291325 dirtiedLines = true;
13301326 }

Source/WebCore/rendering/RootInlineBox.cpp

@@LayoutUnit RootInlineBox::selectionTop() const
593593
594594LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const
595595{
 596 const RootInlineBox& rootBox = root();
596597 LayoutUnit top = selectionTop();
597598
598  RenderObject::SelectionState blockSelectionState = root()->block().selectionState();
 599 RenderObject::SelectionState blockSelectionState = rootBox.block().selectionState();
599600 if (blockSelectionState != RenderObject::SelectionInside && blockSelectionState != RenderObject::SelectionEnd)
600601 return top;
601602
602603 LayoutSize offsetToBlockBefore;
603  if (RenderBlock* block = root()->block().blockBeforeWithinSelectionRoot(offsetToBlockBefore)) {
 604 if (RenderBlock* block = rootBox.block().blockBeforeWithinSelectionRoot(offsetToBlockBefore)) {
604605 if (RootInlineBox* lastLine = block->lastRootBox()) {
605606 RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState();
606607 if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart)