diff --git a/Libraries/LibWeb/CSS/CSSImageValue.cpp b/Libraries/LibWeb/CSS/CSSImageValue.cpp index 3bff62448d4..857931cd5bb 100644 --- a/Libraries/LibWeb/CSS/CSSImageValue.cpp +++ b/Libraries/LibWeb/CSS/CSSImageValue.cpp @@ -7,6 +7,7 @@ #include "CSSImageValue.h" #include #include +#include #include #include @@ -38,4 +39,30 @@ WebIDL::ExceptionOr CSSImageValue::to_string() const return Base::to_string(); } +// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation +WebIDL::ExceptionOr> CSSImageValue::create_an_internal_representation(PropertyNameAndID const& property) const +{ + // If value is a CSSStyleValue subclass, + // If value does not match the grammar of a list-valued property iteration of property, throw a TypeError. + // NB: https://drafts.css-houdini.org/css-typed-om-1/#cssstylevalue-match-a-grammar doesn't list CSSImageValue, but + // we should match . + bool const matches_grammar = [&] { + if (property.is_custom_property()) { + // FIXME: If this is a registered custom property, check if that allows . + return true; + } + return property_accepts_type(property.id(), ValueType::Image); + }(); + if (!matches_grammar) { + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Property '{}' does not accept ", property.name())) }; + } + + // FIXME: If any component of property’s CSS grammar has a limited numeric range, and the corresponding part of value + // is a CSSUnitValue that is outside of that range, replace that value with the result of wrapping it in a + // fresh CSSMathSum whose values internal slot contains only that part of value. + + // Return the value. + return NonnullRefPtr { *source_value() }; +} + } diff --git a/Libraries/LibWeb/CSS/CSSImageValue.h b/Libraries/LibWeb/CSS/CSSImageValue.h index 4777b9e152c..84c6a2e81a3 100644 --- a/Libraries/LibWeb/CSS/CSSImageValue.h +++ b/Libraries/LibWeb/CSS/CSSImageValue.h @@ -21,6 +21,7 @@ public: virtual ~CSSImageValue() override = default; virtual WebIDL::ExceptionOr to_string() const override; + virtual WebIDL::ExceptionOr> create_an_internal_representation(PropertyNameAndID const&) const override; private: explicit CSSImageValue(JS::Realm&, NonnullRefPtr source_value);