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 d6cc72e451eedaad34ef2b71ad43a2af188884a5..6962450da978db8658d114766e75a6a28b1fa98a 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp |
@@ -732,9 +732,16 @@ LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox, |
return LayoutRect(); |
InlineTextBox* box = toInlineTextBox(inlineBox); |
- |
- int height = box->root().selectionHeight().toInt(); |
- int top = box->root().selectionTop().toInt(); |
+ // Find an InlineBox before caret position, which is used to get caret height. |
+ InlineBox* caretBox = box; |
+ if (box->prevLeafChild() && caretOffset == 0) |
drott
2016/12/14 16:42:22
In https://bugs.chromium.org/p/chromium/issues/det
|
+ caretBox = box->prevLeafChild(); |
+ |
+ // 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(); |
// Go ahead and round left to snap it to the nearest pixel. |
LayoutUnit left = box->positionForOffset(caretOffset); |