LibWeb: Add RatioStyleValue and parsing

This commit is contained in:
Sam Atkins 2023-06-06 15:42:43 +01:00 committed by Andreas Kling
commit 5e3da93f1a
Notes: sideshowbarker 2024-07-16 23:38:54 +09:00
8 changed files with 88 additions and 2 deletions

View file

@ -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 };