| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-29 00:09:32 +02:00
										 |  |  | #include <LibGfx/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2020-09-18 09:49:51 +02:00
										 |  |  | #include <LibGfx/Rect.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  | #include <LibWeb/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-22 15:53:01 +01:00
										 |  |  | namespace Web::Layout { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-27 10:26:38 +01:00
										 |  |  | class LineBoxFragment { | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  |     friend class LineBox; | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2020-12-03 19:21:33 +01:00
										 |  |  |     enum class Type { | 
					
						
							|  |  |  |         Normal, | 
					
						
							|  |  |  |         Leading, | 
					
						
							|  |  |  |         Trailing, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-26 09:24:40 +01:00
										 |  |  |     LineBoxFragment(Node const& layout_node, int start, int length, Gfx::FloatPoint const& offset, Gfx::FloatSize const& size, float border_box_top, float border_box_bottom, Type type) | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  |         : m_layout_node(layout_node) | 
					
						
							|  |  |  |         , m_start(start) | 
					
						
							|  |  |  |         , m_length(length) | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  |         , m_offset(offset) | 
					
						
							|  |  |  |         , m_size(size) | 
					
						
							| 
									
										
										
										
											2022-02-26 09:24:40 +01:00
										 |  |  |         , m_border_box_top(border_box_top) | 
					
						
							|  |  |  |         , m_border_box_bottom(border_box_bottom) | 
					
						
							| 
									
										
										
										
											2020-12-03 19:21:33 +01:00
										 |  |  |         , m_type(type) | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  |     Node const& layout_node() const { return m_layout_node; } | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  |     int start() const { return m_start; } | 
					
						
							|  |  |  |     int length() const { return m_length; } | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  |     const Gfx::FloatRect absolute_rect() const; | 
					
						
							| 
									
										
										
										
											2020-12-03 19:21:33 +01:00
										 |  |  |     Type type() const { return m_type; } | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     const Gfx::FloatPoint& offset() const { return m_offset; } | 
					
						
							|  |  |  |     void set_offset(const Gfx::FloatPoint& offset) { m_offset = offset; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Gfx::FloatSize& size() const { return m_size; } | 
					
						
							|  |  |  |     void set_width(float width) { m_size.set_width(width); } | 
					
						
							| 
									
										
										
										
											2020-12-03 19:21:33 +01:00
										 |  |  |     void set_height(float height) { m_size.set_height(height); } | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  |     float width() const { return m_size.width(); } | 
					
						
							|  |  |  |     float height() const { return m_size.height(); } | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-26 09:24:40 +01:00
										 |  |  |     float border_box_height() const { return m_border_box_top + height() + m_border_box_bottom; } | 
					
						
							|  |  |  |     float border_box_top() const { return m_border_box_top; } | 
					
						
							|  |  |  |     float border_box_bottom() const { return m_border_box_bottom; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  |     float absolute_x() const { return absolute_rect().x(); } | 
					
						
							| 
									
										
										
										
											2019-10-20 17:18:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-13 14:59:17 +02:00
										 |  |  |     bool ends_in_whitespace() const; | 
					
						
							| 
									
										
										
										
											2019-10-20 12:30:25 +02:00
										 |  |  |     bool is_justifiable_whitespace() const; | 
					
						
							| 
									
										
										
										
											2019-10-20 17:18:28 +02:00
										 |  |  |     StringView text() const; | 
					
						
							| 
									
										
										
										
											2019-10-20 12:30:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 22:13:26 +01:00
										 |  |  |     int text_index_at(float x) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-29 00:09:32 +02:00
										 |  |  |     Gfx::FloatRect selection_rect(const Gfx::Font&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-24 22:45:51 +01:00
										 |  |  |     float height_of_inline_level_box(FormattingState const&) const; | 
					
						
							|  |  |  |     float top_of_inline_level_box(FormattingState const&) const; | 
					
						
							|  |  |  |     float bottom_of_inline_level_box(FormattingState const&) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-02-20 15:51:24 +01:00
										 |  |  |     Node const& m_layout_node; | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  |     int m_start { 0 }; | 
					
						
							|  |  |  |     int m_length { 0 }; | 
					
						
							| 
									
										
										
										
											2020-06-10 10:42:29 +02:00
										 |  |  |     Gfx::FloatPoint m_offset; | 
					
						
							|  |  |  |     Gfx::FloatSize m_size; | 
					
						
							| 
									
										
										
										
											2022-02-26 09:24:40 +01:00
										 |  |  |     float m_border_box_top { 0 }; | 
					
						
							|  |  |  |     float m_border_box_bottom { 0 }; | 
					
						
							| 
									
										
										
										
											2020-12-03 19:21:33 +01:00
										 |  |  |     Type m_type { Type::Normal }; | 
					
						
							| 
									
										
										
										
											2019-10-03 15:20:13 +02:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |