diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-03-06 13:48:32 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-07 13:42:25 +0100 |
commit | 5f93f1c16135851530a8cd26e630266ba0377dba (patch) | |
tree | 14a7c3ed9110e4c1f8d9711d149925850846facb /Userland/Libraries/LibWeb/CSS/Ratio.h | |
parent | e30bfabbcae4a6a6b4d0a29a49087bf26b1b0b83 (diff) | |
download | serenity-5f93f1c16135851530a8cd26e630266ba0377dba.zip |
LibWeb: Introduce and parse CSS Ratio type
This is only used by media-queries, so for now we can skip
adding/parsing a StyleValue for these.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Ratio.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Ratio.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Ratio.h b/Userland/Libraries/LibWeb/CSS/Ratio.h new file mode 100644 index 0000000000..724530ba50 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/Ratio.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/String.h> + +namespace Web::CSS { + +// https://www.w3.org/TR/css-values-4/#ratios +class Ratio { +public: + Ratio(float first, float second = 1); + float value() const { return m_first_value / m_second_value; } + bool is_degenerate() const; + + String to_string() const; + auto operator<=>(Ratio const& other) const; + +private: + float m_first_value { 0 }; + float m_second_value { 1 }; +}; + +} |