| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 RootInlineBox::RootInlineBox(RenderBlockFlow& block) | 49 RootInlineBox::RootInlineBox(RenderBlockFlow& block) |
| 50 : InlineFlowBox(block) | 50 : InlineFlowBox(block) |
| 51 , m_lineBreakPos(0) | 51 , m_lineBreakPos(0) |
| 52 , m_lineBreakObj(0) | 52 , m_lineBreakObj(0) |
| 53 , m_lineTop(0) | 53 , m_lineTop(0) |
| 54 , m_lineBottom(0) | 54 , m_lineBottom(0) |
| 55 , m_lineTopWithLeading(0) | 55 , m_lineTopWithLeading(0) |
| 56 , m_lineBottomWithLeading(0) | 56 , m_lineBottomWithLeading(0) |
| 57 , m_selectionBottom(0) | 57 , m_selectionBottom(0) |
| 58 { | 58 { |
| 59 setIsHorizontal(block.isHorizontalWritingMode()); | 59 // FIXME(sky): Remove |
| 60 setIsHorizontal(true); |
| 60 } | 61 } |
| 61 | 62 |
| 62 | 63 |
| 63 void RootInlineBox::destroy() | 64 void RootInlineBox::destroy() |
| 64 { | 65 { |
| 65 detachEllipsisBox(); | 66 detachEllipsisBox(); |
| 66 InlineFlowBox::destroy(); | 67 InlineFlowBox::destroy(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void RootInlineBox::detachEllipsisBox() | 70 void RootInlineBox::detachEllipsisBox() |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 { | 252 { |
| 252 float maxLogicalTop = 0; | 253 float maxLogicalTop = 0; |
| 253 computeMaxLogicalTop(maxLogicalTop); | 254 computeMaxLogicalTop(maxLogicalTop); |
| 254 return maxLogicalTop; | 255 return maxLogicalTop; |
| 255 } | 256 } |
| 256 | 257 |
| 257 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const | 258 LayoutUnit RootInlineBox::beforeAnnotationsAdjustment() const |
| 258 { | 259 { |
| 259 LayoutUnit result = 0; | 260 LayoutUnit result = 0; |
| 260 | 261 |
| 261 if (!renderer().style()->isFlippedLinesWritingMode()) { | 262 // Annotations under the previous line may push us down. |
| 262 // Annotations under the previous line may push us down. | 263 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) |
| 263 if (prevRootBox() && prevRootBox()->hasAnnotationsAfter()) | 264 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); |
| 264 result = prevRootBox()->computeUnderAnnotationAdjustment(lineTop()); | |
| 265 | 265 |
| 266 if (!hasAnnotationsBefore()) | 266 if (!hasAnnotationsBefore()) |
| 267 return result; | 267 return result; |
| 268 | 268 |
| 269 // Annotations over this line may push us further down. | 269 // Annotations over this line may push us further down. |
| 270 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox
()->lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBe
fore()); | 270 LayoutUnit highestAllowedPosition = prevRootBox() ? std::min(prevRootBox()->
lineBottom(), lineTop()) + result : static_cast<LayoutUnit>(block().borderBefore
()); |
| 271 result = computeOverAnnotationAdjustment(highestAllowedPosition); | 271 result = computeOverAnnotationAdjustment(highestAllowedPosition); |
| 272 } else { | |
| 273 // Annotations under this line may push us up. | |
| 274 if (hasAnnotationsBefore()) | |
| 275 result = computeUnderAnnotationAdjustment(prevRootBox() ? prevRootBo
x()->lineBottom() : static_cast<LayoutUnit>(block().borderBefore())); | |
| 276 | |
| 277 if (!prevRootBox() || !prevRootBox()->hasAnnotationsAfter()) | |
| 278 return result; | |
| 279 | |
| 280 // We have to compute the expansion for annotations over the previous li
ne to see how much we should move. | |
| 281 LayoutUnit lowestAllowedPosition = std::max(prevRootBox()->lineBottom(),
lineTop()) - result; | |
| 282 result = prevRootBox()->computeOverAnnotationAdjustment(lowestAllowedPos
ition); | |
| 283 } | |
| 284 | 272 |
| 285 return result; | 273 return result; |
| 286 } | 274 } |
| 287 | 275 |
| 288 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoi
nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, | 276 GapRects RootInlineBox::lineSelectionGap(RenderBlock* rootBlock, const LayoutPoi
nt& rootBlockPhysicalPosition, const LayoutSize& offsetFromRootBlock, |
| 289 LayoutUnit selTop, LayoutUnit selHeight
, const PaintInfo* paintInfo) | 277 LayoutUnit selTop, LayoutUnit selHeight
, const PaintInfo* paintInfo) |
| 290 { | 278 { |
| 291 RenderObject::SelectionState lineState = selectionState(); | 279 RenderObject::SelectionState lineState = selectionState(); |
| 292 | 280 |
| 293 bool leftGap, rightGap; | 281 bool leftGap, rightGap; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 369 } |
| 382 | 370 |
| 383 return 0; | 371 return 0; |
| 384 } | 372 } |
| 385 | 373 |
| 386 LayoutUnit RootInlineBox::selectionTop() const | 374 LayoutUnit RootInlineBox::selectionTop() const |
| 387 { | 375 { |
| 388 LayoutUnit selectionTop = m_lineTop; | 376 LayoutUnit selectionTop = m_lineTop; |
| 389 | 377 |
| 390 if (m_hasAnnotationsBefore) | 378 if (m_hasAnnotationsBefore) |
| 391 selectionTop -= !renderer().style()->isFlippedLinesWritingMode() ? compu
teOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineT
op); | 379 selectionTop -= computeOverAnnotationAdjustment(m_lineTop); |
| 392 | 380 |
| 393 if (renderer().style()->isFlippedLinesWritingMode() || !prevRootBox()) | 381 if (!prevRootBox()) |
| 394 return selectionTop; | 382 return selectionTop; |
| 395 | 383 |
| 396 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); | 384 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); |
| 397 if (prevBottom < selectionTop && block().containsFloats()) { | 385 if (prevBottom < selectionTop && block().containsFloats()) { |
| 398 // This line has actually been moved further down, probably from a large
line-height, but possibly because the | 386 // This line has actually been moved further down, probably from a large
line-height, but possibly because the |
| 399 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous | 387 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the previous |
| 400 // line's bottom if the offsets are greater on both sides. | 388 // line's bottom if the offsets are greater on both sides. |
| 401 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, false
); | 389 LayoutUnit prevLeft = block().logicalLeftOffsetForLine(prevBottom, false
); |
| 402 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, fal
se); | 390 LayoutUnit prevRight = block().logicalRightOffsetForLine(prevBottom, fal
se); |
| 403 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, fals
e); | 391 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionTop, fals
e); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 430 } | 418 } |
| 431 } | 419 } |
| 432 } | 420 } |
| 433 | 421 |
| 434 return top; | 422 return top; |
| 435 } | 423 } |
| 436 | 424 |
| 437 LayoutUnit RootInlineBox::selectionBottom() const | 425 LayoutUnit RootInlineBox::selectionBottom() const |
| 438 { | 426 { |
| 439 LayoutUnit selectionBottom = m_selectionBottom; | 427 LayoutUnit selectionBottom = m_selectionBottom; |
| 440 | |
| 441 if (m_hasAnnotationsAfter) | 428 if (m_hasAnnotationsAfter) |
| 442 selectionBottom += !renderer().style()->isFlippedLinesWritingMode() ? co
mputeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m
_lineBottom); | 429 selectionBottom += computeUnderAnnotationAdjustment(m_lineBottom); |
| 443 | 430 return selectionBottom; |
| 444 if (!renderer().style()->isFlippedLinesWritingMode() || !nextRootBox()) | |
| 445 return selectionBottom; | |
| 446 | |
| 447 LayoutUnit nextTop = nextRootBox()->selectionTop(); | |
| 448 if (nextTop > selectionBottom && block().containsFloats()) { | |
| 449 // The next line has actually been moved further over, probably from a l
arge line-height, but possibly because the | |
| 450 // line was forced to clear floats. If so, let's check the offsets, and
only be willing to use the next | |
| 451 // line's top if the offsets are greater on both sides. | |
| 452 LayoutUnit nextLeft = block().logicalLeftOffsetForLine(nextTop, false); | |
| 453 LayoutUnit nextRight = block().logicalRightOffsetForLine(nextTop, false)
; | |
| 454 LayoutUnit newLeft = block().logicalLeftOffsetForLine(selectionBottom, f
alse); | |
| 455 LayoutUnit newRight = block().logicalRightOffsetForLine(selectionBottom,
false); | |
| 456 if (nextLeft > newLeft || nextRight < newRight) | |
| 457 return selectionBottom; | |
| 458 } | |
| 459 | |
| 460 return nextTop; | |
| 461 } | 431 } |
| 462 | 432 |
| 463 int RootInlineBox::blockDirectionPointInLine() const | 433 int RootInlineBox::blockDirectionPointInLine() const |
| 464 { | 434 { |
| 465 return !block().style()->isFlippedBlocksWritingMode() ? std::max(lineTop(),
selectionTop()) : std::min(lineBottom(), selectionBottom()); | 435 return std::max(lineTop(), selectionTop()); |
| 466 } | 436 } |
| 467 | 437 |
| 468 RenderBlockFlow& RootInlineBox::block() const | 438 RenderBlockFlow& RootInlineBox::block() const |
| 469 { | 439 { |
| 470 return toRenderBlockFlow(renderer()); | 440 return toRenderBlockFlow(renderer()); |
| 471 } | 441 } |
| 472 | 442 |
| 473 static bool isEditableLeaf(InlineBox* leaf) | 443 static bool isEditableLeaf(InlineBox* leaf) |
| 474 { | 444 { |
| 475 return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditab
leStyle(); | 445 return leaf && leaf->renderer().node() && leaf->renderer().node()->hasEditab
leStyle(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 } | 828 } |
| 859 | 829 |
| 860 #ifndef NDEBUG | 830 #ifndef NDEBUG |
| 861 const char* RootInlineBox::boxName() const | 831 const char* RootInlineBox::boxName() const |
| 862 { | 832 { |
| 863 return "RootInlineBox"; | 833 return "RootInlineBox"; |
| 864 } | 834 } |
| 865 #endif | 835 #endif |
| 866 | 836 |
| 867 } // namespace blink | 837 } // namespace blink |
| OLD | NEW |