1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 22:25:07 +00:00

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.
This commit is contained in:
Andreas Kling 2022-06-21 20:40:26 +02:00
parent 85f2f8ab3f
commit 967b257518

View file

@ -14,6 +14,7 @@
#include <LibWeb/Layout/Box.h> #include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/FlexFormattingContext.h> #include <LibWeb/Layout/FlexFormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h> #include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/TextNode.h> #include <LibWeb/Layout/TextNode.h>
namespace Web::Layout { 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 // 3. Determine the flex base size and hypothetical main size of each item
for (auto& flex_item : m_flex_items) { 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); determine_flex_base_size_and_hypothetical_main_size(flex_item);
} }