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

Fix several problems related to flex-direction: column #2231

Merged
merged 17 commits into from
Aug 24, 2024

Conversation

dhdaines
Copy link
Contributor

@dhdaines dhdaines commented Aug 17, 2024

Fixes: #2222 with the following crucial fixes:

  • Due to an unfortunate programming error (probably copy-and-paste gone awry) the left and right margins were being used to calculate the used main size of items even when the main axis was vertical e8ef883
  • Flex lines were being calculated using available main size rather than the actual (inner) main size of the flex container bfeefa4
  • Flex item cross sizes were being incorrectly calculated, at least for the case where said flex items are themselves flex containers, because this is done using block_level_layout_switch, which in turn calls back into flex_layout, which clobbers any width or height attributes (which would represent the used main size of the item) in the call to resolve_percentages(parent_box, containing_box) in step 3. ce6253f

Also fixes: #1171 with the following fix:

  • percentage sizes for flex items were being computed relative to the parent of the flex container for some reason (flex containers, like block containers, form a containing block). also the computed sizes were not actually being used for definite cross sizes. also cross width (i.e. with flex-direction: column) of 'auto' was being treated as 'min-content' for some reason 4771c35

Adds a huge amount of commenting and tracing which should aid in the refactoring of the flexbox code.

Note however that said code is definitely not correct. Most importantly it is not clear (even in the spec) where the inner and outer main sizes are used for flex items, and the code also doesn't do this consistently, so there will be some issues where flex items have definite size or definite flex-basis. We can add more tests... the code coverage is not good!

@dhdaines
Copy link
Contributor Author

dhdaines commented Aug 17, 2024

If this is okay for the moment, I would like to do a separate PR to refactor flex_layout given that it is well over a thousand lines long and by design should be decomposed into individual steps. I don't think it necessarily needs to be rewritten given that it follows the algorithm in the spec pretty closely, it's just that many parts of the algorithm are incompletely or incorrectly implemented and need to be unit tested (which can't be done in the current monolithic state of the code).

@dhdaines
Copy link
Contributor Author

I fixed #1171 here too (it was not the same issue). I'll stop there for now :)

@liZe
Copy link
Member

liZe commented Aug 24, 2024

Thanks a lot for this PR! ❤️

I’ll change some little things (mainly remove the debug messages, as explained in #2220) and merge this PR soon!

The level been added to avoid debug messages that were not used before. This
will be handled differently in a future commit.
Even if it could be useful for print()-based debugging sessions, it gives
different results depending on the id field presence, and is actually
useless when using a debugger and unrelated to Kozea#2231.

Let’s use a debugger!
@liZe liZe added the bug Existing features not working as expected label Aug 24, 2024
@liZe liZe added this to the 63.0 milestone Aug 24, 2024
@liZe liZe merged commit b08110f into Kozea:main Aug 24, 2024
6 checks passed
@dhdaines
Copy link
Contributor Author

Thanks a lot for this PR! ❤️

I’ll change some little things (mainly remove the debug messages, as explained in #2220) and merge this PR soon!

Thank you! I was going to do that myself eventually but I was on vacation last week. I'll make sure to keep them out of future PRs (perhaps in a separate local branch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
2 participants