mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 18:37:58 +03:00
LibWeb: Pass state to create_independent_formatting_context_if_needed()
Instead of using the current m_state implicitly, make this function take a FormattingState&. This will allow us to use it for throwaway layouts.
This commit is contained in:
parent
ffbd630ca6
commit
726edd2d3b
Notes:
sideshowbarker
2024-07-17 18:07:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/726edd2d3b
@ -391,7 +391,7 @@ void BlockFormattingContext::layout_block_level_children(BlockContainer const& b
|
||||
|
||||
OwnPtr<FormattingContext> independent_formatting_context;
|
||||
if (child_box.can_have_children()) {
|
||||
independent_formatting_context = create_independent_formatting_context_if_needed(child_box);
|
||||
independent_formatting_context = create_independent_formatting_context_if_needed(m_state, child_box);
|
||||
if (independent_formatting_context)
|
||||
independent_formatting_context->run(child_box, layout_mode);
|
||||
else
|
||||
|
@ -75,7 +75,7 @@ bool FormattingContext::creates_block_formatting_context(const Box& box)
|
||||
return false;
|
||||
}
|
||||
|
||||
OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_context_if_needed(Box const& child_box)
|
||||
OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_context_if_needed(FormattingState& state, Box const& child_box)
|
||||
{
|
||||
if (!child_box.can_have_children())
|
||||
return {};
|
||||
@ -83,20 +83,20 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
||||
auto child_display = child_box.computed_values().display();
|
||||
|
||||
if (is<SVGSVGBox>(child_box))
|
||||
return make<SVGFormattingContext>(m_state, child_box, this);
|
||||
return make<SVGFormattingContext>(state, child_box, this);
|
||||
|
||||
if (child_display.is_flex_inside())
|
||||
return make<FlexFormattingContext>(m_state, child_box, this);
|
||||
return make<FlexFormattingContext>(state, child_box, this);
|
||||
|
||||
if (creates_block_formatting_context(child_box))
|
||||
return make<BlockFormattingContext>(m_state, verify_cast<BlockContainer>(child_box), this);
|
||||
return make<BlockFormattingContext>(state, verify_cast<BlockContainer>(child_box), this);
|
||||
|
||||
if (child_display.is_table_inside())
|
||||
return make<TableFormattingContext>(m_state, verify_cast<TableBox>(child_box), this);
|
||||
return make<TableFormattingContext>(state, verify_cast<TableBox>(child_box), this);
|
||||
|
||||
VERIFY(is_block_formatting_context());
|
||||
if (child_box.children_are_inline())
|
||||
return make<InlineFormattingContext>(m_state, verify_cast<BlockContainer>(child_box), static_cast<BlockFormattingContext&>(*this));
|
||||
return make<InlineFormattingContext>(state, verify_cast<BlockContainer>(child_box), static_cast<BlockFormattingContext&>(*this));
|
||||
|
||||
// The child box is a block container that doesn't create its own BFC.
|
||||
// It will be formatted by this BFC.
|
||||
@ -112,7 +112,7 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
||||
}
|
||||
virtual void run(Box const&, LayoutMode) override { }
|
||||
};
|
||||
return make<DummyFormattingContext>(m_state, child_box);
|
||||
return make<DummyFormattingContext>(state, child_box);
|
||||
}
|
||||
VERIFY(child_box.is_block_container());
|
||||
VERIFY(child_display.is_flow_inside());
|
||||
@ -124,7 +124,7 @@ OwnPtr<FormattingContext> FormattingContext::layout_inside(Box const& child_box,
|
||||
if (!child_box.can_have_children())
|
||||
return {};
|
||||
|
||||
auto independent_formatting_context = create_independent_formatting_context_if_needed(child_box);
|
||||
auto independent_formatting_context = create_independent_formatting_context_if_needed(m_state, child_box);
|
||||
if (independent_formatting_context)
|
||||
independent_formatting_context->run(child_box, layout_mode);
|
||||
else
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
static float compute_width_for_replaced_element(FormattingState const&, ReplacedBox const&);
|
||||
static float compute_height_for_replaced_element(FormattingState const&, ReplacedBox const&);
|
||||
|
||||
OwnPtr<FormattingContext> create_independent_formatting_context_if_needed(Box const& child_box);
|
||||
OwnPtr<FormattingContext> create_independent_formatting_context_if_needed(FormattingState&, Box const& child_box);
|
||||
|
||||
virtual void parent_context_did_dimension_child_root_box() { }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user