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

Unified Diff: third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp

Issue 2736003003: Try to show the full ellipsis at all times (Closed)
Patch Set: bug 697448 Created 3 years, 9 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/LayoutTests/platform/linux/fast/text/emphasis-ellipsis-complextext-expected.png ('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/line/InlineTextBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
index de36b881bd4f832c2bd2e153a5e7ffca85785c6c..4a7da7df98c098f5ebbc38b764546df452579f0d 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
@@ -363,9 +363,10 @@ LayoutUnit InlineTextBox::placeEllipsisBox(bool flowIsLTR,
: logicalRight() - visibleBoxWidth;
}
- // The box's width includes partial glyphs, so respect that when placing
- // the ellipsis.
- int offset = offsetForPosition(ellipsisX);
+ // We measure the text using the second half of the previous character and
+ // the first half of the current one when the text is rtl. This gives a
+ // more accurate position in rtl text.
+ int offset = offsetForPosition(ellipsisX, !ltr);
// Full truncation is only necessary when we're flowing left-to-right.
if (flowIsLTR && offset == 0 && ltr == flowIsLTR) {
// No characters should be laid out. Set ourselves to full truncation and
@@ -375,6 +376,13 @@ LayoutUnit InlineTextBox::placeEllipsisBox(bool flowIsLTR,
return std::min(ellipsisX, logicalLeft());
}
+ // When the text's direction doesn't match the flow's direction we can
+ // choose an offset that starts outside the visible box: compensate for that
+ // if necessary.
+ if (flowIsLTR != ltr && logicalLeft() < 0 && offset >= m_start &&
+ positionForOffset(offset) < logicalLeft().abs())
+ offset++;
+
// Set the truncation index on the text run.
setTruncation(offset);
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/linux/fast/text/emphasis-ellipsis-complextext-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698