diff options
Diffstat (limited to 'Libraries/LibWeb/Layout/LayoutDocument.cpp')
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutDocument.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index e49807e82f..8dd4f2db2c 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -29,6 +29,7 @@ #include <LibWeb/Layout/LayoutDocument.h> #include <LibWeb/Layout/LayoutImage.h> #include <LibWeb/Layout/LayoutWidget.h> +#include <LibWeb/Layout/StackingContext.h> namespace Web { @@ -41,8 +42,31 @@ LayoutDocument::~LayoutDocument() { } +void LayoutDocument::build_stacking_context_tree() +{ + if (stacking_context()) + return; + + set_stacking_context(make<StackingContext>(*this, nullptr)); + + for_each_in_subtree_of_type<LayoutBox>([&](LayoutBox& box) { + if (&box == this) + return IterationDecision::Continue; + if (!box.establishes_stacking_context()) { + ASSERT(!box.stacking_context()); + return IterationDecision::Continue; + } + auto* parent_context = box.enclosing_stacking_context(); + ASSERT(parent_context); + box.set_stacking_context(make<StackingContext>(box, parent_context)); + return IterationDecision::Continue; + }); +} + void LayoutDocument::layout(LayoutMode layout_mode) { + build_stacking_context_tree(); + set_width(frame().size().width()); LayoutNode::layout(layout_mode); @@ -76,4 +100,9 @@ void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect& a_v }); } +void LayoutDocument::render(RenderingContext& context) +{ + stacking_context()->render(context); +} + } |