| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-02-14 20:19:58 +00:00
										 |  |  |  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/NonnullRefPtr.h>
 | 
					
						
							|  |  |  | #include <AK/Optional.h>
 | 
					
						
							|  |  |  | #include <AK/OwnPtr.h>
 | 
					
						
							|  |  |  | #include <AK/RefCounted.h>
 | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  | #include <LibWeb/CSS/CalculatedOr.h>
 | 
					
						
							| 
									
										
										
										
											2021-11-24 14:59:31 +00:00
										 |  |  | #include <LibWeb/CSS/GeneralEnclosed.h>
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  | #include <LibWeb/CSS/MediaFeatureID.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
										 |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |     String to_string() 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>(); } | 
					
						
							| 
									
										
										
										
											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: | 
					
						
							| 
									
										
										
										
											2024-11-29 13:16:15 +01:00
										 |  |  |     Variant<Keyword, LengthOrCalculated, Ratio, ResolutionOrCalculated, IntegerOrCalculated> 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
 | 
					
						
							|  |  |  | class MediaFeature { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     enum class Comparison { | 
					
						
							|  |  |  |         Equal, | 
					
						
							|  |  |  |         LessThan, | 
					
						
							|  |  |  |         LessThanOrEqual, | 
					
						
							|  |  |  |         GreaterThan, | 
					
						
							|  |  |  |         GreaterThanOrEqual, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     // Corresponds to `<mf-boolean>` grammar
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     static MediaFeature boolean(MediaFeatureID id) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |         return MediaFeature(Type::IsTrue, id); | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Corresponds to `<mf-plain>` grammar
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     static MediaFeature plain(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |         return MediaFeature(Type::ExactValue, move(id), move(value)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     static MediaFeature min(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return MediaFeature(Type::MinValue, id, move(value)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     static MediaFeature max(MediaFeatureID id, MediaFeatureValue value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return MediaFeature(Type::MaxValue, id, move(value)); | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     // Corresponds to `<mf-range>` grammar, with a single comparison
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     static MediaFeature half_range(MediaFeatureValue value, Comparison comparison, MediaFeatureID id) | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |         MediaFeature feature { Type::Range, id }; | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |         feature.m_range = Range { | 
					
						
							|  |  |  |             .left_value = value, | 
					
						
							|  |  |  |             .left_comparison = comparison, | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         return feature; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Corresponds to `<mf-range>` grammar, with two comparisons
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     static MediaFeature range(MediaFeatureValue left_value, Comparison left_comparison, MediaFeatureID id, Comparison right_comparison, MediaFeatureValue right_value) | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |         MediaFeature feature { Type::Range, id }; | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |         feature.m_range = Range { | 
					
						
							|  |  |  |             .left_value = left_value, | 
					
						
							|  |  |  |             .left_comparison = left_comparison, | 
					
						
							|  |  |  |             .right_comparison = right_comparison, | 
					
						
							|  |  |  |             .right_value = right_value, | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |         return feature; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 23:08:26 +01:00
										 |  |  |     bool evaluate(HTML::Window const&) const; | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |     String to_string() const; | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     enum class Type { | 
					
						
							|  |  |  |         IsTrue, | 
					
						
							|  |  |  |         ExactValue, | 
					
						
							|  |  |  |         MinValue, | 
					
						
							|  |  |  |         MaxValue, | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |         Range, | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     MediaFeature(Type type, MediaFeatureID id, Optional<MediaFeatureValue> 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)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 23:08:26 +01:00
										 |  |  |     static bool compare(HTML::Window const& window, MediaFeatureValue left, Comparison comparison, MediaFeatureValue right); | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     struct Range { | 
					
						
							|  |  |  |         MediaFeatureValue left_value; | 
					
						
							|  |  |  |         Comparison left_comparison; | 
					
						
							|  |  |  |         Optional<Comparison> right_comparison {}; | 
					
						
							|  |  |  |         Optional<MediaFeatureValue> right_value {}; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     Type m_type; | 
					
						
							| 
									
										
										
										
											2022-03-08 16:51:33 +00:00
										 |  |  |     MediaFeatureID m_id; | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  |     Optional<MediaFeatureValue> m_value {}; | 
					
						
							| 
									
										
										
										
											2022-01-01 16:24:43 +00:00
										 |  |  |     Optional<Range> m_range {}; | 
					
						
							| 
									
										
										
										
											2021-12-29 21:17:44 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  | // https://www.w3.org/TR/mediaqueries-4/#media-conditions
 | 
					
						
							|  |  |  | struct MediaCondition { | 
					
						
							|  |  |  |     enum class Type { | 
					
						
							|  |  |  |         Single, | 
					
						
							|  |  |  |         And, | 
					
						
							|  |  |  |         Or, | 
					
						
							|  |  |  |         Not, | 
					
						
							|  |  |  |         GeneralEnclosed, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-01 11:44:44 +00:00
										 |  |  |     // Only used in parsing
 | 
					
						
							|  |  |  |     enum class AllowOr { | 
					
						
							|  |  |  |         No = 0, | 
					
						
							|  |  |  |         Yes = 1, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  |     static NonnullOwnPtr<MediaCondition> from_general_enclosed(GeneralEnclosed&&); | 
					
						
							|  |  |  |     static NonnullOwnPtr<MediaCondition> from_feature(MediaFeature&&); | 
					
						
							|  |  |  |     static NonnullOwnPtr<MediaCondition> from_not(NonnullOwnPtr<MediaCondition>&&); | 
					
						
							| 
									
										
										
										
											2023-03-06 17:16:25 +01:00
										 |  |  |     static NonnullOwnPtr<MediaCondition> from_and_list(Vector<NonnullOwnPtr<MediaCondition>>&&); | 
					
						
							|  |  |  |     static NonnullOwnPtr<MediaCondition> from_or_list(Vector<NonnullOwnPtr<MediaCondition>>&&); | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-07 23:08:26 +01:00
										 |  |  |     MatchResult evaluate(HTML::Window const&) const; | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |     String to_string() const; | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-03-14 13:21:51 -06:00
										 |  |  |     MediaCondition() = default; | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  |     Type type; | 
					
						
							|  |  |  |     Optional<MediaFeature> feature; | 
					
						
							| 
									
										
										
										
											2023-03-06 17:16:25 +01:00
										 |  |  |     Vector<NonnullOwnPtr<MediaCondition>> conditions; | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  |     Optional<GeneralEnclosed> general_enclosed; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							|  |  |  |     enum class MediaType { | 
					
						
							|  |  |  |         All, | 
					
						
							|  |  |  |         Print, | 
					
						
							|  |  |  |         Screen, | 
					
						
							| 
									
										
										
										
											2022-11-03 08:58:27 +03:00
										 |  |  |         Unknown, | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         // Deprecated, must never match:
 | 
					
						
							|  |  |  |         TTY, | 
					
						
							|  |  |  |         TV, | 
					
						
							|  |  |  |         Projection, | 
					
						
							|  |  |  |         Handheld, | 
					
						
							|  |  |  |         Braille, | 
					
						
							|  |  |  |         Embossed, | 
					
						
							|  |  |  |         Aural, | 
					
						
							|  |  |  |         Speech, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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 }; | 
					
						
							|  |  |  |     MediaType m_media_type { MediaType::All }; | 
					
						
							|  |  |  |     OwnPtr<MediaCondition> 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-03 08:58:27 +03:00
										 |  |  | MediaQuery::MediaType media_type_from_string(StringView); | 
					
						
							| 
									
										
										
										
											2022-04-27 14:58:25 +01:00
										 |  |  | StringView to_string(MediaQuery::MediaType); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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<> | 
					
						
							| 
									
										
										
										
											2021-12-30 14:25:30 +00:00
										 |  |  | struct Formatter<Web::CSS::MediaCondition> : Formatter<StringView> { | 
					
						
							|  |  |  |     ErrorOr<void> format(FormatBuilder& builder, Web::CSS::MediaCondition const& media_condition) | 
					
						
							| 
									
										
										
										
											2021-09-27 17:12:33 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-22 12:40:18 +01:00
										 |  |  |         return Formatter<StringView>::format(builder, media_condition.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
										 |  |  |     } | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |