소스 검색

LibWeb: Layout inner floats/abspos boxes after laying out the top float

Calling parent_context_did_dimension_child_root_box immediately after
laying out the inside of the floating box is not correct, as we haven't
worked out the dimensions of the floating box yet.

In particular, this caused the icons in the top bar of Cookie Clicker
to not hug the top of the viewport. This is because the icons are
absolutely positioned elements inside a floating element which has
padding applied to it. Since we laid out the abspos element before
the floating element, it got padding values of 0 from the parent, the
default value, meaning it didn't take away the padding of it's floating
parent.

This follows how abspos boxes layout their inside boxes as well.
Luke Wilde 2 년 전
부모
커밋
488a979
1개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 4 2
      Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp

+ 4 - 2
Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp

@@ -556,8 +556,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
     float width_of_containing_block = available_space.width.to_px();
 
     compute_width(box, available_space, layout_mode);
-    if (auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space)))
-        independent_formatting_context->parent_context_did_dimension_child_root_box();
+    auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space));
     compute_height(box, available_space);
 
     // First we place the box normally (to get the right y coordinate.)
@@ -674,6 +673,9 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
 
     if (line_builder)
         line_builder->recalculate_available_space();
+
+    if (independent_formatting_context)
+        independent_formatting_context->parent_context_did_dimension_child_root_box();
 }
 
 void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_item_box)