| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Redistribution and use in source and binary forms, with or without | 
					
						
							|  |  |  |  * modification, are permitted provided that the following conditions are met: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 1. Redistributions of source code must retain the above copyright notice, this | 
					
						
							|  |  |  |  *    list of conditions and the following disclaimer. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 2. Redistributions in binary form must reproduce the above copyright notice, | 
					
						
							|  |  |  |  *    this list of conditions and the following disclaimer in the documentation | 
					
						
							|  |  |  |  *    and/or other materials provided with the distribution. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 
					
						
							|  |  |  |  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
					
						
							|  |  |  |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
					
						
							|  |  |  |  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | 
					
						
							|  |  |  |  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
					
						
							|  |  |  |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
					
						
							|  |  |  |  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 
					
						
							|  |  |  |  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
					
						
							|  |  |  |  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
					
						
							|  |  |  |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											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-24 14:17:05 +02:00
										 |  |  | #include <LibWeb/Layout/LayoutStyle.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-03-07 10:27:02 +01:00
										 |  |  | namespace Web { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-28 23:02:22 +02:00
										 |  |  | struct HitTestResult { | 
					
						
							|  |  |  |     RefPtr<LayoutNode> 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
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-25 19:46:01 +02:00
										 |  |  | class LayoutNode : public TreeNode<LayoutNode> { | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | public: | 
					
						
							|  |  |  |     virtual ~LayoutNode(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-16 11:28:47 +02:00
										 |  |  |     bool is_anonymous() const { return !m_node; } | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     const DOM::Node* node() const { return m_node; } | 
					
						
							| 
									
										
										
										
											2020-07-28 19:48:57 +02:00
										 |  |  |     DOM::Node* node() { return m_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(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-04 19:37:52 +01:00
										 |  |  |     const LayoutDocument& root() const; | 
					
						
							|  |  |  |     LayoutDocument& root(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  |     virtual const char* class_name() const = 0; | 
					
						
							|  |  |  |     virtual bool is_root() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  |     virtual bool is_text() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-07-01 07:28:37 +02:00
										 |  |  |     virtual bool is_block() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-10-05 23:20:35 +02:00
										 |  |  |     virtual bool is_replaced() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-11-25 21:21:55 +01:00
										 |  |  |     virtual bool is_widget() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-06-05 23:36:02 +02:00
										 |  |  |     virtual bool is_frame() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-12-18 20:52:36 +01:00
										 |  |  |     virtual bool is_image() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-03-19 19:07:56 +01:00
										 |  |  |     virtual bool is_canvas() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |     virtual bool is_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-10-17 23:34:12 +02:00
										 |  |  |     virtual bool is_table() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_table_row() const { return false; } | 
					
						
							|  |  |  |     virtual bool is_table_cell() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-06-09 21:08:15 +02:00
										 |  |  |     virtual bool is_table_row_group() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-07-26 17:16:18 +02:00
										 |  |  |     virtual bool is_break() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-09-11 18:17:39 +02:00
										 |  |  |     virtual bool is_check_box() const { return false; } | 
					
						
							| 
									
										
										
										
											2020-09-12 17:56:11 +02:00
										 |  |  |     virtual bool is_button() const { return false; } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:19:52 +02:00
										 |  |  |     bool has_style() const { return m_has_style; } | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 16:06:22 +02:00
										 |  |  |     bool is_inline_block() const { return is_inline() && is_block(); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 21:53:10 +02:00
										 |  |  |     enum class LayoutMode { | 
					
						
							|  |  |  |         Default, | 
					
						
							|  |  |  |         AllPossibleLineBreaks, | 
					
						
							|  |  |  |         OnlyRequiredLineBreaks, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void layout(LayoutMode); | 
					
						
							| 
									
										
										
										
											2020-06-18 18:57:35 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     enum class PaintPhase { | 
					
						
							|  |  |  |         Background, | 
					
						
							|  |  |  |         Border, | 
					
						
							|  |  |  |         Foreground, | 
					
						
							| 
									
										
										
										
											2020-08-14 19:40:37 +02:00
										 |  |  |         FocusOutline, | 
					
						
							| 
									
										
										
										
											2020-06-18 18:57:35 +02:00
										 |  |  |         Overlay, | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2020-06-18 21:35:44 +02:00
										 |  |  |     virtual void paint(PaintContext&, PaintPhase); | 
					
						
							| 
									
										
										
										
											2019-06-16 21:35:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 15:08:42 +02:00
										 |  |  |     bool is_floating() 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-01 07:28:37 +02:00
										 |  |  |     const LayoutBlock* containing_block() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-05 16:54:28 +02:00
										 |  |  |     bool can_contain_boxes_with_position_absolute() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-08 17:42:23 +02:00
										 |  |  |     virtual LayoutNode& inline_wrapper() { return *this; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  |     const CSS::StyleProperties& specified_style() const; | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  |     const ImmutableLayoutStyle& style() const; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-18 10:16:33 +02:00
										 |  |  |     LayoutNodeWithStyle* parent(); | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  |     const LayoutNodeWithStyle* parent() const; | 
					
						
							| 
									
										
										
										
											2019-07-24 07:34:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 21:53:10 +02:00
										 |  |  |     void inserted_into(LayoutNode&) { } | 
					
						
							|  |  |  |     void removed_from(LayoutNode&) { } | 
					
						
							|  |  |  |     void children_changed() { } | 
					
						
							| 
									
										
										
										
											2019-09-29 17:40:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-26 21:53:10 +02:00
										 |  |  |     virtual void split_into_lines(LayoutBlock& container, 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
 | 
					
						
							|  |  |  |         Start,       // Selection starts in this LayoutNode
 | 
					
						
							|  |  |  |         End,         // Selection ends in this LayoutNode
 | 
					
						
							|  |  |  |         StartAndEnd, // Selection starts and ends in this LayoutNode
 | 
					
						
							|  |  |  |         Full,        // Selection starts before and ends after this LayoutNode
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     SelectionState selection_state() const { return m_selection_state; } | 
					
						
							|  |  |  |     void set_selection_state(SelectionState state) { m_selection_state = state; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-07-28 19:48:57 +02:00
										 |  |  |     LayoutNode(DOM::Document&, DOM::Node*); | 
					
						
							| 
									
										
										
										
											2019-06-15 22:49:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  |     friend class LayoutNodeWithStyle; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 19:37:56 +02:00
										 |  |  |     DOM::Document& m_document; | 
					
						
							| 
									
										
										
										
											2020-07-28 19:48:57 +02:00
										 |  |  |     DOM::Node* m_node { nullptr }; | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | class LayoutNodeWithStyle : public LayoutNode { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-05-26 21:53:10 +02:00
										 |  |  |     virtual ~LayoutNodeWithStyle() override { } | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  |     const CSS::StyleProperties& specified_style() const { return m_specified_style; } | 
					
						
							|  |  |  |     void set_specified_style(const CSS::StyleProperties& style) { m_specified_style = style; } | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  |     const ImmutableLayoutStyle& style() const { return static_cast<const ImmutableLayoutStyle&>(m_style); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  |     void apply_style(const CSS::StyleProperties&); | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-07-28 19:48:57 +02:00
										 |  |  |     LayoutNodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>); | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  |     LayoutStyle m_style; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  |     NonnullRefPtr<CSS::StyleProperties> m_specified_style; | 
					
						
							| 
									
										
										
										
											2020-06-23 23:15:23 +02:00
										 |  |  |     CSS::Position m_position; | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  | class LayoutNodeWithStyleAndBoxModelMetrics : public LayoutNodeWithStyle { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     BoxModelMetrics& box_model() { return m_box_model; } | 
					
						
							|  |  |  |     const BoxModelMetrics& box_model() const { return m_box_model; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							| 
									
										
										
										
											2020-07-28 19:48:57 +02:00
										 |  |  |     LayoutNodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style) | 
					
						
							| 
									
										
										
										
											2020-06-24 19:41:12 +02:00
										 |  |  |         : LayoutNodeWithStyle(document, node, move(style)) | 
					
						
							| 
									
										
										
										
											2019-10-15 16:48:38 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     BoxModelMetrics m_box_model; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  | inline const CSS::StyleProperties& LayoutNode::specified_style() const | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							| 
									
										
										
										
											2020-06-24 13:51:14 +02:00
										 |  |  |         return static_cast<const LayoutNodeWithStyle*>(this)->specified_style(); | 
					
						
							|  |  |  |     return parent()->specified_style(); | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 14:17:05 +02:00
										 |  |  | inline const ImmutableLayoutStyle& LayoutNode::style() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (m_has_style) | 
					
						
							|  |  |  |         return static_cast<const LayoutNodeWithStyle*>(this)->style(); | 
					
						
							|  |  |  |     return parent()->style(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-07 09:50:31 +02:00
										 |  |  | inline const LayoutNodeWithStyle* LayoutNode::parent() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return static_cast<const LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent()); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-15 14:19:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-18 10:16:33 +02:00
										 |  |  | inline LayoutNodeWithStyle* LayoutNode::parent() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return static_cast<LayoutNodeWithStyle*>(TreeNode<LayoutNode>::parent()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-09 20:42:11 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 17:16:18 +02:00
										 |  |  | AK_BEGIN_TYPE_TRAITS(Web::LayoutNodeWithStyle) | 
					
						
							|  |  |  | static bool is_type(const Web::LayoutNode& node) { return node.has_style(); } | 
					
						
							|  |  |  | AK_END_TYPE_TRAITS() |