mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibWeb: Implement <resolution>
as a media feature type
This is the only dimension type besides `<length>` that is used in any media queries in levels 4 or 5 right now. Others can be included if/when they're needed.
This commit is contained in:
parent
53a3937c34
commit
fd2ef43cb4
3 changed files with 42 additions and 4 deletions
|
@ -30,6 +30,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit MediaFeatureValue(Resolution resolution)
|
||||
: m_value(move(resolution))
|
||||
{
|
||||
}
|
||||
|
||||
explicit MediaFeatureValue(double number)
|
||||
: m_value(number)
|
||||
{
|
||||
|
@ -40,6 +45,7 @@ public:
|
|||
bool is_ident() const { return m_value.has<String>(); }
|
||||
bool is_length() const { return m_value.has<Length>(); }
|
||||
bool is_number() const { return m_value.has<double>(); }
|
||||
bool is_resolution() const { return m_value.has<Resolution>(); }
|
||||
bool is_same_type(MediaFeatureValue const& other) const;
|
||||
|
||||
String const& ident() const
|
||||
|
@ -54,6 +60,12 @@ public:
|
|||
return m_value.get<Length>();
|
||||
}
|
||||
|
||||
Resolution const& resolution() const
|
||||
{
|
||||
VERIFY(is_resolution());
|
||||
return m_value.get<Resolution>();
|
||||
}
|
||||
|
||||
double number() const
|
||||
{
|
||||
VERIFY(is_number());
|
||||
|
@ -62,7 +74,7 @@ public:
|
|||
|
||||
private:
|
||||
// TODO: Support <ratio> once we have that.
|
||||
Variant<String, Length, double> m_value;
|
||||
Variant<String, Length, Resolution, double> m_value;
|
||||
};
|
||||
|
||||
// https://www.w3.org/TR/mediaqueries-4/#mq-features
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue