| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |  * Copyright (c) 2021-2025, Sam Atkins <sam@ladybird.org> | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-19 15:37:56 +01:00
										 |  |  | #include <AK/FlyString.h>
 | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							|  |  |  | #include <AK/Optional.h>
 | 
					
						
							|  |  |  | #include <AK/OwnPtr.h>
 | 
					
						
							|  |  |  | #include <AK/RefCounted.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  | #include <LibWeb/CSS/BooleanExpression.h>
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  | #include <LibWeb/CSS/CalculatedOr.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  | #include <LibWeb/CSS/MediaFeatureID.h>
 | 
					
						
							| 
									
										
										
										
											2025-05-22 11:56:04 +01:00
										 |  |  | #include <LibWeb/CSS/Parser/ComponentValue.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-06 17:50:56 +00:00
										 |  |  | #include <LibWeb/CSS/Ratio.h>
 | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  | // https://www.w3.org/TR/mediaqueries-4/#typedef-mf-value
 | 
					
						
							|  |  |  | class MediaFeatureValue { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     explicit MediaFeatureValue(Keyword ident) | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |         : m_value(move(ident)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     explicit MediaFeatureValue(LengthOrCalculated length) | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |         : m_value(move(length)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-06 17:50:56 +00:00
										 |  |  |     explicit MediaFeatureValue(Ratio ratio) | 
					
						
							|  |  |  |         : m_value(move(ratio)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     explicit MediaFeatureValue(ResolutionOrCalculated resolution) | 
					
						
							| 
									
										
										
										
											2022-02-22 14:09:19 +00:00
										 |  |  |         : m_value(move(resolution)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     explicit MediaFeatureValue(IntegerOrCalculated integer) | 
					
						
							|  |  |  |         : m_value(move(integer)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     explicit MediaFeatureValue(i64 integer) | 
					
						
							|  |  |  |         : m_value(IntegerOrCalculated(integer)) | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-22 11:56:04 +01:00
										 |  |  |     explicit MediaFeatureValue(Vector<Parser::ComponentValue> unknown_tokens) | 
					
						
							|  |  |  |         : m_value(move(unknown_tokens)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:04:18 +12:00
										 |  |  |     String to_string(SerializationMode mode) const; | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     bool is_ident() const { return m_value.has<Keyword>(); } | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     bool is_length() const { return m_value.has<LengthOrCalculated>(); } | 
					
						
							|  |  |  |     bool is_integer() const { return m_value.has<IntegerOrCalculated>(); } | 
					
						
							| 
									
										
										
										
											2022-03-06 17:50:56 +00:00
										 |  |  |     bool is_ratio() const { return m_value.has<Ratio>(); } | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     bool is_resolution() const { return m_value.has<ResolutionOrCalculated>(); } | 
					
						
							| 
									
										
										
										
											2025-05-22 11:56:04 +01:00
										 |  |  |     bool is_unknown() const { return m_value.has<Vector<Parser::ComponentValue>>(); } | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     bool is_same_type(MediaFeatureValue const& other) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |     Keyword const& ident() const | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         VERIFY(is_ident()); | 
					
						
							| 
									
										
										
										
											2024-08-14 14:06:03 +01:00
										 |  |  |         return m_value.get<Keyword>(); | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     LengthOrCalculated const& length() const | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         VERIFY(is_length()); | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |         return m_value.get<LengthOrCalculated>(); | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-06 17:50:56 +00:00
										 |  |  |     Ratio const& ratio() const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         VERIFY(is_ratio()); | 
					
						
							|  |  |  |         return m_value.get<Ratio>(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     ResolutionOrCalculated const& resolution() const | 
					
						
							| 
									
										
										
										
											2022-02-22 14:09:19 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         VERIFY(is_resolution()); | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |         return m_value.get<ResolutionOrCalculated>(); | 
					
						
							| 
									
										
										
										
											2022-02-22 14:09:19 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     IntegerOrCalculated integer() const | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |         VERIFY(is_integer()); | 
					
						
							|  |  |  |         return m_value.get<IntegerOrCalculated>(); | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2025-05-22 11:56:04 +01:00
										 |  |  |     Variant<Keyword, LengthOrCalculated, Ratio, ResolutionOrCalculated, IntegerOrCalculated, Vector<Parser::ComponentValue>> m_value; | 
					
						
							| 
									
										
										
										
											2021-12-29 17:52:14 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | // https://www.w3.org/TR/mediaqueries-4/#mq-features
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  | class MediaFeature final : public BooleanExpression { | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-05-19 12:32:37 +01:00
										 |  |  |     enum class Comparison : u8 { | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |         Equal, | 
					
						
							|  |  |  |         LessThan, | 
					
						
							|  |  |  |         LessThanOrEqual, | 
					
						
							|  |  |  |         GreaterThan, | 
					
						
							|  |  |  |         GreaterThanOrEqual, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     // Corresponds to `<mf-boolean>` grammar
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> boolean(MediaFeatureID id) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::IsTrue, id)); | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Corresponds to `<mf-plain>` grammar
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> plain(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::ExactValue, move(id), move(value))); | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> min(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::MinValue, id, move(value))); | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> max(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::MaxValue, id, move(value))); | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> half_range(MediaFeatureValue value, Comparison comparison, MediaFeatureID id) | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::Range, id, | 
					
						
							|  |  |  |             Range { | 
					
						
							|  |  |  |                 .left_value = move(value), | 
					
						
							|  |  |  |                 .left_comparison = comparison, | 
					
						
							|  |  |  |             })); | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-05-22 12:50:03 +01:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> half_range(MediaFeatureID id, Comparison comparison, MediaFeatureValue value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return adopt_own(*new MediaFeature(Type::Range, id, | 
					
						
							|  |  |  |             Range { | 
					
						
							|  |  |  |                 .right_comparison = comparison, | 
					
						
							|  |  |  |                 .right_value = move(value), | 
					
						
							|  |  |  |             })); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Corresponds to `<mf-range>` grammar, with two comparisons
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     static NonnullOwnPtr<MediaFeature> range(MediaFeatureValue left_value, Comparison left_comparison, MediaFeatureID id, Comparison right_comparison, MediaFeatureValue right_value) | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |         return adopt_own(*new MediaFeature(Type::Range, id, | 
					
						
							|  |  |  |             Range { | 
					
						
							|  |  |  |                 .left_value = move(left_value), | 
					
						
							|  |  |  |                 .left_comparison = left_comparison, | 
					
						
							|  |  |  |                 .right_comparison = right_comparison, | 
					
						
							|  |  |  |                 .right_value = move(right_value), | 
					
						
							|  |  |  |             })); | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     virtual MatchResult evaluate(HTML::Window const*) const override; | 
					
						
							|  |  |  |     virtual String to_string() const override; | 
					
						
							|  |  |  |     virtual void dump(StringBuilder&, int indent_levels = 0) const override; | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2025-05-19 12:32:37 +01:00
										 |  |  |     enum class Type : u8 { | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |         IsTrue, | 
					
						
							|  |  |  |         ExactValue, | 
					
						
							|  |  |  |         MinValue, | 
					
						
							|  |  |  |         MaxValue, | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |         Range, | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |     struct Range { | 
					
						
							| 
									
										
										
										
											2025-05-22 12:50:03 +01:00
										 |  |  |         Optional<MediaFeatureValue> left_value {}; | 
					
						
							|  |  |  |         Optional<Comparison> left_comparison {}; | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |         Optional<Comparison> right_comparison {}; | 
					
						
							|  |  |  |         Optional<MediaFeatureValue> right_value {}; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MediaFeature(Type type, MediaFeatureID id, Variant<Empty, MediaFeatureValue, Range> value = {}) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |         : m_type(type) | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |         , m_id(move(id)) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |         , m_value(move(value)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-22 10:12:10 +01:00
										 |  |  |     static MatchResult compare(HTML::Window const& window, MediaFeatureValue const& left, Comparison comparison, MediaFeatureValue const& right); | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |     MediaFeatureValue const& value() const { return m_value.get<MediaFeatureValue>(); } | 
					
						
							|  |  |  |     Range const& range() const { return m_value.get<Range>(); } | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     Type m_type; | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     MediaFeatureID m_id; | 
					
						
							| 
									
										
										
										
											2025-03-14 10:44:22 +00:00
										 |  |  |     Variant<Empty, MediaFeatureValue, Range> m_value {}; | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | class MediaQuery : public RefCounted<MediaQuery> { | 
					
						
							| 
									
										
										
										
											2022-04-12 12:00:07 +01:00
										 |  |  |     friend class Parser::Parser; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-10-10 00:06:13 -07:00
										 |  |  |     ~MediaQuery() = default; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/mediaqueries-4/#media-types
 | 
					
						
							| 
									
										
										
										
											2025-05-19 15:37:56 +01:00
										 |  |  |     enum class KnownMediaType : u8 { | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |         All, | 
					
						
							|  |  |  |         Print, | 
					
						
							|  |  |  |         Screen, | 
					
						
							| 
									
										
										
										
											2025-05-19 15:37:56 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  |     struct MediaType { | 
					
						
							|  |  |  |         FlyString name; | 
					
						
							|  |  |  |         Optional<KnownMediaType> known_type; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static NonnullRefPtr<MediaQuery> create_not_all(); | 
					
						
							|  |  |  |     static NonnullRefPtr<MediaQuery> create() { return adopt_ref(*new MediaQuery); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:48 +01:00
										 |  |  |     bool matches() const { return m_matches; } | 
					
						
							| 
									
										
										
										
											2022-03-07 23:08:26 +01:00
										 |  |  |     bool evaluate(HTML::Window const&); | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |     String to_string() const; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2021-10-10 00:06:13 -07:00
										 |  |  |     MediaQuery() = default; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // https://www.w3.org/TR/mediaqueries-4/#mq-not
 | 
					
						
							|  |  |  |     bool m_negated { false }; | 
					
						
							| 
									
										
										
										
											2025-05-19 15:37:56 +01:00
										 |  |  |     MediaType m_media_type { .name = "all"_fly_string, .known_type = KnownMediaType::All }; | 
					
						
							| 
									
										
										
										
											2025-03-14 10:31:27 +00:00
										 |  |  |     OwnPtr<BooleanExpression> m_media_condition { nullptr }; | 
					
						
							| 
									
										
										
										
											2021-10-03 19:39:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Cached value, updated by evaluate()
 | 
					
						
							|  |  |  |     bool m_matches { false }; | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  | String serialize_a_media_query_list(Vector<NonnullRefPtr<MediaQuery>> const&); | 
					
						
							| 
									
										
										
										
											2021-10-15 16:40:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-19 15:37:56 +01:00
										 |  |  | Optional<MediaQuery::KnownMediaType> media_type_from_string(StringView); | 
					
						
							|  |  |  | StringView to_string(MediaQuery::KnownMediaType); | 
					
						
							| 
									
										
										
										
											2022-04-27 14:58:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace AK { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | struct Formatter<Web::CSS::MediaFeature> : Formatter<StringView> { | 
					
						
							|  |  |  |     ErrorOr<void> format(FormatBuilder& builder, Web::CSS::MediaFeature const& media_feature) | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |         return Formatter<StringView>::format(builder, media_feature.to_string()); | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template<> | 
					
						
							|  |  |  | struct Formatter<Web::CSS::MediaQuery> : Formatter<StringView> { | 
					
						
							| 
									
										
										
										
											2021-11-16 01:15:21 +01:00
										 |  |  |     ErrorOr<void> format(FormatBuilder& builder, Web::CSS::MediaQuery const& media_query) | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |         return Formatter<StringView>::format(builder, media_query.to_string()); | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |