mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibWeb: Reorganize layout algorithms around available space
This is a big and messy change, and here's the gist: - AvaliableSpace is now 2x AvailableSize (width and height) - Layout algorithms are redesigned around the idea of available space - When doing layout across nested formatting contexts, the parent context tells the child context how much space is available for the child's root box in both axes. - "Available space" replaces "containing block width" in most places. - The width and height in a box's UsedValues are considered to be definite after they're assigned to. Marking something as having definite size is no longer a separate step, This probably introduces various regressions, but the big win here is that our layout system now works with available space, just like the specs are written. Fixing issues will be much easier going forward, since you don't need to do nearly as much conversion from "spec logic" to "LibWeb logic" as you previously did.
This commit is contained in:
@@ -17,7 +17,7 @@ GridFormattingContext::GridFormattingContext(LayoutState& state, BlockContainer
|
||||
|
||||
GridFormattingContext::~GridFormattingContext() = default;
|
||||
|
||||
void GridFormattingContext::run(Box const& box, LayoutMode, [[maybe_unused]] AvailableSpace const& available_width, [[maybe_unused]] AvailableSpace const& available_height)
|
||||
void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const& available_space)
|
||||
{
|
||||
auto should_skip_is_anonymous_text_run = [&](Box& child_box) -> bool {
|
||||
if (child_box.is_anonymous() && !child_box.first_child_of_type<BlockContainer>()) {
|
||||
@@ -374,7 +374,8 @@ void GridFormattingContext::run(Box const& box, LayoutMode, [[maybe_unused]] Ava
|
||||
auto& child_box_state = m_state.get_mutable(positioned_box.box);
|
||||
if (child_box_state.content_height() > positioned_box.computed_height)
|
||||
positioned_box.computed_height = child_box_state.content_height();
|
||||
(void)layout_inside(positioned_box.box, LayoutMode::Normal);
|
||||
if (auto independent_formatting_context = layout_inside(positioned_box.box, LayoutMode::Normal, available_space))
|
||||
independent_formatting_context->parent_context_did_dimension_child_root_box();
|
||||
if (child_box_state.content_height() > positioned_box.computed_height)
|
||||
positioned_box.computed_height = child_box_state.content_height();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user