| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> | 
					
						
							|  |  |  |  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/Enums.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-30 17:13:37 +01:00
										 |  |  | #include <LibWeb/CSS/PercentageOr.h>
 | 
					
						
							| 
									
										
										
										
											2023-11-06 17:46:19 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:11:51 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/StyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<PositionStyleValue const> create(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y) | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-09-20 15:31:38 +01:00
										 |  |  |         return adopt_ref(*new (nothrow) PositionStyleValue(move(edge_x), move(edge_y))); | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<PositionStyleValue const> create_center() | 
					
						
							| 
									
										
										
										
											2023-11-07 12:10:16 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         return adopt_ref(*new (nothrow) PositionStyleValue( | 
					
						
							| 
									
										
										
										
											2024-11-29 22:44:14 +11:00
										 |  |  |             EdgeStyleValue::create(PositionEdge::Center, {}), | 
					
						
							|  |  |  |             EdgeStyleValue::create(PositionEdge::Center, {}))); | 
					
						
							| 
									
										
										
										
											2023-11-07 12:10:16 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |     virtual ~PositionStyleValue() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x() const { return m_properties.edge_x; } | 
					
						
							|  |  |  |     ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y() const { return m_properties.edge_y; } | 
					
						
							| 
									
										
										
										
											2023-11-07 12:10:16 +00:00
										 |  |  |     bool is_center() const; | 
					
						
							|  |  |  |     CSSPixelPoint resolved(Layout::Node const&, CSSPixelRect const&) const; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 00:59:49 +01:00
										 |  |  |     virtual String to_string(SerializationMode) const override; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool properties_equal(PositionStyleValue const& other) const { return m_properties == other.m_properties; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     PositionStyleValue(ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x, ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y) | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |         : StyleValueWithDefaultOperators(Type::Position) | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |         , m_properties { .edge_x = move(edge_x), .edge_y = move(edge_y) } | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Properties { | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |         ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_x; | 
					
						
							|  |  |  |         ValueComparingNonnullRefPtr<EdgeStyleValue const> edge_y; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  |         bool operator==(Properties const&) const = default; | 
					
						
							|  |  |  |     } m_properties; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |