| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Dirk Mueller (mueller@kde.org) | 3 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 5 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 619 |
| 620 RootInlineBox& rootBox = box->root(); | 620 RootInlineBox& rootBox = box->root(); |
| 621 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); | 621 LayoutUnit top = std::min(rootBox.selectionTop(), rootBox.lineTop()); |
| 622 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti
on == top)) { | 622 if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirecti
on == top)) { |
| 623 LayoutUnit bottom = rootBox.selectionBottom(); | 623 LayoutUnit bottom = rootBox.selectionBottom(); |
| 624 if (rootBox.nextRootBox()) | 624 if (rootBox.nextRootBox()) |
| 625 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); | 625 bottom = std::min(bottom, rootBox.nextRootBox()->lineTop()); |
| 626 | 626 |
| 627 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockD
irection == bottom)) { | 627 if (pointBlockDirection < bottom || (blocksAreFlipped && pointBlockD
irection == bottom)) { |
| 628 ShouldAffinityBeDownstream shouldAffinityBeDownstream; | 628 ShouldAffinityBeDownstream shouldAffinityBeDownstream; |
| 629 if (lineDirectionPointFitsInBox(pointLineDirection, box, shouldA
ffinityBeDownstream)) | 629 if (lineDirectionPointFitsInBox(pointLineDirection.toInt(), box,
shouldAffinityBeDownstream)) |
| 630 return createPositionWithAffinityForBoxAfterAdjustingOffsetF
orBiDi(box, box->offsetForPosition(pointLineDirection), shouldAffinityBeDownstre
am); | 630 return createPositionWithAffinityForBoxAfterAdjustingOffsetF
orBiDi(box, box->offsetForPosition(pointLineDirection), shouldAffinityBeDownstre
am); |
| 631 } | 631 } |
| 632 } | 632 } |
| 633 lastBox = box; | 633 lastBox = box; |
| 634 } | 634 } |
| 635 | 635 |
| 636 if (lastBox) { | 636 if (lastBox) { |
| 637 ShouldAffinityBeDownstream shouldAffinityBeDownstream; | 637 ShouldAffinityBeDownstream shouldAffinityBeDownstream; |
| 638 lineDirectionPointFitsInBox(pointLineDirection, lastBox, shouldAffinityB
eDownstream); | 638 lineDirectionPointFitsInBox(pointLineDirection.toInt(), lastBox, shouldA
ffinityBeDownstream); |
| 639 return createPositionWithAffinityForBoxAfterAdjustingOffsetForBiDi(lastB
ox, lastBox->offsetForPosition(pointLineDirection) + lastBox->start(), shouldAff
inityBeDownstream); | 639 return createPositionWithAffinityForBoxAfterAdjustingOffsetForBiDi(lastB
ox, lastBox->offsetForPosition(pointLineDirection) + lastBox->start(), shouldAff
inityBeDownstream); |
| 640 } | 640 } |
| 641 return createPositionWithAffinity(0); | 641 return createPositionWithAffinity(0); |
| 642 } | 642 } |
| 643 | 643 |
| 644 LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
outUnit* extraWidthToEndOfLine) | 644 LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, int caretOffset, Lay
outUnit* extraWidthToEndOfLine) |
| 645 { | 645 { |
| 646 if (!inlineBox) | 646 if (!inlineBox) |
| 647 return LayoutRect(); | 647 return LayoutRect(); |
| 648 | 648 |
| 649 ASSERT(inlineBox->isInlineTextBox()); | 649 ASSERT(inlineBox->isInlineTextBox()); |
| 650 if (!inlineBox->isInlineTextBox()) | 650 if (!inlineBox->isInlineTextBox()) |
| 651 return LayoutRect(); | 651 return LayoutRect(); |
| 652 | 652 |
| 653 InlineTextBox* box = toInlineTextBox(inlineBox); | 653 InlineTextBox* box = toInlineTextBox(inlineBox); |
| 654 | 654 |
| 655 int height = box->root().selectionHeight(); | 655 int height = box->root().selectionHeight().toInt(); |
| 656 int top = box->root().selectionTop(); | 656 int top = box->root().selectionTop().toInt(); |
| 657 | 657 |
| 658 // Go ahead and round left to snap it to the nearest pixel. | 658 // Go ahead and round left to snap it to the nearest pixel. |
| 659 LayoutUnit left = box->positionForOffset(caretOffset); | 659 LayoutUnit left = box->positionForOffset(caretOffset); |
| 660 | 660 |
| 661 // Distribute the caret's width to either side of the offset. | 661 // Distribute the caret's width to either side of the offset. |
| 662 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; | 662 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; |
| 663 left -= caretWidthLeftOfOffset; | 663 left -= caretWidthLeftOfOffset; |
| 664 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; | 664 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; |
| 665 | 665 |
| 666 left = LayoutUnit(left.round()); | 666 left = LayoutUnit(left.round()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 708 } |
| 709 | 709 |
| 710 if (rightAligned) { | 710 if (rightAligned) { |
| 711 left = std::max(left, leftEdge); | 711 left = std::max(left, leftEdge); |
| 712 left = std::min(left, rootRight - caretWidth()); | 712 left = std::min(left, rootRight - caretWidth()); |
| 713 } else { | 713 } else { |
| 714 left = std::min(left, rightEdge - caretWidthRightOfOffset); | 714 left = std::min(left, rightEdge - caretWidthRightOfOffset); |
| 715 left = std::max(left, rootLeft); | 715 left = std::max(left, rootLeft); |
| 716 } | 716 } |
| 717 | 717 |
| 718 return LayoutRect(style()->isHorizontalWritingMode() ? IntRect(left, top, ca
retWidth(), height) : IntRect(top, left, height, caretWidth())); | 718 return LayoutRect(style()->isHorizontalWritingMode() ? IntRect(left.toInt(),
top, caretWidth().toInt(), height) : IntRect(top, left.toInt(), height, caretWi
dth().toInt())); |
| 719 } | 719 } |
| 720 | 720 |
| 721 ALWAYS_INLINE float LayoutText::widthFromFont(const Font& f, int start, int len,
float leadWidth, float textWidthSoFar, TextDirection textDirection, HashSet<con
st SimpleFontData*>* fallbackFonts, FloatRect* glyphBoundsAccumulation) const | 721 ALWAYS_INLINE float LayoutText::widthFromFont(const Font& f, int start, int len,
float leadWidth, float textWidthSoFar, TextDirection textDirection, HashSet<con
st SimpleFontData*>* fallbackFonts, FloatRect* glyphBoundsAccumulation) const |
| 722 { | 722 { |
| 723 if (style()->hasTextCombine() && isCombineText()) { | 723 if (style()->hasTextCombine() && isCombineText()) { |
| 724 const LayoutTextCombine* combineText = toLayoutTextCombine(this); | 724 const LayoutTextCombine* combineText = toLayoutTextCombine(this); |
| 725 if (combineText->isCombined()) | 725 if (combineText->isCombined()) |
| 726 return combineText->combinedTextWidth(f); | 726 return combineText->combinedTextWidth(f); |
| 727 } | 727 } |
| 728 | 728 |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { | 1756 for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) { |
| 1757 invalidateDisplayItemClient(*box, invalidationReason); | 1757 invalidateDisplayItemClient(*box, invalidationReason); |
| 1758 if (box->truncation() != cNoTruncation) { | 1758 if (box->truncation() != cNoTruncation) { |
| 1759 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) | 1759 if (EllipsisBox* ellipsisBox = box->root().ellipsisBox()) |
| 1760 invalidateDisplayItemClient(*ellipsisBox, invalidationReason); | 1760 invalidateDisplayItemClient(*ellipsisBox, invalidationReason); |
| 1761 } | 1761 } |
| 1762 } | 1762 } |
| 1763 } | 1763 } |
| 1764 | 1764 |
| 1765 } // namespace blink | 1765 } // namespace blink |
| OLD | NEW |