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

Unified Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2266733002: Select mixed rtl-ltr correctly when an ellipsis is present (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug 634445-selection Created 4 years, 4 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/paint/InlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
index ca3f747fb3cd1ec5d73b27b632a1c8e62f5334ae..123a9af3e062a73b4c0e316ad6a988c7778ad920 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -451,8 +451,16 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, const Layout
// If the text is truncated, let the thing being painted in the truncation
// draw its own highlight.
- int length = m_inlineTextBox.truncation() != cNoTruncation ? m_inlineTextBox.truncation() : m_inlineTextBox.len();
- StringView string(m_inlineTextBox.getLineLayoutItem().text(), m_inlineTextBox.start(), static_cast<unsigned>(length));
+ unsigned start = m_inlineTextBox.start();
+ int length = m_inlineTextBox.len();
+ bool ltr = m_inlineTextBox.isLeftToRightDirection();
+ bool flowIsLTR = m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
+ if (m_inlineTextBox.truncation() != cNoTruncation) {
+ start = ltr == flowIsLTR ? m_inlineTextBox.start() : m_inlineTextBox.truncation();
+ length = ltr == flowIsLTR ? m_inlineTextBox.truncation() : m_inlineTextBox.len() - m_inlineTextBox.truncation();
+ }
+ StringView string(m_inlineTextBox.getLineLayoutItem().text(), start, static_cast<unsigned>(length));
+
StringBuilder charactersWithHyphen;
bool respectHyphen = ePos == length && m_inlineTextBox.hasHyphen();
@@ -491,6 +499,8 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, const Layout
// TODO(crbug.com/638981): Is the conversion to int intentional?
selectionRect.move(-selectionRect.width().toInt(), 0);
}
+ if (!flowIsLTR && m_inlineTextBox.truncation() != cNoTruncation)
+ selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(), LayoutUnit());
context.fillRect(FloatRect(selectionRect), c);
}
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/linux/editing/selection/select-text-overflow-ellipsis-mixed-in-rtl-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698