1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

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.
This commit is contained in:
Sam Atkins 2022-03-06 13:48:32 +00:00 committed by Andreas Kling
parent e30bfabbca
commit 5f93f1c161
5 changed files with 99 additions and 0 deletions

View file

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