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

LibWeb: Add Layout::FormattingState

The purpose of this new object will be to keep track of various states
during an ongoing layout.

Until now, we've been updating layout tree nodes as we go during layout,
which adds an invisible layer of implicit serialization to the whole
layout system.

My idea with FormattingState is that running layout will produce a
result entirely contained within the FormattingState object. At the end
of layout, it can then be applied to the layout tree, or simply queried
for some metrics we were trying to determine.

When doing subtree layouts to determine intrinsic sizes, we will
eventually be able to clone the current FormattingState, and run the
subtree layout in isolation, opening up opportunities for parallelism.

This first patch doesn't go very far though, it merely adds the object
as a skeleton class, and makes sure the root BFC has one. :^)
This commit is contained in:
Andreas Kling 2022-02-19 20:13:47 +01:00
parent 9c05639d35
commit 561612f219
14 changed files with 50 additions and 31 deletions

View file

@ -18,8 +18,8 @@
namespace Web::Layout {
BlockFormattingContext::BlockFormattingContext(BlockContainer& root, FormattingContext* parent)
: FormattingContext(Type::Block, root, parent)
BlockFormattingContext::BlockFormattingContext(FormattingState& state, BlockContainer& root, FormattingContext* parent)
: FormattingContext(Type::Block, state, root, parent)
{
}
@ -382,7 +382,7 @@ void BlockFormattingContext::layout_inline_children(BlockContainer& block_contai
{
VERIFY(block_container.children_are_inline());
InlineFormattingContext context(block_container, *this);
InlineFormattingContext context(m_state, block_container, *this);
context.run(block_container, layout_mode);
}