mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:07:44 +00:00
LibWeb: Make FFC line and item vectors members instead of locals
This gives all member functions access to these vectors without having to pass them as arguments.
This commit is contained in:
parent
c793797e61
commit
1580c59f39
2 changed files with 89 additions and 94 deletions
|
@ -10,9 +10,6 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
struct FlexItem;
|
||||
struct FlexLine;
|
||||
|
||||
class FlexFormattingContext final : public FormattingContext {
|
||||
public:
|
||||
FlexFormattingContext(Box& flex_container, FormattingContext* parent);
|
||||
|
@ -23,6 +20,38 @@ public:
|
|||
virtual void run(Box&, LayoutMode) override;
|
||||
|
||||
private:
|
||||
struct DirectionAgnosticMargins {
|
||||
float main_before { 0 };
|
||||
float main_after { 0 };
|
||||
float cross_before { 0 };
|
||||
float cross_after { 0 };
|
||||
};
|
||||
|
||||
struct FlexItem {
|
||||
Box& box;
|
||||
float flex_base_size { 0 };
|
||||
float hypothetical_main_size { 0 };
|
||||
float hypothetical_cross_size { 0 };
|
||||
float hypothetical_cross_size_with_margins() { return hypothetical_cross_size + margins.cross_before + margins.cross_after; }
|
||||
float target_main_size { 0 };
|
||||
bool frozen { false };
|
||||
Optional<float> flex_factor {};
|
||||
float scaled_flex_shrink_factor { 0 };
|
||||
float max_content_flex_fraction { 0 };
|
||||
float main_size { 0 };
|
||||
float cross_size { 0 };
|
||||
float main_offset { 0 };
|
||||
float cross_offset { 0 };
|
||||
DirectionAgnosticMargins margins {};
|
||||
bool is_min_violation { false };
|
||||
bool is_max_violation { false };
|
||||
};
|
||||
|
||||
struct FlexLine {
|
||||
Vector<FlexItem*> items;
|
||||
float cross_size { 0 };
|
||||
};
|
||||
|
||||
bool has_definite_main_size(Box const&) const;
|
||||
bool has_definite_cross_size(Box const&) const;
|
||||
float specified_main_size(Box const&) const;
|
||||
|
@ -49,7 +78,7 @@ private:
|
|||
void set_main_axis_first_margin(Box&, float margin);
|
||||
void set_main_axis_second_margin(Box&, float margin);
|
||||
|
||||
void generate_anonymous_flex_items(Box& flex_container, Vector<FlexItem>&);
|
||||
void generate_anonymous_flex_items(Box& flex_container);
|
||||
|
||||
struct AvailableSpace {
|
||||
float main { 0 };
|
||||
|
@ -60,28 +89,32 @@ private:
|
|||
float layout_for_maximum_main_size(Box&);
|
||||
void determine_flex_base_size_and_hypothetical_main_size(Box const& flex_container, FlexItem&);
|
||||
|
||||
void determine_main_size_of_flex_container(Box& flex_container, Vector<FlexItem>&, bool main_is_constrained, bool main_size_is_infinite, float& main_available_size, float main_min_size, float main_max_size);
|
||||
void determine_main_size_of_flex_container(Box& flex_container, bool main_is_constrained, bool main_size_is_infinite, float& main_available_size, float main_min_size, float main_max_size);
|
||||
|
||||
Vector<FlexLine> collect_flex_items_into_flex_lines(Box const& flex_container, Vector<FlexItem>&, float main_available_size);
|
||||
void collect_flex_items_into_flex_lines(Box const& flex_container, float main_available_size);
|
||||
|
||||
void resolve_flexible_lengths(Vector<FlexLine>&, float main_available_size);
|
||||
void resolve_flexible_lengths(float main_available_size);
|
||||
|
||||
float determine_hypothetical_cross_size_of_item(Box&);
|
||||
|
||||
void calculate_cross_size_of_each_flex_line(Box const& flex_container, Vector<FlexLine>&, float cross_min_size, float cross_max_size);
|
||||
void calculate_cross_size_of_each_flex_line(Box const& flex_container, float cross_min_size, float cross_max_size);
|
||||
|
||||
void determine_used_cross_size_of_each_flex_item(Box const& flex_container, Vector<FlexLine>&);
|
||||
void determine_used_cross_size_of_each_flex_item(Box const& flex_container);
|
||||
|
||||
void distribute_any_remaining_free_space(Box const& flex_container, Vector<FlexLine>&, float main_available_size);
|
||||
void distribute_any_remaining_free_space(Box const& flex_container, float main_available_size);
|
||||
|
||||
void align_all_flex_items_along_the_cross_axis(Box const& flex_container, Vector<FlexLine>&);
|
||||
void align_all_flex_items_along_the_cross_axis(Box const& flex_container);
|
||||
|
||||
void determine_flex_container_used_cross_size(Box& flex_container, Vector<FlexLine> const&, float cross_min_size, float cross_max_size);
|
||||
void determine_flex_container_used_cross_size(Box& flex_container, float cross_min_size, float cross_max_size);
|
||||
|
||||
void align_all_flex_lines(Vector<FlexLine>&);
|
||||
void align_all_flex_lines();
|
||||
|
||||
bool is_row_layout() const { return m_flex_direction == CSS::FlexDirection::Row || m_flex_direction == CSS::FlexDirection::RowReverse; }
|
||||
|
||||
void populate_specified_margins(FlexItem&, CSS::FlexDirection) const;
|
||||
|
||||
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