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

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

Issue 1916943002: Show correct part of truncated text before ellipsis in contrary flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@604144
Patch Set: Updated Created 4 years, 8 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/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 6d48d9f5af7ec82a95bb363901322e41c776d65a..35033c3c017158144ac11b6eacc661878d7c7e0c 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
@@ -342,8 +342,8 @@ LayoutUnit InlineTextBox::placeEllipsisBox(bool flowIsLTR, LayoutUnit visibleLef
bool ltr = isLeftToRightDirection();
if (ltr != flowIsLTR) {
// Width in pixels of the visible portion of the box, excluding the ellipsis.
- int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsisWidth;
- ellipsisX = ltr ? logicalLeft() + visibleBoxWidth : logicalRight() - visibleBoxWidth;
+ int visibleBoxWidth = visibleRightEdge - visibleLeftEdge - ellipsisWidth;
+ ellipsisX = flowIsLTR ? logicalLeft() + visibleBoxWidth : logicalRight() - visibleBoxWidth;
}
int offset = offsetForPosition(ellipsisX, false);
@@ -359,8 +359,9 @@ LayoutUnit InlineTextBox::placeEllipsisBox(bool flowIsLTR, LayoutUnit visibleLef
setTruncation(offset);
// If we got here that means that we were only partially truncated and we need to return the pixel offset at which
- // to place the ellipsis.
- LayoutUnit widthOfVisibleText(getLineLayoutItem().width(m_start, offset, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()));
+ // to place the ellipsis. Where the text and its flow have opposite directions then our offset into the text is at
+ // the start of the part that will be visible.
+ LayoutUnit widthOfVisibleText(getLineLayoutItem().width(ltr == flowIsLTR ? m_start : offset, ltr == flowIsLTR ? offset : m_len - offset, textPos(), flowIsLTR ? LTR : RTL, isFirstLineStyle()));
// The ellipsis needs to be placed just after the last visible character.
// Where "after" is defined by the flow directionality, not the inline

Powered by Google App Engine
This is Rietveld 408576698