| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-11-22 16:42:20 +01:00
										 |  |  |  * Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  |  * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org> | 
					
						
							| 
									
										
										
										
											2022-01-24 17:38:29 +00:00
										 |  |  |  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> | 
					
						
							| 
									
										
										
										
											2023-01-13 23:44:44 +00:00
										 |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							| 
									
										
										
										
											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
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  | #include <LibGfx/Font/FontStyleMapping.h>
 | 
					
						
							| 
									
										
										
										
											2024-01-16 14:53:44 +00:00
										 |  |  | #include <LibGfx/Font/FontWeight.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | #include <LibWeb/CSS/CSSStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 16:42:50 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/AbstractImageStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 17:26:13 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 17:44:13 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 17:54:05 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-05-25 23:06:47 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/BasicShapeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-25 00:33:20 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-14 16:37:02 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CSSColorValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CSSKeywordValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-12-11 15:05:56 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CalculatedStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ColorSchemeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 16:09:41 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ConicGradientStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 21:17:43 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ContentStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CounterDefinitionsStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-07-24 14:56:16 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CounterStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-05-25 12:43:52 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/CustomIdentStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-26 21:05:38 +02:00
										 |  |  | #include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-07-06 02:29:36 +03:30
										 |  |  | #include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-02 22:56:45 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 21:26:03 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-09-28 15:18:14 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-23 21:50:24 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-08-17 20:25:18 +02:00
										 |  |  | #include <LibWeb/CSS/StyleValues/GridAutoFlowStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 14:25:00 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/GridTemplateAreaStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 14:53:08 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-29 17:59:07 +02:00
										 |  |  | #include <LibWeb/CSS/StyleValues/GridTrackSizeListStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 15:17:11 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ImageStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 16:17:50 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/LinearGradientStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-09-07 15:29:54 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/MathDepthStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-01 16:16:15 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-09-30 17:05:52 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/OpenTypeTaggedStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:28:43 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:35:31 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/PositionStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 16:35:18 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/RadialGradientStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-06 15:42:43 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/RatioStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-25 00:02:50 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/RectStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:40:28 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-06-26 23:19:38 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ScrollbarGutterStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:45:25 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ShadowStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-09-19 12:21:15 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/ShorthandStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:48:42 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/StringStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/StyleValueList.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:59:33 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-02-19 19:01:34 -07:00
										 |  |  | #include <LibWeb/CSS/StyleValues/TransitionStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-04-20 18:31:00 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/URLStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 23:53:41 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/UnresolvedStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2019-06-22 21:48:21 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  | namespace Web::CSS { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | CSSStyleValue::CSSStyleValue(Type type) | 
					
						
							| 
									
										
										
										
											2019-06-22 21:48:21 +02:00
										 |  |  |     : m_type(type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | AbstractImageStyleValue const& CSSStyleValue::as_abstract_image() const | 
					
						
							| 
									
										
										
										
											2022-07-31 01:11:59 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_abstract_image()); | 
					
						
							|  |  |  |     return static_cast<AbstractImageStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | AngleStyleValue const& CSSStyleValue::as_angle() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_angle()); | 
					
						
							|  |  |  |     return static_cast<AngleStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | BackgroundRepeatStyleValue const& CSSStyleValue::as_background_repeat() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_background_repeat()); | 
					
						
							|  |  |  |     return static_cast<BackgroundRepeatStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | BackgroundSizeStyleValue const& CSSStyleValue::as_background_size() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_background_size()); | 
					
						
							|  |  |  |     return static_cast<BackgroundSizeStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | BasicShapeStyleValue const& CSSStyleValue::as_basic_shape() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_basic_shape()); | 
					
						
							|  |  |  |     return static_cast<BasicShapeStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | BorderRadiusStyleValue const& CSSStyleValue::as_border_radius() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_border_radius()); | 
					
						
							|  |  |  |     return static_cast<BorderRadiusStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-11 15:05:56 +00:00
										 |  |  | CalculatedStyleValue const& CSSStyleValue::as_calculated() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-12-11 15:05:56 +00:00
										 |  |  |     VERIFY(is_calculated()); | 
					
						
							|  |  |  |     return static_cast<CalculatedStyleValue const&>(*this); | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 16:37:02 +01:00
										 |  |  | CSSColorValue const& CSSStyleValue::as_color() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_color()); | 
					
						
							| 
									
										
										
										
											2024-08-14 16:37:02 +01:00
										 |  |  |     return static_cast<CSSColorValue const&>(*this); | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-01-02 12:59:09 +11:00
										 |  |  | ColorSchemeStyleValue const& CSSStyleValue::as_color_scheme() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_color_scheme()); | 
					
						
							|  |  |  |     return static_cast<ColorSchemeStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ConicGradientStyleValue const& CSSStyleValue::as_conic_gradient() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_conic_gradient()); | 
					
						
							|  |  |  |     return static_cast<ConicGradientStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ContentStyleValue const& CSSStyleValue::as_content() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_content()); | 
					
						
							|  |  |  |     return static_cast<ContentStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | CounterStyleValue const& CSSStyleValue::as_counter() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_counter()); | 
					
						
							|  |  |  |     return static_cast<CounterStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | CounterDefinitionsStyleValue const& CSSStyleValue::as_counter_definitions() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_counter_definitions()); | 
					
						
							|  |  |  |     return static_cast<CounterDefinitionsStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | CustomIdentStyleValue const& CSSStyleValue::as_custom_ident() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_custom_ident()); | 
					
						
							|  |  |  |     return static_cast<CustomIdentStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | DisplayStyleValue const& CSSStyleValue::as_display() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_display()); | 
					
						
							|  |  |  |     return static_cast<DisplayStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | EasingStyleValue const& CSSStyleValue::as_easing() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_easing()); | 
					
						
							|  |  |  |     return static_cast<EasingStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | EdgeStyleValue const& CSSStyleValue::as_edge() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_edge()); | 
					
						
							|  |  |  |     return static_cast<EdgeStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | FilterValueListStyleValue const& CSSStyleValue::as_filter_value_list() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_filter_value_list()); | 
					
						
							|  |  |  |     return static_cast<FilterValueListStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | FlexStyleValue const& CSSStyleValue::as_flex() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_flex()); | 
					
						
							|  |  |  |     return static_cast<FlexStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | FrequencyStyleValue const& CSSStyleValue::as_frequency() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_frequency()); | 
					
						
							|  |  |  |     return static_cast<FrequencyStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | GridAutoFlowStyleValue const& CSSStyleValue::as_grid_auto_flow() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_grid_auto_flow()); | 
					
						
							|  |  |  |     return static_cast<GridAutoFlowStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | GridTemplateAreaStyleValue const& CSSStyleValue::as_grid_template_area() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_grid_template_area()); | 
					
						
							|  |  |  |     return static_cast<GridTemplateAreaStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | GridTrackPlacementStyleValue const& CSSStyleValue::as_grid_track_placement() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_grid_track_placement()); | 
					
						
							|  |  |  |     return static_cast<GridTrackPlacementStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | GridTrackSizeListStyleValue const& CSSStyleValue::as_grid_track_size_list() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_grid_track_size_list()); | 
					
						
							|  |  |  |     return static_cast<GridTrackSizeListStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  | CSSKeywordValue const& CSSStyleValue::as_keyword() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  |     VERIFY(is_keyword()); | 
					
						
							|  |  |  |     return static_cast<CSSKeywordValue const&>(*this); | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ImageStyleValue const& CSSStyleValue::as_image() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_image()); | 
					
						
							|  |  |  |     return static_cast<ImageStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | IntegerStyleValue const& CSSStyleValue::as_integer() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_integer()); | 
					
						
							|  |  |  |     return static_cast<IntegerStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | LengthStyleValue const& CSSStyleValue::as_length() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_length()); | 
					
						
							|  |  |  |     return static_cast<LengthStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | LinearGradientStyleValue const& CSSStyleValue::as_linear_gradient() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_linear_gradient()); | 
					
						
							|  |  |  |     return static_cast<LinearGradientStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | MathDepthStyleValue const& CSSStyleValue::as_math_depth() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_math_depth()); | 
					
						
							|  |  |  |     return static_cast<MathDepthStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NumberStyleValue const& CSSStyleValue::as_number() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_number()); | 
					
						
							|  |  |  |     return static_cast<NumberStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-30 17:05:52 +01:00
										 |  |  | OpenTypeTaggedStyleValue const& CSSStyleValue::as_open_type_tagged() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_open_type_tagged()); | 
					
						
							|  |  |  |     return static_cast<OpenTypeTaggedStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | PercentageStyleValue const& CSSStyleValue::as_percentage() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_percentage()); | 
					
						
							|  |  |  |     return static_cast<PercentageStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | PositionStyleValue const& CSSStyleValue::as_position() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_position()); | 
					
						
							|  |  |  |     return static_cast<PositionStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | RadialGradientStyleValue const& CSSStyleValue::as_radial_gradient() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_radial_gradient()); | 
					
						
							|  |  |  |     return static_cast<RadialGradientStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | RatioStyleValue const& CSSStyleValue::as_ratio() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_ratio()); | 
					
						
							|  |  |  |     return static_cast<RatioStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | RectStyleValue const& CSSStyleValue::as_rect() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_rect()); | 
					
						
							|  |  |  |     return static_cast<RectStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ResolutionStyleValue const& CSSStyleValue::as_resolution() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_resolution()); | 
					
						
							|  |  |  |     return static_cast<ResolutionStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ScrollbarGutterStyleValue const& CSSStyleValue::as_scrollbar_gutter() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_scrollbar_gutter()); | 
					
						
							|  |  |  |     return static_cast<ScrollbarGutterStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ShadowStyleValue const& CSSStyleValue::as_shadow() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_shadow()); | 
					
						
							|  |  |  |     return static_cast<ShadowStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ShorthandStyleValue const& CSSStyleValue::as_shorthand() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_shorthand()); | 
					
						
							|  |  |  |     return static_cast<ShorthandStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | StringStyleValue const& CSSStyleValue::as_string() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_string()); | 
					
						
							|  |  |  |     return static_cast<StringStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | TimeStyleValue const& CSSStyleValue::as_time() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_time()); | 
					
						
							|  |  |  |     return static_cast<TimeStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | TransformationStyleValue const& CSSStyleValue::as_transformation() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_transformation()); | 
					
						
							|  |  |  |     return static_cast<TransformationStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | TransitionStyleValue const& CSSStyleValue::as_transition() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_transition()); | 
					
						
							|  |  |  |     return static_cast<TransitionStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | UnresolvedStyleValue const& CSSStyleValue::as_unresolved() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_unresolved()); | 
					
						
							|  |  |  |     return static_cast<UnresolvedStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | URLStyleValue const& CSSStyleValue::as_url() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_url()); | 
					
						
							|  |  |  |     return static_cast<URLStyleValue const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | StyleValueList const& CSSStyleValue::as_value_list() const | 
					
						
							| 
									
										
										
										
											2024-08-14 10:54:09 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_value_list()); | 
					
						
							|  |  |  |     return static_cast<StyleValueList const&>(*this); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-09-23 19:54:19 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | ValueComparingNonnullRefPtr<CSSStyleValue const> CSSStyleValue::absolutized(CSSPixelRect const&, Length::FontMetrics const&, Length::FontMetrics const&) const | 
					
						
							| 
									
										
										
										
											2023-03-31 14:25:38 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return *this; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | bool CSSStyleValue::has_auto() const | 
					
						
							| 
									
										
										
										
											2023-04-19 12:00:38 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     return is_keyword() && as_keyword().keyword() == Keyword::Auto; | 
					
						
							| 
									
										
										
										
											2023-04-19 12:00:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  | Keyword CSSStyleValue::to_keyword() const | 
					
						
							| 
									
										
										
										
											2023-04-19 12:00:38 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  |     if (is_keyword()) | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         return as_keyword().keyword(); | 
					
						
							|  |  |  |     return Keyword::Invalid; | 
					
						
							| 
									
										
										
										
											2023-04-19 12:00:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | int CSSStyleValue::to_font_weight() const | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  |     if (is_keyword()) { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         switch (as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::Normal: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             return Gfx::FontWeight::Regular; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Bold: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             return Gfx::FontWeight::Bold; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Lighter: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             // FIXME: This should be relative to the parent.
 | 
					
						
							|  |  |  |             return Gfx::FontWeight::Regular; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Bolder: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             // FIXME: This should be relative to the parent.
 | 
					
						
							|  |  |  |             return Gfx::FontWeight::Bold; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             return Gfx::FontWeight::Regular; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  |     if (is_number()) { | 
					
						
							|  |  |  |         return round_to<int>(as_number().number()); | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-12-11 15:05:56 +00:00
										 |  |  |     if (is_calculated()) { | 
					
						
							| 
									
										
										
										
											2024-12-11 15:16:34 +00:00
										 |  |  |         auto maybe_weight = as_calculated().resolve_integer(); | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |         if (maybe_weight.has_value()) | 
					
						
							|  |  |  |             return maybe_weight.value(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return Gfx::FontWeight::Regular; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | int CSSStyleValue::to_font_slope() const | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     // FIXME: Implement oblique <angle>
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  |     if (is_keyword()) { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         switch (as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::Italic: { | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             static int italic_slope = Gfx::name_to_slope("Italic"sv); | 
					
						
							|  |  |  |             return italic_slope; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Oblique: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |             static int oblique_slope = Gfx::name_to_slope("Oblique"sv); | 
					
						
							|  |  |  |             return oblique_slope; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Normal: | 
					
						
							| 
									
										
										
										
											2023-05-24 15:28:09 +02:00
										 |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     static int normal_slope = Gfx::name_to_slope("Normal"sv); | 
					
						
							|  |  |  |     return normal_slope; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-27 14:04:59 +01:00
										 |  |  | int CSSStyleValue::to_font_width() const | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     int width = Gfx::FontWidth::Normal; | 
					
						
							| 
									
										
										
										
											2024-08-14 11:46:56 +01:00
										 |  |  |     if (is_keyword()) { | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         switch (as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::UltraCondensed: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::UltraCondensed; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::ExtraCondensed: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::ExtraCondensed; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Condensed: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::Condensed; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::SemiCondensed: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::SemiCondensed; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Normal: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::Normal; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::SemiExpanded: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::SemiExpanded; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::Expanded: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::Expanded; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::ExtraExpanded: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::ExtraExpanded; | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         case Keyword::UltraExpanded: | 
					
						
							| 
									
										
										
										
											2023-08-07 21:44:10 +02:00
										 |  |  |             width = Gfx::FontWidth::UltraExpanded; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } else if (is_percentage()) { | 
					
						
							|  |  |  |         float percentage = as_percentage().percentage().value(); | 
					
						
							|  |  |  |         if (percentage <= 50) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::UltraCondensed; | 
					
						
							|  |  |  |         } else if (percentage <= 62.5f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::ExtraCondensed; | 
					
						
							|  |  |  |         } else if (percentage <= 75.0f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::Condensed; | 
					
						
							|  |  |  |         } else if (percentage <= 87.5f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::SemiCondensed; | 
					
						
							|  |  |  |         } else if (percentage <= 100.0f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::Normal; | 
					
						
							|  |  |  |         } else if (percentage <= 112.5f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::SemiExpanded; | 
					
						
							|  |  |  |         } else if (percentage <= 125.0f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::Expanded; | 
					
						
							|  |  |  |         } else if (percentage <= 150.0f) { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::ExtraExpanded; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             width = Gfx::FontWidth::UltraExpanded; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return width; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-05 01:19:03 +01:00
										 |  |  | Optional<Gfx::FontVariantAlternates> CSSStyleValue::to_font_variant_alternates() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_keyword()); | 
					
						
							|  |  |  |     switch (as_keyword().keyword()) { | 
					
						
							|  |  |  |     case Keyword::Normal: | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     case Keyword::HistoricalForms: | 
					
						
							|  |  |  |         return Gfx::FontVariantAlternates { .historical_forms = true }; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<FontVariantCaps> CSSStyleValue::to_font_variant_caps() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_keyword()); | 
					
						
							|  |  |  |     return keyword_to_font_variant_caps(as_keyword().keyword()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<Gfx::FontVariantEastAsian> CSSStyleValue::to_font_variant_east_asian() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_value_list()); | 
					
						
							|  |  |  |     auto& list = as_value_list(); | 
					
						
							|  |  |  |     Gfx::FontVariantEastAsian east_asian {}; | 
					
						
							|  |  |  |     for (auto& value : list.values()) { | 
					
						
							|  |  |  |         VERIFY(value->is_keyword()); | 
					
						
							|  |  |  |         switch (value->as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::Normal: | 
					
						
							|  |  |  |             return {}; | 
					
						
							|  |  |  |         case Keyword::Jis78: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Jis78; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Jis83: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Jis83; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Jis90: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Jis90; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Jis04: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Jis04; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Simplified: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Simplified; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Traditional: | 
					
						
							|  |  |  |             east_asian.variant = Gfx::FontVariantEastAsian::Variant::Traditional; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::FullWidth: | 
					
						
							|  |  |  |             east_asian.width = Gfx::FontVariantEastAsian::Width::FullWidth; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::ProportionalWidth: | 
					
						
							|  |  |  |             east_asian.width = Gfx::FontVariantEastAsian::Width::Proportional; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Ruby: | 
					
						
							|  |  |  |             east_asian.ruby = true; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return east_asian; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<FontVariantEmoji> CSSStyleValue::to_font_variant_emoji() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_keyword()); | 
					
						
							|  |  |  |     return keyword_to_font_variant_emoji(as_keyword().keyword()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<Gfx::FontVariantLigatures> CSSStyleValue::to_font_variant_ligatures() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!is_value_list()) { | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     auto const& list = as_value_list(); | 
					
						
							|  |  |  |     Gfx::FontVariantLigatures ligatures {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (auto& value : list.values()) { | 
					
						
							|  |  |  |         if (!value->is_keyword()) | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         switch (value->as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::Normal: | 
					
						
							|  |  |  |             return {}; | 
					
						
							|  |  |  |         case Keyword::None: | 
					
						
							|  |  |  |             ligatures.none = true; | 
					
						
							|  |  |  |             return ligatures; | 
					
						
							|  |  |  |         case Keyword::CommonLigatures: | 
					
						
							|  |  |  |             ligatures.common = Gfx::FontVariantLigatures::Common::Common; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::NoCommonLigatures: | 
					
						
							|  |  |  |             ligatures.common = Gfx::FontVariantLigatures::Common::NoCommon; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::DiscretionaryLigatures: | 
					
						
							|  |  |  |             ligatures.discretionary = Gfx::FontVariantLigatures::Discretionary::Discretionary; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::NoDiscretionaryLigatures: | 
					
						
							|  |  |  |             ligatures.discretionary = Gfx::FontVariantLigatures::Discretionary::NoDiscretionary; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::HistoricalLigatures: | 
					
						
							|  |  |  |             ligatures.historical = Gfx::FontVariantLigatures::Historical::Historical; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::NoHistoricalLigatures: | 
					
						
							|  |  |  |             ligatures.historical = Gfx::FontVariantLigatures::Historical::NoHistorical; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::Contextual: | 
					
						
							|  |  |  |             ligatures.contextual = Gfx::FontVariantLigatures::Contextual::Contextual; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::NoContextual: | 
					
						
							|  |  |  |             ligatures.contextual = Gfx::FontVariantLigatures::Contextual::NoContextual; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return ligatures; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<Gfx::FontVariantNumeric> CSSStyleValue::to_font_variant_numeric() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_value_list()); | 
					
						
							|  |  |  |     auto& list = as_value_list(); | 
					
						
							|  |  |  |     Gfx::FontVariantNumeric numeric {}; | 
					
						
							|  |  |  |     for (auto& value : list.values()) { | 
					
						
							|  |  |  |         VERIFY(value->is_keyword()); | 
					
						
							|  |  |  |         switch (value->as_keyword().keyword()) { | 
					
						
							|  |  |  |         case Keyword::Normal: | 
					
						
							|  |  |  |             return {}; | 
					
						
							|  |  |  |         case Keyword::Ordinal: | 
					
						
							|  |  |  |             numeric.ordinal = true; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::SlashedZero: | 
					
						
							|  |  |  |             numeric.slashed_zero = true; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::OldstyleNums: | 
					
						
							|  |  |  |             numeric.figure = Gfx::FontVariantNumeric::Figure::Oldstyle; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::LiningNums: | 
					
						
							|  |  |  |             numeric.figure = Gfx::FontVariantNumeric::Figure::Lining; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::ProportionalNums: | 
					
						
							|  |  |  |             numeric.spacing = Gfx::FontVariantNumeric::Spacing::Proportional; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::TabularNums: | 
					
						
							|  |  |  |             numeric.spacing = Gfx::FontVariantNumeric::Spacing::Tabular; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::DiagonalFractions: | 
					
						
							|  |  |  |             numeric.fraction = Gfx::FontVariantNumeric::Fraction::Diagonal; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         case Keyword::StackedFractions: | 
					
						
							|  |  |  |             numeric.fraction = Gfx::FontVariantNumeric::Fraction::Stacked; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return numeric; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<FontVariantPosition> CSSStyleValue::to_font_variant_position() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(is_keyword()); | 
					
						
							|  |  |  |     return keyword_to_font_variant_position(as_keyword().keyword()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | } |