|
@@ -553,23 +553,20 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
|
|
|
m_margin_state.reset();
|
|
|
}
|
|
|
|
|
|
- CSSPixels margin_top = 0;
|
|
|
auto independent_formatting_context = create_independent_formatting_context_if_needed(m_state, box);
|
|
|
|
|
|
+ m_margin_state.add_margin(box_state.margin_top);
|
|
|
+ m_margin_state.update_block_waiting_for_final_y_position();
|
|
|
+ CSSPixels margin_top = m_margin_state.current_collapsed_margin();
|
|
|
+
|
|
|
+ if (m_margin_state.has_block_container_waiting_for_final_y_position()) {
|
|
|
+ // If first child margin top will collapse with margin-top of containing block then margin-top of child is 0
|
|
|
+ margin_top = 0;
|
|
|
+ }
|
|
|
+
|
|
|
if (independent_formatting_context) {
|
|
|
// Margins of elements that establish new formatting contexts do not collapse with their in-flow children
|
|
|
m_margin_state.reset();
|
|
|
-
|
|
|
- margin_top = box_state.margin_top;
|
|
|
- } else {
|
|
|
- m_margin_state.add_margin(box_state.margin_top);
|
|
|
- m_margin_state.update_block_waiting_for_final_y_position();
|
|
|
-
|
|
|
- margin_top = m_margin_state.current_collapsed_margin();
|
|
|
- if (m_margin_state.has_block_container_waiting_for_final_y_position()) {
|
|
|
- // If first child margin top will collapse with margin-top of containing block then margin-top of child is 0
|
|
|
- margin_top = 0;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
place_block_level_element_in_normal_flow_vertically(box, y + margin_top);
|