1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

LibWeb: Keep track of the parent of each formatting context

This will allow us to find the containing block formatting context
when needed later on.
This commit is contained in:
Andreas Kling 2020-11-25 20:08:52 +01:00
parent 2f491e7769
commit b1e75437c9
9 changed files with 25 additions and 19 deletions

View file

@ -32,8 +32,9 @@
namespace Web::Layout {
FormattingContext::FormattingContext(Box& context_box)
: m_context_box(context_box)
FormattingContext::FormattingContext(Box& context_box, FormattingContext* parent)
: m_parent(parent)
, m_context_box(context_box)
{
}
@ -44,13 +45,13 @@ FormattingContext::~FormattingContext()
void FormattingContext::layout_inside(Box& box, LayoutMode layout_mode)
{
if (box.is_table()) {
TableFormattingContext context(box);
TableFormattingContext context(box, this);
context.run(layout_mode);
} else if (box.children_are_inline()) {
InlineFormattingContext context(box);
InlineFormattingContext context(box, this);
context.run(layout_mode);
} else {
BlockFormattingContext context(box);
BlockFormattingContext context(box, this);
context.run(layout_mode);
}
}