mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibWeb/CSS: Make media-type more permissive
The current spec defines this simply as `<ident>`, but does apparently serialize as lowercase. Because of this change, we no longer need to care about the deprecated media types, as they all behave the same as unknown ones. We still keep an enum around for KnownMediaType, to avoid repeated string comparisons when evaluating it. Gets us 2 WPT passes.
This commit is contained in:
parent
bb035fbfe0
commit
38aca62ef5
Notes:
github-actions[bot]
2025-05-23 09:19:52 +00:00
Author: https://github.com/AtkinsSJ
Commit: 38aca62ef5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4817
4 changed files with 52 additions and 89 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -189,21 +190,14 @@ public:
|
|||
~MediaQuery() = default;
|
||||
|
||||
// https://www.w3.org/TR/mediaqueries-4/#media-types
|
||||
enum class MediaType {
|
||||
enum class KnownMediaType : u8 {
|
||||
All,
|
||||
Print,
|
||||
Screen,
|
||||
Unknown,
|
||||
|
||||
// Deprecated, must never match:
|
||||
TTY,
|
||||
TV,
|
||||
Projection,
|
||||
Handheld,
|
||||
Braille,
|
||||
Embossed,
|
||||
Aural,
|
||||
Speech,
|
||||
};
|
||||
struct MediaType {
|
||||
FlyString name;
|
||||
Optional<KnownMediaType> known_type;
|
||||
};
|
||||
|
||||
static NonnullRefPtr<MediaQuery> create_not_all();
|
||||
|
@ -218,7 +212,7 @@ private:
|
|||
|
||||
// https://www.w3.org/TR/mediaqueries-4/#mq-not
|
||||
bool m_negated { false };
|
||||
MediaType m_media_type { MediaType::All };
|
||||
MediaType m_media_type { .name = "all"_fly_string, .known_type = KnownMediaType::All };
|
||||
OwnPtr<BooleanExpression> m_media_condition { nullptr };
|
||||
|
||||
// Cached value, updated by evaluate()
|
||||
|
@ -227,8 +221,8 @@ private:
|
|||
|
||||
String serialize_a_media_query_list(Vector<NonnullRefPtr<MediaQuery>> const&);
|
||||
|
||||
MediaQuery::MediaType media_type_from_string(StringView);
|
||||
StringView to_string(MediaQuery::MediaType);
|
||||
Optional<MediaQuery::KnownMediaType> media_type_from_string(StringView);
|
||||
StringView to_string(MediaQuery::KnownMediaType);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue