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

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: fix test fail Created 3 years, 11 months 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/Source/core/editing/VisibleUnits.cpp ('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 88a17f89c1243747ed87292b32c4fec4af2723e4..86b2cf65277bb8f985250f19f133f7ec8c62199e 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::kLtr) {
+ 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();
// 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/Source/core/editing/VisibleUnits.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698