Commit a1ed9449 authored by Javier Fernández García-Boente's avatar Javier Fernández García-Boente Committed by Commit Bot

Use nullopt when the non-hangable-run-end is not applicable

The new trailing space logic refactoring, landed in r806928 and relanded
again in 807457, assigned the current offset as the non-hangable-run-end
when this is not applicable.

The root cause of this issue is that this offset must not exceed the
item s range-end, so that we clamp it to this range-end value. However,
since in some cases we use the original offset as the the
non-hangable-run-end, we may lead to a situation where the offset used
exceed the item's range end. This is precisely the DCHECK violation
described in the issue 1130288.

Since r808007 we have decided to use optional values for the
non-hangable-run-end, but we didn't update the implementation of the
PreviousBreakOpportunities and NextBreakOpportunities functions
accordingly.

Bug: 1130288
Change-Id: If5e5fb380320ca54f7a6d17d1c2bd020a643e12e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421728Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Cr-Commit-Position: refs/heads/master@{#809016}
parent 85808e15
...@@ -168,12 +168,10 @@ ShapingLineBreaker::PreviousBreakOpportunity(unsigned offset, ...@@ -168,12 +168,10 @@ ShapingLineBreaker::PreviousBreakOpportunity(unsigned offset,
// end of non-hangable character (i.e., start of the space run). // end of non-hangable character (i.e., start of the space run).
unsigned break_offset = unsigned break_offset =
break_iterator_->PreviousBreakOpportunity(offset, start); break_iterator_->PreviousBreakOpportunity(offset, start);
unsigned non_hangable_run_end = if (IsBreakableSpace(text[break_offset - 1]))
IsBreakableSpace(text[break_offset - 1]) return {break_offset, FindNonHangableEnd(text, break_offset - 1), false};
? FindNonHangableEnd(text, break_offset - 1)
: break_offset;
return {break_offset, non_hangable_run_end, false}; return {break_offset, false};
} }
ShapingLineBreaker::BreakOpportunity ShapingLineBreaker::NextBreakOpportunity( ShapingLineBreaker::BreakOpportunity ShapingLineBreaker::NextBreakOpportunity(
...@@ -196,12 +194,10 @@ ShapingLineBreaker::BreakOpportunity ShapingLineBreaker::NextBreakOpportunity( ...@@ -196,12 +194,10 @@ ShapingLineBreaker::BreakOpportunity ShapingLineBreaker::NextBreakOpportunity(
// end of non-hangable character (i.e., start of the space run), // end of non-hangable character (i.e., start of the space run),
// which may be useful to avoid reshaping. // which may be useful to avoid reshaping.
unsigned break_offset = break_iterator_->NextBreakOpportunity(offset, len); unsigned break_offset = break_iterator_->NextBreakOpportunity(offset, len);
unsigned non_hangable_run_end = if (IsBreakableSpace(text[break_offset - 1]))
IsBreakableSpace(text[break_offset - 1]) return {break_offset, FindNonHangableEnd(text, break_offset - 1), false};
? FindNonHangableEnd(text, break_offset - 1)
: break_offset;
return {break_offset, non_hangable_run_end, false}; return {break_offset, false};
} }
// Shapes a line of text by finding a valid and appropriate break opportunity // Shapes a line of text by finding a valid and appropriate break opportunity
......
<title>CSS Text Test: Under quirks mode, a white space, followed by a Cham symbol, makes chrome to crash</title>
<link rel="help" href="https://crbug.com/972992">
<style>
body { margin: 40 91 18446744073709551526px 5307% }
#tCF9 { line-break: anywhere; }
</style>
s a<custom-element-middle id=tCF9> <highlight>&#xaa2c;</highlight>
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