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::Ltr) { | |
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(); | |
yosin_UTC9
2017/01/05 07:31:31
Is this baseline.y - font.ascent?
joone
2017/01/06 20:40:43
Yes
| |
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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1992 LayoutRect rect = LayoutRect( | 2005 LayoutRect rect = LayoutRect( |
1993 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 2006 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
1994 LayoutBlock* block = containingBlock(); | 2007 LayoutBlock* block = containingBlock(); |
1995 if (block && hasTextBoxes()) | 2008 if (block && hasTextBoxes()) |
1996 block->adjustChildDebugRect(rect); | 2009 block->adjustChildDebugRect(rect); |
1997 | 2010 |
1998 return rect; | 2011 return rect; |
1999 } | 2012 } |
2000 | 2013 |
2001 } // namespace blink | 2014 } // namespace blink |
OLD | NEW |