mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
LibWeb: Add RatioStyleValue and parsing
This commit is contained in:
parent
b9f9d87bd0
commit
5e3da93f1a
8 changed files with 88 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -19,6 +19,23 @@ public:
|
|||
|
||||
ErrorOr<String> to_string() const;
|
||||
|
||||
bool operator==(Ratio const& other) const
|
||||
{
|
||||
return value() == other.value();
|
||||
}
|
||||
|
||||
int operator<=>(Ratio const& other) const
|
||||
{
|
||||
auto this_value = value();
|
||||
auto other_value = other.value();
|
||||
|
||||
if (this_value < other_value)
|
||||
return -1;
|
||||
if (this_value > other_value)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_first_value { 0 };
|
||||
float m_second_value { 1 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue