Closed Bug 1783934 Opened 2 years ago Closed 2 years ago

Add a way to incrementally migrate -moz-box layout to modern flexbox

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: emilio, Assigned: emilio)

References

Details

Attachments

(1 file)

We have layout.css.emulate-moz-box-with-flex, which is ultimately a one-off switch to replace all of legacy box layout with flexbox-based layout.

Recently, I've come across various broken XUL / block interactions that wouldn't be broken if they were Flex / block interactions. See the "see also" field for some examples that I believe this would fix.

These bugs are really annoying to workaround, but we're nowhere close to ship layout.css.emulate-moz-box-with-flex all at once. However, I think we could take incremental steps towards that.

So, what do y'all think about an inherited -moz-box-layout: legacy | flex property, that allows us to toggle legacy / flex based layout on a per-subtree basis?

The idea would be to start using it where possible, and eventually probably switch the default value to "flex". That hopefully provides a path towards removing legacy XUL incrementally.

cc'ing / ni'ing some potentially interested parties for feedback, but I'll try to take a look at this next week unless someone thinks it's a bad idea for some reason.

Flags: needinfo?(gijskruitbosch+bugs)
Flags: needinfo?(dao+bmo)
Flags: needinfo?(bgrinstead)
Flags: needinfo?(emilio)
Depends on: 1783940
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Flags: needinfo?(emilio)

Do we have a reasonable way of querying for nodes that use either model once we introduce this? I'm a bit worried about that given it's CSS based and the markup will be elsewhere. Without an automated querying/replacement system I'm nervous that this step:

The idea would be to start using it where possible, and eventually probably switch the default value to "flex".

Is going to not be very feasible until we get very close to finishing this. Or am I missing something obvious here?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(emilio)

(In reply to :Gijs (he/him) from comment #2)

Do we have a reasonable way of querying for nodes that use either model once we introduce this? I'm a bit worried about that given it's CSS based and the markup will be elsewhere.

Can you elaborate? It should show up in devtools like other properties. We could expose this in getComputedStyle or via WebIDL to chrome code or so if needed, though it's a bit unclear in why would it be needed, because ideally the models are not that different. In practice the differences I'm aware of are:

  • The new "flex" model interacts better with other HTML layout modes (like block / etc).
  • The old model looks not only at CSS but also XUL "flex" attributes.

Other than those, for the most part they should behave equivalently.

Without an automated querying/replacement system I'm nervous that this step:

The idea would be to start using it where possible, and eventually probably switch the default value to "flex".

Is going to not be very feasible until we get very close to finishing this. Or am I missing something obvious here?

I think that's right, but I guess I'm not sure how that's necessarily related to the querying?

Flags: needinfo?(emilio) → needinfo?(gijskruitbosch+bugs)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/449fe2d946ea
Add a chrome-only -moz-box-layout: legacy | flex, and use that to implement flexbox emulation. r=dholbert

Backed out changeset 449fe2d946ea (Bug 1783934) for causing mochitest failures on test_animation-type-longhand.html.
Backout link
Push with failures <--> c1
Failure Log
Also 5 Failure Log

Flags: needinfo?(emilio)

Grr, I swear I thought I had uploaded the version with the fix for that test, but apparently I had not...

Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/23c5d9491a56
Add a chrome-only -moz-box-layout: legacy | flex, and use that to implement flexbox emulation. r=dholbert
Pushed by emilio@crisal.io:
https://hg.mozilla.org/integration/autoland/rev/b9d5a4b375f6
Fix newly introduced test to actually flex the item.
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch

(In reply to Emilio Cobos Álvarez (:emilio) from comment #3)

(In reply to :Gijs (he/him) from comment #2)

Do we have a reasonable way of querying for nodes that use either model once we introduce this? I'm a bit worried about that given it's CSS based and the markup will be elsewhere.

Can you elaborate? It should show up in devtools like other properties. We could expose this in getComputedStyle or via WebIDL to chrome code or so if needed, though it's a bit unclear in why would it be needed, because ideally the models are not that different. In practice the differences I'm aware of are:

  • The new "flex" model interacts better with other HTML layout modes (like block / etc).
  • The old model looks not only at CSS but also XUL "flex" attributes.

Other than those, for the most part they should behave equivalently.

Without an automated querying/replacement system I'm nervous that this step:

The idea would be to start using it where possible, and eventually probably switch the default value to "flex".

Is going to not be very feasible until we get very close to finishing this. Or am I missing something obvious here?

I think that's right, but I guess I'm not sure how that's necessarily related to the querying?

Well, if there was a straightforward way of automatically finding (querying for) instances of using the non-default model in the source tree, that would make it easier to make a switch like this? We could automatically transform such nodes - e.g. if we had an opt-in attribute for the new model, we could remove those once we switch to that model by default, and/or add new opt-out attributes for things that need to keep using the old model for the moment. It would also help in terms of assessing where to focus QA effort when making these changes.

I don't think that manually auditing via devtools scales for the size of our project - even just browser/ has some 80 HTML markup files we'd need to open and then check with devtools...

Does that make more sense of my concern?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(emilio)

I see. Sure, when switching the behavior of something like that, what we've done in the past is adding assertions before landing (and ensuring they're not hit on automation by fixing the relevant styles). Bug 1580012 is an example of that. Doing such thing should be feasible here to make sure we're not changing behavior. Does that alleviate your concern?

Flags: needinfo?(emilio) → needinfo?(gijskruitbosch+bugs)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #11)

I see. Sure, when switching the behavior of something like that, what we've done in the past is adding assertions before landing (and ensuring they're not hit on automation by fixing the relevant styles). Bug 1580012 is an example of that. Doing such thing should be feasible here to make sure we're not changing behavior. Does that alleviate your concern?

Yeah, that helps. I think we'll still miss things because some parts of Firefox are, let's say, better-tested than others... but automation should be enough for the 95% cases.

Flags: needinfo?(gijskruitbosch+bugs)
Blocks: 1784265
Blocks: 1784349

I'm late to the party, but yeah this was / is a good idea. :)

Flags: needinfo?(dao+bmo)
Flags: needinfo?(bgrinstead)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: