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

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

Issue 2615843002: Revert of Don't paint underline or selections over ellipsis in mixed-flow contexts (Closed)
Patch Set: 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
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 2b15321b37756984e354ea4a781c4aa1ab391f14..cb57b3186901f06f3867a0a00d08deba963baf2a 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -559,21 +559,11 @@
if (respectHyphen)
selectionEnd = textRun.length();
- bool ltr = m_inlineTextBox.isLeftToRightDirection();
- bool flowIsLTR =
- m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
if (m_inlineTextBox.truncation() != cNoTruncation) {
- // In a mixed-direction flow the ellipsis is at the start of the text
- // rather than at the end of it.
selectionStart =
- ltr == flowIsLTR
- ? std::min<int>(selectionStart, m_inlineTextBox.truncation())
- : std::max<int>(selectionStart, m_inlineTextBox.truncation());
- selectionEnd =
- ltr == flowIsLTR
- ? std::min<int>(selectionEnd, m_inlineTextBox.truncation())
- : std::max<int>(selectionEnd, m_inlineTextBox.truncation());
- length = ltr == flowIsLTR ? m_inlineTextBox.truncation() : textRun.length();
+ std::min<int>(selectionStart, m_inlineTextBox.truncation());
+ selectionEnd = std::min<int>(selectionEnd, m_inlineTextBox.truncation());
+ length = m_inlineTextBox.truncation();
}
TextPainter textPainter(context, font, textRun, textOrigin, boxRect,
@@ -586,23 +576,25 @@
emphasisMarkPosition);
if (combinedText)
textPainter.setCombinedText(combinedText);
- if (m_inlineTextBox.truncation() != cNoTruncation && ltr != flowIsLTR)
- textPainter.setEllipsisOffset(m_inlineTextBox.truncation());
if (!paintSelectedTextOnly) {
int startOffset = 0;
int endOffset = length;
+ if (paintSelectedTextSeparately && selectionStart < selectionEnd) {
+ startOffset = selectionEnd;
+ endOffset = selectionStart;
+ }
// Where the text and its flow have opposite directions then our offset into
// the text given by |truncation| is at the start of the part that will be
// visible.
- if (m_inlineTextBox.truncation() != cNoTruncation && ltr != flowIsLTR) {
+ if (m_inlineTextBox.truncation() != cNoTruncation &&
+ m_inlineTextBox.getLineLayoutItem()
+ .containingBlock()
+ .style()
+ ->isLeftToRightDirection() !=
+ m_inlineTextBox.isLeftToRightDirection()) {
startOffset = m_inlineTextBox.truncation();
endOffset = textRun.length();
- }
-
- if (paintSelectedTextSeparately && selectionStart < selectionEnd) {
- startOffset = selectionEnd;
- endOffset = selectionStart;
}
// FIXME: This cache should probably ultimately be held somewhere else.
@@ -953,13 +945,11 @@
bool flowIsLTR =
m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
if (m_inlineTextBox.truncation() != cNoTruncation) {
- // In a mixed-direction flow the ellipsis is at the start of the text
- // so we need to start after it. Otherwise we just need to make sure
- // the end of the text is where the ellipsis starts.
- if (ltr != flowIsLTR)
- sPos = std::max<int>(sPos, m_inlineTextBox.truncation());
- else
- length = m_inlineTextBox.truncation();
+ 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));
@@ -998,12 +988,10 @@
(boxRect.y() - deltaY).toFloat());
LayoutRect selectionRect = LayoutRect(
font.selectionRectForText(textRun, localOrigin, selHeight, sPos, ePos));
- // For line breaks, just painting a selection where the line break itself
- // is rendered is sufficient. Don't select it if there's an ellipsis
- // there.
- if (m_inlineTextBox.hasWrappedSelectionNewline() &&
- m_inlineTextBox.truncation() == cNoTruncation &&
- !m_inlineTextBox.isLineBreak())
+ if (m_inlineTextBox.hasWrappedSelectionNewline()
+ // For line breaks, just painting a selection where the line break itself
+ // is rendered is sufficient.
+ && !m_inlineTextBox.isLineBreak())
expandToIncludeNewlineForSelection(selectionRect);
// Line breaks report themselves as having zero width for layout purposes,
@@ -1013,7 +1001,7 @@
if (!m_inlineTextBox.isLeftToRightDirection() &&
m_inlineTextBox.isLineBreak())
selectionRect.move(-selectionRect.width(), LayoutUnit());
- if (!flowIsLTR && !ltr && m_inlineTextBox.truncation() != cNoTruncation)
+ if (!flowIsLTR && m_inlineTextBox.truncation() != cNoTruncation)
selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(),
LayoutUnit());
@@ -1050,9 +1038,8 @@
bool flowIsLTR =
m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width(
- ltr == flowIsLTR
- ? m_inlineTextBox.start()
- : m_inlineTextBox.start() + m_inlineTextBox.truncation(),
+ ltr == flowIsLTR ? m_inlineTextBox.start()
+ : m_inlineTextBox.truncation(),
ltr == flowIsLTR ? m_inlineTextBox.truncation()
: m_inlineTextBox.len() - m_inlineTextBox.truncation(),
m_inlineTextBox.textPos(),

Powered by Google App Engine
This is Rietveld 408576698