| 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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 const ComputedStyle* styleToUse = | 756 const ComputedStyle* styleToUse = |
| 757 caretBox->getLineLayoutItem().style(caretBox->isFirstLineStyle()); | 757 caretBox->getLineLayoutItem().style(caretBox->isFirstLineStyle()); |
| 758 if (!styleToUse->font().primaryFont()) | 758 if (!styleToUse->font().primaryFont()) |
| 759 return LayoutRect(); | 759 return LayoutRect(); |
| 760 | 760 |
| 761 int height = styleToUse->font().primaryFont()->getFontMetrics().height(); | 761 int height = styleToUse->font().primaryFont()->getFontMetrics().height(); |
| 762 int top = caretBox->logicalTop().toInt(); | 762 int top = caretBox->logicalTop().toInt(); |
| 763 | 763 |
| 764 // Go ahead and round left to snap it to the nearest pixel. | 764 // Go ahead and round left to snap it to the nearest pixel. |
| 765 LayoutUnit left = box->positionForOffset(caretOffset); | 765 LayoutUnit left = box->positionForOffset(caretOffset); |
| 766 LayoutUnit caretWidth = frameView()->caretWidth(); |
| 766 | 767 |
| 767 // Distribute the caret's width to either side of the offset. | 768 // Distribute the caret's width to either side of the offset. |
| 768 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; | 769 LayoutUnit caretWidthLeftOfOffset = caretWidth / 2; |
| 769 left -= caretWidthLeftOfOffset; | 770 left -= caretWidthLeftOfOffset; |
| 770 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; | 771 LayoutUnit caretWidthRightOfOffset = caretWidth - caretWidthLeftOfOffset; |
| 771 | 772 |
| 772 left = LayoutUnit(left.round()); | 773 left = LayoutUnit(left.round()); |
| 773 | 774 |
| 774 LayoutUnit rootLeft = box->root().logicalLeft(); | 775 LayoutUnit rootLeft = box->root().logicalLeft(); |
| 775 LayoutUnit rootRight = box->root().logicalRight(); | 776 LayoutUnit rootRight = box->root().logicalRight(); |
| 776 | 777 |
| 777 // FIXME: should we use the width of the root inline box or the | 778 // FIXME: should we use the width of the root inline box or the |
| 778 // width of the containing block for this? | 779 // width of the containing block for this? |
| 779 if (extraWidthToEndOfLine) | 780 if (extraWidthToEndOfLine) |
| 780 *extraWidthToEndOfLine = | 781 *extraWidthToEndOfLine = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 810 | 811 |
| 811 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct | 812 // for unicode-bidi: plaintext, use inlineBoxBidiLevel() to test the correct |
| 812 // direction for the cursor. | 813 // direction for the cursor. |
| 813 if (rightAligned && style()->getUnicodeBidi() == UnicodeBidi::kPlaintext) { | 814 if (rightAligned && style()->getUnicodeBidi() == UnicodeBidi::kPlaintext) { |
| 814 if (inlineBox->bidiLevel() % 2 != 1) | 815 if (inlineBox->bidiLevel() % 2 != 1) |
| 815 rightAligned = false; | 816 rightAligned = false; |
| 816 } | 817 } |
| 817 | 818 |
| 818 if (rightAligned) { | 819 if (rightAligned) { |
| 819 left = std::max(left, leftEdge); | 820 left = std::max(left, leftEdge); |
| 820 left = std::min(left, rootRight - caretWidth()); | 821 left = std::min(left, rootRight - caretWidth); |
| 821 } else { | 822 } else { |
| 822 left = std::min(left, rightEdge - caretWidthRightOfOffset); | 823 left = std::min(left, rightEdge - caretWidthRightOfOffset); |
| 823 left = std::max(left, rootLeft); | 824 left = std::max(left, rootLeft); |
| 824 } | 825 } |
| 825 | 826 |
| 826 return LayoutRect( | 827 return LayoutRect( |
| 827 style()->isHorizontalWritingMode() | 828 style()->isHorizontalWritingMode() |
| 828 ? IntRect(left.toInt(), top, caretWidth().toInt(), height) | 829 ? IntRect(left.toInt(), top, caretWidth.toInt(), height) |
| 829 : IntRect(top, left.toInt(), height, caretWidth().toInt())); | 830 : IntRect(top, left.toInt(), height, caretWidth.toInt())); |
| 830 } | 831 } |
| 831 | 832 |
| 832 ALWAYS_INLINE float LayoutText::widthFromFont( | 833 ALWAYS_INLINE float LayoutText::widthFromFont( |
| 833 const Font& f, | 834 const Font& f, |
| 834 int start, | 835 int start, |
| 835 int len, | 836 int len, |
| 836 float leadWidth, | 837 float leadWidth, |
| 837 float textWidthSoFar, | 838 float textWidthSoFar, |
| 838 TextDirection textDirection, | 839 TextDirection textDirection, |
| 839 HashSet<const SimpleFontData*>* fallbackFonts, | 840 HashSet<const SimpleFontData*>* fallbackFonts, |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 LayoutRect rect = LayoutRect( | 2020 LayoutRect rect = LayoutRect( |
| 2020 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 2021 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
| 2021 LayoutBlock* block = containingBlock(); | 2022 LayoutBlock* block = containingBlock(); |
| 2022 if (block && hasTextBoxes()) | 2023 if (block && hasTextBoxes()) |
| 2023 block->adjustChildDebugRect(rect); | 2024 block->adjustChildDebugRect(rect); |
| 2024 | 2025 |
| 2025 return rect; | 2026 return rect; |
| 2026 } | 2027 } |
| 2027 | 2028 |
| 2028 } // namespace blink | 2029 } // namespace blink |
| OLD | NEW |