Index: third_party/WebKit/Source/core/layout/LayoutText.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutText.cpp b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
index dd8366d87a8887878a576fce62ffb90d4076b5cf..823667c9c9c4c2b30cb6899dffe989dba31f12d1 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
@@ -741,9 +741,22 @@ LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, |
return LayoutRect(); |
InlineTextBox* box = toInlineTextBox(inlineBox); |
+ // Find an InlineBox before caret position, which is used to get caret height. |
+ InlineBox* caretBox = box; |
+ if (box->getLineLayoutItem().style(box->isFirstLineStyle())->direction() == |
+ TextDirection::Ltr) { |
+ if (box->prevLeafChild() && caretOffset == 0) |
+ caretBox = box->prevLeafChild(); |
+ } else { |
+ if (box->nextLeafChild() && caretOffset == 0) |
+ caretBox = box->nextLeafChild(); |
+ } |
- int height = box->root().selectionHeight().toInt(); |
- int top = box->root().selectionTop().toInt(); |
+ // Get caret height from a font of character. |
+ const ComputedStyle* styleToUse = |
+ caretBox->getLineLayoutItem().style(caretBox->isFirstLineStyle()); |
+ int height = styleToUse->font().primaryFont()->getFontMetrics().height(); |
+ 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
|
// Go ahead and round left to snap it to the nearest pixel. |
LayoutUnit left = box->positionForOffset(caretOffset); |