Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LayoutNG] Fix NGLineBreaker not to hang on negative margins #19660

Merged
merged 1 commit into from Oct 15, 2019

Conversation

chromium-wpt-export-bot
Copy link
Collaborator

@chromium-wpt-export-bot chromium-wpt-export-bot commented Oct 13, 2019

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}

Copy link
Collaborator

@wpt-pr-bot wpt-pr-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already reviewed downstream.

@chromium-wpt-export-bot chromium-wpt-export-bot force-pushed the chromium-export-cl-1849737 branch 3 times, most recently from 54aed8d to 3e51c98 Compare October 15, 2019 05:07
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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants