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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 int caretOffset, | 734 int caretOffset, |
735 LayoutUnit* extraWidthToEndOfLine) { | 735 LayoutUnit* extraWidthToEndOfLine) { |
736 if (!inlineBox) | 736 if (!inlineBox) |
737 return LayoutRect(); | 737 return LayoutRect(); |
738 | 738 |
739 ASSERT(inlineBox->isInlineTextBox()); | 739 ASSERT(inlineBox->isInlineTextBox()); |
740 if (!inlineBox->isInlineTextBox()) | 740 if (!inlineBox->isInlineTextBox()) |
741 return LayoutRect(); | 741 return LayoutRect(); |
742 | 742 |
743 InlineTextBox* box = toInlineTextBox(inlineBox); | 743 InlineTextBox* box = toInlineTextBox(inlineBox); |
| 744 // Find an InlineBox before caret position, which is used to get caret height. |
| 745 InlineBox* caretBox = box; |
| 746 if (box->getLineLayoutItem().style(box->isFirstLineStyle())->direction() == |
| 747 TextDirection::kLtr) { |
| 748 if (box->prevLeafChild() && caretOffset == 0) |
| 749 caretBox = box->prevLeafChild(); |
| 750 } else { |
| 751 if (box->nextLeafChild() && caretOffset == 0) |
| 752 caretBox = box->nextLeafChild(); |
| 753 } |
744 | 754 |
745 int height = box->root().selectionHeight().toInt(); | 755 // Get caret height from a font of character. |
746 int top = box->root().selectionTop().toInt(); | 756 const ComputedStyle* styleToUse = |
| 757 caretBox->getLineLayoutItem().style(caretBox->isFirstLineStyle()); |
| 758 int height = styleToUse->font().primaryFont()->getFontMetrics().height(); |
| 759 int top = caretBox->logicalTop().toInt(); |
747 | 760 |
748 // Go ahead and round left to snap it to the nearest pixel. | 761 // Go ahead and round left to snap it to the nearest pixel. |
749 LayoutUnit left = box->positionForOffset(caretOffset); | 762 LayoutUnit left = box->positionForOffset(caretOffset); |
750 | 763 |
751 // Distribute the caret's width to either side of the offset. | 764 // Distribute the caret's width to either side of the offset. |
752 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; | 765 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; |
753 left -= caretWidthLeftOfOffset; | 766 left -= caretWidthLeftOfOffset; |
754 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; | 767 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; |
755 | 768 |
756 left = LayoutUnit(left.round()); | 769 left = LayoutUnit(left.round()); |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 LayoutRect rect = LayoutRect( | 2006 LayoutRect rect = LayoutRect( |
1994 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 2007 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
1995 LayoutBlock* block = containingBlock(); | 2008 LayoutBlock* block = containingBlock(); |
1996 if (block && hasTextBoxes()) | 2009 if (block && hasTextBoxes()) |
1997 block->adjustChildDebugRect(rect); | 2010 block->adjustChildDebugRect(rect); |
1998 | 2011 |
1999 return rect; | 2012 return rect; |
2000 } | 2013 } |
2001 | 2014 |
2002 } // namespace blink | 2015 } // namespace blink |
OLD | NEW |