mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-04 15:19:16 +00:00
CSSUnitValue is a typed-om type which we will implement separately in the future. However, it still seems useful to give our dimension values a base class. (Maybe they could be templated in the future?) So instead of deleting it entirely, rename it to DimensionStyleValue and make its API match our style better.
34 lines
812 B
C++
34 lines
812 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 {
|
|
|
|
class DimensionStyleValue : public StyleValue {
|
|
public:
|
|
virtual ~DimensionStyleValue() override = default;
|
|
|
|
virtual double raw_value() const = 0;
|
|
virtual StringView unit_name() const = 0;
|
|
virtual Vector<Parser::ComponentValue> tokenize() const override
|
|
{
|
|
return { Parser::Token::create_dimension(raw_value(), FlyString::from_utf8_without_validation(unit_name().bytes())) };
|
|
}
|
|
|
|
protected:
|
|
explicit DimensionStyleValue(Type type)
|
|
: StyleValue(type)
|
|
{
|
|
}
|
|
};
|
|
|
|
}
|