Fix flexbox baseline alignment#325
Conversation
1dc8683 to
ef8e73d
Compare
- Introduce LayoutAlgorithm trait
ef8e73d to
2cc99ee
Compare
|
This still doesn't implement baseline alignment for CSS Grid, but I now think I'd like to merge this without that to unblock #326. These changes (fixing baseline alignment for flexbox, and refactoring the flexbox implementation so that it doesn't require accessing the layout of descendant nodes other than direct children) are worthwhile on their own, and baseline alignment for CSS Grid can follow in another PR. |
src/compute/flexbox.rs
Outdated
|
|
||
| /// Computes the layout of [`LayoutTree`] according to the flexbox algorithm | ||
| pub fn compute( | ||
| pub fn compute_generic( |
There was a problem hiding this comment.
This name isn't very clear.
src/compute/grid/mod.rs
Outdated
| /// - Track (row/column) sizing | ||
| /// - Alignment & Final item placement | ||
| pub fn compute( | ||
| pub fn compute_generic( |
There was a problem hiding this comment.
Ditto on the name here.
|
|
||
| /// The public interface to a generic algorithm that abstracts over all of Taffy's algorithms | ||
| /// and applies the correct one based on the `Display` style | ||
| pub struct GenericAlgorithm; |
There was a problem hiding this comment.
Hmm. I'm not very happy with this naming / docs. Maybe something like UnifyingLayoutAlgorithm?
There was a problem hiding this comment.
This struct actually disappears in my latest version of #326, as I've made the "generic" algorithm and the "leaf" algorithm operate on &mut Taffy rather than &mut impl LayoutTree (so they don't fit the LayoutAlgorithm trait anymore). This allows us to remove measure_funcs from the LayoutTree trait and make them an implementation detail of our Taffy storage implementation.
There was a problem hiding this comment.
Good I'm fine to wait.
alice-i-cecile
left a comment
There was a problem hiding this comment.
Some feedback on structure and docs. I would like to get this merged quickly though, so feel free to defer some of the work (e.g. the trait refactor) to a follow-up PR.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
|
@alice-i-cecile I've renamed the Is there anything else blocking this? |
|
Nope, this now LGTM. |
Objective
Context
Note: This PR depends on #320 which in turn depends on #317both now merged!I did a quick run of the benchmarks vs.
mainto check for regressions, and actually I'm seeing mild performance wins (10% - 30% on some benchmarks) on quite a few of the benchmarks. There is also a ~10% regression on a couple, but those are the very smallest ones that are completing in single-digit microseconds anyway, so I'm not going to worry too much about those (we probably ought to remove those super small ones at some point - I don't think they're very representative of real-world performance).Feedback wanted
Does changing each algorithm's
perform_layoutfunction to return:instead of
Size<f32>as I have done in this PR seem reasonable? This is instead of the 3rd layout method proposed in #28 (comment)