/* * Copyright (c) 2025, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Web::CSS { struct CSSNumericType { Optional length; Optional angle; Optional time; Optional frequency; Optional resolution; Optional flex; Optional percent; Optional percent_hint; }; // https://drafts.css-houdini.org/css-typed-om-1/#cssnumericvalue class CSSNumericValue : public CSSStyleValue { WEB_PLATFORM_OBJECT(CSSNumericValue, CSSStyleValue); GC_DECLARE_ALLOCATOR(CSSNumericValue); public: struct SerializationParams { Optional minimum {}; Optional maximum {}; bool nested { false }; bool parenless { false }; }; virtual ~CSSNumericValue() override = default; CSSNumericType type_for_bindings() const; NumericType const& type() const { return m_type; } virtual String to_string() const final override { return to_string({}); } String to_string(SerializationParams const&) const; static WebIDL::ExceptionOr> parse(JS::VM&, String const& css_text); protected: explicit CSSNumericValue(JS::Realm&, NumericType); virtual void initialize(JS::Realm&) override; NumericType m_type; }; // https://drafts.css-houdini.org/css-typed-om-1/#typedefdef-cssnumberish using CSSNumberish = Variant>; GC::Ref rectify_a_numberish_value(JS::Realm&, CSSNumberish const&, Optional unit = {}); }