mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Reduce usage of Node::containing_block() in BFC
Explicitly pass containing block width in resolve_vertical_box_model_metrics() instead of doing containing block box lookup. This is a part of refactoring towards removing containing_block() usage that will allow us introduce partial layout.
This commit is contained in:
parent
676e54c397
commit
07d8ddb5fa
Notes:
github-actions[bot]
2024-11-11 19:21:51 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/07d8ddb5fa5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2285
3 changed files with 6 additions and 7 deletions
|
@ -651,7 +651,7 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
|||
if (is<ListItemMarkerBox>(box))
|
||||
return;
|
||||
|
||||
resolve_vertical_box_model_metrics(box);
|
||||
resolve_vertical_box_model_metrics(box, m_state.get(block_container).content_width());
|
||||
|
||||
if (box.is_floating()) {
|
||||
auto const y = m_y_offset_of_current_block_container.value();
|
||||
|
@ -848,11 +848,10 @@ void BlockFormattingContext::layout_block_level_children(BlockContainer const& b
|
|||
}
|
||||
}
|
||||
|
||||
void BlockFormattingContext::resolve_vertical_box_model_metrics(Box const& box)
|
||||
void BlockFormattingContext::resolve_vertical_box_model_metrics(Box const& box, CSSPixels width_of_containing_block)
|
||||
{
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
auto const& computed_values = box.computed_values();
|
||||
auto width_of_containing_block = containing_block_width_for(box);
|
||||
|
||||
box_state.margin_top = computed_values.margin().top().to_px(box, width_of_containing_block);
|
||||
box_state.margin_bottom = computed_values.margin().bottom().to_px(box, width_of_containing_block);
|
||||
|
@ -1006,14 +1005,14 @@ void BlockFormattingContext::layout_viewport(AvailableSpace const& available_spa
|
|||
}
|
||||
}
|
||||
|
||||
void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer const&, AvailableSpace const& available_space, CSSPixels y, LineBuilder* line_builder)
|
||||
void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer const& block_container, AvailableSpace const& available_space, CSSPixels y, LineBuilder* line_builder)
|
||||
{
|
||||
VERIFY(box.is_floating());
|
||||
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
auto const& computed_values = box.computed_values();
|
||||
|
||||
resolve_vertical_box_model_metrics(box);
|
||||
resolve_vertical_box_model_metrics(box, m_state.get(block_container).content_width());
|
||||
|
||||
compute_width(box, available_space);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
|
||||
void layout_block_level_box(Box const&, BlockContainer const&, CSSPixels& bottom_of_lowest_margin_box, AvailableSpace const&);
|
||||
|
||||
void resolve_vertical_box_model_metrics(Box const&);
|
||||
void resolve_vertical_box_model_metrics(Box const&, CSSPixels width_of_containing_block);
|
||||
|
||||
enum class DidIntroduceClearance {
|
||||
Yes,
|
||||
|
|
|
@ -46,7 +46,7 @@ CSSPixels TableFormattingContext::run_caption_layout(CSS::CaptionSide phase)
|
|||
auto const& child_box = static_cast<Box const&>(*child);
|
||||
// FIXME: Since caption only has inline children, BlockFormattingContext doesn't resolve the vertical metrics.
|
||||
// We need to do it manually here.
|
||||
caption_context->resolve_vertical_box_model_metrics(child_box);
|
||||
caption_context->resolve_vertical_box_model_metrics(child_box, m_available_space->width.to_px_or_zero());
|
||||
auto const& caption_state = m_state.get(child_box);
|
||||
if (phase == CSS::CaptionSide::Top) {
|
||||
m_state.get_mutable(table_box()).set_content_y(caption_state.content_height() + caption_state.margin_box_bottom());
|
||||
|
|
Loading…
Reference in a new issue