diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.cpp b/Libraries/LibWeb/CSS/CSSStyleValue.cpp index 7865d3ae599..846d838e5d5 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleValue.cpp @@ -13,12 +13,12 @@ namespace Web::CSS { GC_DEFINE_ALLOCATOR(CSSStyleValue); -GC::Ref CSSStyleValue::create(JS::Realm& realm, Optional associated_property, Optional constructed_from_string) +GC::Ref CSSStyleValue::create(JS::Realm& realm, String associated_property, String constructed_from_string) { return realm.create(realm, move(associated_property), move(constructed_from_string)); } -CSSStyleValue::CSSStyleValue(JS::Realm& realm, Optional associated_property, Optional constructed_from_string) +CSSStyleValue::CSSStyleValue(JS::Realm& realm, String associated_property, String constructed_from_string) : PlatformObject(realm) , m_associated_property(move(associated_property)) , m_constructed_from_string(move(constructed_from_string)) diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.h b/Libraries/LibWeb/CSS/CSSStyleValue.h index bc2dbb5ad63..eb18a13297b 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -16,14 +16,14 @@ class CSSStyleValue : public Bindings::PlatformObject { GC_DECLARE_ALLOCATOR(CSSStyleValue); public: - [[nodiscard]] static GC::Ref create(JS::Realm&, Optional associated_property = {}, Optional constructed_from_string = {}); + [[nodiscard]] static GC::Ref create(JS::Realm&, String associated_property, String constructed_from_string); virtual ~CSSStyleValue() override = default; virtual String to_string() const; private: - explicit CSSStyleValue(JS::Realm&, Optional associated_property = {}, Optional constructed_from_string = {}); + explicit CSSStyleValue(JS::Realm&, String associated_property, String constructed_from_string); virtual void initialize(JS::Realm&) override; diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp index 02f3295914f..d0bb26a0577 100644 --- a/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/StyleValue.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -142,6 +143,13 @@ Vector StyleValue::tokenize() const return Parser::Parser::create(Parser::ParsingParams {}, to_string(SerializationMode::Normal)).parse_as_list_of_component_values(); } +// https://drafts.css-houdini.org/css-typed-om-1/#reify-as-a-cssstylevalue +GC::Ref StyleValue::reify(JS::Realm& realm, String const& associated_property) const +{ + // 1. Return a new CSSStyleValue object representing value whose [[associatedProperty]] internal slot is set to property. + return CSSStyleValue::create(realm, associated_property, to_string(SerializationMode::Normal)); +} + int StyleValue::to_font_weight() const { if (is_keyword()) { diff --git a/Libraries/LibWeb/CSS/StyleValues/StyleValue.h b/Libraries/LibWeb/CSS/StyleValues/StyleValue.h index 2cfc712bcac..930062d659a 100644 --- a/Libraries/LibWeb/CSS/StyleValues/StyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/StyleValue.h @@ -207,6 +207,7 @@ public: virtual String to_string(SerializationMode) const = 0; virtual Vector tokenize() const; + virtual GC::Ref reify(JS::Realm&, String const& associated_property) const; [[nodiscard]] int to_font_weight() const; [[nodiscard]] int to_font_slope() const;