forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. :^)
- Loading branch information
1 parent
9c05639
commit 561612f
Showing
14 changed files
with
50 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2020-2021, Andreas Kling <[email protected]> | ||
* Copyright (c) 2020-2022, Andreas Kling <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -19,10 +19,11 @@ | |
|
||
namespace Web::Layout { | ||
|
||
FormattingContext::FormattingContext(Type type, Box& context_box, FormattingContext* parent) | ||
FormattingContext::FormattingContext(Type type, FormattingState& state, Box& context_box, FormattingContext* parent) | ||
: m_type(type) | ||
, m_parent(parent) | ||
, m_context_box(context_box) | ||
, m_state(state) | ||
{ | ||
} | ||
|
||
|
@@ -82,20 +83,20 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte | |
auto child_display = child_box.computed_values().display(); | ||
|
||
if (is<SVGSVGBox>(child_box)) | ||
return make<SVGFormattingContext>(child_box, this); | ||
return make<SVGFormattingContext>(m_state, child_box, this); | ||
|
||
if (child_display.is_flex_inside()) | ||
return make<FlexFormattingContext>(child_box, this); | ||
return make<FlexFormattingContext>(m_state, child_box, this); | ||
|
||
if (creates_block_formatting_context(child_box)) | ||
return make<BlockFormattingContext>(verify_cast<BlockContainer>(child_box), this); | ||
return make<BlockFormattingContext>(m_state, verify_cast<BlockContainer>(child_box), this); | ||
|
||
if (child_display.is_table_inside()) | ||
return make<TableFormattingContext>(verify_cast<TableBox>(child_box), this); | ||
return make<TableFormattingContext>(m_state, verify_cast<TableBox>(child_box), this); | ||
|
||
VERIFY(is_block_formatting_context()); | ||
if (child_box.children_are_inline()) | ||
return make<InlineFormattingContext>(verify_cast<BlockContainer>(child_box), static_cast<BlockFormattingContext&>(*this)); | ||
return make<InlineFormattingContext>(m_state, verify_cast<BlockContainer>(child_box), static_cast<BlockFormattingContext&>(*this)); | ||
|
||
// The child box is a block container that doesn't create its own BFC. | ||
// It will be formatted by this BFC. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2020, Andreas Kling <[email protected]> | ||
* Copyright (c) 2020-2022, Andreas Kling <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
@@ -8,6 +8,7 @@ | |
|
||
#include <AK/OwnPtr.h> | ||
#include <LibWeb/Forward.h> | ||
#include <LibWeb/Layout/FormattingState.h> | ||
|
||
namespace Web::Layout { | ||
|
||
|
@@ -46,7 +47,7 @@ class FormattingContext { | |
virtual void parent_context_did_dimension_child_root_box() { } | ||
|
||
protected: | ||
FormattingContext(Type, Box&, FormattingContext* parent = nullptr); | ||
FormattingContext(Type, FormattingState&, Box&, FormattingContext* parent = nullptr); | ||
|
||
OwnPtr<FormattingContext> layout_inside(Box&, LayoutMode); | ||
|
||
|
@@ -77,6 +78,8 @@ class FormattingContext { | |
|
||
FormattingContext* m_parent { nullptr }; | ||
Box& m_context_box; | ||
|
||
FormattingState& m_state; | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2022, Andreas Kling <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace Web::Layout { | ||
|
||
struct FormattingState { | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters