diff options
author | Andreas Kling <kling@serenityos.org> | 2022-10-04 18:57:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-04 21:30:58 +0200 |
commit | f5844b85ff93e087662e83a32dd9d0f478abf07b (patch) | |
tree | 7c71e3769d45482b9135174e07ee3875a8fc0ab4 /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | |
parent | 97ca45d9c6a6c54b174722a1ad8e84d47bf22402 (diff) | |
download | serenity-f5844b85ff93e087662e83a32dd9d0f478abf07b.zip |
LibWeb: Let FFC parent context "handle" sizing of child FFC container
When we have nested flexbox layouts within one another, and the child
context wants to call up to the parent context and ask for help with
dimensioning the child flex container, we now simply do nothing.
As far as I can tell, this works out just fine, since the child flex
container will already be dimensioned by the flex layout algorithm.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index cd34662c42..45b8b8af3d 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -768,12 +768,36 @@ float FlexFormattingContext::content_based_minimum_size(FlexItem const& item) co return unclamped_size; } +bool FlexFormattingContext::can_determine_size_of_child() const +{ + return true; +} + +void FlexFormattingContext::determine_width_of_child(Box const&, AvailableSpace const&) +{ + // NOTE: For now, we simply do nothing here. If a child context is calling up to us + // and asking us to determine its width, we've already done so as part of the + // flex layout algorithm. +} + +void FlexFormattingContext::determine_height_of_child(Box const&, AvailableSpace const&) +{ + // NOTE: For now, we simply do nothing here. If a child context is calling up to us + // and asking us to determine its height, we've already done so as part of the + // flex layout algorithm. +} + // https://drafts.csswg.org/css-flexbox-1/#algo-main-container void FlexFormattingContext::determine_main_size_of_flex_container() { // Determine the main size of the flex container using the rules of the formatting context in which it participates. // NOTE: The automatic block size of a block-level flex container is its max-content size. + // FIXME: The code below doesn't know how to size absolutely positioned flex containers at all. + // We just leave it alone for now and let the parent context deal with it. + if (flex_container().is_absolutely_positioned()) + return; + // FIXME: Once all parent contexts now how to size a given child, we can remove // `can_determine_size_of_child()`. if (parent()->can_determine_size_of_child()) { @@ -785,11 +809,6 @@ void FlexFormattingContext::determine_main_size_of_flex_container() return; } - // HACK: The hack below doesn't know how to size absolutely positioned flex containers at all. - // We just leave it alone for now and let the parent context deal with it. - if (flex_container().is_absolutely_positioned()) - return; - if (is_row_layout()) { if (!flex_container().is_out_of_flow(*parent()) && m_state.get(*flex_container().containing_block()).has_definite_width()) { set_main_size(flex_container(), calculate_stretch_fit_width(flex_container(), m_available_space_for_flex_container->space.width)); |