diff --git a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 3729ae7fb98..05b18c5b7a8 100644 --- a/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -208,12 +208,14 @@ void BlockFormattingContext::compute_width(Box const& box, AvailableSpace const& auto zero_value = CSS::Length::make_px(0); - auto margin_left = CSS::Length::make_auto(); - auto margin_right = CSS::Length::make_auto(); + auto margin_left = computed_values.margin().left().resolved(box, width_of_containing_block); + auto margin_right = computed_values.margin().right().resolved(box, width_of_containing_block); auto const padding_left = computed_values.padding().left().resolved(box, width_of_containing_block).to_px(box); auto const padding_right = computed_values.padding().right().resolved(box, width_of_containing_block).to_px(box); auto& box_state = m_state.get_mutable(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; diff --git a/Tests/LibWeb/Layout/expected/bfc-fit-content-width-with-margin.txt b/Tests/LibWeb/Layout/expected/bfc-fit-content-width-with-margin.txt new file mode 100644 index 00000000000..a0a9c603b7a --- /dev/null +++ b/Tests/LibWeb/Layout/expected/bfc-fit-content-width-with-margin.txt @@ -0,0 +1,53 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x304 [BFC] children: not-inline + BlockContainer
at (8,8) content-size 784x288 children: not-inline + BlockContainer