Explorar o código

LibWeb: Make FFC prepare replaced child boxes for layout

Before we ask a replaced box about its intrinsic dimensions, we have
to "prepare" the box, which tells it to go and work out what its
intrinsic dimensions are.

I've added a FIXME about how this is silly (and clearly bug-prone)
but this patch only patches it locally in FFC for now.
Andreas Kling %!s(int64=3) %!d(string=hai) anos
pai
achega
967b257518
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp

+ 5 - 0
Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp

@@ -14,6 +14,7 @@
 #include <LibWeb/Layout/Box.h>
 #include <LibWeb/Layout/FlexFormattingContext.h>
 #include <LibWeb/Layout/InitialContainingBlock.h>
+#include <LibWeb/Layout/ReplacedBox.h>
 #include <LibWeb/Layout/TextNode.h>
 
 namespace Web::Layout {
@@ -70,6 +71,10 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode layout_mode)
 
     // 3. Determine the flex base size and hypothetical main size of each item
     for (auto& flex_item : m_flex_items) {
+        if (flex_item.box.is_replaced_box()) {
+            // FIXME: Get rid of prepare_for_replaced_layout() and make replaced elements figure out their intrinsic size lazily.
+            static_cast<ReplacedBox&>(flex_item.box).prepare_for_replaced_layout();
+        }
         determine_flex_base_size_and_hypothetical_main_size(flex_item);
     }