Commit 8691b058 authored by robhogan's avatar robhogan Committed by Commit bot

Don't paint underline or selections over ellipsis in mixed-flow contexts

Also, ensure the selected text is painted correctly when an ellipsis is present
in a mixed-flow context (e.g. ltr text in an rtl container).

BUG=642454, 642450, 642460
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2

Review-Url: https://codereview.chromium.org/2594983002
Cr-Commit-Position: refs/heads/master@{#441486}
parent d701b6e5
...@@ -1263,6 +1263,19 @@ crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/contentSecurit ...@@ -1263,6 +1263,19 @@ crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/contentSecurit
crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/xssAuditor/cached-frame.html [ Failure ] crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/xssAuditor/cached-frame.html [ Failure ]
crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/xssAuditor/chunked-big-script.html [ Failure ] crbug.com/528062 [ Win ] virtual/mojo-loading/http/tests/security/xssAuditor/chunked-big-script.html [ Failure ]
crbug.com/642454 [ Win Mac ] editing/selection/dont-select-text-overflow-ellipsis-when-wrapping-ltr-mixed.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/dont-select-text-overflow-ellipsis-when-wrapping-rtl-mixed.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/dont-select-text-overflow-ellipsis-when-wrapping-rtl.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/dont-select-text-overflow-ellipsis-when-wrapping.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/select-text-overflow-ellipsis-mixed-in-ltr-2.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/select-text-overflow-ellipsis-mixed-in-ltr.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] editing/selection/select-text-overflow-ellipsis-mixed-in-rtl-2.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] fast/css/text-overflow-ellipsis-strict.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] fast/css/text-overflow-ellipsis.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] fast/text/ellipsis-mixed-text-in-ltr-flow-underline-2.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] fast/text/ellipsis-mixed-text-in-ltr-flow-underline.html [ NeedsRebaseline ]
crbug.com/642454 [ Win Mac ] fast/text/ellipsis-mixed-text-in-rtl-flow-underline-2.html [ NeedsRebaseline ]
crbug.com/392706 virtual/threaded/animations/play-state-initially-paused.html [ Failure ] crbug.com/392706 virtual/threaded/animations/play-state-initially-paused.html [ Failure ]
# Part of a larger issue referenced in the bug. This specific issue will be fixed shortly. # Part of a larger issue referenced in the bug. This specific issue will be fixed shortly.
......
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x104
LayoutBlockFlow {HTML} at (0,0) size 800x104
LayoutBlockFlow {BODY} at (8,16) size 784x80
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 459x19
text run at (0,0) width 459: "crbug.com/642454: Don't select part of the ellipsis when wrapping selection."
LayoutBlockFlow {DL} at (200,36) size 384x44
LayoutBlockFlow {DT} at (0,22) size 384x22
LayoutText {#text} at (0,0) size 206x21
text run at (0,0) width 206: "Lorem ipsum dolor sit amet"
layer at (248,52) size 344x22 scrollWidth 1177
LayoutBlockFlow {DD} at (40,0) size 344x22
LayoutText {#text} at (0,0) size 1178x21
text run at (0,0) width 1178: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 10 of child 0 {#text} of child 3 {DT} of child 2 {DL} of body
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x104
LayoutBlockFlow {HTML} at (0,0) size 800x104
LayoutBlockFlow {BODY} at (8,16) size 784x80
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 459x19
text run at (0,0) width 459: "crbug.com/642454: Don't select part of the ellipsis when wrapping selection."
LayoutBlockFlow {DL} at (200,36) size 384x44
LayoutBlockFlow {DT} at (0,22) size 384x22
LayoutText {#text} at (0,0) size 206x21
text run at (0,0) width 206: "Lorem ipsum dolor sit amet"
layer at (248,52) size 344x22 scrollWidth 393
LayoutBlockFlow {DD} at (40,0) size 344x22
LayoutText {#text} at (0,0) size 393x21
text run at (0,0) width 54: "Lorem "
text run at (54,0) width 339 RTL: "\x{5DC}\x{5D5}\x{5E8}\x{5DD} \x{5D0}\x{5D9}\x{5E4}\x{5E1}\x{5D5}\x{5DD} \x{5D4}\x{5D5}\x{5D0} \x{5DB}\x{5D9}\x{5E0}\x{5D5}\x{5D9} \x{5DC}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D7}\x{5E1}\x{5E8} \x{5DE}\x{5E9}\x{5DE}\x{5E2}\x{5D5}\x{5EA} \x{5DC}\x{5D7}\x{5DC}\x{5D5}\x{5D8}\x{5D9}\x{5DF}"
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 10 of child 0 {#text} of child 3 {DT} of child 2 {DL} of body
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
}
</style>
<p>crbug.com/642454: Don't select part of the ellipsis when wrapping selection.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem לורם איפסום הוא כינוי לטקסט חסר משמעות לחלוטין</dd>
<dt id="wrapped">Lorem ipsum dolor sit amet</dt>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, wrapped.firstChild, 10);
}, true);
</script>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x104
LayoutBlockFlow {HTML} at (0,0) size 800x104
LayoutBlockFlow {BODY} at (8,16) size 784x80
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 459x19
text run at (0,0) width 459: "crbug.com/642454: Don't select part of the ellipsis when wrapping selection."
LayoutBlockFlow {DL} at (200,36) size 384x44
LayoutBlockFlow {DT} at (0,22) size 384x22
LayoutText {#text} at (0,0) size 206x21
text run at (0,0) width 206: "Lorem ipsum dolor sit amet"
layer at (208,52) size 344x22 scrollX 833.00 scrollWidth 1177
LayoutBlockFlow {DD} at (0,0) size 344x22
LayoutText {#text} at (-833,0) size 1178x21
text run at (-833,0) width 5 RTL: "."
text run at (-828,0) width 1172: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua"
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 10 of child 0 {#text} of child 3 {DT} of child 2 {DL} of body
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x104
LayoutBlockFlow {HTML} at (0,0) size 800x104
LayoutBlockFlow {BODY} at (8,16) size 784x80
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 459x19
text run at (0,0) width 459: "crbug.com/642454: Don't select part of the ellipsis when wrapping selection."
LayoutBlockFlow {DL} at (200,36) size 384x44
LayoutBlockFlow {DT} at (0,22) size 384x22
LayoutText {#text} at (0,0) size 206x21
text run at (0,0) width 206: "Lorem ipsum dolor sit amet"
layer at (208,52) size 344x22 scrollX 49.00 scrollWidth 393
LayoutBlockFlow {DD} at (0,0) size 344x22
LayoutText {#text} at (-49,0) size 393x21
text run at (-49,0) width 344 RTL: " \x{5DC}\x{5D5}\x{5E8}\x{5DD} \x{5D0}\x{5D9}\x{5E4}\x{5E1}\x{5D5}\x{5DD} \x{5D4}\x{5D5}\x{5D0} \x{5DB}\x{5D9}\x{5E0}\x{5D5}\x{5D9} \x{5DC}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D7}\x{5E1}\x{5E8} \x{5DE}\x{5E9}\x{5DE}\x{5E2}\x{5D5}\x{5EA} \x{5DC}\x{5D7}\x{5DC}\x{5D5}\x{5D8}\x{5D9}\x{5DF}"
text run at (295,0) width 49: "Lorem"
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 10 of child 0 {#text} of child 3 {DT} of child 2 {DL} of body
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
direction:rtl;
}
</style>
<p>crbug.com/642454: Don't select part of the ellipsis when wrapping selection.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem לורם איפסום הוא כינוי לטקסט חסר משמעות לחלוטין</dd>
<dt id="wrapped">Lorem ipsum dolor sit amet</dt>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, wrapped.firstChild, 10);
}, true);
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
direction:rtl;
}
</style>
<p>crbug.com/642454: Don't select part of the ellipsis when wrapping selection.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</dd>
<dt id="wrapped">Lorem ipsum dolor sit amet</dt>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, wrapped.firstChild, 10);
}, true);
</script>
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
}
</style>
<p>crbug.com/642454: Don't select part of the ellipsis when wrapping selection.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</dd>
<dt id="wrapped">Lorem ipsum dolor sit amet</dt>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, wrapped.firstChild, 10);
}, true);
</script>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x82
LayoutBlockFlow {HTML} at (0,0) size 800x82
LayoutBlockFlow {BODY} at (8,16) size 784x58
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 658x19
text run at (0,0) width 658: "crbug.com/642454: Select all text in mixed ltr-rtl in rtl flow. None of the dots in the ellipsis should be selected."
LayoutBlockFlow {DL} at (200,36) size 384x22
layer at (248,52) size 344x22 scrollWidth 506
LayoutBlockFlow {DD} at (40,0) size 344x22
LayoutText {#text} at (0,0) size 506x21
text run at (0,0) width 104: "Lorem ipsum "
text run at (104,0) width 402 RTL: "\x{5D9}\x{5E0}\x{5D8}\x{5E8}\x{5E0}\x{5D8} \x{5D5}\x{5DB}\x{5D5}' \x{5D1}\x{5DE}\x{5E7}\x{5D5}\x{5DD} \x{5D4}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D4}\x{5D0}\x{5DE}\x{5D9}\x{5EA}\x{5D9} \x{5D4}\x{5E1}\x{5D5}\x{5E4}\x{5D9}\x{5E2}\x{5D3} \x{5E9}\x{5D9}\x{5D4}\x{5D9}\x{5D4} \x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D0}\x{5DE}\x{5D9}\x{5EA}"
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 66 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
}
</style>
<p>crbug.com/642454: Select all text in mixed ltr-rtl in rtl flow. None of the dots in the ellipsis should be selected.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem ipsum ינטרנט וכו' במקום הטקסט האמיתי הסופיעד שיהיה טקסט אמית</dd>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, selection_with_ellipsis.firstChild, 155);
}, true);
</script>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x82
LayoutBlockFlow {HTML} at (0,0) size 800x82
LayoutBlockFlow {BODY} at (8,16) size 784x58
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 658x19
text run at (0,0) width 658: "crbug.com/642454: Select all text in mixed ltr-rtl in rtl flow. None of the dots in the ellipsis should be selected."
LayoutBlockFlow {DL} at (200,36) size 384x22
layer at (208,52) size 344x22 scrollX 162.00 scrollWidth 506
LayoutBlockFlow {DD} at (0,0) size 344x22
LayoutText {#text} at (-162,0) size 506x21
text run at (-162,0) width 407 RTL: " \x{5D9}\x{5E0}\x{5D8}\x{5E8}\x{5E0}\x{5D8} \x{5D5}\x{5DB}\x{5D5}' \x{5D1}\x{5DE}\x{5E7}\x{5D5}\x{5DD} \x{5D4}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D4}\x{5D0}\x{5DE}\x{5D9}\x{5EA}\x{5D9} \x{5D4}\x{5E1}\x{5D5}\x{5E4}\x{5D9}\x{5E2}\x{5D3} \x{5E9}\x{5D9}\x{5D4}\x{5D9}\x{5D4} \x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D0}\x{5DE}\x{5D9}\x{5EA}"
text run at (245,0) width 99: "Lorem ipsum"
selection start: position 0 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
selection end: position 66 of child 0 {#text} of child 1 {DD} of child 2 {DL} of body
<!DOCTYPE html>
<meta charset=utf-8>
<style>
dl {
max-width: 20em;
margin: auto;
font-size: 120%;
white-space: nowrap;
}
dd {
overflow: hidden;
text-overflow: ellipsis;
text-decoration: inherit;
direction: rtl;
}
</style>
<p>crbug.com/642454: Select all text in mixed ltr-rtl in rtl flow. None of the dots in the ellipsis should be selected.</p>
<dl>
<dd id="selection_with_ellipsis">Lorem ipsum ינטרנט וכו' במקום הטקסט האמיתי הסופיעד שיהיה טקסט אמית</dd>
</dl>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
runAfterLayoutAndPaint(function() {
getSelection().setBaseAndExtent(selection_with_ellipsis.firstChild, 0, selection_with_ellipsis.firstChild, 155);
}, true);
</script>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x116
LayoutBlockFlow {HTML} at (0,0) size 800x116
LayoutBlockFlow {BODY} at (8,16) size 784x92
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 456x19
text run at (0,0) width 456: "crbug.com/634445: Rtl text in a ltr flow should truncate the text left-to-right."
LayoutBlockFlow {P} at (0,36) size 784x20
LayoutText {#text} at (0,0) size 382x19
text run at (0,0) width 382: "You should see an underline beneath the text but not the ellipsis."
layer at (8,88) size 350x20 scrollWidth 425
LayoutBlockFlow {DIV} at (0,72) size 350x20
LayoutText {#text} at (0,0) size 425x19
text run at (0,0) width 83: "Lorem ipsum "
text run at (83,0) width 342 RTL: "\x{5D9}\x{5E0}\x{5D8}\x{5E8}\x{5E0}\x{5D8} \x{5D5}\x{5DB}\x{5D5}' \x{5D1}\x{5DE}\x{5E7}\x{5D5}\x{5DD} \x{5D4}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D4}\x{5D0}\x{5DE}\x{5D9}\x{5EA}\x{5D9} \x{5D4}\x{5E1}\x{5D5}\x{5E4}\x{5D9}\x{5E2}\x{5D3} \x{5E9}\x{5D9}\x{5D4}\x{5D9}\x{5D4} \x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D0}\x{5DE}\x{5D9}\x{5EA}"
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
div {
width: 350px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-decoration: underline;
}
</style>
<p>crbug.com/634445: Rtl text in a ltr flow should truncate the text left-to-right.</p>
<p>You should see an underline beneath the text but not the ellipsis.</p>
<div>Lorem ipsum ינטרנט וכו' במקום הטקסט האמיתי הסופיעד שיהיה טקסט אמית</div>
layer at (0,0) size 800x600
LayoutView at (0,0) size 800x600
layer at (0,0) size 800x116
LayoutBlockFlow {HTML} at (0,0) size 800x116
LayoutBlockFlow {BODY} at (8,16) size 784x92
LayoutBlockFlow {P} at (0,0) size 784x20
LayoutText {#text} at (0,0) size 456x19
text run at (0,0) width 456: "crbug.com/634445: Rtl text in a ltr flow should truncate the text left-to-right."
LayoutBlockFlow {P} at (0,36) size 784x20
LayoutText {#text} at (0,0) size 382x19
text run at (0,0) width 382: "You should see an underline beneath the text but not the ellipsis."
layer at (8,88) size 350x20 scrollX 75.00 scrollWidth 425
LayoutBlockFlow {DIV} at (0,72) size 350x20
LayoutText {#text} at (-75,0) size 425x19
text run at (-75,0) width 346 RTL: " \x{5D9}\x{5E0}\x{5D8}\x{5E8}\x{5E0}\x{5D8} \x{5D5}\x{5DB}\x{5D5}' \x{5D1}\x{5DE}\x{5E7}\x{5D5}\x{5DD} \x{5D4}\x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D4}\x{5D0}\x{5DE}\x{5D9}\x{5EA}\x{5D9} \x{5D4}\x{5E1}\x{5D5}\x{5E4}\x{5D9}\x{5E2}\x{5D3} \x{5E9}\x{5D9}\x{5D4}\x{5D9}\x{5D4} \x{5D8}\x{5E7}\x{5E1}\x{5D8} \x{5D0}\x{5DE}\x{5D9}\x{5EA}"
text run at (271,0) width 79: "Lorem ipsum"
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
div {
width: 350px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-decoration: underline;
direction: rtl;
}
</style>
<p>crbug.com/634445: Rtl text in a ltr flow should truncate the text left-to-right.</p>
<p>You should see an underline beneath the text but not the ellipsis.</p>
<div>Lorem ipsum ינטרנט וכו' במקום הטקסט האמיתי הסופיעד שיהיה טקסט אמית</div>
...@@ -559,11 +559,21 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, ...@@ -559,11 +559,21 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
if (respectHyphen) if (respectHyphen)
selectionEnd = textRun.length(); selectionEnd = textRun.length();
bool ltr = m_inlineTextBox.isLeftToRightDirection();
bool flowIsLTR =
m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
if (m_inlineTextBox.truncation() != cNoTruncation) { 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 = selectionStart =
std::min<int>(selectionStart, m_inlineTextBox.truncation()); ltr == flowIsLTR
selectionEnd = std::min<int>(selectionEnd, m_inlineTextBox.truncation()); ? std::min<int>(selectionStart, m_inlineTextBox.truncation())
length = 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();
} }
TextPainter textPainter(context, font, textRun, textOrigin, boxRect, TextPainter textPainter(context, font, textRun, textOrigin, boxRect,
...@@ -576,27 +586,25 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, ...@@ -576,27 +586,25 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo,
emphasisMarkPosition); emphasisMarkPosition);
if (combinedText) if (combinedText)
textPainter.setCombinedText(combinedText); textPainter.setCombinedText(combinedText);
if (m_inlineTextBox.truncation() != cNoTruncation && ltr != flowIsLTR)
textPainter.setEllipsisOffset(m_inlineTextBox.truncation());
if (!paintSelectedTextOnly) { if (!paintSelectedTextOnly) {
int startOffset = 0; int startOffset = 0;
int endOffset = length; int endOffset = length;
if (paintSelectedTextSeparately && selectionStart < selectionEnd) {
startOffset = selectionEnd;
endOffset = selectionStart;
}
// Where the text and its flow have opposite directions then our offset into // 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 // the text given by |truncation| is at the start of the part that will be
// visible. // visible.
if (m_inlineTextBox.truncation() != cNoTruncation && if (m_inlineTextBox.truncation() != cNoTruncation && ltr != flowIsLTR) {
m_inlineTextBox.getLineLayoutItem()
.containingBlock()
.style()
->isLeftToRightDirection() !=
m_inlineTextBox.isLeftToRightDirection()) {
startOffset = m_inlineTextBox.truncation(); startOffset = m_inlineTextBox.truncation();
endOffset = textRun.length(); endOffset = textRun.length();
} }
if (paintSelectedTextSeparately && selectionStart < selectionEnd) {
startOffset = selectionEnd;
endOffset = selectionStart;
}
// FIXME: This cache should probably ultimately be held somewhere else. // FIXME: This cache should probably ultimately be held somewhere else.
// A hashmap is convenient to avoid a memory hit when the // A hashmap is convenient to avoid a memory hit when the
// RuntimeEnabledFeature is off. // RuntimeEnabledFeature is off.
...@@ -945,11 +953,13 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, ...@@ -945,11 +953,13 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
bool flowIsLTR = bool flowIsLTR =
m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
if (m_inlineTextBox.truncation() != cNoTruncation) { if (m_inlineTextBox.truncation() != cNoTruncation) {
start = ltr == flowIsLTR ? m_inlineTextBox.start() // In a mixed-direction flow the ellipsis is at the start of the text
: m_inlineTextBox.truncation(); // so we need to start after it. Otherwise we just need to make sure
length = ltr == flowIsLTR // the end of the text is where the ellipsis starts.
? m_inlineTextBox.truncation() if (ltr != flowIsLTR)
: m_inlineTextBox.len() - m_inlineTextBox.truncation(); sPos = std::max<int>(sPos, m_inlineTextBox.truncation());
else
length = m_inlineTextBox.truncation();
} }
StringView string(m_inlineTextBox.getLineLayoutItem().text(), start, StringView string(m_inlineTextBox.getLineLayoutItem().text(), start,
static_cast<unsigned>(length)); static_cast<unsigned>(length));
...@@ -988,10 +998,12 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, ...@@ -988,10 +998,12 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
(boxRect.y() - deltaY).toFloat()); (boxRect.y() - deltaY).toFloat());
LayoutRect selectionRect = LayoutRect( LayoutRect selectionRect = LayoutRect(
font.selectionRectForText(textRun, localOrigin, selHeight, sPos, ePos)); font.selectionRectForText(textRun, localOrigin, selHeight, sPos, ePos));
if (m_inlineTextBox.hasWrappedSelectionNewline() // For line breaks, just painting a selection where the line break itself
// 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
// is rendered is sufficient. // there.
&& !m_inlineTextBox.isLineBreak()) if (m_inlineTextBox.hasWrappedSelectionNewline() &&
m_inlineTextBox.truncation() == cNoTruncation &&
!m_inlineTextBox.isLineBreak())
expandToIncludeNewlineForSelection(selectionRect); expandToIncludeNewlineForSelection(selectionRect);
// Line breaks report themselves as having zero width for layout purposes, // Line breaks report themselves as having zero width for layout purposes,
...@@ -1001,7 +1013,7 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, ...@@ -1001,7 +1013,7 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context,
if (!m_inlineTextBox.isLeftToRightDirection() && if (!m_inlineTextBox.isLeftToRightDirection() &&
m_inlineTextBox.isLineBreak()) m_inlineTextBox.isLineBreak())
selectionRect.move(-selectionRect.width(), LayoutUnit()); selectionRect.move(-selectionRect.width(), LayoutUnit());
if (!flowIsLTR && m_inlineTextBox.truncation() != cNoTruncation) if (!flowIsLTR && !ltr && m_inlineTextBox.truncation() != cNoTruncation)
selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(), selectionRect.move(m_inlineTextBox.logicalWidth() - selectionRect.width(),
LayoutUnit()); LayoutUnit());
...@@ -1038,8 +1050,9 @@ void InlineTextBoxPainter::paintDecorations( ...@@ -1038,8 +1050,9 @@ void InlineTextBoxPainter::paintDecorations(
bool flowIsLTR = bool flowIsLTR =
m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection(); m_inlineTextBox.getLineLayoutItem().style()->isLeftToRightDirection();
width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width( width = LayoutUnit(m_inlineTextBox.getLineLayoutItem().width(
ltr == flowIsLTR ? m_inlineTextBox.start() ltr == flowIsLTR
: m_inlineTextBox.truncation(), ? m_inlineTextBox.start()
: m_inlineTextBox.start() + m_inlineTextBox.truncation(),
ltr == flowIsLTR ? m_inlineTextBox.truncation() ltr == flowIsLTR ? m_inlineTextBox.truncation()
: m_inlineTextBox.len() - m_inlineTextBox.truncation(), : m_inlineTextBox.len() - m_inlineTextBox.truncation(),
m_inlineTextBox.textPos(), m_inlineTextBox.textPos(),
......
...@@ -36,7 +36,8 @@ TextPainter::TextPainter(GraphicsContext& context, ...@@ -36,7 +36,8 @@ TextPainter::TextPainter(GraphicsContext& context,
m_textBounds(textBounds), m_textBounds(textBounds),
m_horizontal(horizontal), m_horizontal(horizontal),
m_emphasisMarkOffset(0), m_emphasisMarkOffset(0),
m_combinedText(0) {} m_combinedText(0),
m_ellipsisOffset(0) {}
TextPainter::~TextPainter() {} TextPainter::~TextPainter() {}
...@@ -247,7 +248,7 @@ void TextPainter::paintInternal(unsigned startOffset, ...@@ -247,7 +248,7 @@ void TextPainter::paintInternal(unsigned startOffset,
paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset); paintInternalRun<Step>(textRunPaintInfo, startOffset, endOffset);
} else { } else {
if (endOffset > 0) if (endOffset > 0)
paintInternalRun<Step>(textRunPaintInfo, 0, endOffset); paintInternalRun<Step>(textRunPaintInfo, m_ellipsisOffset, endOffset);
if (startOffset < truncationPoint) if (startOffset < truncationPoint)
paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint); paintInternalRun<Step>(textRunPaintInfo, startOffset, truncationPoint);
} }
......
...@@ -47,6 +47,7 @@ class CORE_EXPORT TextPainter { ...@@ -47,6 +47,7 @@ class CORE_EXPORT TextPainter {
void setCombinedText(LayoutTextCombine* combinedText) { void setCombinedText(LayoutTextCombine* combinedText) {
m_combinedText = combinedText; m_combinedText = combinedText;
} }
void setEllipsisOffset(int offset) { m_ellipsisOffset = offset; }
static void updateGraphicsContext(GraphicsContext&, static void updateGraphicsContext(GraphicsContext&,
const Style&, const Style&,
...@@ -117,6 +118,7 @@ class CORE_EXPORT TextPainter { ...@@ -117,6 +118,7 @@ class CORE_EXPORT TextPainter {
AtomicString m_emphasisMark; AtomicString m_emphasisMark;
int m_emphasisMarkOffset; int m_emphasisMarkOffset;
LayoutTextCombine* m_combinedText; LayoutTextCombine* m_combinedText;
int m_ellipsisOffset;
}; };
inline AffineTransform TextPainter::rotation( inline AffineTransform TextPainter::rotation(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment