/* * Copyright (c) 2025, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace Web::CSS { // https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue class CSSStyleValue : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(CSSStyleValue, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(CSSStyleValue); public: [[nodiscard]] static GC::Ref create(JS::Realm&, FlyString associated_property, NonnullRefPtr); virtual ~CSSStyleValue() override; virtual void initialize(JS::Realm&) override; Optional const& associated_property() const { return m_associated_property; } RefPtr const& source_value() const { return m_source_value; } static WebIDL::ExceptionOr> parse(JS::VM&, FlyString const& property, String css_text); static WebIDL::ExceptionOr>> parse_all(JS::VM&, FlyString const& property, String css_text); enum class ParseMultiple : u8 { No, Yes, }; static WebIDL::ExceptionOr, GC::RootVector>>> parse_a_css_style_value(JS::VM&, FlyString property, String css_text, ParseMultiple); virtual WebIDL::ExceptionOr to_string() const; // FIXME: Temporary hack. Really we want to pass something like a CalculationContext with the valid types and ranges. enum class PerformTypeCheck : u8 { No, Yes, }; virtual WebIDL::ExceptionOr> create_an_internal_representation(PropertyNameAndID const&, PerformTypeCheck) const; protected: explicit CSSStyleValue(JS::Realm&); explicit CSSStyleValue(JS::Realm&, NonnullRefPtr source_value); private: explicit CSSStyleValue(JS::Realm&, FlyString associated_property, NonnullRefPtr source_value); // https://drafts.css-houdini.org/css-typed-om-1/#dom-cssstylevalue-associatedproperty-slot Optional m_associated_property; RefPtr m_source_value; }; }