ladybird/Libraries/LibWeb/CSS/StyleValues/CSSUnitValue.h
Sam Atkins 51a657ca47 LibWeb/CSS: Delete CSSNumericValue
This will need to be re-added later as a proper typed-om type, but right
now it's useless.
2025-08-08 15:19:03 +01:00

35 lines
836 B
C++

/*
* Copyright (c) 2024-2025, Sam Atkins <sam@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/FlyString.h>
#include <LibWeb/CSS/Parser/ComponentValue.h>
#include <LibWeb/CSS/Parser/Token.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
// https://drafts.css-houdini.org/css-typed-om-1/#cssunitvalue
class CSSUnitValue : public StyleValue {
public:
virtual ~CSSUnitValue() override = default;
virtual double value() const = 0;
virtual StringView unit() const = 0;
virtual Vector<Parser::ComponentValue> tokenize() const override
{
return { Parser::Token::create_dimension(value(), FlyString::from_utf8_without_validation(unit().bytes())) };
}
protected:
explicit CSSUnitValue(Type type)
: StyleValue(type)
{
}
};
}