mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibWeb: Always resolve horizontal padding and borders on block-level boxes
We were neglecting to resolve the used horizontal padding and border properties on block-level boxes when treating their width as `auto` during intrinsic sizing. This led to padding and border not contributing to the intrinsic width of their containing block
This commit is contained in:
parent
4580e054f5
commit
27b63feae5
1 changed files with 11 additions and 11 deletions
|
@ -107,9 +107,6 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
|
||||
auto const& computed_values = box.computed_values();
|
||||
|
||||
if (should_treat_width_as_auto(box, available_space) && available_space.width.is_intrinsic_sizing_constraint())
|
||||
return;
|
||||
|
||||
float width_of_containing_block = available_space.width.to_px();
|
||||
auto width_of_containing_block_as_length_for_resolve = available_space.width.is_definite() ? CSS::Length::make_px(width_of_containing_block) : CSS::Length::make_px(0);
|
||||
|
||||
|
@ -117,8 +114,17 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
|
||||
auto margin_left = CSS::Length::make_auto();
|
||||
auto margin_right = CSS::Length::make_auto();
|
||||
auto padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
|
||||
auto padding_right = computed_values.padding().right().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
|
||||
auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
|
||||
auto const padding_right = computed_values.padding().right().resolved(box, width_of_containing_block_as_length_for_resolve).resolved(box);
|
||||
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
box_state.border_left = computed_values.border_left().width;
|
||||
box_state.border_right = computed_values.border_right().width;
|
||||
box_state.padding_left = padding_left.to_px(box);
|
||||
box_state.padding_right = padding_right.to_px(box);
|
||||
|
||||
if (should_treat_width_as_auto(box, available_space) && available_space.width.is_intrinsic_sizing_constraint())
|
||||
return;
|
||||
|
||||
auto try_compute_width = [&](auto const& a_width) {
|
||||
CSS::Length width = a_width;
|
||||
|
@ -203,17 +209,11 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const&
|
|||
}
|
||||
}
|
||||
|
||||
auto& box_state = m_state.get_mutable(box);
|
||||
|
||||
if (!is<ReplacedBox>(box) && !used_width.is_auto())
|
||||
box_state.set_content_width(used_width.to_px(box));
|
||||
|
||||
box_state.margin_left = margin_left.to_px(box);
|
||||
box_state.margin_right = margin_right.to_px(box);
|
||||
box_state.border_left = computed_values.border_left().width;
|
||||
box_state.border_right = computed_values.border_right().width;
|
||||
box_state.padding_left = padding_left.to_px(box);
|
||||
box_state.padding_right = padding_right.to_px(box);
|
||||
}
|
||||
|
||||
void BlockFormattingContext::compute_width_for_floating_box(Box const& box, AvailableSpace const& available_space)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue