| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 // Next iterate over all the line boxes on the line. If we find a replaced
element that intersects | 111 // Next iterate over all the line boxes on the line. If we find a replaced
element that intersects |
| 112 // then we refuse to accommodate the ellipsis. Otherwise we're ok. | 112 // then we refuse to accommodate the ellipsis. Otherwise we're ok. |
| 113 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); | 113 return InlineFlowBox::canAccommodateEllipsis(ltr, blockEdge, ellipsisWidth); |
| 114 } | 114 } |
| 115 | 115 |
| 116 FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisS
tr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockR
ightEdge, FloatWillBeLayoutUnit ellipsisWidth, InlineBox* markupBox) | 116 FloatWillBeLayoutUnit RootInlineBox::placeEllipsis(const AtomicString& ellipsisS
tr, bool ltr, FloatWillBeLayoutUnit blockLeftEdge, FloatWillBeLayoutUnit blockR
ightEdge, FloatWillBeLayoutUnit ellipsisWidth, InlineBox* markupBox) |
| 117 { | 117 { |
| 118 // Create an ellipsis box. | 118 // Create an ellipsis box. |
| 119 EllipsisBox* ellipsisBox = new EllipsisBox(renderer(), ellipsisStr, this, | 119 EllipsisBox* ellipsisBox = new EllipsisBox(layoutObject(), ellipsisStr, this
, |
| 120 ellipsisWidth - (markupBox ? markupBox->logicalWidth().toFloat() : 0), l
ogicalHeight().toFloat(), | 120 ellipsisWidth - (markupBox ? markupBox->logicalWidth().toFloat() : 0), l
ogicalHeight().toFloat(), |
| 121 x(), y(), !prevRootBox(), isHorizontal(), markupBox); | 121 x(), y(), !prevRootBox(), isHorizontal(), markupBox); |
| 122 | 122 |
| 123 if (!gEllipsisBoxMap) | 123 if (!gEllipsisBoxMap) |
| 124 gEllipsisBoxMap = new EllipsisBoxMap(); | 124 gEllipsisBoxMap = new EllipsisBoxMap(); |
| 125 gEllipsisBoxMap->add(this, ellipsisBox); | 125 gEllipsisBoxMap->add(this, ellipsisBox); |
| 126 setHasEllipsisBox(true); | 126 setHasEllipsisBox(true); |
| 127 | 127 |
| 128 // FIXME: Do we need an RTL version of this? | 128 // FIXME: Do we need an RTL version of this? |
| 129 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { | 129 if (ltr && (logicalLeft() + logicalWidth() + ellipsisWidth) <= blockRightEdg
e) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 | 153 |
| 154 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) | 154 void RootInlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 155 { | 155 { |
| 156 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); | 156 RootInlineBoxPainter(*this).paint(paintInfo, paintOffset, lineTop, lineBotto
m); |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) | 159 bool RootInlineBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& re
sult, const HitTestLocation& locationInContainer, const LayoutPoint& accumulated
Offset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 160 { | 160 { |
| 161 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { | 161 if (hasEllipsisBox() && visibleToHitTestRequest(request)) { |
| 162 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc
umulatedOffset, lineTop, lineBottom)) { | 162 if (ellipsisBox()->nodeAtPoint(request, result, locationInContainer, acc
umulatedOffset, lineTop, lineBottom)) { |
| 163 renderer().updateHitTestResult(result, locationInContainer.point() -
toLayoutSize(accumulatedOffset)); | 163 layoutObject().updateHitTestResult(result, locationInContainer.point
() - toLayoutSize(accumulatedOffset)); |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu
mulatedOffset, lineTop, lineBottom); | 167 return InlineFlowBox::nodeAtPoint(request, result, locationInContainer, accu
mulatedOffset, lineTop, lineBottom); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn
it dy) | 170 void RootInlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUn
it dy) |
| 171 { | 171 { |
| 172 InlineFlowBox::adjustPosition(dx, dy); | 172 InlineFlowBox::adjustPosition(dx, dy); |
| 173 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. | 173 LayoutUnit blockDirectionDelta = isHorizontal() ? dy : dx; // The block dire
ction delta is a LayoutUnit. |
| 174 m_lineTop += blockDirectionDelta; | 174 m_lineTop += blockDirectionDelta; |
| 175 m_lineBottom += blockDirectionDelta; | 175 m_lineBottom += blockDirectionDelta; |
| 176 m_lineTopWithLeading += blockDirectionDelta; | 176 m_lineTopWithLeading += blockDirectionDelta; |
| 177 m_lineBottomWithLeading += blockDirectionDelta; | 177 m_lineBottomWithLeading += blockDirectionDelta; |
| 178 m_selectionBottom += blockDirectionDelta; | 178 m_selectionBottom += blockDirectionDelta; |
| 179 if (hasEllipsisBox()) | 179 if (hasEllipsisBox()) |
| 180 ellipsisBox()->adjustPosition(dx, dy); | 180 ellipsisBox()->adjustPosition(dx, dy); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void RootInlineBox::childRemoved(InlineBox* box) | 183 void RootInlineBox::childRemoved(InlineBox* box) |
| 184 { | 184 { |
| 185 if (&box->renderer() == m_lineBreakObj) | 185 if (&box->layoutObject() == m_lineBreakObj) |
| 186 setLineBreakInfo(0, 0, BidiStatus()); | 186 setLineBreakInfo(0, 0, BidiStatus()); |
| 187 | 187 |
| 188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == &b
ox->renderer(); prev = prev->prevRootBox()) { | 188 for (RootInlineBox* prev = prevRootBox(); prev && prev->lineBreakObj() == &b
ox->layoutObject(); prev = prev->prevRootBox()) { |
| 189 prev->setLineBreakInfo(0, 0, BidiStatus()); | 189 prev->setLineBreakInfo(0, 0, BidiStatus()); |
| 190 prev->markDirty(); | 190 prev->markDirty(); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G
lyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertical
PositionCache) | 194 LayoutUnit RootInlineBox::alignBoxesInBlockDirection(LayoutUnit heightOfBlock, G
lyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache& vertical
PositionCache) |
| 195 { | 195 { |
| 196 // SVG will handle vertical alignment on its own. | 196 // SVG will handle vertical alignment on its own. |
| 197 if (isSVGRootInlineBox()) | 197 if (isSVGRootInlineBox()) |
| 198 return 0; | 198 return 0; |
| 199 | 199 |
| 200 LayoutUnit maxPositionTop = 0; | 200 LayoutUnit maxPositionTop = 0; |
| 201 LayoutUnit maxPositionBottom = 0; | 201 LayoutUnit maxPositionBottom = 0; |
| 202 int maxAscent = 0; | 202 int maxAscent = 0; |
| 203 int maxDescent = 0; | 203 int maxDescent = 0; |
| 204 bool setMaxAscent = false; | 204 bool setMaxAscent = false; |
| 205 bool setMaxDescent = false; | 205 bool setMaxDescent = false; |
| 206 | 206 |
| 207 // Figure out if we're in no-quirks mode. | 207 // Figure out if we're in no-quirks mode. |
| 208 bool noQuirksMode = renderer().document().inNoQuirksMode(); | 208 bool noQuirksMode = layoutObject().document().inNoQuirksMode(); |
| 209 | 209 |
| 210 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBa
seline : AlphabeticBaseline; | 210 m_baselineType = requiresIdeographicBaseline(textBoxDataMap) ? IdeographicBa
seline : AlphabeticBaseline; |
| 211 | 211 |
| 212 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline
Type(), verticalPositionCache); | 212 computeLogicalBoxHeights(this, maxPositionTop, maxPositionBottom, maxAscent,
maxDescent, setMaxAscent, setMaxDescent, noQuirksMode, textBoxDataMap, baseline
Type(), verticalPositionCache); |
| 213 | 213 |
| 214 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) | 214 if (maxAscent + maxDescent < std::max(maxPositionTop, maxPositionBottom)) |
| 215 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi
tionBottom); | 215 adjustMaxAscentAndDescent(maxAscent, maxDescent, maxPositionTop, maxPosi
tionBottom); |
| 216 | 216 |
| 217 LayoutUnit maxHeight = maxAscent + maxDescent; | 217 LayoutUnit maxHeight = maxAscent + maxDescent; |
| 218 LayoutUnit lineTop = heightOfBlock; | 218 LayoutUnit lineTop = heightOfBlock; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 246 { | 246 { |
| 247 FloatWillBeLayoutUnit maxLogicalTop; | 247 FloatWillBeLayoutUnit maxLogicalTop; |
| 248 computeMaxLogicalTop(maxLogicalTop); | 248 computeMaxLogicalTop(maxLogicalTop); |
| 249 return maxLogicalTop; | 249 return maxLogicalTop; |
| 250 } | 250 } |
| 251 | 251 |
| 252 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const | 252 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const |
| 253 { | 253 { |
| 254 LayoutUnit result = 0; | 254 LayoutUnit result = 0; |
| 255 | 255 |
| 256 if (!renderer().style()->isFlippedLinesWritingMode()) { | 256 if (!layoutObject().style()->isFlippedLinesWritingMode()) { |
| 257 // Annotations under the previous line may push us down. | 257 // Annotations under the previous line may push us down. |
| 258 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) | 258 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) |
| 259 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); | 259 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); |
| 260 | 260 |
| 261 if (!hasAnnotationsBefore()) | 261 if (!hasAnnotationsBefore()) |
| 262 return result; | 262 return result; |
| 263 | 263 |
| 264 // Annotations over this line may push us further down. | 264 // Annotations over this line may push us further down. |
| 265 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox
()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe
fore()); | 265 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox
()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe
fore()); |
| 266 result = computeOverAnnotationAdjustment(highestAllowedPosition); | 266 result = computeOverAnnotationAdjustment(highestAllowedPosition); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 286 | 286 |
| 287 bool leftGap, rightGap; | 287 bool leftGap, rightGap; |
| 288 block().getSelectionGapInfo(lineState, leftGap, rightGap); | 288 block().getSelectionGapInfo(lineState, leftGap, rightGap); |
| 289 | 289 |
| 290 GapRects result; | 290 GapRects result; |
| 291 | 291 |
| 292 InlineBox* firstBox = firstSelectedBox(); | 292 InlineBox* firstBox = firstSelectedBox(); |
| 293 InlineBox* lastBox = lastSelectedBox(); | 293 InlineBox* lastBox = lastSelectedBox(); |
| 294 if (leftGap) { | 294 if (leftGap) { |
| 295 result.uniteLeft(block().logicalLeftSelectionGap(rootBlock, rootBlockPhy
sicalPosition, offsetFromRootBlock, | 295 result.uniteLeft(block().logicalLeftSelectionGap(rootBlock, rootBlockPhy
sicalPosition, offsetFromRootBlock, |
| 296 &firstBox->parent()->renderer(), firstBox->logicalLeft(), selTop, se
lHeight, paintInfo)); | 296 &firstBox->parent()->layoutObject(), firstBox->logicalLeft(), selTop
, selHeight, paintInfo)); |
| 297 } | 297 } |
| 298 if (rightGap) { | 298 if (rightGap) { |
| 299 result.uniteRight(block().logicalRightSelectionGap(rootBlock, rootBlockP
hysicalPosition, offsetFromRootBlock, | 299 result.uniteRight(block().logicalRightSelectionGap(rootBlock, rootBlockP
hysicalPosition, offsetFromRootBlock, |
| 300 &lastBox->parent()->renderer(), lastBox->logicalRight(), selTop, sel
Height, paintInfo)); | 300 &lastBox->parent()->layoutObject(), lastBox->logicalRight(), selTop,
selHeight, paintInfo)); |
| 301 } | 301 } |
| 302 | 302 |
| 303 // When dealing with bidi text, a non-contiguous selection region is possibl
e. | 303 // When dealing with bidi text, a non-contiguous selection region is possibl
e. |
| 304 // e.g. The logical text aaaAAAbbb (capitals denote RTL text and non-capital
s LTR) is layed out | 304 // e.g. The logical text aaaAAAbbb (capitals denote RTL text and non-capital
s LTR) is layed out |
| 305 // visually as 3 text runs |aaa|bbb|AAA| if we select 4 characters from the
start of the text the | 305 // visually as 3 text runs |aaa|bbb|AAA| if we select 4 characters from the
start of the text the |
| 306 // selection will look like (underline denotes selection): | 306 // selection will look like (underline denotes selection): |
| 307 // |aaa|bbb|AAA| | 307 // |aaa|bbb|AAA| |
| 308 // ___ _ | 308 // ___ _ |
| 309 // We can see that the |bbb| run is not part of the selection while the runs
around it are. | 309 // We can see that the |bbb| run is not part of the selection while the runs
around it are. |
| 310 if (firstBox && firstBox != lastBox) { | 310 if (firstBox && firstBox != lastBox) { |
| 311 // Now fill in any gaps on the line that occurred between two selected e
lements. | 311 // Now fill in any gaps on the line that occurred between two selected e
lements. |
| 312 LayoutUnit lastLogicalLeft = firstBox->logicalRight(); | 312 LayoutUnit lastLogicalLeft = firstBox->logicalRight(); |
| 313 bool isPreviousBoxSelected = firstBox->selectionState() != LayoutObject:
:SelectionNone; | 313 bool isPreviousBoxSelected = firstBox->selectionState() != LayoutObject:
:SelectionNone; |
| 314 for (InlineBox* box = firstBox->nextLeafChild(); box; box = box->nextLea
fChild()) { | 314 for (InlineBox* box = firstBox->nextLeafChild(); box; box = box->nextLea
fChild()) { |
| 315 if (box->selectionState() != LayoutObject::SelectionNone) { | 315 if (box->selectionState() != LayoutObject::SelectionNone) { |
| 316 LayoutRect logicalRect(lastLogicalLeft, selTop, box->logicalLeft
() - lastLogicalLeft, selHeight); | 316 LayoutRect logicalRect(lastLogicalLeft, selTop, box->logicalLeft
() - lastLogicalLeft, selHeight); |
| 317 logicalRect.move(renderer().isHorizontalWritingMode() ? offsetFr
omRootBlock : LayoutSize(offsetFromRootBlock.height(), offsetFromRootBlock.width
())); | 317 logicalRect.move(layoutObject().isHorizontalWritingMode() ? offs
etFromRootBlock : LayoutSize(offsetFromRootBlock.height(), offsetFromRootBlock.w
idth())); |
| 318 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBl
ockPhysicalPosition, logicalRect); | 318 LayoutRect gapRect = rootBlock->logicalRectToPhysicalRect(rootBl
ockPhysicalPosition, logicalRect); |
| 319 if (isPreviousBoxSelected && gapRect.width() > 0 && gapRect.heig
ht() > 0) { | 319 if (isPreviousBoxSelected && gapRect.width() > 0 && gapRect.heig
ht() > 0) { |
| 320 if (paintInfo && box->parent()->renderer().style()->visibili
ty() == VISIBLE) | 320 if (paintInfo && box->parent()->layoutObject().style()->visi
bility() == VISIBLE) |
| 321 paintInfo->context->fillRect(gapRect, box->parent()->ren
derer().selectionBackgroundColor()); | 321 paintInfo->context->fillRect(gapRect, box->parent()->lay
outObject().selectionBackgroundColor()); |
| 322 // VisibleSelection may be non-contiguous, see comment above
. | 322 // VisibleSelection may be non-contiguous, see comment above
. |
| 323 result.uniteCenter(gapRect); | 323 result.uniteCenter(gapRect); |
| 324 } | 324 } |
| 325 lastLogicalLeft = box->logicalRight(); | 325 lastLogicalLeft = box->logicalRight(); |
| 326 } | 326 } |
| 327 if (box == lastBox) | 327 if (box == lastBox) |
| 328 break; | 328 break; |
| 329 isPreviousBoxSelected = box->selectionState() != LayoutObject::Selec
tionNone; | 329 isPreviousBoxSelected = box->selectionState() != LayoutObject::Selec
tionNone; |
| 330 } | 330 } |
| 331 } | 331 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 373 } |
| 374 | 374 |
| 375 return 0; | 375 return 0; |
| 376 } | 376 } |
| 377 | 377 |
| 378 LayoutUnit RootInlineBox::selectionTop() const | 378 LayoutUnit RootInlineBox::selectionTop() const |
| 379 { | 379 { |
| 380 LayoutUnit selectionTop = m_lineTop; | 380 LayoutUnit selectionTop = m_lineTop; |
| 381 | 381 |
| 382 if (m_hasAnnotationsBefore) | 382 if (m_hasAnnotationsBefore) |
| 383 selectionTop -= !renderer().style()->isFlippedLinesWritingMode() ? compu
teOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineT
op); | 383 selectionTop -= !layoutObject().style()->isFlippedLinesWritingMode() ? c
omputeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_l
ineTop); |
| 384 | 384 |
| 385 if (renderer().style()->isFlippedLinesWritingMode() || !prevRootBox()) | 385 if (layoutObject().style()->isFlippedLinesWritingMode() || !prevRootBox()) |
| 386 return selectionTop; | 386 return selectionTop; |
| 387 | 387 |
| 388 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); | 388 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); |
| 389 if (prevBottom < selectionTop && block().containsFloats()) { | 389 if (prevBottom < selectionTop && block().containsFloats()) { |
| 390 // This line has actually been moved further down, probably from a large
line-height, but possibly because the | 390 // This line has actually been moved further down, probably from a large
line-height, but possibly because the |
| 391 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous | 391 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous |
| 392 // line's bottom if the offsets are greater on both sides. | 392 // line's bottom if the offsets are greater on both sides. |
| 393 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, false
); | 393 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, false
); |
| 394 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, fal
se); | 394 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, fal
se); |
| 395 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, fals
e); | 395 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, fals
e); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 424 } | 424 } |
| 425 | 425 |
| 426 return top; | 426 return top; |
| 427 } | 427 } |
| 428 | 428 |
| 429 LayoutUnit RootInlineBox::selectionBottom() const | 429 LayoutUnit RootInlineBox::selectionBottom() const |
| 430 { | 430 { |
| 431 LayoutUnit selectionBottom = m_selectionBottom; | 431 LayoutUnit selectionBottom = m_selectionBottom; |
| 432 | 432 |
| 433 if (m_hasAnnotationsAfter) | 433 if (m_hasAnnotationsAfter) |
| 434 selectionBottom += !renderer().style()->isFlippedLinesWritingMode() ? co
mputeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m
_lineBottom); | 434 selectionBottom += !layoutObject().style()->isFlippedLinesWritingMode()
? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustme
nt(m_lineBottom); |
| 435 | 435 |
| 436 if (!renderer().style()->isFlippedLinesWritingMode() || !nextRootBox()) | 436 if (!layoutObject().style()->isFlippedLinesWritingMode() || !nextRootBox()) |
| 437 return selectionBottom; | 437 return selectionBottom; |
| 438 | 438 |
| 439 LayoutUnit nextTop = nextRootBox()->selectionTop(); | 439 LayoutUnit nextTop = nextRootBox()->selectionTop(); |
| 440 if (nextTop > selectionBottom && block().containsFloats()) { | 440 if (nextTop > selectionBottom && block().containsFloats()) { |
| 441 // The next line has actually been moved further over, probably from a l
arge line-height, but possibly because the | 441 // The next line has actually been moved further over, probably from a l
arge line-height, but possibly because the |
| 442 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the next | 442 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the next |
| 443 // line's top if the offsets are greater on both sides. | 443 // line's top if the offsets are greater on both sides. |
| 444 LayoutUnit nextLeft = block().logicalLeftOffsetForLine(nextTop, false); | 444 LayoutUnit nextLeft = block().logicalLeftOffsetForLine(nextTop, false); |
| 445 LayoutUnit nextRight = block().logicalRightOffsetForLine(nextTop, false)
; | 445 LayoutUnit nextRight = block().logicalRightOffsetForLine(nextTop, false)
; |
| 446 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionBottom, f
alse); | 446 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionBottom, f
alse); |
| 447 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom,
false); | 447 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom,
false); |
| 448 if (nextLeft > newLeft || nextRight < newRight) | 448 if (nextLeft > newLeft || nextRight < newRight) |
| 449 return selectionBottom; | 449 return selectionBottom; |
| 450 } | 450 } |
| 451 | 451 |
| 452 return nextTop; | 452 return nextTop; |
| 453 } | 453 } |
| 454 | 454 |
| 455 LayoutUnit RootInlineBox::blockDirectionPointInLine() const | 455 LayoutUnit RootInlineBox::blockDirectionPointInLine() const |
| 456 { | 456 { |
| 457 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(),
selectionTop()) : std::min(lineBottom(), selectionBottom()); | 457 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(),
selectionTop()) : std::min(lineBottom(), selectionBottom()); |
| 458 } | 458 } |
| 459 | 459 |
| 460 LayoutBlockFlow& RootInlineBox::block() const | 460 LayoutBlockFlow& RootInlineBox::block() const |
| 461 { | 461 { |
| 462 return toLayoutBlockFlow(renderer()); | 462 return toLayoutBlockFlow(layoutObject()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 static bool isEditableLeaf(InlineBox* leaf) | 465 static bool isEditableLeaf(InlineBox* leaf) |
| 466 { | 466 { |
| 467 return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditab
leStyle(); | 467 return leaf && leaf->layoutObject().node() && leaf->layoutObject().node()->h
asEditableStyle(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 InlineBox* RootInlineBox::closestLeafChildForPoint(const LayoutPoint& pointInCon
tents, bool onlyEditableLeaves) | 470 InlineBox* RootInlineBox::closestLeafChildForPoint(const LayoutPoint& pointInCon
tents, bool onlyEditableLeaves) |
| 471 { | 471 { |
| 472 return closestLeafChildForLogicalLeftPosition(block().isHorizontalWritingMod
e() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves); | 472 return closestLeafChildForLogicalLeftPosition(block().isHorizontalWritingMod
e() ? pointInContents.x() : pointInContents.y(), onlyEditableLeaves); |
| 473 } | 473 } |
| 474 | 474 |
| 475 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(LayoutUnit left
Position, bool onlyEditableLeaves) | 475 InlineBox* RootInlineBox::closestLeafChildForLogicalLeftPosition(LayoutUnit left
Position, bool onlyEditableLeaves) |
| 476 { | 476 { |
| 477 InlineBox* firstLeaf = firstLeafChild(); | 477 InlineBox* firstLeaf = firstLeafChild(); |
| 478 InlineBox* lastLeaf = lastLeafChild(); | 478 InlineBox* lastLeaf = lastLeafChild(); |
| 479 | 479 |
| 480 if (firstLeaf != lastLeaf) { | 480 if (firstLeaf != lastLeaf) { |
| 481 if (firstLeaf->isLineBreak()) | 481 if (firstLeaf->isLineBreak()) |
| 482 firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); | 482 firstLeaf = firstLeaf->nextLeafChildIgnoringLineBreak(); |
| 483 else if (lastLeaf->isLineBreak()) | 483 else if (lastLeaf->isLineBreak()) |
| 484 lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); | 484 lastLeaf = lastLeaf->prevLeafChildIgnoringLineBreak(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLea
f))) | 487 if (firstLeaf == lastLeaf && (!onlyEditableLeaves || isEditableLeaf(firstLea
f))) |
| 488 return firstLeaf; | 488 return firstLeaf; |
| 489 | 489 |
| 490 // Avoid returning a list marker when possible. | 490 // Avoid returning a list marker when possible. |
| 491 if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->renderer().isLis
tMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) { | 491 if (leftPosition <= firstLeaf->logicalLeft() && !firstLeaf->layoutObject().i
sListMarker() && (!onlyEditableLeaves || isEditableLeaf(firstLeaf))) { |
| 492 // The leftPosition coordinate is less or equal to left edge of the firs
tLeaf. | 492 // The leftPosition coordinate is less or equal to left edge of the firs
tLeaf. |
| 493 // Return it. | 493 // Return it. |
| 494 return firstLeaf; | 494 return firstLeaf; |
| 495 } | 495 } |
| 496 | 496 |
| 497 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->renderer().isList
Marker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { | 497 if (leftPosition >= lastLeaf->logicalRight() && !lastLeaf->layoutObject().is
ListMarker() && (!onlyEditableLeaves || isEditableLeaf(lastLeaf))) { |
| 498 // The leftPosition coordinate is greater or equal to right edge of the
lastLeaf. | 498 // The leftPosition coordinate is greater or equal to right edge of the
lastLeaf. |
| 499 // Return it. | 499 // Return it. |
| 500 return lastLeaf; | 500 return lastLeaf; |
| 501 } | 501 } |
| 502 | 502 |
| 503 InlineBox* closestLeaf = 0; | 503 InlineBox* closestLeaf = 0; |
| 504 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi
neBreak()) { | 504 for (InlineBox* leaf = firstLeaf; leaf; leaf = leaf->nextLeafChildIgnoringLi
neBreak()) { |
| 505 if (!leaf->renderer().isListMarker() && (!onlyEditableLeaves || isEditab
leLeaf(leaf))) { | 505 if (!leaf->layoutObject().isListMarker() && (!onlyEditableLeaves || isEd
itableLeaf(leaf))) { |
| 506 closestLeaf = leaf; | 506 closestLeaf = leaf; |
| 507 if (leftPosition < leaf->logicalRight()) { | 507 if (leftPosition < leaf->logicalRight()) { |
| 508 // The x coordinate is less than the right edge of the box. | 508 // The x coordinate is less than the right edge of the box. |
| 509 // Return it. | 509 // Return it. |
| 510 return leaf; | 510 return leaf; |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 | 514 |
| 515 return closestLeaf ? closestLeaf : lastLeaf; | 515 return closestLeaf ? closestLeaf : lastLeaf; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 descent = std::max(descent, newDescent); | 591 descent = std::max(descent, newDescent); |
| 592 } | 592 } |
| 593 } | 593 } |
| 594 | 594 |
| 595 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb
ackFontsMap& textBoxDataMap, int& ascent, int& descent, bool& affectsAscent, boo
l& affectsDescent) const | 595 void RootInlineBox::ascentAndDescentForBox(InlineBox* box, GlyphOverflowAndFallb
ackFontsMap& textBoxDataMap, int& ascent, int& descent, bool& affectsAscent, boo
l& affectsDescent) const |
| 596 { | 596 { |
| 597 bool ascentDescentSet = false; | 597 bool ascentDescentSet = false; |
| 598 | 598 |
| 599 // Replaced boxes will return 0 for the line-height if line-box-contain says
they are | 599 // Replaced boxes will return 0 for the line-height if line-box-contain says
they are |
| 600 // not to be included. | 600 // not to be included. |
| 601 if (box->renderer().isReplaced()) { | 601 if (box->layoutObject().isReplaced()) { |
| 602 if (renderer().style(isFirstLineStyle())->lineBoxContain() & LineBoxCont
ainReplaced) { | 602 if (layoutObject().style(isFirstLineStyle())->lineBoxContain() & LineBox
ContainReplaced) { |
| 603 ascent = box->baselinePosition(baselineType()); | 603 ascent = box->baselinePosition(baselineType()); |
| 604 descent = box->lineHeight() - ascent; | 604 descent = box->lineHeight() - ascent; |
| 605 | 605 |
| 606 // Replaced elements always affect both the ascent and descent. | 606 // Replaced elements always affect both the ascent and descent. |
| 607 affectsAscent = true; | 607 affectsAscent = true; |
| 608 affectsDescent = true; | 608 affectsDescent = true; |
| 609 } | 609 } |
| 610 return; | 610 return; |
| 611 } | 611 } |
| 612 | 612 |
| 613 Vector<const SimpleFontData*>* usedFonts = 0; | 613 Vector<const SimpleFontData*>* usedFonts = 0; |
| 614 GlyphOverflow* glyphOverflow = 0; | 614 GlyphOverflow* glyphOverflow = 0; |
| 615 if (box->isText()) { | 615 if (box->isText()) { |
| 616 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn
lineTextBox(box)); | 616 GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(toIn
lineTextBox(box)); |
| 617 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; | 617 usedFonts = it == textBoxDataMap.end() ? 0 : &it->value.first; |
| 618 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; | 618 glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; |
| 619 } | 619 } |
| 620 | 620 |
| 621 bool includeLeading = includeLeadingForBox(box); | 621 bool includeLeading = includeLeadingForBox(box); |
| 622 bool includeFont = includeFontForBox(box); | 622 bool includeFont = includeFontForBox(box); |
| 623 | 623 |
| 624 bool setUsedFont = false; | 624 bool setUsedFont = false; |
| 625 bool setUsedFontWithLeading = false; | 625 bool setUsedFontWithLeading = false; |
| 626 | 626 |
| 627 if (usedFonts && !usedFonts->isEmpty() && (includeFont || (box->renderer().s
tyle(isFirstLineStyle())->lineHeight().isNegative() && includeLeading))) { | 627 if (usedFonts && !usedFonts->isEmpty() && (includeFont || (box->layoutObject
().style(isFirstLineStyle())->lineHeight().isNegative() && includeLeading))) { |
| 628 usedFonts->append(box->renderer().style(isFirstLineStyle())->font().prim
aryFont()); | 628 usedFonts->append(box->layoutObject().style(isFirstLineStyle())->font().
primaryFont()); |
| 629 for (size_t i = 0; i < usedFonts->size(); ++i) { | 629 for (size_t i = 0; i < usedFonts->size(); ++i) { |
| 630 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); | 630 const FontMetrics& fontMetrics = usedFonts->at(i)->fontMetrics(); |
| 631 int usedFontAscent = fontMetrics.ascent(baselineType()); | 631 int usedFontAscent = fontMetrics.ascent(baselineType()); |
| 632 int usedFontDescent = fontMetrics.descent(baselineType()); | 632 int usedFontDescent = fontMetrics.descent(baselineType()); |
| 633 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height())
/ 2; | 633 int halfLeading = (fontMetrics.lineSpacing() - fontMetrics.height())
/ 2; |
| 634 int usedFontAscentAndLeading = usedFontAscent + halfLeading; | 634 int usedFontAscentAndLeading = usedFontAscent + halfLeading; |
| 635 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont
AscentAndLeading; | 635 int usedFontDescentAndLeading = fontMetrics.lineSpacing() - usedFont
AscentAndLeading; |
| 636 if (includeFont) { | 636 if (includeFont) { |
| 637 setAscentAndDescent(ascent, descent, usedFontAscent, usedFontDes
cent, ascentDescentSet); | 637 setAscentAndDescent(ascent, descent, usedFontAscent, usedFontDes
cent, ascentDescentSet); |
| 638 setUsedFont = true; | 638 setUsedFont = true; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 656 | 656 |
| 657 // Examine the font box for inline flows and text boxes to see if any pa
rt of it is above the baseline. | 657 // Examine the font box for inline flows and text boxes to see if any pa
rt of it is above the baseline. |
| 658 // If the top of our font box relative to the root box baseline is above
the root box baseline, then | 658 // If the top of our font box relative to the root box baseline is above
the root box baseline, then |
| 659 // we are contributing to the maxAscent value. Descent is similar. If an
y part of our font box is below | 659 // we are contributing to the maxAscent value. Descent is similar. If an
y part of our font box is below |
| 660 // the root box's baseline, then we contribute to the maxDescent value. | 660 // the root box's baseline, then we contribute to the maxDescent value. |
| 661 affectsAscent = ascentWithLeading - box->logicalTop() > 0; | 661 affectsAscent = ascentWithLeading - box->logicalTop() > 0; |
| 662 affectsDescent = descentWithLeading + box->logicalTop() > 0; | 662 affectsDescent = descentWithLeading + box->logicalTop() > 0; |
| 663 } | 663 } |
| 664 | 664 |
| 665 if (includeFontForBox(box) && !setUsedFont) { | 665 if (includeFontForBox(box) && !setUsedFont) { |
| 666 int fontAscent = box->renderer().style(isFirstLineStyle())->fontMetrics(
).ascent(baselineType()); | 666 int fontAscent = box->layoutObject().style(isFirstLineStyle())->fontMetr
ics().ascent(baselineType()); |
| 667 int fontDescent = box->renderer().style(isFirstLineStyle())->fontMetrics
().descent(baselineType()); | 667 int fontDescent = box->layoutObject().style(isFirstLineStyle())->fontMet
rics().descent(baselineType()); |
| 668 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc
entSet); | 668 setAscentAndDescent(ascent, descent, fontAscent, fontDescent, ascentDesc
entSet); |
| 669 affectsAscent = fontAscent - box->logicalTop() > 0; | 669 affectsAscent = fontAscent - box->logicalTop() > 0; |
| 670 affectsDescent = fontDescent + box->logicalTop() > 0; | 670 affectsDescent = fontDescent + box->logicalTop() > 0; |
| 671 } | 671 } |
| 672 | 672 |
| 673 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound
s) { | 673 if (includeGlyphsForBox(box) && glyphOverflow && glyphOverflow->computeBound
s) { |
| 674 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow->
bottom, ascentDescentSet); | 674 setAscentAndDescent(ascent, descent, glyphOverflow->top, glyphOverflow->
bottom, ascentDescentSet); |
| 675 affectsAscent = glyphOverflow->top - box->logicalTop() > 0; | 675 affectsAscent = glyphOverflow->top - box->logicalTop() > 0; |
| 676 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0; | 676 affectsDescent = glyphOverflow->bottom + box->logicalTop() > 0; |
| 677 } | 677 } |
| 678 | 678 |
| 679 if (includeMarginForBox(box)) { | 679 if (includeMarginForBox(box)) { |
| 680 LayoutUnit ascentWithMargin = box->renderer().style(isFirstLineStyle())-
>fontMetrics().ascent(baselineType()); | 680 LayoutUnit ascentWithMargin = box->layoutObject().style(isFirstLineStyle
())->fontMetrics().ascent(baselineType()); |
| 681 LayoutUnit descentWithMargin = box->renderer().style(isFirstLineStyle())
->fontMetrics().descent(baselineType()); | 681 LayoutUnit descentWithMargin = box->layoutObject().style(isFirstLineStyl
e())->fontMetrics().descent(baselineType()); |
| 682 if (box->parent() && !box->renderer().isText()) { | 682 if (box->parent() && !box->layoutObject().isText()) { |
| 683 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box
ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore(); | 683 ascentWithMargin += box->boxModelObject()->borderBefore() + box->box
ModelObject()->paddingBefore() + box->boxModelObject()->marginBefore(); |
| 684 descentWithMargin += box->boxModelObject()->borderAfter() + box->box
ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter(); | 684 descentWithMargin += box->boxModelObject()->borderAfter() + box->box
ModelObject()->paddingAfter() + box->boxModelObject()->marginAfter(); |
| 685 } | 685 } |
| 686 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin
, ascentDescentSet); | 686 setAscentAndDescent(ascent, descent, ascentWithMargin, descentWithMargin
, ascentDescentSet); |
| 687 | 687 |
| 688 // Treat like a replaced element, since we're using the margin box. | 688 // Treat like a replaced element, since we're using the margin box. |
| 689 affectsAscent = true; | 689 affectsAscent = true; |
| 690 affectsDescent = true; | 690 affectsDescent = true; |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 | 693 |
| 694 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
nCache& verticalPositionCache) | 694 LayoutUnit RootInlineBox::verticalPositionForBox(InlineBox* box, VerticalPositio
nCache& verticalPositionCache) |
| 695 { | 695 { |
| 696 if (box->renderer().isText()) | 696 if (box->layoutObject().isText()) |
| 697 return box->parent()->logicalTop(); | 697 return box->parent()->logicalTop(); |
| 698 | 698 |
| 699 LayoutBoxModelObject* renderer = box->boxModelObject(); | 699 LayoutBoxModelObject* renderer = box->boxModelObject(); |
| 700 ASSERT(renderer->isInline()); | 700 ASSERT(renderer->isInline()); |
| 701 if (!renderer->isInline()) | 701 if (!renderer->isInline()) |
| 702 return 0; | 702 return 0; |
| 703 | 703 |
| 704 // This method determines the vertical position for inline elements. | 704 // This method determines the vertical position for inline elements. |
| 705 bool firstLine = isFirstLineStyle(); | 705 bool firstLine = isFirstLineStyle(); |
| 706 if (firstLine && !renderer->document().styleEngine().usesFirstLineRules()) | 706 if (firstLine && !renderer->document().styleEngine().usesFirstLineRules()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 758 |
| 759 // Store the cached value. | 759 // Store the cached value. |
| 760 if (isLayoutInline && !firstLine) | 760 if (isLayoutInline && !firstLine) |
| 761 verticalPositionCache.set(renderer, baselineType(), verticalPosition); | 761 verticalPositionCache.set(renderer, baselineType(), verticalPosition); |
| 762 | 762 |
| 763 return verticalPosition; | 763 return verticalPosition; |
| 764 } | 764 } |
| 765 | 765 |
| 766 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const | 766 bool RootInlineBox::includeLeadingForBox(InlineBox* box) const |
| 767 { | 767 { |
| 768 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex
t())) | 768 if (box->layoutObject().isReplaced() || (box->layoutObject().isText() && !bo
x->isText())) |
| 769 return false; | 769 return false; |
| 770 | 770 |
| 771 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 771 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 772 return (lineBoxContain & LineBoxContainInline) || (box == this && (lineBoxCo
ntain & LineBoxContainBlock)); | 772 return (lineBoxContain & LineBoxContainInline) || (box == this && (lineBoxCo
ntain & LineBoxContainBlock)); |
| 773 } | 773 } |
| 774 | 774 |
| 775 bool RootInlineBox::includeFontForBox(InlineBox* box) const | 775 bool RootInlineBox::includeFontForBox(InlineBox* box) const |
| 776 { | 776 { |
| 777 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex
t())) | 777 if (box->layoutObject().isReplaced() || (box->layoutObject().isText() && !bo
x->isText())) |
| 778 return false; | 778 return false; |
| 779 | 779 |
| 780 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe
xtChildren()) | 780 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe
xtChildren()) |
| 781 return false; | 781 return false; |
| 782 | 782 |
| 783 // For now map "glyphs" to "font" in vertical text mode until the bounds ret
urned by glyphs aren't garbage. | 783 // For now map "glyphs" to "font" in vertical text mode until the bounds ret
urned by glyphs aren't garbage. |
| 784 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 784 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 785 return (lineBoxContain & LineBoxContainFont) || (!isHorizontal() && (lineBox
Contain & LineBoxContainGlyphs)); | 785 return (lineBoxContain & LineBoxContainFont) || (!isHorizontal() && (lineBox
Contain & LineBoxContainGlyphs)); |
| 786 } | 786 } |
| 787 | 787 |
| 788 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const | 788 bool RootInlineBox::includeGlyphsForBox(InlineBox* box) const |
| 789 { | 789 { |
| 790 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex
t())) | 790 if (box->layoutObject().isReplaced() || (box->layoutObject().isText() && !bo
x->isText())) |
| 791 return false; | 791 return false; |
| 792 | 792 |
| 793 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe
xtChildren()) | 793 if (!box->isText() && box->isInlineFlowBox() && !toInlineFlowBox(box)->hasTe
xtChildren()) |
| 794 return false; | 794 return false; |
| 795 | 795 |
| 796 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret
urned are garbage. | 796 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret
urned are garbage. |
| 797 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 797 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 798 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); | 798 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); |
| 799 } | 799 } |
| 800 | 800 |
| 801 bool RootInlineBox::includeMarginForBox(InlineBox* box) const | 801 bool RootInlineBox::includeMarginForBox(InlineBox* box) const |
| 802 { | 802 { |
| 803 if (box->renderer().isReplaced() || (box->renderer().isText() && !box->isTex
t())) | 803 if (box->layoutObject().isReplaced() || (box->layoutObject().isText() && !bo
x->isText())) |
| 804 return false; | 804 return false; |
| 805 | 805 |
| 806 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 806 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 807 return lineBoxContain & LineBoxContainInlineBox; | 807 return lineBoxContain & LineBoxContainInlineBox; |
| 808 } | 808 } |
| 809 | 809 |
| 810 | 810 |
| 811 bool RootInlineBox::fitsToGlyphs() const | 811 bool RootInlineBox::fitsToGlyphs() const |
| 812 { | 812 { |
| 813 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret
urned are garbage. | 813 // FIXME: We can't fit to glyphs yet for vertical text, since the bounds ret
urned are garbage. |
| 814 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 814 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 815 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); | 815 return isHorizontal() && (lineBoxContain & LineBoxContainGlyphs); |
| 816 } | 816 } |
| 817 | 817 |
| 818 bool RootInlineBox::includesRootLineBoxFontOrLeading() const | 818 bool RootInlineBox::includesRootLineBoxFontOrLeading() const |
| 819 { | 819 { |
| 820 LineBoxContain lineBoxContain = renderer().style()->lineBoxContain(); | 820 LineBoxContain lineBoxContain = layoutObject().style()->lineBoxContain(); |
| 821 return (lineBoxContain & LineBoxContainBlock) || (lineBoxContain & LineBoxCo
ntainInline) || (lineBoxContain & LineBoxContainFont); | 821 return (lineBoxContain & LineBoxContainBlock) || (lineBoxContain & LineBoxCo
ntainInline) || (lineBoxContain & LineBoxContainFont); |
| 822 } | 822 } |
| 823 | 823 |
| 824 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const | 824 Node* RootInlineBox::getLogicalStartBoxWithNode(InlineBox*& startBox) const |
| 825 { | 825 { |
| 826 Vector<InlineBox*> leafBoxesInLogicalOrder; | 826 Vector<InlineBox*> leafBoxesInLogicalOrder; |
| 827 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); | 827 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); |
| 828 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { | 828 for (size_t i = 0; i < leafBoxesInLogicalOrder.size(); ++i) { |
| 829 if (leafBoxesInLogicalOrder[i]->renderer().nonPseudoNode()) { | 829 if (leafBoxesInLogicalOrder[i]->layoutObject().nonPseudoNode()) { |
| 830 startBox = leafBoxesInLogicalOrder[i]; | 830 startBox = leafBoxesInLogicalOrder[i]; |
| 831 return startBox->renderer().nonPseudoNode(); | 831 return startBox->layoutObject().nonPseudoNode(); |
| 832 } | 832 } |
| 833 } | 833 } |
| 834 startBox = 0; | 834 startBox = 0; |
| 835 return 0; | 835 return 0; |
| 836 } | 836 } |
| 837 | 837 |
| 838 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const | 838 Node* RootInlineBox::getLogicalEndBoxWithNode(InlineBox*& endBox) const |
| 839 { | 839 { |
| 840 Vector<InlineBox*> leafBoxesInLogicalOrder; | 840 Vector<InlineBox*> leafBoxesInLogicalOrder; |
| 841 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); | 841 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder); |
| 842 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { | 842 for (size_t i = leafBoxesInLogicalOrder.size(); i > 0; --i) { |
| 843 if (leafBoxesInLogicalOrder[i - 1]->renderer().nonPseudoNode()) { | 843 if (leafBoxesInLogicalOrder[i - 1]->layoutObject().nonPseudoNode()) { |
| 844 endBox = leafBoxesInLogicalOrder[i - 1]; | 844 endBox = leafBoxesInLogicalOrder[i - 1]; |
| 845 return endBox->renderer().nonPseudoNode(); | 845 return endBox->layoutObject().nonPseudoNode(); |
| 846 } | 846 } |
| 847 } | 847 } |
| 848 endBox = 0; | 848 endBox = 0; |
| 849 return 0; | 849 return 0; |
| 850 } | 850 } |
| 851 | 851 |
| 852 #ifndef NDEBUG | 852 #ifndef NDEBUG |
| 853 const char* RootInlineBox::boxName() const | 853 const char* RootInlineBox::boxName() const |
| 854 { | 854 { |
| 855 return "RootInlineBox"; | 855 return "RootInlineBox"; |
| 856 } | 856 } |
| 857 #endif | 857 #endif |
| 858 | 858 |
| 859 } // namespace blink | 859 } // namespace blink |
| OLD | NEW |