1
Fork 0
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:
Sam Atkins 2023-06-06 15:42:43 +01:00 committed by Andreas Kling
parent b9f9d87bd0
commit 5e3da93f1a
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 };