mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibWeb: Add comparison operators to CSS numeric types (except Length)
This is to make it easier to bounds-check their values during parsing. Length is left out because many length units are relative to the context in which they are used, and so we cannot easily compare `10px` and `1em`, for example.
This commit is contained in:
parent
06617a982e
commit
fbfce2e73e
6 changed files with 69 additions and 3 deletions
|
@ -35,6 +35,18 @@ public:
|
|||
return m_type == other.m_type && m_value == other.m_value;
|
||||
}
|
||||
|
||||
int operator<=>(Frequency const& other) const
|
||||
{
|
||||
auto this_hertz = to_hertz();
|
||||
auto other_hertz = other.to_hertz();
|
||||
|
||||
if (this_hertz < other_hertz)
|
||||
return -1;
|
||||
if (this_hertz > other_hertz)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
StringView unit_name() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue