Chromium Code Reviews| 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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 int caretOffset, | 725 int caretOffset, |
| 726 LayoutUnit* extraWidthToEndOfLine) { | 726 LayoutUnit* extraWidthToEndOfLine) { |
| 727 if (!inlineBox) | 727 if (!inlineBox) |
| 728 return LayoutRect(); | 728 return LayoutRect(); |
| 729 | 729 |
| 730 ASSERT(inlineBox->isInlineTextBox()); | 730 ASSERT(inlineBox->isInlineTextBox()); |
| 731 if (!inlineBox->isInlineTextBox()) | 731 if (!inlineBox->isInlineTextBox()) |
| 732 return LayoutRect(); | 732 return LayoutRect(); |
| 733 | 733 |
| 734 InlineTextBox* box = toInlineTextBox(inlineBox); | 734 InlineTextBox* box = toInlineTextBox(inlineBox); |
| 735 // Find an InlineBox before caret position, which is used to get caret height. | |
| 736 InlineBox* caretBox = box; | |
| 737 if (box->prevLeafChild() && caretOffset == 0) | |
|
drott
2016/12/14 16:42:22
In https://bugs.chromium.org/p/chromium/issues/det
| |
| 738 caretBox = box->prevLeafChild(); | |
| 735 | 739 |
| 736 int height = box->root().selectionHeight().toInt(); | 740 // Get caret height from a font of character. |
| 737 int top = box->root().selectionTop().toInt(); | 741 const ComputedStyle* styleToUse = |
| 742 caretBox->getLineLayoutItem().style(caretBox->isFirstLineStyle()); | |
| 743 int height = styleToUse->font().primaryFont()->getFontMetrics().height(); | |
| 744 int top = caretBox->logicalTop().toInt(); | |
| 738 | 745 |
| 739 // Go ahead and round left to snap it to the nearest pixel. | 746 // Go ahead and round left to snap it to the nearest pixel. |
| 740 LayoutUnit left = box->positionForOffset(caretOffset); | 747 LayoutUnit left = box->positionForOffset(caretOffset); |
| 741 | 748 |
| 742 // Distribute the caret's width to either side of the offset. | 749 // Distribute the caret's width to either side of the offset. |
| 743 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; | 750 LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2; |
| 744 left -= caretWidthLeftOfOffset; | 751 left -= caretWidthLeftOfOffset; |
| 745 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; | 752 LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset; |
| 746 | 753 |
| 747 left = LayoutUnit(left.round()); | 754 left = LayoutUnit(left.round()); |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1975 LayoutRect rect = LayoutRect( | 1982 LayoutRect rect = LayoutRect( |
| 1976 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); | 1983 IntRect(firstRunX(), firstRunY(), linesBox.width(), linesBox.height())); |
| 1977 LayoutBlock* block = containingBlock(); | 1984 LayoutBlock* block = containingBlock(); |
| 1978 if (block && hasTextBoxes()) | 1985 if (block && hasTextBoxes()) |
| 1979 block->adjustChildDebugRect(rect); | 1986 block->adjustChildDebugRect(rect); |
| 1980 | 1987 |
| 1981 return rect; | 1988 return rect; |
| 1982 } | 1989 } |
| 1983 | 1990 |
| 1984 } // namespace blink | 1991 } // namespace blink |
| OLD | NEW |