| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							|  |  |  | #include <LibWeb/Layout/LayoutPosition.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 { | 
					
						
							|  |  |  |     Default, | 
					
						
							|  |  |  |     AllPossibleLineBreaks, | 
					
						
							|  |  |  |     OnlyRequiredLineBreaks, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-03 19:15:27 +01:00
										 |  |  | enum class PaintPhase { | 
					
						
							|  |  |  |     Background, | 
					
						
							|  |  |  |     Border, | 
					
						
							|  |  |  |     Foreground, | 
					
						
							|  |  |  |     FocusOutline, | 
					
						
							|  |  |  |     Overlay, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-28 23:02:22 +02:00
										 |  |  | struct HitTestResult { | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     RefPtr<Node> layout_node; | 
					
						
							| 
									
										
										
										
											2019-11-05 22:13:26 +01:00
										 |  |  |     int index_in_node { 0 }; | 
					
						
							| 
									
										
										
										
											2020-08-21 17:50:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     enum InternalPosition { | 
					
						
							|  |  |  |         None, | 
					
						
							|  |  |  |         Before, | 
					
						
							|  |  |  |         Inside, | 
					
						
							|  |  |  |         After, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     InternalPosition internal_position { None }; | 
					
						
							| 
									
										
										
										
											2019-09-28 23:02:22 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-05 16:55:56 +02:00
										 |  |  | enum class HitTestType { | 
					
						
							|  |  |  |     Exact,      // Exact matches only
 | 
					
						
							|  |  |  |     TextCursor, // Clicking past the right/bottom edge of text will still hit the text
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | class Node : public TreeNode<Node> { | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-05 16:55:56 +02:00
										 |  |  |     virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const; | 
					
						
							| 
									
										
										
										
											2019-09-28 23:02:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 14:46:36 +01:00
										 |  |  |     bool is_anonymous() const { return !m_dom_node; } | 
					
						
							|  |  |  |     const DOM::Node* dom_node() const { return m_dom_node; } | 
					
						
							|  |  |  |     DOM::Node* dom_node() { return m_dom_node; } | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     DOM::Document& document() { return m_document; } | 
					
						
							|  |  |  |     const DOM::Document& document() const { return m_document; } | 
					
						
							| 
									
										
										
										
											2019-09-29 11:43:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-14 16:45:45 +02:00
										 |  |  |     const Frame& frame() const; | 
					
						
							|  |  |  |     Frame& frame(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     const InitialContainingBlockBox& root() const; | 
					
						
							|  |  |  |     InitialContainingBlockBox& root(); | 
					
						
							| 
									
										
										
										
											2019-11-04 19:37:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 20:10:02 +01:00
										 |  |  |     bool is_root_element() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 16:42:44 +01:00
										 |  |  |     String class_name() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  |     bool is_inline() const { return m_inline; } | 
					
						
							|  |  |  |     void set_inline(bool b) { m_inline = b; } | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-01 18:55:47 +01:00
										 |  |  |     bool is_inline_block() const; | 
					
						
							| 
									
										
										
										
											2020-05-05 16:06:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-11 18:15:47 +02:00
										 |  |  |     virtual bool wants_mouse_events() const { return false; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers); | 
					
						
							|  |  |  |     virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers); | 
					
						
							|  |  |  |     virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers); | 
					
						
							| 
									
										
										
										
											2021-03-02 08:36:58 +11:00
										 |  |  |     virtual bool handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned buttons, unsigned modifiers, int wheel_delta); | 
					
						
							| 
									
										
										
										
											2020-09-11 18:15:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-05 16:11:33 -07:00
										 |  |  |     virtual void before_children_paint(PaintContext&, PaintPhase) {}; | 
					
						
							| 
									
										
										
										
											2020-06-18 21:35:44 +02:00
										 |  |  |     virtual void paint(PaintContext&, PaintPhase); | 
					
						
							| 
									
										
										
										
											2020-12-03 19:30:48 +01:00
										 |  |  |     virtual void paint_fragment(PaintContext&, const LineBoxFragment&, PaintPhase) const { } | 
					
						
							| 
									
										
										
										
											2020-10-05 16:11:33 -07:00
										 |  |  |     virtual void after_children_paint(PaintContext&, PaintPhase) {}; | 
					
						
							| 
									
										
										
										
											2019-06-16 21:35:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-01-17 09:34:01 +01:00
										 |  |  |     virtual bool is_block_box() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_text_node() const { return false; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     const BlockBox* containing_block() const; | 
					
						
							| 
									
										
										
										
											2020-12-06 19:48:02 +01:00
										 |  |  |     BlockBox* containing_block() { return const_cast<BlockBox*>(const_cast<const Node*>(this)->containing_block()); } | 
					
						
							| 
									
										
										
										
											2019-07-01 07:28:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  |     bool can_contain_boxes_with_position_absolute() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  |     const Gfx::Font& font() const; | 
					
						
							| 
									
										
										
										
											2021-01-06 11:07:02 +01:00
										 |  |  |     const CSS::ImmutableComputedValues& computed_values() const; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     NodeWithStyle* parent(); | 
					
						
							|  |  |  |     const NodeWithStyle* 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-05 20:10:39 +01:00
										 |  |  |     virtual void split_into_lines(InlineFormattingContext&, LayoutMode); | 
					
						
							| 
									
										
										
										
											2019-10-05 23:20:35 +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-06-07 17:55:46 +02:00
										 |  |  |     float font_size() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     template<typename Callback> | 
					
						
							|  |  |  |     void for_each_child_in_paint_order(Callback callback) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for_each_child([&](auto& child) { | 
					
						
							|  |  |  |             if (is<Box>(child) && downcast<Box>(child).stacking_context()) | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             if (!child.is_positioned()) | 
					
						
							|  |  |  |                 callback(child); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         for_each_child([&](auto& child) { | 
					
						
							|  |  |  |             if (is<Box>(child) && downcast<Box>(child).stacking_context()) | 
					
						
							|  |  |  |                 return; | 
					
						
							|  |  |  |             if (child.is_positioned()) | 
					
						
							|  |  |  |                 callback(child); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     friend class NodeWithStyle; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-22 20:26:32 +02:00
										 |  |  |     NonnullRefPtr<DOM::Document> m_document; | 
					
						
							| 
									
										
										
										
											2020-11-22 14:46:36 +01:00
										 |  |  |     RefPtr<DOM::Node> m_dom_node; | 
					
						
							| 
									
										
										
										
											2019-06-25 19:46:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-05 22:07:45 +02:00
										 |  |  |     bool m_inline { 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 }; | 
					
						
							| 
									
										
										
										
											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 { | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     virtual ~NodeWithStyle() override { } | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  |     const Gfx::Font& font() const { return *m_font; } | 
					
						
							| 
									
										
										
										
											2021-01-06 11:31:19 +01:00
										 |  |  |     float line_height() const { return m_line_height; } | 
					
						
							|  |  |  |     float font_size() const { return m_font_size; } | 
					
						
							|  |  |  |     const CSS::ImageStyleValue* background_image() const { return m_background_image; } | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 14:10:53 +01:00
										 |  |  |     NonnullRefPtr<NodeWithStyle> create_anonymous_wrapper() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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 }; | 
					
						
							|  |  |  |     float m_font_size { 0 }; | 
					
						
							|  |  |  |     RefPtr<CSS::ImageStyleValue> m_background_image; | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 23:15:23 +02:00
										 |  |  |     CSS::Position m_position; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle { | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     BoxModelMetrics& box_model() { return m_box_model; } | 
					
						
							|  |  |  |     const BoxModelMetrics& box_model() const { return m_box_model; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 11:05:23 +01:00
										 |  |  | inline const Gfx::Font& Node::font() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							|  |  |  |         return static_cast<const NodeWithStyle*>(this)->font(); | 
					
						
							|  |  |  |     return parent()->font(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-06 11:31:19 +01:00
										 |  |  | inline float Node::font_size() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							|  |  |  |         return static_cast<const NodeWithStyle*>(this)->font_size(); | 
					
						
							|  |  |  |     return parent()->font_size(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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) | 
					
						
							| 
									
										
										
										
											2021-01-06 10:34:31 +01:00
										 |  |  |         return static_cast<const NodeWithStyle*>(this)->computed_values(); | 
					
						
							|  |  |  |     return parent()->computed_values(); | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | inline const NodeWithStyle* Node::parent() const | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  |     return static_cast<const NodeWithStyle*>(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
										 |  |  | } |