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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { | 382 for (InlineBox* box = lastLeafChild(); box; box = box->prevLeafChild()) { |
383 if (box->getSelectionState() != SelectionNone) | 383 if (box->getSelectionState() != SelectionNone) |
384 return box; | 384 return box; |
385 } | 385 } |
386 | 386 |
387 return nullptr; | 387 return nullptr; |
388 } | 388 } |
389 | 389 |
390 LayoutUnit RootInlineBox::selectionTop() const { | 390 LayoutUnit RootInlineBox::selectionTop() const { |
391 LayoutUnit selectionTop = m_lineTop; | 391 LayoutUnit selectionTop = m_lineTop; |
392 | |
393 if (m_hasAnnotationsBefore) | 392 if (m_hasAnnotationsBefore) |
394 selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode() | 393 selectionTop -= !getLineLayoutItem().style()->isFlippedLinesWritingMode() |
395 ? computeOverAnnotationAdjustment(m_lineTop) | 394 ? computeOverAnnotationAdjustment(m_lineTop) |
396 : computeUnderAnnotationAdjustment(m_lineTop); | 395 : computeUnderAnnotationAdjustment(m_lineTop); |
397 | 396 |
398 if (getLineLayoutItem().style()->isFlippedLinesWritingMode() || | 397 if (getLineLayoutItem().style()->isFlippedLinesWritingMode() || |
399 !prevRootBox()) | 398 !prevRootBox()) |
400 return selectionTop; | 399 return selectionTop; |
401 | 400 |
402 LayoutUnit prevBottom = prevRootBox()->selectionBottom(); | 401 return std::min(selectionTop, prevRootBox()->selectionBottom()); |
403 if (prevBottom < selectionTop && block().containsFloats()) { | |
404 // This line has actually been moved further down, probably from a large | |
pdr.
2016/12/01 21:54:48
I traced this code back 12 years and found it was
eae
2016/12/02 10:12:30
Nice detective work there pdr!
| |
405 // line-height, but possibly because the line was forced to clear floats. | |
406 // If so, let's check the offsets, and only be willing to use the previous | |
407 // line's bottom if the offsets are greater on both sides. | |
408 LayoutUnit prevLeft = | |
409 block().logicalLeftOffsetForLine(prevBottom, DoNotIndentText); | |
410 LayoutUnit prevRight = | |
411 block().logicalRightOffsetForLine(prevBottom, DoNotIndentText); | |
412 LayoutUnit newLeft = | |
413 block().logicalLeftOffsetForLine(selectionTop, DoNotIndentText); | |
414 LayoutUnit newRight = | |
415 block().logicalRightOffsetForLine(selectionTop, DoNotIndentText); | |
416 if (prevLeft > newLeft || prevRight < newRight) | |
417 return selectionTop; | |
418 } | |
419 | |
420 return prevBottom; | |
421 } | 402 } |
422 | 403 |
423 LayoutUnit RootInlineBox::selectionBottom() const { | 404 LayoutUnit RootInlineBox::selectionBottom() const { |
424 LayoutUnit selectionBottom = getLineLayoutItem().document().inNoQuirksMode() | 405 LayoutUnit selectionBottom = getLineLayoutItem().document().inNoQuirksMode() |
425 ? m_selectionBottom | 406 ? m_selectionBottom |
426 : m_lineBottom; | 407 : m_lineBottom; |
427 | 408 |
428 if (m_hasAnnotationsAfter) | 409 if (m_hasAnnotationsAfter) |
429 selectionBottom += !getLineLayoutItem().style()->isFlippedLinesWritingMode() | 410 selectionBottom += !getLineLayoutItem().style()->isFlippedLinesWritingMode() |
430 ? computeUnderAnnotationAdjustment(m_lineBottom) | 411 ? computeUnderAnnotationAdjustment(m_lineBottom) |
431 : computeOverAnnotationAdjustment(m_lineBottom); | 412 : computeOverAnnotationAdjustment(m_lineBottom); |
432 | 413 |
433 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode() || | 414 if (!getLineLayoutItem().style()->isFlippedLinesWritingMode() || |
434 !nextRootBox()) | 415 !nextRootBox()) |
435 return selectionBottom; | 416 return selectionBottom; |
436 | 417 |
437 LayoutUnit nextTop = nextRootBox()->selectionTop(); | 418 return std::max(selectionBottom, nextRootBox()->selectionTop()); |
438 if (nextTop > selectionBottom && block().containsFloats()) { | |
439 // The next line has actually been moved further over, probably from a large | |
440 // line-height, but possibly because the line was forced to clear floats. | |
441 // If so, let's check the offsets, and only be willing to use the next | |
442 // line's top if the offsets are greater on both sides. | |
443 LayoutUnit nextLeft = | |
444 block().logicalLeftOffsetForLine(nextTop, DoNotIndentText); | |
445 LayoutUnit nextRight = | |
446 block().logicalRightOffsetForLine(nextTop, DoNotIndentText); | |
447 LayoutUnit newLeft = | |
448 block().logicalLeftOffsetForLine(selectionBottom, DoNotIndentText); | |
449 LayoutUnit newRight = | |
450 block().logicalRightOffsetForLine(selectionBottom, DoNotIndentText); | |
451 if (nextLeft > newLeft || nextRight < newRight) | |
452 return selectionBottom; | |
453 } | |
454 | |
455 return nextTop; | |
456 } | 419 } |
457 | 420 |
458 LayoutUnit RootInlineBox::blockDirectionPointInLine() const { | 421 LayoutUnit RootInlineBox::blockDirectionPointInLine() const { |
459 return !block().style()->isFlippedBlocksWritingMode() | 422 return !block().style()->isFlippedBlocksWritingMode() |
460 ? std::max(lineTop(), selectionTop()) | 423 ? std::max(lineTop(), selectionTop()) |
461 : std::min(lineBottom(), selectionBottom()); | 424 : std::min(lineBottom(), selectionBottom()); |
462 } | 425 } |
463 | 426 |
464 LineLayoutBlockFlow RootInlineBox::block() const { | 427 LineLayoutBlockFlow RootInlineBox::block() const { |
465 return LineLayoutBlockFlow(getLineLayoutItem()); | 428 return LineLayoutBlockFlow(getLineLayoutItem()); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 } | 781 } |
819 endBox = nullptr; | 782 endBox = nullptr; |
820 return nullptr; | 783 return nullptr; |
821 } | 784 } |
822 | 785 |
823 const char* RootInlineBox::boxName() const { | 786 const char* RootInlineBox::boxName() const { |
824 return "RootInlineBox"; | 787 return "RootInlineBox"; |
825 } | 788 } |
826 | 789 |
827 } // namespace blink | 790 } // namespace blink |
OLD | NEW |