Nothing Special   »   [go: up one dir, main page]

Page MenuHomePhabricator

Bug 1731541 - Implement text-wrap: balance for nsBlockFrame reflow. r=#layout-reviewers
ClosedPublic

Authored by jfkthame on Sep 6 2023, 10:29 AM.
Referenced Files
Unknown Object (File)
Tue, Oct 15, 7:31 PM
Unknown Object (File)
Tue, Oct 15, 7:31 PM
Unknown Object (File)
Tue, Oct 15, 7:31 PM
Unknown Object (File)
Tue, Oct 15, 7:31 PM
Unknown Object (File)
Tue, Oct 15, 4:26 PM
Unknown Object (File)
Mon, Oct 14, 6:39 AM
Unknown Object (File)
Thu, Oct 10, 4:07 AM
Unknown Object (File)
Thu, Oct 10, 4:07 AM

Details

Summary

A simple form of balance for short blocks, implemented by incrementally reducing
the effective inline-size used during line-breaking, up to the point where an
extra line would be created.

This fails the test text-wrap-balance-line-clamp-001.html, but it's unclear to me
if that test is correct (see https://github.com/w3c/csswg-drafts/issues/9310).
If we do want the behavior expected by that test, an additional patch to handle
the interaction with line-clamp will be required.

Depends on D187543

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable
Build Status
Buildable 582660
Build 680605: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
phab-bot changed the visibility from "Custom Policy" to "Public (No Login Required)".
phab-bot changed the edit policy from "Custom Policy" to "Restricted Project (Project)".
phab-bot removed a project: secure-revision.
emilio requested changes to this revision.Sep 6 2023, 10:53 AM

It seems tests are clearly lacking here, as anything with a float would have revealed the destructor issue right? Can we make sure various edge cases are tested?

layout/generic/nsBlockFrame.cpp
1850

This leaks (at best), as BlockReflowState has float arrays and what not. You need to destroy it first using state.~BlockReflowState().

But that's actually not enough because that would lose all the state that has been modified until now like ReflowPushedFloats etc, right?

Also, what about the OverflowTracker etc?

layout/generic/nsLineLayout.cpp
199

This kinda feels like a text-indent right? I wonder if we could reuse more of the text-indent code somehow. But no big deal if not I guess.

modules/libpref/init/StaticPrefList.yaml
8783

How does this compare with Blink's / WebKit's limit out of curiosity?

This revision now requires changes to proceed.Sep 6 2023, 10:53 AM

Code analysis found 3 defects in diff 760543:

  • 3 defects found by clang-tidy
WARNING: Found 3 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 760543.

It seems tests are clearly lacking here, as anything with a float would have revealed the destructor issue right? Can we make sure various edge cases are tested?

Yeah, there are only a few very simple tests at the moment, we should add some more coverage.

layout/generic/nsBlockFrame.cpp
1850

Yeah, clearly this is too simplistic; will look into it.

layout/generic/nsLineLayout.cpp
199

Yes and no.... it's like an indent in that it'll affect how much more content can go on the line, but unlike an indent, it doesn't affect the space within which inline-alignment will happen. Because of that difference, I don't think we can merge them.

modules/libpref/init/StaticPrefList.yaml
8783

I'm seeing a limit of 4 in current Chrome release, increasing to 6 in Canary.
The current WebKit PR at https://github.com/WebKit/WebKit/pull/16502 doesn't impose a limit, but that's an unreviewed PR so we'll see what happens...

jfkthame updated this revision to Diff 762346.
jfkthame edited the summary of this revision. (Show Details)

Updated to work with floats (example: https://codepen.io/jfkthame/pen/MWZJZOE). I'll put together some WPT reftests in a following patch.

Code analysis found 5 defects in diff 762346:

  • 5 defects found by clang-tidy

3 defects unresolved compared to the previous diff 760543.

WARNING: Found 5 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 762346.

A couple minor fixes incoming...

jfkthame updated this revision to Diff 763033.
jfkthame updated this revision to Diff 763225.
jfkthame edited the summary of this revision. (Show Details)
emilio requested changes to this revision.Sep 22 2023, 2:00 PM
emilio added a project: testing-approved.

Looks good with those comments fixed and the mutable reflowinput stuff cleaned up. I'll try to send a patch later today for that.

layout/generic/nsBlockFrame.cpp
1432

This is fine, but we should probably just use a single ReflowInput thing. Given some of this is D181857, what about just fixing that patch? I think we might find pagination regressions otherwise.

1968

Presumably it's intentional that we don't PopState here, right? Maybe worth a comment.

layout/generic/nsBlockFrame.h
542

I was very confused about this. The comment seems to be for TrialReflow, right? Also it seems to reference aInset which is not a thing. Mind fixing the doc?

This revision now requires changes to proceed.Sep 22 2023, 2:00 PM
jfkthame added inline comments.
layout/generic/nsBlockFrame.h
542

Yeah, sorry - the comment dates from a much earlier version, before the state record existed - will fix!

jfkthame updated this revision to Diff 767141.
jfkthame edited the summary of this revision. (Show Details)
jfkthame marked an inline comment as done.

Rebase, update comments

jfkthame edited the summary of this revision. (Show Details)

Code analysis found 5 defects in diff 767143:

  • 5 defects found by clang-tidy
WARNING: Found 5 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 767143.

emilio removed a reviewer: layout-reviewers.
emilio added inline comments.
layout/generic/nsBlockFrame.cpp
1531

clang-tidy is right: Just make the pref signed, or make countLinesUpTo work in terms of unsigned?

1811

Hmmm... Do you know why this is? Shouldn't it be enough to mark the first line as dirty and let the rest flow through?

This revision is now accepted and ready to land.Sep 26 2023, 2:13 PM
layout/generic/nsBlockFrame.cpp
1811

When we adjust the amount of inset being applied, this might not cause any change to the first line, so then we'd conclude that no more reflowing is needed. But there may be lines later in the block that *do* need to be affected by the changed inset.

Code analysis found 2 defects in diff 768777:

  • 2 defects found by clang-tidy

2 defects unresolved and 3 defects closed compared to the previous diff 767143.

WARNING: Found 2 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 768777.

This revision is now accepted and ready to land.Sep 28 2023, 9:13 AM

Code analysis found 2 defects in diff 769154:

  • 2 defects found by clang-tidy
WARNING: Found 2 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 769154.

This revision is now accepted and ready to land.Sep 28 2023, 8:52 PM

Code analysis found 2 defects in diff 769511:

  • 2 defects found by clang-tidy
WARNING: Found 2 defects (warning level) that can be dismissed.

You can run this analysis locally with:

  • ./mach static-analysis check --outgoing (C/C++)

If you see a problem in this automated review, please report it here.

You can view these defects in the Diff Detail section of Phabricator diff 769511.