| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-01-01 16:08:19 +01:00
										 |  |  |  * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-21 18:45:35 +02:00
										 |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							| 
									
										
										
										
											2020-07-26 17:16:18 +02:00
										 |  |  | #include <AK/TypeCasts.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | #include <AK/Vector.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-06 12:04:00 +01:00
										 |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  | #include <LibJS/Heap/Handle.h>
 | 
					
						
							| 
									
										
										
										
											2021-01-06 10:34:31 +01:00
										 |  |  | #include <LibWeb/CSS/ComputedValues.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:32:51 +01:00
										 |  |  | #include <LibWeb/CSS/StyleProperties.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-09 20:42:11 +02:00
										 |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:32:51 +01:00
										 |  |  | #include <LibWeb/Layout/BoxModelMetrics.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-18 21:35:44 +02:00
										 |  |  | #include <LibWeb/Painting/PaintContext.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:32:51 +01:00
										 |  |  | #include <LibWeb/TreeNode.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | namespace Web::Layout { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | enum class LayoutMode { | 
					
						
							| 
									
										
										
										
											2022-07-09 15:17:47 +02:00
										 |  |  |     // Normal layout. No min-content or max-content constraints applied.
 | 
					
						
							| 
									
										
										
										
											2022-03-19 15:44:02 +01:00
										 |  |  |     Normal, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-09 15:17:47 +02:00
										 |  |  |     // Intrinsic size determination.
 | 
					
						
							| 
									
										
										
										
											2022-07-16 23:43:48 +02:00
										 |  |  |     // Boxes honor min-content and max-content constraints (set via LayoutState::UsedValues::{width,height}_constraint)
 | 
					
						
							| 
									
										
										
										
											2022-07-09 15:17:47 +02:00
										 |  |  |     // by considering their containing block to be 0-sized or infinitely large in the relevant axis.
 | 
					
						
							| 
									
										
										
										
											2022-07-20 18:12:12 +02:00
										 |  |  |     // https://drafts.csswg.org/css-sizing-3/#intrinsic-sizing
 | 
					
						
							|  |  |  |     IntrinsicSizing, | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  | class Node | 
					
						
							|  |  |  |     : public JS::Cell | 
					
						
							|  |  |  |     , public TreeNode<Node> | 
					
						
							|  |  |  |     , public Weakable<Node> { | 
					
						
							|  |  |  |     JS_CELL(Node, JS::Cell); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     virtual ~Node(); | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 17:12:58 +02:00
										 |  |  |     size_t serial_id() const { return m_serial_id; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     bool is_anonymous() const; | 
					
						
							|  |  |  |     DOM::Node const* dom_node() const; | 
					
						
							|  |  |  |     DOM::Node* dom_node(); | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-28 17:11:23 +02:00
										 |  |  |     bool is_generated() const { return m_generated; } | 
					
						
							|  |  |  |     void set_generated(bool b) { m_generated = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 22:38:08 +01:00
										 |  |  |     Painting::Paintable* paintable() { return m_paintable; } | 
					
						
							| 
									
										
										
										
											2022-03-10 15:50:57 +01:00
										 |  |  |     Painting::Paintable const* paintable() const { return m_paintable; } | 
					
						
							| 
									
										
										
										
											2022-03-10 22:38:08 +01:00
										 |  |  |     void set_paintable(RefPtr<Painting::Paintable>); | 
					
						
							| 
									
										
										
										
											2022-03-10 15:50:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-10 22:38:08 +01:00
										 |  |  |     virtual RefPtr<Painting::Paintable> create_paintable() const; | 
					
						
							| 
									
										
										
										
											2022-03-10 15:50:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 13:42:07 +02:00
										 |  |  |     DOM::Document& document(); | 
					
						
							|  |  |  |     DOM::Document const& document() const; | 
					
						
							| 
									
										
										
										
											2019-09-29 11:43:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-18 15:01:28 +01:00
										 |  |  |     HTML::BrowsingContext const& browsing_context() const; | 
					
						
							|  |  |  |     HTML::BrowsingContext& browsing_context(); | 
					
						
							| 
									
										
										
										
											2020-06-14 16:45:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     InitialContainingBlock const& root() const; | 
					
						
							| 
									
										
										
										
											2021-09-08 11:27:46 +02:00
										 |  |  |     InitialContainingBlock& root(); | 
					
						
							| 
									
										
										
										
											2019-11-04 19:37:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 20:10:02 +01:00
										 |  |  |     bool is_root_element() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 18:02:33 +00:00
										 |  |  |     DeprecatedString debug_description() const; | 
					
						
							| 
									
										
										
										
											2021-01-01 16:42:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 14:19:52 +02:00
										 |  |  |     bool has_style() const { return m_has_style; } | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-29 15:29:10 +01:00
										 |  |  |     virtual bool can_have_children() const { return true; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-06 15:33:09 +02:00
										 |  |  |     CSS::Display display() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-06 14:39:11 +02:00
										 |  |  |     bool is_inline() const; | 
					
						
							| 
									
										
										
										
											2021-01-01 18:55:47 +01:00
										 |  |  |     bool is_inline_block() const; | 
					
						
							| 
									
										
										
										
											2020-05-05 16:06:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-22 18:34:02 +01:00
										 |  |  |     bool is_out_of_flow(FormattingContext const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-17 09:34:01 +01:00
										 |  |  |     // These are used to optimize hot is<T> variants for some classes where dynamic_cast is too slow.
 | 
					
						
							| 
									
										
										
										
											2021-01-07 17:31:26 +01:00
										 |  |  |     virtual bool is_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-10-06 20:07:13 +02:00
										 |  |  |     virtual bool is_block_container() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-10-26 16:15:53 +02:00
										 |  |  |     virtual bool is_break_node() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-01-17 09:34:01 +01:00
										 |  |  |     virtual bool is_text_node() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-08-18 11:44:05 +02:00
										 |  |  |     virtual bool is_initial_containing_block_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-10-18 16:26:05 +02:00
										 |  |  |     virtual bool is_svg_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-02-11 12:37:22 +00:00
										 |  |  |     virtual bool is_svg_geometry_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-10-27 17:58:19 +02:00
										 |  |  |     virtual bool is_label() const { return false; } | 
					
						
							| 
									
										
										
										
											2022-03-13 17:21:27 +01:00
										 |  |  |     virtual bool is_replaced_box() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_list_item_marker_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2021-01-17 09:34:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     template<typename T> | 
					
						
							|  |  |  |     bool fast_is() const = delete; | 
					
						
							| 
									
										
										
										
											2021-01-07 17:31:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 15:08:42 +02:00
										 |  |  |     bool is_floating() const; | 
					
						
							| 
									
										
										
										
											2020-12-06 19:54:23 +01:00
										 |  |  |     bool is_positioned() const; | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  |     bool is_absolutely_positioned() const; | 
					
						
							| 
									
										
										
										
											2020-06-12 14:19:03 +02:00
										 |  |  |     bool is_fixed_position() const; | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-29 22:36:15 +02:00
										 |  |  |     bool is_flex_item() const { return m_is_flex_item; } | 
					
						
							|  |  |  |     void set_flex_item(bool b) { m_is_flex_item = b; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     BlockContainer const* containing_block() const; | 
					
						
							|  |  |  |     BlockContainer* containing_block() { return const_cast<BlockContainer*>(const_cast<Node const*>(this)->containing_block()); } | 
					
						
							| 
									
										
										
										
											2019-07-01 07:28:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-07 19:03:25 +03:00
										 |  |  |     bool establishes_stacking_context() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  |     bool can_contain_boxes_with_position_absolute() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Gfx::Font const& font() const; | 
					
						
							| 
									
										
										
										
											2021-01-06 11:07:02 +01:00
										 |  |  |     const CSS::ImmutableComputedValues& computed_values() const; | 
					
						
							| 
									
										
										
										
											2022-03-24 17:37:24 +01:00
										 |  |  |     float line_height() const; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     NodeWithStyle* parent(); | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     NodeWithStyle const* parent() const; | 
					
						
							| 
									
										
										
										
											2019-07-24 07:34:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     void inserted_into(Node&) { } | 
					
						
							|  |  |  |     void removed_from(Node&) { } | 
					
						
							| 
									
										
										
										
											2020-05-26 21:53:10 +02:00
										 |  |  |     void children_changed() { } | 
					
						
							| 
									
										
										
										
											2019-09-29 17:40:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-09 21:25:29 +02:00
										 |  |  |     bool is_visible() const { return m_visible; } | 
					
						
							|  |  |  |     void set_visible(bool visible) { m_visible = visible; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |     virtual void set_needs_display(); | 
					
						
							| 
									
										
										
										
											2019-10-09 21:25:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 23:32:08 +02:00
										 |  |  |     bool children_are_inline() const { return m_children_are_inline; } | 
					
						
							|  |  |  |     void set_children_are_inline(bool value) { m_children_are_inline = value; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-06 14:35:54 +01:00
										 |  |  |     Gfx::FloatPoint box_type_agnostic_position() const; | 
					
						
							| 
									
										
										
										
											2019-10-20 09:14:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-21 17:50:41 +02:00
										 |  |  |     enum class SelectionState { | 
					
						
							|  |  |  |         None,        // No selection
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |         Start,       // Selection starts in this Node
 | 
					
						
							|  |  |  |         End,         // Selection ends in this Node
 | 
					
						
							|  |  |  |         StartAndEnd, // Selection starts and ends in this Node
 | 
					
						
							|  |  |  |         Full,        // Selection starts before and ends after this Node
 | 
					
						
							| 
									
										
										
										
											2020-08-21 17:50:41 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     SelectionState selection_state() const { return m_selection_state; } | 
					
						
							|  |  |  |     void set_selection_state(SelectionState state) { m_selection_state = state; } | 
					
						
							| 
									
										
										
										
											2020-12-06 19:59:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     Node(DOM::Document&, DOM::Node*); | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     virtual void visit_edges(Cell::Visitor&) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     friend class NodeWithStyle; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS::NonnullGCPtr<DOM::Node> m_dom_node; | 
					
						
							| 
									
										
										
										
											2022-03-10 22:38:08 +01:00
										 |  |  |     RefPtr<Painting::Paintable> m_paintable; | 
					
						
							| 
									
										
										
										
											2019-06-25 19:46:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-20 18:20:34 +02:00
										 |  |  |     JS::NonnullGCPtr<HTML::BrowsingContext> m_browsing_context; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 17:12:58 +02:00
										 |  |  |     size_t m_serial_id { 0 }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-16 16:42:39 +02:00
										 |  |  |     bool m_anonymous { false }; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  |     bool m_has_style { false }; | 
					
						
							| 
									
										
										
										
											2019-10-09 21:25:29 +02:00
										 |  |  |     bool m_visible { true }; | 
					
						
							| 
									
										
										
										
											2019-10-17 23:32:08 +02:00
										 |  |  |     bool m_children_are_inline { false }; | 
					
						
							| 
									
										
										
										
											2020-08-21 17:50:41 +02:00
										 |  |  |     SelectionState m_selection_state { SelectionState::None }; | 
					
						
							| 
									
										
										
										
											2021-05-29 22:36:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool m_is_flex_item { false }; | 
					
						
							| 
									
										
										
										
											2022-09-28 17:11:23 +02:00
										 |  |  |     bool m_generated { false }; | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | class NodeWithStyle : public Node { | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS_CELL(NodeWithStyle, Node); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-03-14 13:21:51 -06:00
										 |  |  |     virtual ~NodeWithStyle() override = default; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 10:34:31 +01:00
										 |  |  |     const CSS::ImmutableComputedValues& computed_values() const { return static_cast<const CSS::ImmutableComputedValues&>(m_computed_values); } | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  |     void apply_style(const CSS::StyleProperties&); | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     Gfx::Font const& font() const { return *m_font; } | 
					
						
							| 
									
										
										
										
											2021-01-06 11:31:19 +01:00
										 |  |  |     float line_height() const { return m_line_height; } | 
					
						
							| 
									
										
										
										
											2021-11-12 12:11:01 +00:00
										 |  |  |     Vector<CSS::BackgroundLayerData> const& background_layers() const { return computed_values().background_layers(); } | 
					
						
							| 
									
										
										
										
											2022-07-31 01:11:59 +01:00
										 |  |  |     const CSS::AbstractImageStyleValue* list_style_image() const { return m_list_style_image; } | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS::NonnullGCPtr<NodeWithStyle> create_anonymous_wrapper() const; | 
					
						
							| 
									
										
										
										
											2021-01-06 14:10:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>); | 
					
						
							| 
									
										
										
										
											2021-01-06 14:10:53 +01:00
										 |  |  |     NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedValues); | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2021-01-06 10:34:31 +01:00
										 |  |  |     CSS::ComputedValues m_computed_values; | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  |     RefPtr<Gfx::Font> m_font; | 
					
						
							| 
									
										
										
										
											2021-01-06 11:31:19 +01:00
										 |  |  |     float m_line_height { 0 }; | 
					
						
							| 
									
										
										
										
											2022-07-31 01:11:59 +01:00
										 |  |  |     RefPtr<CSS::AbstractImageStyleValue> m_list_style_image; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle { | 
					
						
							| 
									
										
										
										
											2022-10-17 14:41:50 +02:00
										 |  |  |     JS_CELL(NodeWithStyleAndBoxModelMetrics, NodeWithStyle); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     BoxModelMetrics& box_model() { return m_box_model; } | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     BoxModelMetrics const& box_model() const { return m_box_model; } | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style) | 
					
						
							|  |  |  |         : NodeWithStyle(document, node, move(style)) | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 14:10:53 +01:00
										 |  |  |     NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values) | 
					
						
							|  |  |  |         : NodeWithStyle(document, node, move(computed_values)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | private: | 
					
						
							|  |  |  |     BoxModelMetrics m_box_model; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  | inline Gfx::Font const& Node::font() const | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |         return static_cast<NodeWithStyle const*>(this)->font(); | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  |     return parent()->font(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 11:07:02 +01:00
										 |  |  | inline const CSS::ImmutableComputedValues& Node::computed_values() const | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |         return static_cast<NodeWithStyle const*>(this)->computed_values(); | 
					
						
							| 
									
										
										
										
											2021-01-06 10:34:31 +01:00
										 |  |  |     return parent()->computed_values(); | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-24 17:37:24 +01:00
										 |  |  | inline float Node::line_height() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							|  |  |  |         return static_cast<NodeWithStyle const*>(this)->line_height(); | 
					
						
							|  |  |  |     return parent()->line_height(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  | inline NodeWithStyle const* Node::parent() const | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  |     return static_cast<NodeWithStyle const*>(TreeNode<Node>::parent()); | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:19:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | inline NodeWithStyle* Node::parent() | 
					
						
							| 
									
										
										
										
											2019-10-18 10:16:33 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     return static_cast<NodeWithStyle*>(TreeNode<Node>::parent()); | 
					
						
							| 
									
										
										
										
											2019-10-18 10:16:33 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-09 20:42:11 +02:00
										 |  |  | } |