| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  |  * Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  |  * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-01-18 09:38:21 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | #include <AK/TypeCasts.h>
 | 
					
						
							| 
									
										
										
										
											2020-02-06 15:04:03 +01:00
										 |  |  | #include <LibCore/DirIterator.h>
 | 
					
						
							| 
									
										
										
										
											2022-07-31 18:47:09 +02:00
										 |  |  | #include <LibWeb/CSS/Clip.h>
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:32:51 +01:00
										 |  |  | #include <LibWeb/CSS/StyleProperties.h>
 | 
					
						
							|  |  |  | #include <LibWeb/FontCache.h>
 | 
					
						
							| 
									
										
										
										
											2021-10-06 20:02:41 +02:00
										 |  |  | #include <LibWeb/Layout/BlockContainer.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-12 16:41:09 +01:00
										 |  |  | #include <LibWeb/Layout/Node.h>
 | 
					
						
							| 
									
										
										
										
											2022-09-17 21:25:50 +02:00
										 |  |  | #include <LibWeb/Platform/FontPlugin.h>
 | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-26 20:01:35 +02:00
										 |  |  | namespace Web::CSS { | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  | StyleProperties::StyleProperties(StyleProperties const& other) | 
					
						
							| 
									
										
										
										
											2020-04-08 17:18:47 +02:00
										 |  |  |     : m_property_values(other.m_property_values) | 
					
						
							| 
									
										
										
										
											2020-01-05 16:54:38 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     if (other.m_font) { | 
					
						
							|  |  |  |         m_font = other.m_font->clone(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         m_font = nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NonnullRefPtr<StyleProperties> StyleProperties::clone() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2021-04-23 16:46:57 +02:00
										 |  |  |     return adopt_ref(*new StyleProperties(*this)); | 
					
						
							| 
									
										
										
										
											2020-01-05 16:54:38 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  | void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value) | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |     m_property_values[to_underlying(id)] = move(value); | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  | NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID property_id) const | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |     auto value = m_property_values[to_underlying(property_id)]; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     // By the time we call this method, all properties have values assigned.
 | 
					
						
							|  |  |  |     VERIFY(!value.is_null()); | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |     return value.release_nonnull(); | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  | RefPtr<StyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const | 
					
						
							| 
									
										
										
										
											2022-10-28 15:42:18 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return m_property_values[to_underlying(property_id)]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-25 15:47:40 +02:00
										 |  |  | CSS::Size StyleProperties::size_value(CSS::PropertyID id) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(id); | 
					
						
							|  |  |  |     if (value->is_identifier()) { | 
					
						
							|  |  |  |         switch (value->to_identifier()) { | 
					
						
							|  |  |  |         case ValueID::Auto: | 
					
						
							|  |  |  |             return CSS::Size::make_auto(); | 
					
						
							|  |  |  |         case ValueID::MinContent: | 
					
						
							|  |  |  |             return CSS::Size::make_min_content(); | 
					
						
							|  |  |  |         case ValueID::MaxContent: | 
					
						
							|  |  |  |             return CSS::Size::make_max_content(); | 
					
						
							|  |  |  |         case ValueID::None: | 
					
						
							|  |  |  |             return CSS::Size::make_none(); | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_calculated()) | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  |         return CSS::Size::make_length(CSS::Length::make_calculated(const_cast<CalculatedStyleValue&>(value->as_calculated()))); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:47:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_percentage()) | 
					
						
							|  |  |  |         return CSS::Size::make_percentage(value->as_percentage().percentage()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->has_length()) { | 
					
						
							|  |  |  |         auto length = value->to_length(); | 
					
						
							|  |  |  |         if (length.is_auto()) | 
					
						
							|  |  |  |             return CSS::Size::make_auto(); | 
					
						
							|  |  |  |         return CSS::Size::make_length(value->to_length()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // FIXME: Support `fit-content(<length>)`
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     dbgln("FIXME: Unsupported size value: `{}`, treating as `auto`", value->to_string()); | 
					
						
							| 
									
										
										
										
											2022-09-25 15:47:40 +02:00
										 |  |  |     return CSS::Size::make_auto(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 16:19:43 +00:00
										 |  |  | LengthPercentage StyleProperties::length_percentage_or_fallback(CSS::PropertyID id, LengthPercentage const& fallback) const | 
					
						
							| 
									
										
										
										
											2022-02-18 15:10:11 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return length_percentage(id).value_or(fallback); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<LengthPercentage> StyleProperties::length_percentage(CSS::PropertyID id) const | 
					
						
							| 
									
										
										
										
											2022-01-19 16:19:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(id); | 
					
						
							| 
									
										
										
										
											2022-01-19 16:19:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 14:38:59 +00:00
										 |  |  |     if (value->is_calculated()) | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  |         return LengthPercentage { const_cast<CalculatedStyleValue&>(value->as_calculated()) }; | 
					
						
							| 
									
										
										
										
											2022-01-19 16:19:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_percentage()) | 
					
						
							|  |  |  |         return value->as_percentage().percentage(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->has_length()) | 
					
						
							|  |  |  |         return value->to_length(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-18 15:10:11 +00:00
										 |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2019-09-21 15:32:17 +03:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-09-25 11:55:04 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-15 20:01:00 +01:00
										 |  |  | LengthBox StyleProperties::length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id, const CSS::Length& default_value) const | 
					
						
							| 
									
										
										
										
											2020-05-11 23:04:59 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-06-24 17:45:42 +02:00
										 |  |  |     LengthBox box; | 
					
						
							| 
									
										
										
										
											2022-09-13 17:42:39 +02:00
										 |  |  |     box.left() = length_percentage_or_fallback(left_id, default_value); | 
					
						
							|  |  |  |     box.top() = length_percentage_or_fallback(top_id, default_value); | 
					
						
							|  |  |  |     box.right() = length_percentage_or_fallback(right_id, default_value); | 
					
						
							|  |  |  |     box.bottom() = length_percentage_or_fallback(bottom_id, default_value); | 
					
						
							| 
									
										
										
										
											2020-06-24 17:45:42 +02:00
										 |  |  |     return box; | 
					
						
							| 
									
										
										
										
											2020-05-11 23:04:59 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-16 19:20:20 +01:00
										 |  |  | Color StyleProperties::color_or_fallback(CSS::PropertyID id, Layout::NodeWithStyle const& node, Color fallback) const | 
					
						
							| 
									
										
										
										
											2019-09-28 22:18:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-10-08 15:34:19 +02:00
										 |  |  |     auto value = property(id); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->has_color()) | 
					
						
							| 
									
										
										
										
											2019-09-28 22:18:19 +02:00
										 |  |  |         return fallback; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value->to_color(node); | 
					
						
							| 
									
										
										
										
											2019-09-28 22:18:19 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-06 11:23:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  | NonnullRefPtr<Gfx::Font const> StyleProperties::font_fallback(bool monospace, bool bold) | 
					
						
							| 
									
										
										
										
											2021-04-22 20:47:47 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (monospace && bold) | 
					
						
							| 
									
										
										
										
											2022-09-17 21:25:50 +02:00
										 |  |  |         return Platform::FontPlugin::the().default_fixed_width_font().bold_variant(); | 
					
						
							| 
									
										
										
										
											2021-04-22 20:47:47 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (monospace) | 
					
						
							| 
									
										
										
										
											2022-09-17 21:25:50 +02:00
										 |  |  |         return Platform::FontPlugin::the().default_fixed_width_font(); | 
					
						
							| 
									
										
										
										
											2021-04-22 20:47:47 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (bold) | 
					
						
							| 
									
										
										
										
											2022-09-17 21:25:50 +02:00
										 |  |  |         return Platform::FontPlugin::the().default_font().bold_variant(); | 
					
						
							| 
									
										
										
										
											2021-04-22 20:47:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 21:25:50 +02:00
										 |  |  |     return Platform::FontPlugin::the().default_font(); | 
					
						
							| 
									
										
										
										
											2021-04-22 20:47:47 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-17 23:08:45 +01:00
										 |  |  | // FIXME: This implementation is almost identical to line_height(Layout::Node) below. Maybe they can be combined somehow.
 | 
					
						
							|  |  |  | CSSPixels StyleProperties::line_height(CSSPixelRect const& viewport_rect, Gfx::FontPixelMetrics const& font_metrics, CSSPixels font_size, CSSPixels root_font_size, CSSPixels parent_line_height, CSSPixels root_line_height) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto line_height = property(CSS::PropertyID::LineHeight); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal) | 
					
						
							|  |  |  |         return font_metrics.line_spacing(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (line_height->is_length()) { | 
					
						
							|  |  |  |         auto line_height_length = line_height->to_length(); | 
					
						
							|  |  |  |         if (!line_height_length.is_auto()) | 
					
						
							|  |  |  |             return line_height_length.to_px(viewport_rect, font_metrics, font_size, root_font_size, parent_line_height, root_line_height); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (line_height->is_numeric()) | 
					
						
							|  |  |  |         return Length(line_height->to_number(), Length::Type::Em).to_px(viewport_rect, font_metrics, font_size, root_font_size, parent_line_height, root_line_height); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (line_height->is_percentage()) { | 
					
						
							|  |  |  |         // Percentages are relative to 1em. https://www.w3.org/TR/css-inline-3/#valdef-line-height-percentage
 | 
					
						
							|  |  |  |         auto& percentage = line_height->as_percentage().percentage(); | 
					
						
							|  |  |  |         return Length(percentage.as_fraction(), Length::Type::Em).to_px(viewport_rect, font_metrics, font_size, root_font_size, parent_line_height, root_line_height); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-18 21:15:51 +01:00
										 |  |  |     if (line_height->is_calculated()) { | 
					
						
							|  |  |  |         // FIXME: Handle `line-height: calc(...)` despite not having a LayoutNode here.
 | 
					
						
							|  |  |  |         return font_metrics.line_spacing(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-17 23:08:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return font_metrics.line_spacing(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-08 11:31:24 +00:00
										 |  |  | CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const | 
					
						
							| 
									
										
										
										
											2019-10-12 13:42:58 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto line_height = property(CSS::PropertyID::LineHeight); | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal) | 
					
						
							|  |  |  |         return layout_node.font().pixel_metrics().line_spacing(); | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (line_height->is_length()) { | 
					
						
							|  |  |  |         auto line_height_length = line_height->to_length(); | 
					
						
							|  |  |  |         if (!line_height_length.is_auto()) | 
					
						
							|  |  |  |             return line_height_length.to_px(layout_node); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (line_height->is_numeric()) | 
					
						
							|  |  |  |         return Length(line_height->to_number(), Length::Type::Em).to_px(layout_node); | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (line_height->is_percentage()) { | 
					
						
							|  |  |  |         // Percentages are relative to 1em. https://www.w3.org/TR/css-inline-3/#valdef-line-height-percentage
 | 
					
						
							|  |  |  |         auto& percentage = line_height->as_percentage().percentage(); | 
					
						
							|  |  |  |         return Length(percentage.as_fraction(), Length::Type::Em).to_px(layout_node); | 
					
						
							| 
									
										
										
										
											2022-01-18 15:50:20 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-01 14:47:26 +01:00
										 |  |  |     if (line_height->is_calculated()) | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  |         return CSS::Length::make_calculated(const_cast<CalculatedStyleValue&>(line_height->as_calculated())).to_px(layout_node); | 
					
						
							| 
									
										
										
										
											2023-01-01 14:47:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-29 00:49:05 +02:00
										 |  |  |     return layout_node.font().pixel_metrics().line_spacing(); | 
					
						
							| 
									
										
										
										
											2019-10-12 13:42:58 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-15 17:29:35 +02:00
										 |  |  | Optional<int> StyleProperties::z_index() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::ZIndex); | 
					
						
							| 
									
										
										
										
											2021-09-23 19:54:19 +01:00
										 |  |  |     if (value->has_auto()) | 
					
						
							| 
									
										
										
										
											2022-03-04 15:01:01 +01:00
										 |  |  |         return {}; | 
					
						
							| 
									
										
										
										
											2021-10-19 16:43:56 +01:00
										 |  |  |     if (value->has_integer()) | 
					
						
							|  |  |  |         return value->to_integer(); | 
					
						
							| 
									
										
										
										
											2021-09-10 20:37:09 +01:00
										 |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2020-06-15 17:29:35 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-19 15:27:40 +02:00
										 |  |  | float StyleProperties::opacity() const | 
					
						
							| 
									
										
										
										
											2021-07-23 13:18:09 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::Opacity); | 
					
						
							| 
									
										
										
										
											2021-09-10 20:23:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 17:44:22 +00:00
										 |  |  |     float unclamped_opacity = 1.0f; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->has_number()) { | 
					
						
							|  |  |  |         unclamped_opacity = value->to_number(); | 
					
						
							|  |  |  |     } else if (value->is_calculated()) { | 
					
						
							|  |  |  |         auto& calculated = value->as_calculated(); | 
					
						
							|  |  |  |         if (calculated.resolved_type() == CalculatedStyleValue::ResolvedType::Percentage) { | 
					
						
							|  |  |  |             auto maybe_percentage = value->as_calculated().resolve_percentage(); | 
					
						
							|  |  |  |             if (maybe_percentage.has_value()) | 
					
						
							|  |  |  |                 unclamped_opacity = maybe_percentage->as_fraction(); | 
					
						
							|  |  |  |             else | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |                 dbgln("Unable to resolve calc() as opacity (percentage): {}", value->to_string()); | 
					
						
							| 
									
										
										
										
											2022-01-27 17:44:22 +00:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2023-02-20 18:56:08 +01:00
										 |  |  |             auto maybe_number = const_cast<CalculatedStyleValue&>(value->as_calculated()).resolve_number(); | 
					
						
							| 
									
										
										
										
											2022-01-27 17:44:22 +00:00
										 |  |  |             if (maybe_number.has_value()) | 
					
						
							|  |  |  |                 unclamped_opacity = maybe_number.value(); | 
					
						
							|  |  |  |             else | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |                 dbgln("Unable to resolve calc() as opacity (number): {}", value->to_string()); | 
					
						
							| 
									
										
										
										
											2022-01-27 17:44:22 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     } else if (value->is_percentage()) { | 
					
						
							|  |  |  |         unclamped_opacity = value->as_percentage().percentage().as_fraction(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-07-23 13:18:09 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-27 17:44:22 +00:00
										 |  |  |     return clamp(unclamped_opacity, 0.0f, 1.0f); | 
					
						
							| 
									
										
										
										
											2021-07-23 13:18:09 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-18 17:41:57 +01:00
										 |  |  | Optional<CSS::FlexDirection> StyleProperties::flex_direction() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::FlexDirection); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_flex_direction(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-01-18 17:41:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-30 12:11:32 +02:00
										 |  |  | Optional<CSS::FlexWrap> StyleProperties::flex_wrap() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::FlexWrap); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_flex_wrap(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-05-30 12:11:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-30 14:23:43 +02:00
										 |  |  | Optional<CSS::FlexBasisData> StyleProperties::flex_basis() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::FlexBasis); | 
					
						
							| 
									
										
										
										
											2021-05-30 14:23:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 11:52:01 +00:00
										 |  |  |     if (value->is_identifier() && value->to_identifier() == CSS::ValueID::Content) | 
					
						
							| 
									
										
										
										
											2021-05-30 14:23:43 +02:00
										 |  |  |         return { { CSS::FlexBasis::Content, {} } }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 11:52:01 +00:00
										 |  |  |     if (value->has_auto()) | 
					
						
							| 
									
										
										
										
											2021-08-06 22:00:25 +02:00
										 |  |  |         return { { CSS::FlexBasis::Auto, {} } }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-19 11:52:01 +00:00
										 |  |  |     if (value->is_percentage()) | 
					
						
							|  |  |  |         return { { CSS::FlexBasis::LengthPercentage, value->as_percentage().percentage() } }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->has_length()) | 
					
						
							|  |  |  |         return { { CSS::FlexBasis::LengthPercentage, value->to_length() } }; | 
					
						
							| 
									
										
										
										
											2021-05-30 14:23:43 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-19 15:22:08 +02:00
										 |  |  | float StyleProperties::flex_grow() const | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::FlexGrow); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->has_number()) | 
					
						
							| 
									
										
										
										
											2021-10-19 15:22:08 +02:00
										 |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value->to_number(); | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-19 15:22:08 +02:00
										 |  |  | float StyleProperties::flex_shrink() const | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::FlexShrink); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->has_number()) | 
					
						
							| 
									
										
										
										
											2021-10-19 15:22:08 +02:00
										 |  |  |         return 1; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value->to_number(); | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-10-19 15:22:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-31 22:11:38 +02:00
										 |  |  | int StyleProperties::order() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Order); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->has_integer()) | 
					
						
							| 
									
										
										
										
											2022-03-31 22:11:38 +02:00
										 |  |  |         return 0; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value->to_integer(); | 
					
						
							| 
									
										
										
										
											2022-03-31 22:11:38 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-18 12:21:27 +01:00
										 |  |  | Optional<CSS::ImageRendering> StyleProperties::image_rendering() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::ImageRendering); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_image_rendering(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2022-02-18 12:21:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-31 18:47:09 +02:00
										 |  |  | CSS::Clip StyleProperties::clip() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Clip); | 
					
						
							|  |  |  |     if (!value->has_rect()) | 
					
						
							|  |  |  |         return CSS::Clip::make_auto(); | 
					
						
							|  |  |  |     return CSS::Clip(value->as_rect().rect()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-16 18:38:26 +02:00
										 |  |  | Optional<CSS::JustifyContent> StyleProperties::justify_content() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::JustifyContent); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_justify_content(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-07-16 18:38:26 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-05-30 20:22:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  | Vector<CSS::Transformation> StyleProperties::transformations() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Transform); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (value->is_identifier() && value->to_identifier() == CSS::ValueID::None) | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |         return {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->is_value_list()) | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |         return {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto& list = value->as_value_list(); | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Vector<CSS::Transformation> transformations; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (auto& it : list.values()) { | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |         if (!it->is_transformation()) | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |             return {}; | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |         auto& transformation_style_value = it->as_transformation(); | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |         CSS::Transformation transformation; | 
					
						
							|  |  |  |         transformation.function = transformation_style_value.transform_function(); | 
					
						
							| 
									
										
										
										
											2022-07-14 17:45:23 +01:00
										 |  |  |         Vector<TransformValue> values; | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |         for (auto& transformation_value : transformation_style_value.values()) { | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |             if (transformation_value->is_length()) { | 
					
						
							|  |  |  |                 values.append({ transformation_value->to_length() }); | 
					
						
							|  |  |  |             } else if (transformation_value->is_percentage()) { | 
					
						
							|  |  |  |                 values.append({ transformation_value->as_percentage().percentage() }); | 
					
						
							|  |  |  |             } else if (transformation_value->is_numeric()) { | 
					
						
							|  |  |  |                 values.append({ transformation_value->to_number() }); | 
					
						
							|  |  |  |             } else if (transformation_value->is_angle()) { | 
					
						
							|  |  |  |                 values.append({ transformation_value->as_angle().angle() }); | 
					
						
							| 
									
										
										
										
											2021-09-18 17:20:00 +02:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 dbgln("FIXME: Unsupported value in transform!"); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         transformation.values = move(values); | 
					
						
							|  |  |  |         transformations.append(move(transformation)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return transformations; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-21 19:38:00 +01:00
										 |  |  | static Optional<LengthPercentage> length_percentage_for_style_value(StyleValue const& value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (value.is_length()) | 
					
						
							|  |  |  |         return value.to_length(); | 
					
						
							|  |  |  |     if (value.is_percentage()) | 
					
						
							|  |  |  |         return value.as_percentage().percentage(); | 
					
						
							|  |  |  |     return {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CSS::TransformOrigin StyleProperties::transform_origin() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::TransformOrigin); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->is_value_list() || value->as_value_list().size() != 2) | 
					
						
							| 
									
										
										
										
											2022-03-21 19:38:00 +01:00
										 |  |  |         return {}; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto const& list = value->as_value_list(); | 
					
						
							| 
									
										
										
										
											2022-03-21 19:38:00 +01:00
										 |  |  |     auto x_value = length_percentage_for_style_value(list.values()[0]); | 
					
						
							|  |  |  |     auto y_value = length_percentage_for_style_value(list.values()[1]); | 
					
						
							|  |  |  |     if (!x_value.has_value() || !y_value.has_value()) { | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return { x_value.value(), y_value.value() }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-14 13:50:06 +02:00
										 |  |  | Optional<CSS::AlignContent> StyleProperties::align_content() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::AlignContent); | 
					
						
							|  |  |  |     return value_id_to_align_content(value->to_identifier()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-15 18:27:20 +02:00
										 |  |  | Optional<CSS::AlignItems> StyleProperties::align_items() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::AlignItems); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_align_items(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-09-15 18:27:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-11 23:52:36 +02:00
										 |  |  | Optional<CSS::AlignSelf> StyleProperties::align_self() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::AlignSelf); | 
					
						
							|  |  |  |     return value_id_to_align_self(value->to_identifier()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-22 16:05:11 +01:00
										 |  |  | Optional<CSS::Appearance> StyleProperties::appearance() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Appearance); | 
					
						
							|  |  |  |     auto appearance = value_id_to_appearance(value->to_identifier()); | 
					
						
							|  |  |  |     if (appearance.has_value()) { | 
					
						
							|  |  |  |         switch (*appearance) { | 
					
						
							|  |  |  |         // Note: All these compatibility values can be treated as 'auto'
 | 
					
						
							|  |  |  |         case CSS::Appearance::Textfield: | 
					
						
							|  |  |  |         case CSS::Appearance::MenulistButton: | 
					
						
							|  |  |  |         case CSS::Appearance::Searchfield: | 
					
						
							|  |  |  |         case CSS::Appearance::Textarea: | 
					
						
							|  |  |  |         case CSS::Appearance::PushButton: | 
					
						
							|  |  |  |         case CSS::Appearance::SliderHorizontal: | 
					
						
							|  |  |  |         case CSS::Appearance::Checkbox: | 
					
						
							|  |  |  |         case CSS::Appearance::Radio: | 
					
						
							|  |  |  |         case CSS::Appearance::SquareButton: | 
					
						
							|  |  |  |         case CSS::Appearance::Menulist: | 
					
						
							|  |  |  |         case CSS::Appearance::Listbox: | 
					
						
							|  |  |  |         case CSS::Appearance::Meter: | 
					
						
							|  |  |  |         case CSS::Appearance::ProgressBar: | 
					
						
							|  |  |  |         case CSS::Appearance::Button: | 
					
						
							|  |  |  |             appearance = CSS::Appearance::Auto; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return appearance; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-15 08:31:19 +01:00
										 |  |  | CSS::BackdropFilter StyleProperties::backdrop_filter() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::BackdropFilter); | 
					
						
							|  |  |  |     if (value->is_filter_value_list()) | 
					
						
							|  |  |  |         return BackdropFilter(value->as_filter_value_list()); | 
					
						
							|  |  |  |     return BackdropFilter::make_none(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-14 18:47:00 +01:00
										 |  |  | Optional<CSS::Position> StyleProperties::position() const | 
					
						
							| 
									
										
										
										
											2020-03-23 17:29:15 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-12-14 18:47:00 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::Position); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_position(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-03-23 17:29:15 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-01 20:58:27 +03:00
										 |  |  | bool StyleProperties::operator==(StyleProperties const& other) const | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (m_property_values.size() != other.m_property_values.size()) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |     for (size_t i = 0; i < m_property_values.size(); ++i) { | 
					
						
							|  |  |  |         auto const& my_ptr = m_property_values[i]; | 
					
						
							| 
									
										
										
										
											2022-03-12 23:57:40 +01:00
										 |  |  |         auto const& other_ptr = other.m_property_values[i]; | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |         if (!my_ptr) { | 
					
						
							|  |  |  |             if (other_ptr) | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             continue; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (!other_ptr) | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2022-02-18 20:21:49 +01:00
										 |  |  |         auto const& my_value = *my_ptr; | 
					
						
							|  |  |  |         auto const& other_value = *other_ptr; | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  |         if (my_value.type() != other_value.type()) | 
					
						
							|  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2020-12-14 15:56:01 +01:00
										 |  |  |         if (my_value != other_value) | 
					
						
							| 
									
										
										
										
											2019-10-14 18:32:02 +02:00
										 |  |  |             return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return true; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-14 18:38:02 +01:00
										 |  |  | Optional<CSS::TextAlign> StyleProperties::text_align() const | 
					
						
							| 
									
										
										
										
											2020-06-13 10:54:58 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-12-14 18:38:02 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::TextAlign); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_text_align(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2022-03-12 19:31:32 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<CSS::TextJustify> StyleProperties::text_justify() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::TextJustify); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_text_justify(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-06-13 10:54:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-05 19:47:13 +01:00
										 |  |  | Optional<CSS::PointerEvents> StyleProperties::pointer_events() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::PointerEvents); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_pointer_events(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-10-05 19:47:13 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:37:44 +02:00
										 |  |  | Optional<CSS::WhiteSpace> StyleProperties::white_space() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::WhiteSpace); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_white_space(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-06-24 16:37:44 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-04 16:11:55 +01:00
										 |  |  | Optional<CSS::LineStyle> StyleProperties::line_style(CSS::PropertyID property_id) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(property_id); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_line_style(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-12-04 16:11:55 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-26 15:08:42 +02:00
										 |  |  | Optional<CSS::Float> StyleProperties::float_() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Float); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_float(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-06-26 15:08:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-06 01:45:51 +01:00
										 |  |  | Optional<CSS::Clear> StyleProperties::clear() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Clear); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_clear(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-12-06 01:45:51 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  | CSS::ContentData StyleProperties::content() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::Content); | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  |     if (value->is_content()) { | 
					
						
							|  |  |  |         auto& content_style_value = value->as_content(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         CSS::ContentData content_data; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         // FIXME: The content is a list of things: strings, identifiers or functions that return strings, and images.
 | 
					
						
							|  |  |  |         //        So it can't always be represented as a single String, but may have to be multiple boxes.
 | 
					
						
							|  |  |  |         //        For now, we'll just assume strings since that is easiest.
 | 
					
						
							|  |  |  |         StringBuilder builder; | 
					
						
							|  |  |  |         for (auto const& item : content_style_value.content().values()) { | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |             if (item->is_string()) { | 
					
						
							|  |  |  |                 builder.append(item->to_string().release_value_but_fixme_should_propagate_errors()); | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  |             } else { | 
					
						
							|  |  |  |                 // TODO: Implement quotes, counters, images, and other things.
 | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         content_data.type = ContentData::Type::String; | 
					
						
							| 
									
										
										
										
											2023-02-14 16:05:40 +00:00
										 |  |  |         content_data.data = builder.to_string().release_value_but_fixme_should_propagate_errors(); | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (content_style_value.has_alt_text()) { | 
					
						
							|  |  |  |             StringBuilder alt_text_builder; | 
					
						
							|  |  |  |             for (auto const& item : content_style_value.alt_text()->values()) { | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |                 if (item->is_string()) { | 
					
						
							|  |  |  |                     alt_text_builder.append(item->to_string().release_value_but_fixme_should_propagate_errors()); | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  |                 } else { | 
					
						
							|  |  |  |                     // TODO: Implement counters
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-02-14 16:05:40 +00:00
										 |  |  |             content_data.alt_text = alt_text_builder.to_string().release_value_but_fixme_should_propagate_errors(); | 
					
						
							| 
									
										
										
										
											2022-02-24 16:52:58 +00:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return content_data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (value->to_identifier()) { | 
					
						
							|  |  |  |     case ValueID::None: | 
					
						
							|  |  |  |         return { ContentData::Type::None }; | 
					
						
							|  |  |  |     case ValueID::Normal: | 
					
						
							|  |  |  |         return { ContentData::Type::Normal }; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return CSS::ContentData {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-21 17:41:00 +00:00
										 |  |  | Optional<CSS::Cursor> StyleProperties::cursor() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Cursor); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_cursor(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-02-21 17:41:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-21 15:42:57 +01:00
										 |  |  | Optional<CSS::Visibility> StyleProperties::visibility() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::Visibility); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->is_identifier()) | 
					
						
							| 
									
										
										
										
											2022-03-21 15:42:57 +01:00
										 |  |  |         return {}; | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_visibility(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2022-03-21 15:42:57 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 16:22:16 +02:00
										 |  |  | CSS::Display StyleProperties::display() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     auto value = property(CSS::PropertyID::Display); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (!value->is_identifier()) | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Inline); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     switch (value->to_identifier()) { | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::None: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::None); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::Block: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Block); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::Inline: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Inline); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::InlineBlock: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::InlineBlock); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::ListItem: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::ListItem); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::Table: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Table); | 
					
						
							| 
									
										
										
										
											2023-01-16 13:13:31 +01:00
										 |  |  |     case CSS::ValueID::InlineTable: | 
					
						
							|  |  |  |         return CSS::Display::from_short(CSS::Display::Short::InlineTable); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::TableRow: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableRow }; | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::TableCell: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableCell }; | 
					
						
							| 
									
										
										
										
											2021-01-07 14:40:02 +01:00
										 |  |  |     case CSS::ValueID::TableColumn: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableColumn }; | 
					
						
							| 
									
										
										
										
											2021-01-07 14:40:02 +01:00
										 |  |  |     case CSS::ValueID::TableColumnGroup: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableColumnGroup }; | 
					
						
							| 
									
										
										
										
											2021-01-07 14:40:02 +01:00
										 |  |  |     case CSS::ValueID::TableCaption: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableCaption }; | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::TableRowGroup: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableRowGroup }; | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::TableHeaderGroup: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableHeaderGroup }; | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     case CSS::ValueID::TableFooterGroup: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display { CSS::Display::Internal::TableFooterGroup }; | 
					
						
							| 
									
										
										
										
											2021-01-18 17:32:34 +01:00
										 |  |  |     case CSS::ValueID::Flex: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Flex); | 
					
						
							| 
									
										
										
										
											2022-02-07 17:29:36 +00:00
										 |  |  |     case CSS::ValueID::InlineFlex: | 
					
						
							|  |  |  |         return CSS::Display::from_short(CSS::Display::Short::InlineFlex); | 
					
						
							| 
									
										
										
										
											2022-08-23 10:13:07 +02:00
										 |  |  |     case CSS::ValueID::Grid: | 
					
						
							|  |  |  |         return CSS::Display::from_short(CSS::Display::Short::Grid); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     default: | 
					
						
							| 
									
										
										
										
											2021-10-06 17:57:44 +02:00
										 |  |  |         return CSS::Display::from_short(CSS::Display::Short::Block); | 
					
						
							| 
									
										
										
										
											2020-12-14 22:22:35 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-24 16:22:16 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 16:22:35 +01:00
										 |  |  | Vector<CSS::TextDecorationLine> StyleProperties::text_decoration_line() const | 
					
						
							| 
									
										
										
										
											2020-12-15 13:36:27 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::TextDecorationLine); | 
					
						
							| 
									
										
										
										
											2022-04-14 16:22:35 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_value_list()) { | 
					
						
							|  |  |  |         Vector<CSS::TextDecorationLine> lines; | 
					
						
							|  |  |  |         auto& values = value->as_value_list().values(); | 
					
						
							|  |  |  |         for (auto const& item : values) { | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |             lines.append(value_id_to_text_decoration_line(item->to_identifier()).value()); | 
					
						
							| 
									
										
										
										
											2022-04-14 16:22:35 +01:00
										 |  |  |         } | 
					
						
							|  |  |  |         return lines; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_identifier() && value->to_identifier() == ValueID::None) | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-06 19:02:26 +01:00
										 |  |  |     dbgln("FIXME: Unsupported value for text-decoration-line: {}", value->to_string()); | 
					
						
							| 
									
										
										
										
											2022-11-02 19:07:17 +01:00
										 |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2020-12-15 13:36:27 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-20 20:27:55 +01:00
										 |  |  | Optional<CSS::TextDecorationStyle> StyleProperties::text_decoration_style() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::TextDecorationStyle); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_text_decoration_style(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2022-01-20 20:27:55 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-15 14:15:49 +01:00
										 |  |  | Optional<CSS::TextTransform> StyleProperties::text_transform() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::TextTransform); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_text_transform(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-12-15 14:15:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-15 16:50:39 +01:00
										 |  |  | Optional<CSS::ListStyleType> StyleProperties::list_style_type() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::ListStyleType); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_list_style_type(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2020-12-15 16:50:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-22 15:20:31 +01:00
										 |  |  | Optional<CSS::Overflow> StyleProperties::overflow_x() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return overflow(CSS::PropertyID::OverflowX); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<CSS::Overflow> StyleProperties::overflow_y() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return overflow(CSS::PropertyID::OverflowY); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<CSS::Overflow> StyleProperties::overflow(CSS::PropertyID property_id) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(property_id); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_overflow(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-02-22 15:20:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  | Vector<ShadowData> StyleProperties::shadow(PropertyID property_id) const | 
					
						
							| 
									
										
										
										
											2021-07-23 21:22:31 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     auto value = property(property_id); | 
					
						
							| 
									
										
										
										
											2021-07-23 21:22:31 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  |     auto make_shadow_data = [](ShadowStyleValue const& value) { | 
					
						
							|  |  |  |         return ShadowData { value.color(), value.offset_x(), value.offset_y(), value.blur_radius(), value.spread_distance(), value.placement() }; | 
					
						
							| 
									
										
										
										
											2022-02-08 14:48:37 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (value->is_value_list()) { | 
					
						
							|  |  |  |         auto& value_list = value->as_value_list(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  |         Vector<ShadowData> shadow_data; | 
					
						
							|  |  |  |         shadow_data.ensure_capacity(value_list.size()); | 
					
						
							| 
									
										
										
										
											2022-02-08 14:48:37 +00:00
										 |  |  |         for (auto const& layer_value : value_list.values()) | 
					
						
							| 
									
										
										
										
											2023-03-06 14:33:11 +01:00
										 |  |  |             shadow_data.append(make_shadow_data(layer_value->as_shadow())); | 
					
						
							| 
									
										
										
										
											2022-02-08 14:48:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  |         return shadow_data; | 
					
						
							| 
									
										
										
										
											2022-02-08 14:48:37 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 16:55:22 +00:00
										 |  |  |     if (value->is_shadow()) { | 
					
						
							|  |  |  |         auto& box = value->as_shadow(); | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  |         return { make_shadow_data(box) }; | 
					
						
							| 
									
										
										
										
											2022-02-08 14:48:37 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2021-07-23 21:22:31 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-10-05 16:55:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 21:16:36 +00:00
										 |  |  | Vector<ShadowData> StyleProperties::box_shadow() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return shadow(PropertyID::BoxShadow); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Vector<ShadowData> StyleProperties::text_shadow() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return shadow(PropertyID::TextShadow); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-13 19:33:56 +01:00
										 |  |  | Optional<CSS::BoxSizing> StyleProperties::box_sizing() const | 
					
						
							| 
									
										
										
										
											2021-10-05 16:55:02 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::BoxSizing); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_box_sizing(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2021-10-05 16:55:02 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-02-26 01:34:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | Variant<CSS::VerticalAlign, CSS::LengthPercentage> StyleProperties::vertical_align() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::VerticalAlign); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (value->is_identifier()) | 
					
						
							|  |  |  |         return value_id_to_vertical_align(value->to_identifier()).release_value(); | 
					
						
							| 
									
										
										
										
											2022-02-26 01:34:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (value->is_length()) | 
					
						
							|  |  |  |         return CSS::LengthPercentage(value->to_length()); | 
					
						
							| 
									
										
										
										
											2022-02-26 01:34:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     if (value->is_percentage()) | 
					
						
							|  |  |  |         return CSS::LengthPercentage(value->as_percentage().percentage()); | 
					
						
							| 
									
										
										
										
											2022-02-26 01:34:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     VERIFY_NOT_REACHED(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-23 14:54:21 +01:00
										 |  |  | Optional<CSS::FontVariant> StyleProperties::font_variant() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::FontVariant); | 
					
						
							| 
									
										
										
										
											2022-04-14 11:52:35 +01:00
										 |  |  |     return value_id_to_font_variant(value->to_identifier()); | 
					
						
							| 
									
										
										
										
											2022-03-23 14:54:21 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | CSS::GridTrackSizeList StyleProperties::grid_template_columns() const | 
					
						
							| 
									
										
										
										
											2022-08-23 19:49:07 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridTemplateColumns); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     return value->as_grid_track_size_list().grid_track_size_list(); | 
					
						
							| 
									
										
										
										
											2022-08-23 19:49:07 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  | CSS::GridTrackSizeList StyleProperties::grid_template_rows() const | 
					
						
							| 
									
										
										
										
											2022-08-23 19:49:07 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridTemplateRows); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:27:57 +01:00
										 |  |  |     return value->as_grid_track_size_list().grid_track_size_list(); | 
					
						
							| 
									
										
										
										
											2022-08-23 19:49:07 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-23 19:58:00 +02:00
										 |  |  | CSS::GridTrackPlacement StyleProperties::grid_column_end() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridColumnEnd); | 
					
						
							|  |  |  |     return value->as_grid_track_placement().grid_track_placement(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CSS::GridTrackPlacement StyleProperties::grid_column_start() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridColumnStart); | 
					
						
							|  |  |  |     return value->as_grid_track_placement().grid_track_placement(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CSS::GridTrackPlacement StyleProperties::grid_row_end() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridRowEnd); | 
					
						
							|  |  |  |     return value->as_grid_track_placement().grid_track_placement(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CSS::GridTrackPlacement StyleProperties::grid_row_start() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridRowStart); | 
					
						
							|  |  |  |     return value->as_grid_track_placement().grid_track_placement(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-02 23:01:29 +01:00
										 |  |  | Optional<CSS::BorderCollapse> StyleProperties::border_collapse() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::BorderCollapse); | 
					
						
							|  |  |  |     return value_id_to_border_collapse(value->to_identifier()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-16 18:17:05 +01:00
										 |  |  | Vector<Vector<String>> StyleProperties::grid_template_areas() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridTemplateAreas); | 
					
						
							|  |  |  |     return value->as_grid_template_area().grid_template_area(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-16 19:02:39 +01:00
										 |  |  | String StyleProperties::grid_area() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     auto value = property(CSS::PropertyID::GridArea); | 
					
						
							|  |  |  |     return value->as_string().to_string().release_value_but_fixme_should_propagate_errors(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-07 10:27:02 +01:00
										 |  |  | } |