mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 17:19:13 +00:00
LibWeb: Remove box
argument from FormattingContext::run()
Root formatting context box is passed into constructor and saved in FC, so it's possible to access it from there instead of passing the same box into run().
This commit is contained in:
parent
67981af276
commit
623e358d7a
Notes:
github-actions[bot]
2024-09-11 07:31:05 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 623e358d7a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1367
15 changed files with 37 additions and 41 deletions
|
@ -171,13 +171,13 @@ static bool is_container_element(Node const& node)
|
|||
return false;
|
||||
}
|
||||
|
||||
void SVGFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const& available_space)
|
||||
void SVGFormattingContext::run(LayoutMode, AvailableSpace const& available_space)
|
||||
{
|
||||
// NOTE: SVG doesn't have a "formatting context" in the spec, but this is the most
|
||||
// obvious way to drive SVG layout in our engine at the moment.
|
||||
|
||||
auto& svg_viewport = dynamic_cast<SVG::SVGViewport const&>(*box.dom_node());
|
||||
auto& svg_box_state = m_state.get_mutable(box);
|
||||
auto& svg_viewport = dynamic_cast<SVG::SVGViewport const&>(*context_box().dom_node());
|
||||
auto& svg_box_state = m_state.get_mutable(context_box());
|
||||
|
||||
// NOTE: We consider all SVG root elements to have definite size in both axes.
|
||||
// I'm not sure if this is good or bad, but our viewport transform logic depends on it.
|
||||
|
@ -254,7 +254,7 @@ void SVGFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const&
|
|||
m_svg_offset = svg_box_state.offset;
|
||||
m_viewport_size = { viewport_width, viewport_height };
|
||||
|
||||
box.for_each_child_of_type<Box>([&](Box const& child) {
|
||||
context_box().for_each_child_of_type<Box>([&](Box const& child) {
|
||||
layout_svg_element(child);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
@ -266,7 +266,7 @@ void SVGFormattingContext::layout_svg_element(Box const& child)
|
|||
layout_nested_viewport(child);
|
||||
} else if (is<SVG::SVGForeignObjectElement>(child.dom_node()) && is<BlockContainer>(child)) {
|
||||
Layout::BlockFormattingContext bfc(m_state, static_cast<BlockContainer const&>(child), this);
|
||||
bfc.run(child, LayoutMode::Normal, *m_available_space);
|
||||
bfc.run(LayoutMode::Normal, *m_available_space);
|
||||
auto& child_state = m_state.get_mutable(child);
|
||||
child_state.set_content_offset(child_state.offset.translated(m_svg_offset));
|
||||
child.for_each_child_of_type<SVGMaskBox>([&](SVGMaskBox const& child) {
|
||||
|
@ -301,7 +301,7 @@ void SVGFormattingContext::layout_nested_viewport(Box const& viewport)
|
|||
nested_viewport_state.set_content_height(nested_viewport_height);
|
||||
nested_viewport_state.set_has_definite_width(true);
|
||||
nested_viewport_state.set_has_definite_height(true);
|
||||
nested_context.run(static_cast<Box const&>(viewport), LayoutMode::Normal, *m_available_space);
|
||||
nested_context.run(LayoutMode::Normal, *m_available_space);
|
||||
}
|
||||
|
||||
Gfx::Path SVGFormattingContext::compute_path_for_text(SVGTextBox const& text_box)
|
||||
|
@ -459,7 +459,7 @@ void SVGFormattingContext::layout_mask_or_clip(SVGBox const& mask_or_clip)
|
|||
SVGFormattingContext nested_context(m_state, mask_or_clip, this, parent_viewbox_transform);
|
||||
layout_state.set_has_definite_width(true);
|
||||
layout_state.set_has_definite_height(true);
|
||||
nested_context.run(static_cast<Box const&>(mask_or_clip), LayoutMode::Normal, *m_available_space);
|
||||
nested_context.run(LayoutMode::Normal, *m_available_space);
|
||||
}
|
||||
|
||||
void SVGFormattingContext::layout_container_element(SVGBox const& container)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue