Commit 54f63b81 authored by Alexander Pisarev's avatar Alexander Pisarev Committed by Commit Bot

Fix line clamp ellipsis with enough free space.

There is a special case in line clamp logic when a line has enough free space at the end. In this situation, a line has no truncation but still has an ellipsis. But all other logic didn't count on it.
This false assumption of truncation for ellipsis was removed from the code.

And fix braces in if's for 2+ lines bodies to be able to commit it.

Bug: 788141
Change-Id: I06893d47533031f79c610bd6f5258f7359f541f5
Reviewed-on: https://chromium-review.googlesource.com/787590Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Emil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523219}
parent a03ca60d
<!DOCTYPE html>
<head>
<title>Test to check that ellipsis in free space is moving with text.</title>
<style>
#text {
width: 80px;
margin: 0 auto;
}
h2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
</head>
<body>
<div id="main" style="width: 500px">
<div id="place" style="width: 200px">
<div id="text">
<h2>test1 test2 test3</h2>
</div>
</div>
</div>
</script>
</body>
</html>
<!DOCTYPE html>
<head>
<title>Test to check that ellipsis in free space is moving with text.</title>
<style>
#text {
width: 80px;
margin: 0 auto;
}
h2 {
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
</head>
<body onload="run()">
<script src="../../resources/run-after-layout-and-paint.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsTextWithPixelResults();
testRunner.waitUntilDone();
}
function run() {
var place = document.getElementById('place');
runAfterLayoutAndPaint(function() {
place.setAttribute("style","width: 200px");
}, true);
}
</script>
<div id="main" style="width: 500px">
<div id="place" style="width: 100px">
<div id="text">
<h2>test1 test2 test3</h2>
</div>
</div>
</div>
</body>
</html>
...@@ -2229,11 +2229,9 @@ void LayoutText::InvalidateDisplayItemClients( ...@@ -2229,11 +2229,9 @@ void LayoutText::InvalidateDisplayItemClients(
for (InlineTextBox* box : InlineTextBoxesOf(*this)) { for (InlineTextBox* box : InlineTextBoxesOf(*this)) {
paint_invalidator.InvalidateDisplayItemClient(*box, invalidation_reason); paint_invalidator.InvalidateDisplayItemClient(*box, invalidation_reason);
if (box->Truncation() != kCNoTruncation) { if (EllipsisBox* ellipsis_box = box->Root().GetEllipsisBox()) {
if (EllipsisBox* ellipsis_box = box->Root().GetEllipsisBox()) { paint_invalidator.InvalidateDisplayItemClient(*ellipsis_box,
paint_invalidator.InvalidateDisplayItemClient(*ellipsis_box, invalidation_reason);
invalidation_reason);
}
} }
} }
} }
......
...@@ -226,8 +226,7 @@ SelectionState InlineTextBox::GetSelectionState() const { ...@@ -226,8 +226,7 @@ SelectionState InlineTextBox::GetSelectionState() const {
} }
// If there are ellipsis following, make sure their selection is updated. // If there are ellipsis following, make sure their selection is updated.
if (truncation_ != kCNoTruncation && Root().GetEllipsisBox()) { if (EllipsisBox* ellipsis = Root().GetEllipsisBox()) {
EllipsisBox* ellipsis = Root().GetEllipsisBox();
if (state != SelectionState::kNone) { if (state != SelectionState::kNone) {
int start, end; int start, end;
SelectionStartEnd(start, end); SelectionStartEnd(start, end);
......
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