| 
									
										
										
										
											2022-02-19 20:13:47 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2022, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2022-02-19 20:13:47 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | #include <AK/HashMap.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-09 14:00:10 +02:00
										 |  |  | #include <LibGfx/Path.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | #include <LibGfx/Point.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-21 11:22:08 +01:00
										 |  |  | #include <LibWeb/Layout/Box.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | #include <LibWeb/Layout/LineBox.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-10 23:13:37 +01:00
										 |  |  | #include <LibWeb/Painting/PaintableBox.h>
 | 
					
						
							| 
									
										
										
										
											2023-10-29 19:11:46 +00:00
										 |  |  | #include <LibWeb/Painting/SVGGraphicsPaintable.h>
 | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-19 20:13:47 +01:00
										 |  |  | namespace Web::Layout { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-09 15:17:47 +02:00
										 |  |  | enum class SizeConstraint { | 
					
						
							|  |  |  |     None, | 
					
						
							|  |  |  |     MinContent, | 
					
						
							|  |  |  |     MaxContent, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 15:29:17 +02:00
										 |  |  | class AvailableSize; | 
					
						
							|  |  |  | class AvailableSpace; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-10 19:02:03 +02:00
										 |  |  | // https://www.w3.org/TR/css-position-3/#static-position-rectangle
 | 
					
						
							|  |  |  | struct StaticPositionRect { | 
					
						
							|  |  |  |     enum class Alignment { | 
					
						
							|  |  |  |         Start, | 
					
						
							|  |  |  |         Center, | 
					
						
							|  |  |  |         End, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CSSPixelRect rect; | 
					
						
							|  |  |  |     Alignment horizontal_alignment { Alignment::Start }; | 
					
						
							|  |  |  |     Alignment vertical_alignment { Alignment::Start }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CSSPixelPoint aligned_position_for_box_with_size(CSSPixelSize const& size) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         CSSPixelPoint position = rect.location(); | 
					
						
							|  |  |  |         if (horizontal_alignment == Alignment::Center) | 
					
						
							|  |  |  |             position.set_x(position.x() + (rect.width() - size.width()) / 2); | 
					
						
							|  |  |  |         else if (horizontal_alignment == Alignment::End) | 
					
						
							|  |  |  |             position.set_x(position.x() + rect.width() - size.width()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (vertical_alignment == Alignment::Center) | 
					
						
							|  |  |  |             position.set_y(position.y() + (rect.height() - size.height()) / 2); | 
					
						
							|  |  |  |         else if (vertical_alignment == Alignment::End) | 
					
						
							|  |  |  |             position.set_y(position.y() + rect.height() - size.height()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return position; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:30:32 +02:00
										 |  |  | struct LayoutState { | 
					
						
							|  |  |  |     LayoutState() | 
					
						
							| 
									
										
										
										
											2022-03-18 12:31:26 +01:00
										 |  |  |         : m_root(*this) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 07:47:37 +02:00
										 |  |  |     explicit LayoutState(LayoutState const* parent); | 
					
						
							|  |  |  |     ~LayoutState(); | 
					
						
							| 
									
										
										
										
											2022-03-18 12:31:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:30:32 +02:00
										 |  |  |     LayoutState const& find_root() const | 
					
						
							| 
									
										
										
										
											2022-03-12 16:33:11 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-07-16 23:30:32 +02:00
										 |  |  |         LayoutState const* root = this; | 
					
						
							| 
									
										
										
										
											2022-03-18 12:31:26 +01:00
										 |  |  |         for (auto* state = m_parent; state; state = state->m_parent) | 
					
						
							|  |  |  |             root = state; | 
					
						
							|  |  |  |         return *root; | 
					
						
							| 
									
										
										
										
											2022-03-12 16:33:11 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:43:48 +02:00
										 |  |  |     struct UsedValues { | 
					
						
							| 
									
										
										
										
											2023-09-04 12:24:48 +02:00
										 |  |  |         NodeWithStyle const& node() const { return *m_node; } | 
					
						
							|  |  |  |         void set_node(NodeWithStyle&, UsedValues const* containing_block_used_values); | 
					
						
							| 
									
										
										
										
											2022-07-11 17:12:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-17 11:23:33 +01:00
										 |  |  |         UsedValues const* containing_block_used_values() const { return m_containing_block_used_values; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels content_width() const { return m_content_width; } | 
					
						
							|  |  |  |         CSSPixels content_height() const { return m_content_height; } | 
					
						
							|  |  |  |         void set_content_width(CSSPixels); | 
					
						
							|  |  |  |         void set_content_height(CSSPixels); | 
					
						
							| 
									
										
										
										
											2022-07-17 17:59:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-27 14:12:05 +02:00
										 |  |  |         void set_indefinite_content_width(); | 
					
						
							|  |  |  |         void set_indefinite_content_height(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-29 15:35:02 +01:00
										 |  |  |         void set_has_definite_width(bool has_definite_width) { m_has_definite_width = has_definite_width; } | 
					
						
							|  |  |  |         void set_has_definite_height(bool has_definite_height) { m_has_definite_height = has_definite_height; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-15 09:26:30 +02:00
										 |  |  |         // NOTE: These are used by FlexFormattingContext to assign a temporary main size to items
 | 
					
						
							|  |  |  |         //       early on, so that descendants have something to resolve percentages against.
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         void set_temporary_content_width(CSSPixels); | 
					
						
							|  |  |  |         void set_temporary_content_height(CSSPixels); | 
					
						
							| 
									
										
										
										
											2022-10-15 09:26:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-17 18:46:38 +02:00
										 |  |  |         bool has_definite_width() const { return m_has_definite_width && width_constraint == SizeConstraint::None; } | 
					
						
							|  |  |  |         bool has_definite_height() const { return m_has_definite_height && height_constraint == SizeConstraint::None; } | 
					
						
							| 
									
										
										
										
											2022-09-27 15:29:17 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Returns the available space for content inside this layout box.
 | 
					
						
							|  |  |  |         // If the space in an axis is indefinite, and the outer space is an intrinsic sizing constraint,
 | 
					
						
							|  |  |  |         // the constraint is used in that axis instead.
 | 
					
						
							|  |  |  |         AvailableSpace available_inner_space_or_constraints_from(AvailableSpace const& outer_space) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         void set_content_offset(CSSPixelPoint); | 
					
						
							|  |  |  |         void set_content_x(CSSPixels); | 
					
						
							|  |  |  |         void set_content_y(CSSPixels); | 
					
						
							| 
									
										
										
										
											2022-07-17 18:46:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixelPoint offset; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-09 15:17:47 +02:00
										 |  |  |         SizeConstraint width_constraint { SizeConstraint::None }; | 
					
						
							|  |  |  |         SizeConstraint height_constraint { SizeConstraint::None }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels margin_left { 0 }; | 
					
						
							|  |  |  |         CSSPixels margin_right { 0 }; | 
					
						
							|  |  |  |         CSSPixels margin_top { 0 }; | 
					
						
							|  |  |  |         CSSPixels margin_bottom { 0 }; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels border_left { 0 }; | 
					
						
							|  |  |  |         CSSPixels border_right { 0 }; | 
					
						
							|  |  |  |         CSSPixels border_top { 0 }; | 
					
						
							|  |  |  |         CSSPixels border_bottom { 0 }; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels padding_left { 0 }; | 
					
						
							|  |  |  |         CSSPixels padding_right { 0 }; | 
					
						
							|  |  |  |         CSSPixels padding_top { 0 }; | 
					
						
							|  |  |  |         CSSPixels padding_bottom { 0 }; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels inset_left { 0 }; | 
					
						
							|  |  |  |         CSSPixels inset_right { 0 }; | 
					
						
							|  |  |  |         CSSPixels inset_top { 0 }; | 
					
						
							|  |  |  |         CSSPixels inset_bottom { 0 }; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         Vector<LineBox> line_boxes; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-07 05:31:54 +00:00
										 |  |  |         CSSPixels margin_box_left() const { return margin_left + border_left_collapsed() + padding_left; } | 
					
						
							|  |  |  |         CSSPixels margin_box_right() const { return margin_right + border_right_collapsed() + padding_right; } | 
					
						
							|  |  |  |         CSSPixels margin_box_top() const { return margin_top + border_top_collapsed() + padding_top; } | 
					
						
							|  |  |  |         CSSPixels margin_box_bottom() const { return margin_bottom + border_bottom_collapsed() + padding_bottom; } | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels margin_box_width() const { return margin_box_left() + content_width() + margin_box_right(); } | 
					
						
							|  |  |  |         CSSPixels margin_box_height() const { return margin_box_top() + content_height() + margin_box_bottom(); } | 
					
						
							| 
									
										
										
										
											2022-03-24 18:06:45 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-07 05:31:54 +00:00
										 |  |  |         CSSPixels border_box_left() const { return border_left_collapsed() + padding_left; } | 
					
						
							|  |  |  |         CSSPixels border_box_right() const { return border_right_collapsed() + padding_right; } | 
					
						
							|  |  |  |         CSSPixels border_box_top() const { return border_top_collapsed() + padding_top; } | 
					
						
							|  |  |  |         CSSPixels border_box_bottom() const { return border_bottom_collapsed() + padding_bottom; } | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels border_box_width() const { return border_box_left() + content_width() + border_box_right(); } | 
					
						
							|  |  |  |         CSSPixels border_box_height() const { return border_box_top() + content_height() + border_box_bottom(); } | 
					
						
							| 
									
										
										
										
											2022-02-21 11:22:08 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-28 12:41:23 +01:00
										 |  |  |         Optional<LineBoxFragmentCoordinate> containing_line_box_fragment; | 
					
						
							| 
									
										
										
										
											2022-07-17 17:59:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-09 23:56:55 +02:00
										 |  |  |         void add_floating_descendant(Box const& box) { m_floating_descendants.set(&box); } | 
					
						
							|  |  |  |         auto const& floating_descendants() const { return m_floating_descendants; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-12 04:20:37 +00:00
										 |  |  |         void set_override_borders_data(Painting::PaintableBox::BordersDataWithElementKind const& override_borders_data) { m_override_borders_data = override_borders_data; } | 
					
						
							| 
									
										
										
										
											2023-06-04 14:21:20 +00:00
										 |  |  |         auto const& override_borders_data() const { return m_override_borders_data; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-01 02:58:11 +00:00
										 |  |  |         void set_table_cell_coordinates(Painting::PaintableBox::TableCellCoordinates const& table_cell_coordinates) { m_table_cell_coordinates = table_cell_coordinates; } | 
					
						
							|  |  |  |         auto const& table_cell_coordinates() const { return m_table_cell_coordinates; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-09 14:00:10 +02:00
										 |  |  |         void set_computed_svg_path(Gfx::Path const& svg_path) { m_computed_svg_path = svg_path; } | 
					
						
							| 
									
										
										
										
											2023-10-29 19:11:46 +00:00
										 |  |  |         auto& computed_svg_path() { return m_computed_svg_path; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         void set_computed_svg_transforms(Painting::SVGGraphicsPaintable::ComputedTransforms const& computed_transforms) { m_computed_svg_transforms = computed_transforms; } | 
					
						
							|  |  |  |         auto const& computed_svg_transforms() const { return m_computed_svg_transforms; } | 
					
						
							| 
									
										
										
										
											2023-10-29 17:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-09 12:15:49 +02:00
										 |  |  |         void set_grid_template_columns(RefPtr<CSS::GridTrackSizeListStyleValue> used_values_for_grid_template_columns) { m_grid_template_columns = move(used_values_for_grid_template_columns); } | 
					
						
							|  |  |  |         auto const& grid_template_columns() const { return m_grid_template_columns; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         void set_grid_template_rows(RefPtr<CSS::GridTrackSizeListStyleValue> used_values_for_grid_template_rows) { m_grid_template_rows = move(used_values_for_grid_template_rows); } | 
					
						
							|  |  |  |         auto const& grid_template_rows() const { return m_grid_template_rows; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-10 19:02:03 +02:00
										 |  |  |         void set_static_position_rect(StaticPositionRect const& static_position_rect) { m_static_position_rect = static_position_rect; } | 
					
						
							|  |  |  |         CSSPixelPoint static_position() const | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             CSSPixelSize size; | 
					
						
							|  |  |  |             size.set_width(content_width() + padding_left + padding_right + border_left + border_right + margin_left + margin_right); | 
					
						
							|  |  |  |             size.set_height(content_height() + padding_top + padding_bottom + border_top + border_bottom + margin_top + margin_bottom); | 
					
						
							|  |  |  |             return m_static_position_rect->aligned_position_for_box_with_size(size); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-17 17:59:02 +02:00
										 |  |  |     private: | 
					
						
							| 
									
										
										
										
											2022-09-27 15:29:17 +02:00
										 |  |  |         AvailableSize available_width_inside() const; | 
					
						
							|  |  |  |         AvailableSize available_height_inside() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-07 05:31:54 +00:00
										 |  |  |         bool use_collapsing_borders_model() const { return m_override_borders_data.has_value(); } | 
					
						
							|  |  |  |         // Implement the collapsing border model https://www.w3.org/TR/CSS22/tables.html#collapsing-borders.
 | 
					
						
							|  |  |  |         CSSPixels border_left_collapsed() const { return use_collapsing_borders_model() ? round(border_left / 2) : border_left; } | 
					
						
							|  |  |  |         CSSPixels border_right_collapsed() const { return use_collapsing_borders_model() ? round(border_right / 2) : border_right; } | 
					
						
							|  |  |  |         CSSPixels border_top_collapsed() const { return use_collapsing_borders_model() ? round(border_top / 2) : border_top; } | 
					
						
							|  |  |  |         CSSPixels border_bottom_collapsed() const { return use_collapsing_borders_model() ? round(border_bottom / 2) : border_bottom; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |         GC::Ptr<Layout::NodeWithStyle> m_node { nullptr }; | 
					
						
							| 
									
										
										
										
											2024-01-17 11:23:33 +01:00
										 |  |  |         UsedValues const* m_containing_block_used_values { nullptr }; | 
					
						
							| 
									
										
										
										
											2022-07-17 18:46:38 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         CSSPixels m_content_width { 0 }; | 
					
						
							|  |  |  |         CSSPixels m_content_height { 0 }; | 
					
						
							| 
									
										
										
										
											2022-07-17 18:46:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         bool m_has_definite_width { false }; | 
					
						
							|  |  |  |         bool m_has_definite_height { false }; | 
					
						
							| 
									
										
										
										
											2022-09-09 23:56:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |         HashTable<GC::Ptr<Box const>> m_floating_descendants; | 
					
						
							| 
									
										
										
										
											2023-06-04 14:21:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-12 04:20:37 +00:00
										 |  |  |         Optional<Painting::PaintableBox::BordersDataWithElementKind> m_override_borders_data; | 
					
						
							| 
									
										
										
										
											2023-07-01 02:58:11 +00:00
										 |  |  |         Optional<Painting::PaintableBox::TableCellCoordinates> m_table_cell_coordinates; | 
					
						
							| 
									
										
										
										
											2023-10-29 17:08:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-09 14:00:10 +02:00
										 |  |  |         Optional<Gfx::Path> m_computed_svg_path; | 
					
						
							| 
									
										
										
										
											2023-10-29 19:11:46 +00:00
										 |  |  |         Optional<Painting::SVGGraphicsPaintable::ComputedTransforms> m_computed_svg_transforms; | 
					
						
							| 
									
										
										
										
											2024-09-09 12:15:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         RefPtr<CSS::GridTrackSizeListStyleValue> m_grid_template_columns; | 
					
						
							|  |  |  |         RefPtr<CSS::GridTrackSizeListStyleValue> m_grid_template_rows; | 
					
						
							| 
									
										
										
										
											2024-09-10 19:02:03 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         Optional<StaticPositionRect> m_static_position_rect; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-18 12:30:27 +02:00
										 |  |  |     // Commits the used values produced by layout and builds a paintable tree.
 | 
					
						
							|  |  |  |     void commit(Box& root); | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:43:48 +02:00
										 |  |  |     // NOTE: get_mutable() will CoW the UsedValues if it's inherited from an ancestor state;
 | 
					
						
							| 
									
										
										
										
											2023-09-04 12:24:48 +02:00
										 |  |  |     UsedValues& get_mutable(NodeWithStyle const&); | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:43:48 +02:00
										 |  |  |     // NOTE: get() will not CoW the UsedValues.
 | 
					
						
							| 
									
										
										
										
											2023-09-04 12:24:48 +02:00
										 |  |  |     UsedValues const& get(NodeWithStyle const&) const; | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     HashMap<GC::Ref<Layout::Node const>, NonnullOwnPtr<UsedValues>> used_values_per_layout_node; | 
					
						
							| 
									
										
										
										
											2022-03-12 14:36:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // We cache intrinsic sizes once determined, as they will not change over the course of a full layout.
 | 
					
						
							|  |  |  |     // This avoids computing them several times while performing flex layout.
 | 
					
						
							|  |  |  |     struct IntrinsicSizes { | 
					
						
							| 
									
										
										
										
											2022-11-04 20:32:50 +00:00
										 |  |  |         Optional<CSSPixels> min_content_width; | 
					
						
							|  |  |  |         Optional<CSSPixels> max_content_width; | 
					
						
							| 
									
										
										
										
											2022-10-08 20:27:54 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-12 15:17:17 +02:00
										 |  |  |         HashMap<CSSPixels, Optional<CSSPixels>> min_content_height; | 
					
						
							|  |  |  |         HashMap<CSSPixels, Optional<CSSPixels>> max_content_height; | 
					
						
							| 
									
										
										
										
											2022-03-12 14:36:59 +01:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2022-07-08 12:44:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-15 04:01:23 +13:00
										 |  |  |     HashMap<GC::Ptr<NodeWithStyle const>, NonnullOwnPtr<IntrinsicSizes>> mutable intrinsic_sizes; | 
					
						
							| 
									
										
										
										
											2022-03-12 16:33:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:30:32 +02:00
										 |  |  |     LayoutState const* m_parent { nullptr }; | 
					
						
							|  |  |  |     LayoutState const& m_root; | 
					
						
							| 
									
										
										
										
											2023-08-15 15:11:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2024-01-18 14:03:30 +01:00
										 |  |  |     void resolve_relative_positions(); | 
					
						
							| 
									
										
										
										
											2022-02-19 20:13:47 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |