-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
layout: Refactor box size computation #34671
Conversation
🔨 Triggering try run (#12379836631) for Linux WPT |
Test results for linux-wpt-layout-2020 from try job (#12379836631): Flaky unexpected result (24)
Stable unexpected results that are known to be intermittent (14)
Stable unexpected results (46)
|
|
c3c6875
to
ddef0a3
Compare
🤖 Opened new upstream WPT pull request (web-platform-tests/wpt#49748) with upstreamable changes. |
🔨 Triggering try run (#12383519621) for Linux WPT |
📝 Transplanted new upstreamable changes to existing upstream WPT pull request (web-platform-tests/wpt#49748). |
Test results for linux-wpt-layout-2020 from try job (#12383519621): Flaky unexpected result (21)
Stable unexpected results that are known to be intermittent (12)
|
✨ Try run (#12383519621) succeeded. |
Why do the It feels like the interface between layout algorithms is getting quite big. |
What code are you referring to, exactly? This isn't passing any new data, it's just reorganizing a few places that had 3 The data that is passed to the child is typically a |
LogicalVec2 { | ||
inline: Size::Numeric(inline_size), | ||
block: block_size.non_auto().map_or(Size::Initial, Size::Numeric), | ||
}, | ||
flex_axis | ||
.vec2_to_flow_relative(self.content_min_size) | ||
.map(|size| Size::Numeric(*size)), | ||
flex_axis | ||
.vec2_to_flow_relative(self.content_max_size) | ||
.map(|size| size.map_or(Size::Initial, Size::Numeric)), | ||
&Sizes::new( | ||
block_size.non_auto().map_or(Size::Initial, Size::Numeric), | ||
Size::Numeric(min_size.block), | ||
max_size.block.map_or(Size::Initial, Size::Numeric), | ||
), | ||
&Sizes::new( | ||
Size::Numeric(inline_size), | ||
Size::Numeric(min_size.inline), | ||
max_size.inline.map_or(Size::Initial, Size::Numeric), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Loirooriol I'm referring to things like this code. Does the replaced box not know it's own min-
and max-
sizes?
I realise this isn't introduced in this PR. But I was just wondering whether we could eliminate these parameters entirely so that we don't need a new type to cut down on the boilerplate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, yes, that's what used_size_as_if_inline_element()
does: it takes the computed values from the style and resolves them with the containing block.
In this case flexbox is using used_size_as_if_inline_element_from_content_box_sizes
which is like a lower-level API. I think the reasons were that it already has the data (so no need to resolve percentages again and such) and also to handle automatic minimums, which are typically zero but not in flexbox.
That said I still haven't implemented sizing keywords for flexbox so this may need to change a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the reasons were that it already has the data (so no need to resolve percentages again and such) and also to handle automatic minimums, which are typically zero but not in flexbox.
I think I'd be more inclined to keep the interface simple here as I feel like the performance gains are probably quite minor. But I we sort this out (either way) later :)
in each layout logic, in order to correctly resolve sizing keywords. This patch adds a new `Sizes` struct which holds the preferred, min and max sizing values for one axis, and unifies the logic to resolve the final size into there. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
ddef0a3
to
fbcd6ee
Compare
🤖 This change no longer contains upstreamable changes to WPT; closed existing upstream pull request (web-platform-tests/wpt#49748). |
{"fail_fast": false, "matrix": [{"name": "WebGPU CTS", "workflow": "linux", "wpt_layout": "2020", "profile": "production", "unit_tests": false, "bencher": false, "wpt_args": "_webgpu"}]}
#32853 has been adding quite a bit of boilerplate that keeps repeating in each layout logic, in order to correctly resolve sizing keywords.
This patch adds a new
Sizes
struct which holds the preferred, min and max sizing values for one axis, and unifies the logic to resolve the final size into there../mach build -d
does not report any errors./mach test-tidy
does not report any errors