Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutText.cpp

Issue 2517383002: Use the font height as caret height instead of the line height (Closed)
Patch Set: Get caret height from an InlineBox before caret position Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/caret/caret-height-multi-line.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/caret/caret-height-multi-line.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698