1 /* 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public License 15 * along with this library; see the file COPYING.LIB. If not, write to 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #include "config.h" 21 #include "core/rendering/RootInlineBox.h" 22 23 #include "core/dom/Document.h" 24 #include "core/rendering/EllipsisBox.h" 25 #include "core/rendering/HitTestResult.h" 26 #include "core/rendering/InlineTextBox.h" 27 #include "core/rendering/PaintInfo.h" 28 #include "core/rendering/RenderBlockFlow.h" 29 #include "core/rendering/RenderFlowThread.h" 30 #include "core/rendering/RenderInline.h" 31 #include "core/rendering/RenderView.h" 32 #include "core/rendering/VerticalPositionCache.h" 33 #include "platform/text/BidiResolver.h" 34 #include "wtf/unicode/Unicode.h" 35 36 using namespace std; 37 38 namespace WebCore { 39 40 struct SameSizeAsRootInlineBox : public InlineFlowBox { 41 unsigned variables[5]; 42 void* pointers[4]; 43 }; 44 45 COMPILE_ASSERT(sizeof(RootInlineBox) == sizeof(SameSizeAsRootInlineBox), RootInlineBox_should_stay_small); 46 47 typedef WTF::HashMap<const RootInlineBox*, EllipsisBox*> EllipsisBoxMap; 48 static EllipsisBoxMap* gEllipsisBoxMap = 0; 49 50 RootInlineBox::RootInlineBox(RenderBlockFlow* block) 51 : InlineFlowBox(block) 52 , m_lineBreakPos(0) 53 , m_lineBreakObj(0) 54 , m_lineTop(0) 55 , m_lineBottom(0) 56 , m_lineTopWithLeading(0) 57 , m_lineBottomWithLeading(0) 58 { 59 setIsHorizontal(block->isHorizontalWritingMode()); 60 } 61 62 63 void RootInlineBox::destroy() 64 { 65 detachEllipsisBox(); 66 InlineFlowBox::destroy(); 67 } 68 69 void RootInlineBox::detachEllipsisBox() 70 { 71 if (hasEllipsisBox()) { 72 EllipsisBox* box = gEllipsisBoxMap->take(this); 73 box->setParent(0); 74 box->destroy(); 75 setHasEllipsisBox(false); 76 } 77 } 78 79 RenderLineBoxList* RootInlineBox::rendererLineBoxes() const 80 { 81 return block()->lineBoxes(); 82 } 83 84 void RootInlineBox::clearTruncation() 85 { 86 if (hasEllipsisBox()) { 87 detachEllipsisBox(); 88 InlineFlowBox::clearTruncation(); 89 } 90 } 91 92 bool RootInlineBox::isHyphenated() const 93 { 94 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 95 if (box->isInlineTextBox()) { 96 if (toInlineTextBox(box)->hasHyphen()) 97 return true; 98 } 99 } 100 101 return false; 102 } 103 104 int RootInlineBox::baselinePosition(FontBaseline baselineType) const 105 { 106 return boxModelObject()->baselinePosition(baselineType, isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); 107 } 108 109 LayoutUnit RootInlineBox::lineHeight() const 110 { 111 return boxModelObject()->lineHeight(isFirstLineStyle(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); 112 } 113 114 bool RootInlineBox::lineCanAccommodateEllipsis(bool ltr, int blockEdge, int lineBoxEdge, int ellipsisWidth) 115 { 116 // First sanity-check the unoverflowed width of the whole line to see if there is sufficient room. 117 int delta = ltr ? lineBoxEdge - blockEdge : blockEdge - lineBoxEdge; 118 if (logicalWidth() - delta < ellipsisWidth) 119 return false; 120 121 // Next iterate over all the line boxes on the line. If we find a replaced element that intersects 122 // then we refuse to accommodate the ellipsis. Otherwise we're ok. 123 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); 124 } 125 126 float RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr, bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, 127 InlineBox* markupBox) 128 { 129 // Create an ellipsis box. 130 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, 131 ellipsisWidth - (markupBox ? markupBox->logicalWidth() : 0), logicalHeight(), 132 x(), y(), !prevRootBox(), isHorizontal(), markupBox); 133 134 if (!gEllipsisBoxMap) 135 gEllipsisBoxMap = new EllipsisBoxMap(); 136 gEllipsisBoxMap->add(this, ellipsisBox); 137 setHasEllipsisBox(true); 138 139 // FIXME: Do we need an RTL version of this? 140 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdge) { 141 ellipsisBox->setLogicalLeft(logicalLeft() + logicalWidth()); 142 return logicalWidth() + ellipsisWidth; 143 } 144 145 // Now attempt to find the nearest glyph horizontally and place just to the right (or left in RTL) 146 // of that glyph. Mark all of the objects that intersect the ellipsis box as not painting (as being 147 // truncated). 148 bool foundBox = false; 149 float truncatedWidth = 0; 150 float position = placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); 151 ellipsisBox->setLogicalLeft(position); 152 return truncatedWidth; 153 } 154 155 float RootInlineBox::placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) 156 { 157 float result = InlineFlowBox::placeEllipsisBox(ltr, blockLeftEdge, blockRightEdge, ellipsisWidth, truncatedWidth, foundBox); 158 if (result == -1) { 159 result = ltr ? blockRightEdge - ellipsisWidth : blockLeftEdge; 160 truncatedWidth = blockRightEdge - blockLeftEdge; 161 } 162 return result; 163 } 164 165 void RootInlineBox::paintEllipsisBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) const 166 { 167 if (hasEllipsisBox() && paintInfo.shouldPaintWithinRoot(renderer()) && renderer()->style()->visibility() == VISIBLE 168 && paintInfo.phase == PaintPhaseForeground) 169 ellipsisBox()->paint(paintInfo, paintOffset, lineTop, lineBottom); 170 } 171 172 void RootInlineBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) 173 { 174 InlineFlowBox::paint(paintInfo, paintOffset, lineTop, lineBottom); 175 paintEllipsisBox(paintInfo, paintOffset, lineTop, lineBottom); 176 } 177 178 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) 179 { 180 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { 181 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom)) { 182 renderer()->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset)); 183 return true; 184 } 185 } 186 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom); 187 } 188 189 void RootInlineBox::adjustPosition(float dx, float dy) 190 { 191 InlineFlowBox::adjustPosition(dx, dy); 192 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block direction delta is a LayoutUnit. 193 m_lineTop += blockDirectionDelta; 194 m_lineBottom += blockDirectionDelta; 195 m_lineTopWithLeading += blockDirectionDelta; 196 m_lineBottomWithLeading += blockDirectionDelta; 197 if (hasEllipsisBox()) 198 ellipsisBox()->adjustPosition(dx, dy); 199 } 200 201 void RootInlineBox::childRemoved(InlineBox* box) 202 { 203 if (box->renderer() == m_lineBreakObj) 204 setLineBreakInfo(0, 0, BidiStatus()); 205 206 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == box->renderer(); prev = prev->prevRootBox()) { 207 prev->setLineBreakInfo(0, 0, BidiStatus()); 208 prev->markDirty(); 209 } 210 } 211 212 RenderRegion* RootInlineBox::containingRegion() const 213 { 214 RenderRegion* region = m_fragmentationData ? m_fragmentationData->m_containingRegion : 0; 215 216 #ifndef NDEBUG 217 if (region) { 218 RenderFlowThread* flowThread = block()->flowThreadContainingBlock(); 219 const RenderRegionList& regionList = flowThread->renderRegionList(); 220 ASSERT(regionList.contains(region)); 221 } 222 #endif 223 224 return region; 225 } 226 227 void RootInlineBox::setContainingRegion(RenderRegion* region) 228 { 229 ASSERT(!isDirty()); 230 ASSERT(block()->flowThreadContainingBlock()); 231 LineFragmentationData* fragmentationData = ensureLineFragmentationData(); 232 fragmentationData->m_containingRegion = region; 233 } 234 235 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& verticalPositionCache) 236 { 237 // SVG will handle vertical alignment on its own. 238 if (isSVGRootInlineBox()) 239 return 0; 240 241 LayoutUnit maxPositionTop = 0; 242 LayoutUnit maxPositionBottom = 0; 243 int maxAscent = 0; 244 int maxDescent = 0; 245 bool setMaxAscent = false; 246 bool setMaxDescent = false; 247 248 // Figure out if we're in no-quirks mode. 249 bool noQuirksMode = renderer()->document().inNoQuirksMode(); 250 251 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBaseline : AlphabeticBaseline; 252 253 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent, maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, 254 textBoxDataMap, baselineType(), verticalPositionCache); 255 256 if (maxAscent + maxDescent < max(maxPositionTop, maxPositionBottom)) 257 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPositionBottom); 258 259 LayoutUnit maxHeight = maxAscent + maxDescent; 260 LayoutUnit lineTop = heightOfBlock; 261 LayoutUnit lineBottom = heightOfBlock; 262 LayoutUnit lineTopIncludingMargins = heightOfBlock; 263 LayoutUnit lineBottomIncludingMargins = heightOfBlock; 264 bool setLineTop = false; 265 bool hasAnnotationsBefore = false; 266 bool hasAnnotationsAfter = false; 267 placeBoxesInBlockDirection(heightOfBlock, maxHeight, maxAscent, noQuirksMode, lineTop, lineBottom, setLineTop, 268 lineTopIncludingMargins, lineBottomIncludingMargins, hasAnnotationsBefore, hasAnnotationsAfter, baselineType()); 269 m_hasAnnotationsBefore = hasAnnotationsBefore; 270 m_hasAnnotationsAfter = hasAnnotationsAfter; 271 272 maxHeight = max<LayoutUnit>(0, maxHeight); // FIXME: Is this really necessary? 273 274 setLineTopBottomPositions(lineTop, lineBottom, heightOfBlock, heightOfBlock + maxHeight); 275 setPaginatedLineWidth(block()->availableLogicalWidthForContent(heightOfBlock)); 276 277 LayoutUnit annotationsAdjustment = beforeAnnotationsAdjustment(); 278 if (annotationsAdjustment) { 279 // FIXME: Need to handle pagination here. We might have to move to the next page/column as a result of the 280 // ruby expansion. 281 adjustBlockDirectionPosition(annotationsAdjustment); 282 heightOfBlock += annotationsAdjustment; 283 } 284 285 LayoutUnit gridSnapAdjustment = lineSnapAdjustment(); 286 if (gridSnapAdjustment) { 287 adjustBlockDirectionPosition(gridSnapAdjustment); 288 heightOfBlock += gridSnapAdjustment; 289 } 290 291 return heightOfBlock + maxHeight; 292 } 293 294 float RootInlineBox::maxLogicalTop() const 295 { 296 float maxLogicalTop = 0; 297 computeMaxLogicalTop(maxLogicalTop); 298 return maxLogicalTop; 299 } 300 301 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const 302 { 303 LayoutUnit result = 0; 304 305 if (!renderer()->style()->isFlippedLinesWritingMode()) { 306 // Annotations under the previous line may push us down. 307 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) 308 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); 309 310 if (!hasAnnotationsBefore()) 311 return result; 312 313 // Annotations over this line may push us further down. 314 LayoutUnit highestAllowedPosition = prevRootBox() ? min(prevRootBox()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block()->borderBefore()); 315 result = computeOverAnnotationAdjustment(highestAllowedPosition); 316 } else { 317 // Annotations under this line may push us up. 318 if (hasAnnotationsBefore()) 319 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBox()->lineBottom() : static_cast<LayoutUnit>(block()->borderBefore())); 320 321 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) 322 return result; 323 324 // We have to compute the expansion for annotations over the previous line to see how much we should move. 325 LayoutUnit lowestAllowedPosition = max(prevRootBox()->lineBottom(), lineTop()) - result; 326 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPosition); 327 } 328 329 return result; 330 } 331 332 LayoutUnit RootInlineBox::lineSnapAdjustment(LayoutUnit delta) const 333 { 334 // If our block doesn't have snapping turned on, do nothing. 335 // FIXME: Implement bounds snapping. 336 if (block()->style()->lineSnap() == LineSnapNone) 337 return 0; 338 339 // Get the current line grid and offset. 340 LayoutState* layoutState = block()->view()->layoutState(); 341 RenderBlockFlow* lineGrid = layoutState->lineGrid(); 342 LayoutSize lineGridOffset = layoutState->lineGridOffset(); 343 if (!lineGrid || lineGrid->style()->writingMode() != block()->style()->writingMode()) 344 return 0; 345 346 // Get the hypothetical line box used to establish the grid. 347 RootInlineBox* lineGridBox = lineGrid->lineGridBox(); 348 if (!lineGridBox) 349 return 0; 350 351 LayoutUnit lineGridBlockOffset = lineGrid->isHorizontalWritingMode() ? lineGridOffset.height() : lineGridOffset.width(); 352 LayoutUnit blockOffset = block()->isHorizontalWritingMode() ? layoutState->layoutOffset().height() : layoutState->layoutOffset().width(); 353 354 // Now determine our position on the grid. Our baseline needs to be adjusted to the nearest baseline multiple 355 // as established by the line box. 356 // FIXME: Need to handle crazy line-box-contain values that cause the root line box to not be considered. I assume 357 // the grid should honor line-box-contain. 358 LayoutUnit gridLineHeight = lineGridBox->lineBottomWithLeading() - lineGridBox->lineTopWithLeading(); 359 if (!gridLineHeight) 360 return 0; 361 362 LayoutUnit lineGridFontAscent = lineGrid->style()->fontMetrics().ascent(baselineType()); 363 LayoutUnit lineGridFontHeight = lineGridBox->logicalHeight(); 364 LayoutUnit firstTextTop = lineGridBlockOffset + lineGridBox->logicalTop(); 365 LayoutUnit firstLineTopWithLeading = lineGridBlockOffset + lineGridBox->lineTopWithLeading(); 366 LayoutUnit firstBaselinePosition = firstTextTop + lineGridFontAscent; 367 368 LayoutUnit currentTextTop = blockOffset + logicalTop() + delta; 369 LayoutUnit currentFontAscent = block()->style()->fontMetrics().ascent(baselineType()); 370 LayoutUnit currentBaselinePosition = currentTextTop + currentFontAscent; 371 372 LayoutUnit lineGridPaginationOrigin = isHorizontal() ? layoutState->lineGridPaginationOrigin().height() : layoutState->lineGridPaginationOrigin().width(); 373 374 // If we're paginated, see if we're on a page after the first one. If so, the grid resets on subsequent pages. 375 // FIXME: If the grid is an ancestor of the pagination establisher, then this is incorrect. 376 LayoutUnit pageLogicalTop = 0; 377 if (layoutState->isPaginated() && layoutState->pageLogicalHeight()) { 378 pageLogicalTop = block()->pageLogicalTopForOffset(lineTopWithLeading() + delta); 379 if (pageLogicalTop > firstLineTopWithLeading) 380 firstTextTop = pageLogicalTop + lineGridBox->logicalTop() - lineGrid->borderBefore() - lineGrid->paddingBefore() + lineGridPaginationOrigin; 381 } 382 383 if (block()->style()->lineSnap() == LineSnapContain) { 384 // Compute the desired offset from the text-top of a grid line. 385 // Look at our height (logicalHeight()). 386 // Look at the total available height. It's going to be (textBottom - textTop) + (n-1)*(multiple with leading) 387 // where n is number of grid lines required to enclose us. 388 if (logicalHeight() <= lineGridFontHeight) 389 firstTextTop += (lineGridFontHeight - logicalHeight()) / 2; 390 else { 391 LayoutUnit numberOfLinesWithLeading = ceilf(static_cast<float>(logicalHeight() - lineGridFontHeight) / gridLineHeight); 392 LayoutUnit totalHeight = lineGridFontHeight + numberOfLinesWithLeading * gridLineHeight; 393 firstTextTop += (totalHeight - logicalHeight()) / 2; 394 } 395 firstBaselinePosition = firstTextTop + currentFontAscent; 396 } else 397 firstBaselinePosition = firstTextTop + lineGridFontAscent; 398 399 // If we're above the first line, just push to the first line. 400 if (currentBaselinePosition < firstBaselinePosition) 401 return delta + firstBaselinePosition - currentBaselinePosition; 402 403 // Otherwise we're in the middle of the grid somewhere. Just push to the next line. 404 LayoutUnit baselineOffset = currentBaselinePosition - firstBaselinePosition; 405 LayoutUnit remainder = roundToInt(baselineOffset) % roundToInt(gridLineHeight); 406 LayoutUnit result = delta; 407 if (remainder) 408 result += gridLineHeight - remainder; 409 410 // If we aren't paginated we can return the result. 411 if (!layoutState->isPaginated() || !layoutState->pageLogicalHeight() || result == delta) 412 return result; 413 414 // We may end up shifted to a new page. We need to do a re-snap when that happens. 415 LayoutUnit newPageLogicalTop = block()->pageLogicalTopForOffset(lineBottomWithLeading() + result); 416 if (newPageLogicalTop == pageLogicalTop) 417 return result; 418 419 // Put ourselves at the top of the next page to force a snap onto the new grid established by that page. 420 return lineSnapAdjustment(newPageLogicalTop - (blockOffset + lineTopWithLeading())); 421 } 422 423 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoint& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, 424 LayoutUnit selTop, LayoutUnit selHeight, const PaintInfo* paintInfo) 425 { 426 RenderObject::SelectionState lineState = selectionState(); 427 428 bool leftGap, rightGap; 429 block()->getSelectionGapInfo(lineState, leftGap, rightGap); 430 431 GapRects result; 432 433 InlineBox* firstBox = firstSelectedBox(); 434 InlineBox* lastBox = lastSelectedBox(); 435 if (leftGap) 436 result.uniteLeft(block()->logicalLeftSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, 437 firstBox->parent()->renderer(), firstBox->logicalLeft(), selTop, selHeight, paintInfo)); 438 if (rightGap) 439 result.uniteRight(block()->logicalRightSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, 440 lastBox->parent()->renderer(), lastBox->logicalRight(), selTop, selHeight, paintInfo)); 441 442 // When dealing with bidi text, a non-contiguous selection region is possible. 443 // e.g. The logical text aaaAAAbbb (capitals denote RTL text and non-capitals LTR) is layed out 444 // visually as 3 text runs |aaa|bbb|AAA| if we select 4 characters from the start of the text the 445 // selection will look like (underline denotes selection): 446 // |aaa|bbb|AAA| 447 // ___ _ 448 // We can see that the |bbb| run is not part of the selection while the runs around it are. 449 if (firstBox && firstBox != lastBox) { 450 // Now fill in any gaps on the line that occurred between two selected elements. 451 LayoutUnit lastLogicalLeft = firstBox->logicalRight(); 452 bool isPreviousBoxSelected = firstBox->selectionState() != RenderObject::SelectionNone; 453 for (InlineBox* box = firstBox->nextLeafChild(); box; box = box->nextLeafChild()) { 454 if (box->selectionState() != RenderObject::SelectionNone) { 455 LayoutRect logicalRect(lastLogicalLeft, selTop, box->logicalLeft() - lastLogicalLeft, selHeight); 456 logicalRect.move(renderer()->isHorizontalWritingMode() ? offsetFromRootBlock : LayoutSize(offsetFromRootBlock.height(), offsetFromRootBlock.width())); 457 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBlockPhysicalPosition, logicalRect); 458 if (isPreviousBoxSelected && gapRect.width() > 0 && gapRect.height() > 0) { 459 if (paintInfo && box->parent()->renderer()->style()->visibility() == VISIBLE) 460 paintInfo->context->fillRect(gapRect, box->parent()->renderer()->selectionBackgroundColor()); 461 // VisibleSelection may be non-contiguous, see comment above. 462 result.uniteCenter(gapRect); 463 } 464 lastLogicalLeft = box->logicalRight(); 465 } 466 if (box == lastBox) 467 break; 468 isPreviousBoxSelected = box->selectionState() != RenderObject::SelectionNone; 469 } 470 } 471 472 return result; 473 } 474 475 RenderObject::SelectionState RootInlineBox::selectionState() 476 { 477 // Walk over all of the selected boxes. 478 RenderObject::SelectionState state = RenderObject::SelectionNone; 479 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 480 RenderObject::SelectionState boxState = box->selectionState(); 481 if ((boxState == RenderObject::SelectionStart && state == RenderObject::SelectionEnd) || 482 (boxState == RenderObject::SelectionEnd && state == RenderObject::SelectionStart)) 483 state = RenderObject::SelectionBoth; 484 else if (state == RenderObject::SelectionNone || 485 ((boxState == RenderObject::SelectionStart || boxState == RenderObject::SelectionEnd) && 486 (state == RenderObject::SelectionNone || state == RenderObject::SelectionInside))) 487 state = boxState; 488 else if (boxState == RenderObject::SelectionNone && state == RenderObject::SelectionStart) { 489 // We are past the end of the selection. 490 state = RenderObject::SelectionBoth; 491 } 492 if (state == RenderObject::SelectionBoth) 493 break; 494 } 495 496 return state; 497 } 498 499 InlineBox* RootInlineBox::firstSelectedBox() 500 { 501 for (InlineBox* box = firstLeafChild(); box; box = box->nextLeafChild()) { 502 if (box->selectionState() != RenderObject::SelectionNone) 503 return box; 504 } 505 506 return 0; 507 } 508 509 InlineBox* RootInlineBox::lastSelectedBox() 510 { 511 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { 512 if (box->selectionState() != RenderObject::SelectionNone) 513 return box; 514 } 515 516 return 0; 517 } 518 519 LayoutUnit RootInlineBox::selectionTop() const 520 { 521 LayoutUnit selectionTop = m_lineTop; 522 523 if (m_hasAnnotationsBefore) 524 selectionTop -= !renderer()->style()->isFlippedLinesWritingMode() ? computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineTop); 525 526 if (renderer()->style()->isFlippedLinesWritingMode()) 527 return selectionTop; 528 529 LayoutUnit prevBottom = prevRootBox() ? prevRootBox()->selectionBottom() : block()->borderBefore() + block()->paddingBefore(); 530 if (prevBottom < selectionTop && block()->containsFloats()) { 531 // This line has actually been moved further down, probably from a large line-height, but possibly because the 532 // line was forced to clear floats. If so, let's check the offsets, and only be willing to use the previous 533 // line's bottom if the offsets are greater on both sides. 534 LayoutUnit prevLeft = block()->logicalLeftOffsetForLine(prevBottom, false); 535 LayoutUnit prevRight = block()->logicalRightOffsetForLine(prevBottom, false); 536 LayoutUnit newLeft = block()->logicalLeftOffsetForLine(selectionTop, false); 537 LayoutUnit newRight = block()->logicalRightOffsetForLine(selectionTop, false); 538 if (prevLeft > newLeft || prevRight < newRight) 539 return selectionTop; 540 } 541 542 return prevBottom; 543 } 544 545 LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const 546 { 547 LayoutUnit top = selectionTop(); 548 549 RenderObject::SelectionState blockSelectionState = root()->block()->selectionState(); 550 if (blockSelectionState != RenderObject::SelectionInside && blockSelectionState != RenderObject::SelectionEnd) 551 return top; 552 553 LayoutSize offsetToBlockBefore; 554 if (RenderBlock* block = root()->block()->blockBeforeWithinSelectionRoot(offsetToBlockBefore)) { 555 if (RootInlineBox* lastLine = block->lastRootBox()) { 556 RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState(); 557 if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart) 558 return top; 559 560 LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + offsetToBlockBefore.height(); 561 top = max(top, lastLineSelectionBottom); 562 } 563 } 564 565 return top; 566 } 567 568 LayoutUnit RootInlineBox::selectionBottom() const 569 { 570 LayoutUnit selectionBottom = m_lineBottom; 571 572 if (m_hasAnnotationsAfter) 573 selectionBottom += !renderer()->style()->isFlippedLinesWritingMode() ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m_lineBottom); 574 575 if (!renderer()->style()->isFlippedLinesWritingMode() || !nextRootBox()) 576 return selectionBottom; 577 578 LayoutUnit nextTop = nextRootBox()->selectionTop(); 579 if (nextTop > selectionBottom && block()->containsFloats()) { 580 // The next line has actually been moved further over, probably from a large line-height, but possibly because the 581 // line was forced to clear floats. If so, let's check the offsets, and only be willing to use the next 582 // line's top if the offsets are greater on both sides. 583 LayoutUnit nextLeft = block()->logicalLeftOffsetForLine(nextTop, false); 584 LayoutUnit nextRight = block()->logicalRightOffsetForLine(nextTop, false); 585 LayoutUnit newLeft = block()->logicalLeftOffsetForLine(selectionBottom, false); 586 LayoutUnit newRight = block()->logicalRightOffsetForLine(selectionBottom, false); 587 if (nextLeft > newLeft || nextRight < newRight) 588 return selectionBottom; 589 } 590 591 return nextTop; 592 } 593 594 int RootInlineBox::blockDirectionPointInLine() const 595 { 596 return !block()->style()->isFlippedBlocksWritingMode() ? max(lineTop(), selectionTop()) : min(lineBottom(), selectionBottom()); 597 } 598 599 RenderBlockFlow* RootInlineBox::block() const 600 { 601 return toRenderBlockFlow(renderer()); 602 } 603 604 static bool isEditableLeaf(InlineBox* leaf) 605 { 606 return leaf && leaf->renderer() && leaf->renderer()->node() && leaf->renderer()->node()->rendererIsEditable(); 607 } 608 609 InlineBox* RootInlineBox::closestLeafChildForPoint(const IntPoint& pointInContents, bool onlyEditableLeaves) 610 { 611 return closestLeafChildForLogicalLeftPosition(block()->isHorizontalWritingMode() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves); 612 } 613 614 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(int leftPosition, bool onlyEditableLeaves) 615 { 616 InlineBox* firstLeaf = firstLeafChild(); 617 InlineBox* lastLeaf = lastLeafChild(); 618 619 if (firstLeaf != lastLeaf) { 620 if (firstLeaf->isLineBreak()) 621 firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); 622 else if (lastLeaf->isLineBreak()) 623 lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); 624 } 625 626 if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) 627 return firstLeaf; 628 629 // Avoid returning a list marker when possible. 630 if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) 631 // The leftPosition coordinate is less or equal to left edge of the firstLeaf. 632 // Return it. 633 return firstLeaf; 634 635 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) 636 // The leftPosition coordinate is greater or equal to right edge of the lastLeaf. 637 // Return it. 638 return lastLeaf; 639 640 InlineBox* closestLeaf = 0; 641 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLineBreak()) { 642 if (!leaf->renderer()->isListMarker() && (!onlyEditableLeaves || isEditableLeaf(leaf))) { 643 closestLeaf = leaf; 644 if (leftPosition < leaf->logicalRight()) 645 // The x coordinate is less than the right edge of the box. 646 // Return it. 647 return leaf; 648 } 649 } 650 651 return closestLeaf ? closestLeaf : lastLeaf; 652 } 653 654 BidiStatus RootInlineBox::lineBreakBidiStatus() const 655 { 656 return BidiStatus(static_cast<WTF::Unicode::Direction>(m_lineBreakBidiStatusEor), static_cast<WTF::Unicode::Direction>(m_lineBreakBidiStatusLastStrong), static_cast<WTF::Unicode::Direction>(m_lineBreakBidiStatusLast), m_lineBreakContext); 657 } 658 659 void RootInlineBox::setLineBreakInfo(RenderObject* obj, unsigned breakPos, const BidiStatus& status) 660 { 661 // When setting lineBreakObj, the RenderObject must not be a RenderInline 662 // with no line boxes, otherwise all sorts of invariants are broken later. 663 // This has security implications because if the RenderObject does not 664 // point to at least one line box, then that RenderInline can be deleted 665 // later without resetting the lineBreakObj, leading to use-after-free. 666 ASSERT_WITH_SECURITY_IMPLICATION(!obj || obj->isText() || !(obj->isRenderInline() && obj->isBox() && !toRenderBox(obj)->inlineBoxWrapper())); 667 668 m_lineBreakObj = obj; 669 m_lineBreakPos = breakPos; 670 m_lineBreakBidiStatusEor = status.eor; 671 m_lineBreakBidiStatusLastStrong = status.lastStrong; 672 m_lineBreakBidiStatusLast = status.last; 673 m_lineBreakContext = status.context; 674 } 675 676 EllipsisBox* RootInlineBox::ellipsisBox() const 677 { 678 if (!hasEllipsisBox()) 679 return 0; 680 return gEllipsisBoxMap->get(this); 681 } 682 683 void RootInlineBox::removeLineBoxFromRenderObject() 684 { 685 block()->lineBoxes()->removeLineBox(this); 686 } 687 688 void RootInlineBox::extractLineBoxFromRenderObject() 689 { 690 block()->lineBoxes()->extractLineBox(this); 691 } 692 693 void RootInlineBox::attachLineBoxToRenderObject() 694 { 695 block()->lineBoxes()->attachLineBox(this); 696 } 697 698 LayoutRect RootInlineBox::paddedLayoutOverflowRect(LayoutUnit endPadding) const 699 { 700 LayoutRect lineLayoutOverflow = layoutOverflowRect(lineTop(), lineBottom()); 701 if (!endPadding) 702 return lineLayoutOverflow; 703 704 if (isHorizontal()) { 705 if (isLeftToRightDirection()) 706 lineLayoutOverflow.shiftMaxXEdgeTo(max<LayoutUnit>(lineLayoutOverflow.maxX(), logicalRight() + endPadding)); 707 else 708 lineLayoutOverflow.shiftXEdgeTo(min<LayoutUnit>(lineLayoutOverflow.x(), logicalLeft() - endPadding)); 709 } else { 710 if (isLeftToRightDirection()) 711 lineLayoutOverflow.shiftMaxYEdgeTo(max<LayoutUnit>(lineLayoutOverflow.maxY(), logicalRight() + endPadding)); 712 else 713 lineLayoutOverflow.shiftYEdgeTo(min<LayoutUnit>(lineLayoutOverflow.y(), logicalLeft() - endPadding)); 714 } 715 716 return lineLayoutOverflow; 717 } 718 719 static void setAscentAndDescent(int& ascent, int& descent, int newAscent, int newDescent, bool& ascentDescentSet) 720 { 721 if (!ascentDescentSet) { 722 ascentDescentSet = true; 723 ascent = newAscent; 724 descent = newDescent; 725 } else { 726 ascent = max(ascent, newAscent); 727 descent = max(descent, newDescent); 728 } 729 } 730 731 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, int& ascent, int& descent, 732 bool& affectsAscent, bool& affectsDescent) const 733 { 734 bool ascentDescentSet = false; 735 736 // Replaced boxes will return 0 for the line-height if line-box-contain says they are 737 // not to be included. 738 if (box->renderer()->isReplaced()) { 739 if (renderer()->style(isFirstLineStyle())->lineBoxContain() & LineBoxContainReplaced) { 740 ascent = box->baselinePosition(baselineType()); 741 descent = box->lineHeight() - ascent; 742 743 // Replaced elements always affect both the ascent and descent. 744 affectsAscent = true; 745 affectsDescent = true; 746 } 747 return; 748 } 749 750 Vector<const SimpleFontData*>* usedFonts = 0; 751 GlyphOverflow* glyphOverflow = 0; 752 if (box->isText()) { 753 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toInlineTextBox(box)); 754 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; 755 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; 756 } 757 758 bool includeLeading = includeLeadingForBox(box); 759 bool includeFont = includeFontForBox(box); 760 761 bool setUsedFont = false; 762 bool setUsedFontWithLeading = false; 763 764 if (usedFonts && !usedFonts->isEmpty() && (includeFont || (box->renderer()->style(isFirstLineStyle())->lineHeight().isNegative() && includeLeading))) { 765 usedFonts->append(box->renderer()->style(isFirstLineStyle())->font().primaryFont()); 766 for (size_t i = 0; i < usedFonts->size(); ++i) { 767 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); 768 int usedFontAscent = fontMetrics.ascent(baselineType()); 769 int usedFontDescent = fontMetrics.descent(baselineType()); 770 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height()) / 2; 771 int usedFontAscentAndLeading = usedFontAscent + halfLeading; 772 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFontAscentAndLeading; 773 if (includeFont) { 774 setAscentAndDescent(ascent, descent, usedFontAscent, usedFontDescent, ascentDescentSet); 775 setUsedFont = true; 776 } 777 if (includeLeading) { 778 setAscentAndDescent(ascent, descent, usedFontAscentAndLeading, usedFontDescentAndLeading, ascentDescentSet); 779 setUsedFontWithLeading = true; 780 } 781 if (!affectsAscent) 782 affectsAscent = usedFontAscent - box->logicalTop() > 0; 783 if (!affectsDescent) 784 affectsDescent = usedFontDescent + box->logicalTop() > 0; 785 } 786 } 787 788 // If leading is included for the box, then we compute that box. 789 if (includeLeading && !setUsedFontWithLeading) { 790 int ascentWithLeading = box->baselinePosition(baselineType()); 791 int descentWithLeading = box->lineHeight() - ascentWithLeading; 792 setAscentAndDescent(ascent, descent, ascentWithLeading, descentWithLeading, ascentDescentSet); 793 794 // Examine the font box for inline flows and text boxes to see if any part of it is above the baseline. 795 // If the top of our font box relative to the root box baseline is above the root box baseline, then 796 // we are contributing to the maxAscent value. Descent is similar. If any part of our font box is below 797 // the root box's baseline, then we contribute to the maxDescent value. 798 affectsAscent = ascentWithLeading - box->logicalTop() > 0; 799 affectsDescent = descentWithLeading + box->logicalTop() > 0; 800 } 801 802 if (includeFontForBox(box) && !setUsedFont) { 803 int fontAscent = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent(baselineType()); 804 int fontDescent = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent(baselineType()); 805 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDescentSet); 806 affectsAscent = fontAscent - box->logicalTop() > 0; 807 affectsDescent = fontDescent + box->logicalTop() > 0; 808 } 809 810 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBounds) { 811 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow->bottom, ascentDescentSet); 812 affectsAscent = glyphOverflow->top - box->logicalTop() > 0; 813 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0; 814 glyphOverflow->top = min(glyphOverflow->top, max(0, glyphOverflow->top - box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent(baselineType()))); 815 glyphOverflow->bottom = min(glyphOverflow->bottom, max(0, glyphOverflow->bottom - box->renderer()->style(isFirstLineStyle())->fontMetrics().descent(baselineType()))); 816 } 817 818 if (includeMarginForBox(box)) { 819 LayoutUnit ascentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().ascent(baselineType()); 820 LayoutUnit descentWithMargin = box->renderer()->style(isFirstLineStyle())->fontMetrics().descent(baselineType()); 821 if (box->parent() && !box->renderer()->isText()) { 822 ascentWithMargin += box->boxModelObject()->borderBefore() + box->boxModelObject()->paddingBefore() + box->boxModelObject()->marginBefore(); 823 descentWithMargin += box->boxModelObject()->borderAfter() + box->boxModelObject()->paddingAfter() + box->boxModelObject()->marginAfter(); 824 } 825 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin, ascentDescentSet); 826 827 // Treat like a replaced element, since we're using the margin box. 828 affectsAscent = true; 829 affectsDescent = true; 830 } 831 } 832 833 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositionCache& verticalPositionCache) 834 { 835 if (box->renderer()->isText()) 836 return box->parent()->logicalTop(); 837 838 RenderBoxModelObject* renderer = box->boxModelObject(); 839 ASSERT(renderer->isInline()); 840 if (!renderer->isInline()) 841 return 0; 842 843 // This method determines the vertical position for inline elements. 844 bool firstLine = isFirstLineStyle(); 845 if (firstLine && !renderer->document().styleEngine()->usesFirstLineRules()) 846 firstLine = false; 847 848 // Check the cache. 849 bool isRenderInline = renderer->isRenderInline(); 850 if (isRenderInline && !firstLine) { 851 LayoutUnit verticalPosition = verticalPositionCache.get(renderer, baselineType()); 852 if (verticalPosition != PositionUndefined) 853 return verticalPosition; 854 } 855 856 LayoutUnit verticalPosition = 0; 857 EVerticalAlign verticalAlign = renderer->style()->verticalAlign(); 858 if (verticalAlign == TOP || verticalAlign == BOTTOM) 859 return 0; 860 861 RenderObject* parent = renderer->parent(); 862 if (parent->isRenderInline() && parent->style()->verticalAlign() != TOP && parent->style()->verticalAlign() != BOTTOM) 863 verticalPosition = box->parent()->logicalTop(); 864 865 if (verticalAlign != BASELINE) { 866 const Font& font = parent->style(firstLine)->font(); 867 const FontMetrics& fontMetrics = font.fontMetrics(); 868 int fontSize = font.pixelSize(); 869 870 LineDirectionMode lineDirection = parent->isHorizontalWritingMode() ? HorizontalLine : VerticalLine; 871 872 if (verticalAlign == SUB) 873 verticalPosition += fontSize / 5 + 1; 874 else if (verticalAlign == SUPER) 875 verticalPosition -= fontSize / 3 + 1; 876 else if (verticalAlign == TEXT_TOP) 877 verticalPosition += renderer->baselinePosition(baselineType(), firstLine, lineDirection) - fontMetrics.ascent(baselineType()); 878 else if (verticalAlign == MIDDLE) 879 verticalPosition = (verticalPosition - static_cast<LayoutUnit>(fontMetrics.xHeight() / 2) - renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection)).round(); 880 else if (verticalAlign == TEXT_BOTTOM) { 881 verticalPosition += fontMetrics.descent(baselineType()); 882 // lineHeight - baselinePosition is always 0 for replaced elements (except inline blocks), so don't bother wasting time in that case. 883 if (!renderer->isReplaced() || renderer->isInlineBlockOrInlineTable()) 884 verticalPosition -= (renderer->lineHeight(firstLine, lineDirection) - renderer->baselinePosition(baselineType(), firstLine, lineDirection)); 885 } else if (verticalAlign == BASELINE_MIDDLE) 886 verticalPosition += -renderer->lineHeight(firstLine, lineDirection) / 2 + renderer->baselinePosition(baselineType(), firstLine, lineDirection); 887 else if (verticalAlign == LENGTH) { 888 LayoutUnit lineHeight; 889 //Per http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align: 'Percentages: refer to the 'line-height' of the element itself'. 890 if (renderer->style()->verticalAlignLength().isPercent()) 891 lineHeight = renderer->style()->computedLineHeight(); 892 else 893 lineHeight = renderer->lineHeight(firstLine, lineDirection); 894 verticalPosition -= valueForLength(renderer->style()->verticalAlignLength(), lineHeight, renderer->view()); 895 } 896 } 897 898 // Store the cached value. 899 if (isRenderInline && !firstLine) 900 verticalPositionCache.set(renderer, baselineType(), verticalPosition); 901 902 return verticalPosition; 903 } 904 905 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const 906 { 907 if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText())) 908 return false; 909 910 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 911 return (lineBoxContain & LineBoxContainInline) || (box == this && (lineBoxContain & LineBoxContainBlock)); 912 } 913 914 bool RootInlineBox::includeFontForBox(InlineBox* box) const 915 { 916 if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText())) 917 return false; 918 919 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren()) 920 return false; 921 922 // For now map "glyphs" to "font" in vertical text mode until the bounds returned by glyphs aren't garbage. 923 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 924 return (lineBoxContain & LineBoxContainFont) || (!isHorizontal() && (lineBoxContain & LineBoxContainGlyphs)); 925 } 926 927 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const 928 { 929 if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText())) 930 return false; 931 932 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTextChildren()) 933 return false; 934 935 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds returned are garbage. 936 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 937 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); 938 } 939 940 bool RootInlineBox::includeMarginForBox(InlineBox* box) const 941 { 942 if (box->renderer()->isReplaced() || (box->renderer()->isText() && !box->isText())) 943 return false; 944 945 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 946 return lineBoxContain & LineBoxContainInlineBox; 947 } 948 949 950 bool RootInlineBox::fitsToGlyphs() const 951 { 952 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds returned are garbage. 953 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 954 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); 955 } 956 957 bool RootInlineBox::includesRootLineBoxFontOrLeading() const 958 { 959 LineBoxContain lineBoxContain = renderer()->style()->lineBoxContain(); 960 return (lineBoxContain & LineBoxContainBlock) || (lineBoxContain & LineBoxContainInline) || (lineBoxContain & LineBoxContainFont); 961 } 962 963 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const 964 { 965 Vector<InlineBox*> leafBoxesInLogicalOrder; 966 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); 967 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { 968 if (leafBoxesInLogicalOrder[i]->renderer()->node()) { 969 startBox = leafBoxesInLogicalOrder[i]; 970 return startBox->renderer()->node(); 971 } 972 } 973 startBox = 0; 974 return 0; 975 } 976 977 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const 978 { 979 Vector<InlineBox*> leafBoxesInLogicalOrder; 980 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); 981 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { 982 if (leafBoxesInLogicalOrder[i - 1]->renderer()->node()) { 983 endBox = leafBoxesInLogicalOrder[i - 1]; 984 return endBox->renderer()->node(); 985 } 986 } 987 endBox = 0; 988 return 0; 989 } 990 991 #ifndef NDEBUG 992 const char* RootInlineBox::boxName() const 993 { 994 return "RootInlineBox"; 995 } 996 #endif 997 998 } // namespace WebCore 999