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

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

Issue 2683233005: Set caret width based on device scale factor (Closed)
Patch Set: Sync with ToT again Created 3 years, 10 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
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 3f4d6a8f309e0e4d0f095ced53f3f17713755d5c..194611d2a9a0880d60102081db075e3f4370367a 100644
--- a/third_party/WebKit/Source/core/layout/LayoutText.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutText.cpp
@@ -763,11 +763,12 @@ LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox,
// Go ahead and round left to snap it to the nearest pixel.
LayoutUnit left = box->positionForOffset(caretOffset);
+ LayoutUnit caretWidth = frameView()->caretWidth();
// Distribute the caret's width to either side of the offset.
- LayoutUnit caretWidthLeftOfOffset = caretWidth() / 2;
+ LayoutUnit caretWidthLeftOfOffset = caretWidth / 2;
left -= caretWidthLeftOfOffset;
- LayoutUnit caretWidthRightOfOffset = caretWidth() - caretWidthLeftOfOffset;
+ LayoutUnit caretWidthRightOfOffset = caretWidth - caretWidthLeftOfOffset;
left = LayoutUnit(left.round());
@@ -817,7 +818,7 @@ LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox,
if (rightAligned) {
left = std::max(left, leftEdge);
- left = std::min(left, rootRight - caretWidth());
+ left = std::min(left, rootRight - caretWidth);
} else {
left = std::min(left, rightEdge - caretWidthRightOfOffset);
left = std::max(left, rootLeft);
@@ -825,8 +826,8 @@ LayoutRect LayoutText::localCaretRect(InlineBox* inlineBox,
return LayoutRect(
style()->isHorizontalWritingMode()
- ? IntRect(left.toInt(), top, caretWidth().toInt(), height)
- : IntRect(top, left.toInt(), height, caretWidth().toInt()));
+ ? IntRect(left.toInt(), top, caretWidth.toInt(), height)
+ : IntRect(top, left.toInt(), height, caretWidth.toInt()));
}
ALWAYS_INLINE float LayoutText::widthFromFont(

Powered by Google App Engine
This is Rietveld 408576698