Files
serenity/Userland/Libraries/LibWeb/CSS/StyleValues/CSSUnitValue.h
Sam Atkins 9a31c3d56b LibWeb/CSS: Introduce CSSNumericValue and CSSUnitValue type stubs
CSS-Typed-OM has the following hierarchy:

CSSStyleValue
- CSSNumericValue
  - CSSUnitValue
  - CSSMathValue
    - ...various math functions...

Somewhat unintuitively, numbers are also stored using CSSUnitValue with
`unit = "number"`.

There are no distinct classes for LengthStyleValue, etc in the spec, but
they're convenient for us, so they are implemented as subclasses of
CSSUnitValue, at least for now.

(cherry picked from commit 895276426791567f22a612c4a40fa177571cc03e)
2024-10-11 10:12:33 -04:00

30 lines
564 B
C++

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