[LayoutNG] Fix NGLineBreaker not to hang on negative margins #19660
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes a case where |NGLineBreaker| loops
infinitely when there is a negative margin. The case was a
regression by r701601 (crrev.com/c/1826063).
Handling combinations of a) trailable items, b) empty spans,
and c) negative margins together is becoming more complex as
we fix issues. This patch revises how we handle them.
One of the complexities is open tags being ambiguous; e.g.,
this open tag is not trailable and thus breaks before it:
<span>text
but these open tags are trailable:
<span> text
<span></span>text
<span> </span>text
and it can even nest more, contain floating/out-of-flow
objects, or have negative margins.
Before this patch, |NGLineBreaker| tries to stop as early as
possible, rewind, and consume trailable items. The last part
(consuming trailable items) is scarly because rewind loops
can occur if we try to rewind again.
The new approach is to try to consume possibly trailable
items before it rewinds, and avoids consuming after rewind.
There might be cases where the new approach consumes more,
but
blink_perf.layout
is neutral:https://pinpoint-dot-chromeperf.appspot.com/job/11fdf216c20000
In the test, case 2 and 5 fail in legacy, because the legacy
behavior is based on a bug (crbug.com/979894) or the new
behavior makes more sense, and the new behavior is
interoperable with Edge/Gecko.
Note, this change should be able to eliminate |kTrailable|
state, and that eliminate consuming after rewind completely,
but we still need it in a few places. It is for future
patches to clean them up.
Bug: 1011816
Change-Id: Ic915a26f1ee570ebe999ffbeee680659dcbd9789
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849737
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705844}