mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibWeb: Start making our layout system "transactional"
This patch adds a map of Layout::Node to FormattingState::NodeState. Instead of updating layout nodes incrementally as layout progresses through the formatting contexts, all updates are now written to the corresponding NodeState instead. At the end of layout, FormattingState::commit() is called, which transfers all the values from the NodeState objects to the Node. This will soon allow us to perform completely non-destructive layouts which don't affect the tree. Note that there are many imperfections here, and still many places where we assign to the NodeState, but later read directly from the Node instead. I'm just committing at this stage to make subsequent diffs easier to understand.
This commit is contained in:
parent
561612f219
commit
c9700e100e
27 changed files with 754 additions and 571 deletions
|
@ -13,14 +13,13 @@ namespace Web::Layout {
|
|||
|
||||
class FlexFormattingContext final : public FormattingContext {
|
||||
public:
|
||||
FlexFormattingContext(FormattingState&, Box& flex_container, FormattingContext* parent);
|
||||
FlexFormattingContext(FormattingState&, Box const& flex_container, FormattingContext* parent);
|
||||
~FlexFormattingContext();
|
||||
|
||||
virtual bool inhibits_floating() const override { return true; }
|
||||
|
||||
virtual void run(Box&, LayoutMode) override;
|
||||
virtual void run(Box const&, LayoutMode) override;
|
||||
|
||||
Box& flex_container() { return context_box(); }
|
||||
Box const& flex_container() const { return context_box(); }
|
||||
|
||||
private:
|
||||
|
@ -76,11 +75,11 @@ private:
|
|||
bool has_cross_max_size(Box const&) const;
|
||||
float sum_of_margin_padding_border_in_main_axis(Box const&) const;
|
||||
|
||||
void set_main_size(Box&, float size);
|
||||
void set_cross_size(Box&, float size);
|
||||
void set_offset(Box&, float main_offset, float cross_offset);
|
||||
void set_main_axis_first_margin(Box&, float margin);
|
||||
void set_main_axis_second_margin(Box&, float margin);
|
||||
void set_main_size(Box const&, float size);
|
||||
void set_cross_size(Box const&, float size);
|
||||
void set_offset(Box const&, float main_offset, float cross_offset);
|
||||
void set_main_axis_first_margin(Box const&, float margin);
|
||||
void set_main_axis_second_margin(Box const&, float margin);
|
||||
|
||||
void generate_anonymous_flex_items();
|
||||
|
||||
|
@ -90,7 +89,7 @@ private:
|
|||
};
|
||||
AvailableSpace determine_available_main_and_cross_space(bool& main_size_is_infinite, bool& main_is_constrained, bool& cross_is_constrained, float& main_min_size, float& main_max_size, float& cross_min_size, float& cross_max_size) const;
|
||||
|
||||
float layout_for_maximum_main_size(Box&);
|
||||
float layout_for_maximum_main_size(Box const&);
|
||||
void determine_flex_base_size_and_hypothetical_main_size(FlexItem&);
|
||||
|
||||
void determine_main_size_of_flex_container(bool main_is_constrained, bool main_size_is_infinite, float& main_available_size, float main_min_size, float main_max_size);
|
||||
|
@ -99,7 +98,7 @@ private:
|
|||
|
||||
void resolve_flexible_lengths(float main_available_size);
|
||||
|
||||
float determine_hypothetical_cross_size_of_item(Box&);
|
||||
float determine_hypothetical_cross_size_of_item(Box const&);
|
||||
|
||||
void calculate_cross_size_of_each_flex_line(float cross_min_size, float cross_max_size);
|
||||
|
||||
|
@ -118,6 +117,8 @@ private:
|
|||
|
||||
void populate_specified_margins(FlexItem&, CSS::FlexDirection) const;
|
||||
|
||||
FormattingState::NodeState& m_flex_container_state;
|
||||
|
||||
Vector<FlexLine> m_flex_lines;
|
||||
Vector<FlexItem> m_flex_items;
|
||||
CSS::FlexDirection m_flex_direction {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue