Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (236894 => 236895)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-10-06 13:57:16 UTC (rev 236895)
@@ -1,3 +1,13 @@
+2018-10-06 Justin Michaud <[email protected]>
+
+ Properly determine if css custom property values are computationally independent
+ https://bugs.webkit.org/show_bug.cgi?id=190303
+
+ Reviewed by Antti Koivisto.
+
+ * web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt:
+ * web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt:
+
2018-10-04 Chris Dumez <[email protected]>
A Document / Window should lose its browsing context as soon as its iframe is removed from the document
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt (236894 => 236895)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/register-property-syntax-parsing-expected.txt 2018-10-06 13:57:16 UTC (rev 236895)
@@ -12,7 +12,7 @@
FAIL syntax:'*', initialValue:':> hello' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'*', initialValue:'([ brackets ]) { yay (??)}' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'*', initialValue:'yep 'this is valid too'' is valid The given initial value does not parse for the given syntax.
-FAIL syntax:'*', initialValue:'unmatched opening bracket is valid :(' is valid The given initial value must be computationally independent.
+FAIL syntax:'*', initialValue:'unmatched opening bracket is valid :(' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'*', initialValue:'"' is valid The given initial value does not parse for the given syntax.
PASS syntax:'<length>', initialValue:'0' is valid
PASS syntax:'<length>', initialValue:'10px /*:)*/' is valid
@@ -37,12 +37,12 @@
FAIL syntax:'<resolution>', initialValue:'10dpi' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<resolution>', initialValue:'3dPpX' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<resolution>', initialValue:'-5.3dpcm' is valid The given initial value does not parse for the given syntax.
-FAIL syntax:'<transform-function>', initialValue:'translateX(2px)' is valid The given initial value must be computationally independent.
+FAIL syntax:'<transform-function>', initialValue:'translateX(2px)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<transform-function>|<integer>', initialValue:'5' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<transform-function>|<integer>', initialValue:'scale(2)' is valid The given initial value does not parse for the given syntax.
-FAIL syntax:'<transform-function>+', initialValue:'translateX(2px) rotate(42deg)' is valid The given initial value must be computationally independent.
+FAIL syntax:'<transform-function>+', initialValue:'translateX(2px) rotate(42deg)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<transform-list>', initialValue:'scale(2)' is valid The given initial value does not parse for the given syntax.
-FAIL syntax:'<transform-list>', initialValue:'translateX(2px) rotate(20deg)' is valid The given initial value must be computationally independent.
+FAIL syntax:'<transform-list>', initialValue:'translateX(2px) rotate(20deg)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<color>', initialValue:'rgb(12, 34, 56)' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<color>', initialValue:'lightgoldenrodyellow' is valid The given initial value does not parse for the given syntax.
FAIL syntax:'<image>', initialValue:'url(a)' is valid The given initial value does not parse for the given syntax.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt (236894 => 236895)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/registered-property-computation-expected.txt 2018-10-06 13:57:16 UTC (rev 236895)
@@ -1,5 +1,5 @@
-FAIL CSS.registerProperty The given initial value must be computationally independent.
+FAIL CSS.registerProperty The given initial value does not parse for the given syntax.
PASS <length> values are computed correctly for divWithFontSizeSet
FAIL <length-percentage> values are computed correctly for divWithFontSizeSet assert_equals: expected "calc(190px + -2%)" but got "calc(190px - 2%)"
FAIL <length># values are computed correctly for divWithFontSizeSet assert_equals: expected "10px, 30px" but got "0px"
Modified: trunk/Source/WebCore/ChangeLog (236894 => 236895)
--- trunk/Source/WebCore/ChangeLog 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/ChangeLog 2018-10-06 13:57:16 UTC (rev 236895)
@@ -1,3 +1,38 @@
+2018-10-06 Justin Michaud <[email protected]>
+
+ Properly determine if css custom property values are computationally independent
+ https://bugs.webkit.org/show_bug.cgi?id=190303
+
+ Reviewed by Antti Koivisto.
+
+ Add getDirectComputationalDependencies method to determine if a value is computationally
+ dependent. Use this method in CSS.registerProperty to replace existing substring checks.
+ No new tests are needed because the existing tests cover this behaviour.
+
+ * css/CSSCalculationValue.cpp:
+ (WebCore::determineCategory):
+ * css/CSSCalculationValue.h:
+ (WebCore::CSSCalcValue::getDirectComputationalDependencies const):
+ (WebCore::CSSCalcValue::getDirectRootComputationalDependencies const):
+ * css/CSSCustomPropertyValue.cpp:
+ (WebCore::CSSCustomPropertyValue::customCSSText const):
+ (WebCore::CSSCustomPropertyValue::tokens const):
+ (WebCore::CSSCustomPropertyValue::setResolvedTypedValue):
+ * css/CSSCustomPropertyValue.h:
+ * css/CSSPrimitiveValue.cpp:
+ (WebCore::CSSPrimitiveValue::getDirectComputationalDependencies const):
+ (WebCore::CSSPrimitiveValue::getDirectRootComputationalDependencies const):
+ * css/CSSPrimitiveValue.h:
+ * css/CSSValue.cpp:
+ (WebCore::CSSValue::getDirectComputationalDependencies const):
+ (WebCore::CSSValue::getDirectRootComputationalDependencies const):
+ * css/CSSValue.h:
+ * css/CSSVariableData.cpp:
+ (WebCore::CSSVariableData::CSSVariableData):
+ (WebCore::CSSVariableData::resolveVariableReference const):
+ * css/DOMCSSRegisterCustomProperty.cpp:
+ (WebCore::DOMCSSRegisterCustomProperty::registerProperty):
+
2018-10-05 Chris Dumez <[email protected]>
Regression(r236862): Crash under DOMWindowExtension::willDetachGlobalObjectFromFrame()
Modified: trunk/Source/WebCore/css/CSSCalculationValue.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/CSSCalculationValue.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSCalculationValue.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -269,6 +269,16 @@
return 0;
}
+ void collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const final
+ {
+ m_value->collectDirectComputationalDependencies(values);
+ }
+
+ void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const final
+ {
+ m_value->collectDirectRootComputationalDependencies(values);
+ }
+
bool equals(const CSSCalcExpressionNode& other) const final
{
if (type() != other.type())
@@ -532,6 +542,18 @@
return evaluate(doubleValues);
}
+ void collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const final
+ {
+ for (auto& child : m_children)
+ child->collectDirectComputationalDependencies(values);
+ }
+
+ void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const final
+ {
+ for (auto& child : m_children)
+ child->collectDirectRootComputationalDependencies(values);
+ }
+
static String buildCssText(Vector<String> childExpressions, CalcOperator op)
{
StringBuilder result;
Modified: trunk/Source/WebCore/css/CSSCalculationValue.h (236894 => 236895)
--- trunk/Source/WebCore/css/CSSCalculationValue.h 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSCalculationValue.h 2018-10-06 13:57:16 UTC (rev 236895)
@@ -31,6 +31,7 @@
#pragma once
#include "CSSPrimitiveValue.h"
+#include "CSSPropertyNames.h"
#include "CalculationValue.h"
namespace WebCore {
@@ -68,6 +69,9 @@
virtual Type type() const = 0;
virtual CSSPrimitiveValue::UnitType primitiveType() const = 0;
+ virtual void collectDirectComputationalDependencies(HashSet<CSSPropertyID>&) const = 0;
+ virtual void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>&) const = 0;
+
CalculationCategory category() const { return m_category; }
bool isInteger() const { return m_isInteger; }
@@ -100,6 +104,9 @@
Ref<CalculationValue> createCalculationValue(const CSSToLengthConversionData&) const;
void setPermittedValueRange(ValueRange);
+ void collectDirectComputationalDependencies(HashSet<CSSPropertyID>&) const;
+ void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>&) const;
+
String customCSSText() const;
bool equals(const CSSCalcValue&) const;
@@ -130,6 +137,16 @@
m_shouldClampToNonNegative = range != ValueRangeAll;
}
+inline void CSSCalcValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ m_expression->collectDirectComputationalDependencies(values);
+}
+
+inline void CSSCalcValue::collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ m_expression->collectDirectRootComputationalDependencies(values);
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSCalcValue, isCalcValue())
Modified: trunk/Source/WebCore/css/CSSCustomPropertyValue.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/CSSCustomPropertyValue.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSCustomPropertyValue.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -25,10 +25,56 @@
#include "config.h"
#include "CSSCustomPropertyValue.h"
+#include "CSSTokenizer.h"
namespace WebCore {
+String CSSCustomPropertyValue::customCSSText() const
+{
+ if (!m_serialized) {
+ m_serialized = true;
+ if (m_resolvedTypedValue) // FIXME: Unit should be based on syntax.
+ m_stringValue = CSSPrimitiveValue::create(m_resolvedTypedValue->value(), CSSPrimitiveValue::CSS_PX)->cssText();
+ else if (m_value)
+ m_stringValue = m_value->tokenRange().serialize();
+ else if (m_valueId != CSSValueInvalid)
+ m_stringValue = getValueName(m_valueId);
+ else
+ m_stringValue = emptyString();
+ }
+ return m_stringValue;
+}
+
+Vector<CSSParserToken> CSSCustomPropertyValue::tokens(const CSSRegisteredCustomPropertySet& registeredProperties, const RenderStyle& style) const
+{
+ if (m_resolvedTypedValue) {
+ Vector<CSSParserToken> result;
+ CSSTokenizer tokenizer(cssText());
+
+ auto tokenizerRange = tokenizer.tokenRange();
+ while (!tokenizerRange.atEnd())
+ result.append(tokenizerRange.consume());
+
+ return result;
+ }
+
+ if (!m_value)
+ return { };
+
+ if (m_containsVariables) {
+ Vector<CSSParserToken> result;
+ // FIXME: Avoid doing this work more than once.
+ RefPtr<CSSVariableData> resolvedData = m_value->resolveVariableReferences(registeredProperties, style);
+ if (resolvedData)
+ result.appendVector(resolvedData->tokens());
+
+ return result;
+ }
+
+ return m_value->tokens();
+}
+
bool CSSCustomPropertyValue::checkVariablesForCycles(const AtomicString& name, const RenderStyle& style, HashSet<AtomicString>& seenProperties, HashSet<AtomicString>& invalidProperties) const
{
ASSERT(containsVariables());
@@ -51,4 +97,10 @@
resolvedValues.append(CSSCustomPropertyValue::createWithID(m_name, CSSValueInvalid));
}
+void CSSCustomPropertyValue::setResolvedTypedValue(Length length)
+{
+ ASSERT(length.isSpecified());
+ m_resolvedTypedValue = WTFMove(length);
}
+
+}
Modified: trunk/Source/WebCore/css/CSSCustomPropertyValue.h (236894 => 236895)
--- trunk/Source/WebCore/css/CSSCustomPropertyValue.h 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSCustomPropertyValue.h 2018-10-06 13:57:16 UTC (rev 236895)
@@ -34,6 +34,9 @@
namespace WebCore {
+class CSSParserToken;
+class RenderStyle;
+
class CSSCustomPropertyValue final : public CSSValue {
public:
static Ref<CSSCustomPropertyValue> createWithVariableData(const AtomicString& name, Ref<CSSVariableData>&& value)
@@ -56,25 +59,13 @@
return adoptRef(*new CSSCustomPropertyValue(other));
}
- String customCSSText() const
- {
- if (!m_serialized) {
- m_serialized = true;
- if (m_value)
- m_stringValue = m_value->tokenRange().serialize();
- else if (m_valueId != CSSValueInvalid)
- m_stringValue = getValueName(m_valueId);
- else
- m_stringValue = emptyString();
- }
- return m_stringValue;
- }
+ String customCSSText() const;
const AtomicString& name() const { return m_name; }
bool equals(const CSSCustomPropertyValue& other) const { return m_name == other.m_name && m_value == other.m_value && m_valueId == other.m_valueId; }
- bool containsVariables() const { return m_containsVariables; }
+ bool containsVariables() const { ASSERT(!m_containsVariables || !m_resolvedTypedValue); return m_containsVariables; }
bool checkVariablesForCycles(const AtomicString& name, const RenderStyle&, HashSet<AtomicString>& seenProperties, HashSet<AtomicString>& invalidProperties) const;
void resolveVariableReferences(const CSSRegisteredCustomPropertySet&, Vector<Ref<CSSCustomPropertyValue>>&, const RenderStyle&) const;
@@ -81,9 +72,10 @@
CSSValueID valueID() const { return m_valueId; }
CSSVariableData* value() const { return m_value.get(); }
+ Vector<CSSParserToken> tokens(const CSSRegisteredCustomPropertySet&, const RenderStyle&) const;
const std::optional<Length>& resolvedTypedValue() const { return m_resolvedTypedValue; }
- void setResolvedTypedValue(Length length) { m_resolvedTypedValue = WTFMove(length); }
+ void setResolvedTypedValue(Length);
private:
CSSCustomPropertyValue(const AtomicString& name, const String& serializedValue)
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -1220,4 +1220,32 @@
return DeprecatedCSSOMPrimitiveValue::create(*this, styleDeclaration);
}
+// https://drafts.css-houdini.org/css-properties-values-api/#dependency-cycles-via-relative-units
+void CSSPrimitiveValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ switch (m_primitiveUnitType) {
+ case CSS_EMS:
+ case CSS_QUIRKY_EMS:
+ case CSS_EXS:
+ case CSS_CHS:
+ values.add(CSSPropertyFontSize);
+ break;
+ case CSS_CALC:
+ m_value.calc->collectDirectComputationalDependencies(values);
+ break;
+ }
+}
+
+void CSSPrimitiveValue::collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ switch (m_primitiveUnitType) {
+ case CSS_REMS:
+ values.add(CSSPropertyFontSize);
+ break;
+ case CSS_CALC:
+ m_value.calc->collectDirectRootComputationalDependencies(values);
+ break;
+ }
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/css/CSSPrimitiveValue.h (236894 => 236895)
--- trunk/Source/WebCore/css/CSSPrimitiveValue.h 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSPrimitiveValue.h 2018-10-06 13:57:16 UTC (rev 236895)
@@ -288,6 +288,9 @@
Ref<DeprecatedCSSOMPrimitiveValue> createDeprecatedCSSOMPrimitiveWrapper(CSSStyleDeclaration&) const;
+ void collectDirectComputationalDependencies(HashSet<CSSPropertyID>&) const;
+ void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>&) const;
+
private:
friend class CSSValuePool;
friend LazyNeverDestroyed<CSSPrimitiveValue>;
Modified: trunk/Source/WebCore/css/CSSValue.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/CSSValue.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSValue.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -117,6 +117,18 @@
return false;
}
+void CSSValue::collectDirectComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ if (is<CSSPrimitiveValue>(*this))
+ downcast<CSSPrimitiveValue>(*this).collectDirectComputationalDependencies(values);
+}
+
+void CSSValue::collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>& values) const
+{
+ if (is<CSSPrimitiveValue>(*this))
+ downcast<CSSPrimitiveValue>(*this).collectDirectRootComputationalDependencies(values);
+}
+
template<class ChildClassType>
inline static bool compareCSSValues(const CSSValue& first, const CSSValue& second)
{
Modified: trunk/Source/WebCore/css/CSSValue.h (236894 => 236895)
--- trunk/Source/WebCore/css/CSSValue.h 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSValue.h 2018-10-06 13:57:16 UTC (rev 236895)
@@ -20,6 +20,7 @@
#pragma once
+#include "CSSPropertyNames.h"
#include "URLHash.h"
#include <wtf/Function.h>
#include <wtf/HashMap.h>
@@ -122,6 +123,11 @@
bool traverseSubresources(const WTF::Function<bool (const CachedResource&)>& handler) const;
+ // What properties does this value rely on (eg, font-size for em units)
+ void collectDirectComputationalDependencies(HashSet<CSSPropertyID>&) const;
+ // What properties in the root element does this value rely on (eg. font-size for rem units)
+ void collectDirectRootComputationalDependencies(HashSet<CSSPropertyID>&) const;
+
bool equals(const CSSValue&) const;
bool operator==(const CSSValue& other) const { return equals(other); }
Modified: trunk/Source/WebCore/css/CSSVariableData.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/CSSVariableData.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/CSSVariableData.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -32,7 +32,6 @@
#include "CSSCustomPropertyValue.h"
#include "CSSParserTokenRange.h"
-#include "CSSTokenizer.h"
#include "CSSValuePool.h"
#include "RenderStyle.h"
#include <wtf/text/AtomicStringHash.h>
@@ -81,7 +80,6 @@
CSSVariableData::CSSVariableData(const CSSParserTokenRange& range, bool needsVariableResolution)
: m_needsVariableResolution(needsVariableResolution)
{
- ASSERT(!range.atEnd());
consumeAndUpdateTokens(range);
}
@@ -146,12 +144,7 @@
auto* property = style.getCustomProperty(variableName);
if (property && property->resolvedTypedValue()) {
- // FIXME: we should not have to serialize a value that was already resolved.
- auto textValue = CSSValuePool::singleton().createValue(*property->resolvedTypedValue(), style)->cssText();
- CSSTokenizer tokenizer(textValue);
- auto tokenizerRange = tokenizer.tokenRange();
- while (!tokenizerRange.atEnd())
- result.append(tokenizerRange.consume());
+ result.appendVector(property->tokens(registeredProperties, style));
return true;
}
@@ -163,16 +156,8 @@
return resolveVariableFallback(registeredProperties, range, result, style);
}
ASSERT(property);
+ result.appendVector(property->tokens(registeredProperties, style));
- if (property->containsVariables()) {
- // FIXME: Avoid doing this work more than once.
- RefPtr<CSSVariableData> resolvedData = property->value()->resolveVariableReferences(registeredProperties, style);
- if (!resolvedData)
- return false;
- result.appendVector(resolvedData->tokens());
- } else
- result.appendVector(property->value()->tokens());
-
return true;
}
Modified: trunk/Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp (236894 => 236895)
--- trunk/Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp 2018-10-06 01:45:04 UTC (rev 236894)
+++ trunk/Source/WebCore/css/DOMCSSRegisterCustomProperty.cpp 2018-10-06 13:57:16 UTC (rev 236895)
@@ -27,6 +27,7 @@
#include "DOMCSSRegisterCustomProperty.h"
#include "CSSCustomPropertyValue.h"
+#include "CSSPropertyNames.h"
#include "CSSRegisteredCustomProperty.h"
#include "CSSTokenizer.h"
#include "DOMCSSNamespace.h"
@@ -39,29 +40,23 @@
ExceptionOr<void> DOMCSSRegisterCustomProperty::registerProperty(Document& document, const DOMCSSCustomPropertyDescriptor& descriptor)
{
- auto initialValueLower = descriptor.initialValue.convertToASCIILowercase();
- for (auto& substring : { "em", "ex", "lh", "cap", "ch", "ic", "var", "env" }) {
- // FIXME: we should be able to check the dependencies of the parsed value
- // Right now, we can't because values that fail to parse here will crash
- if (initialValueLower.contains(substring))
- return Exception { SyntaxError, "The given initial value must be computationally independent." };
- }
-
- CSSTokenizer tokenizer(descriptor.initialValue);
RefPtr<CSSCustomPropertyValue> initialValue;
- if (!tokenizer.tokenRange().atEnd()) {
- initialValue = CSSCustomPropertyValue::createWithVariableData(descriptor.name, CSSVariableData::create(tokenizer.tokenRange(), false));
- if (initialValue->hasVariableReferences())
- return Exception { SyntaxError, "The given initial value must not contain variable references." };
-
+ if (!descriptor.initialValue.isEmpty()) {
+ initialValue = CSSCustomPropertyValue::createWithVariableData(descriptor.name, CSSVariableData::create(CSSParserTokenRange(Vector<CSSParserToken>()), false));
CSSParser parser(document);
- RenderStyle renderStyle = RenderStyle::create();
StyleResolver styleResolver(document);
- auto primitiveVal = parser.parseValueWithVariableReferences(CSSPropertyCustom, *initialValue, document.getCSSRegisteredCustomPropertySet(), renderStyle);
+ auto primitiveVal = parser.parseSingleValue(CSSPropertyCustom, descriptor.initialValue);
if (!primitiveVal || !primitiveVal->isPrimitiveValue())
return Exception { SyntaxError, "The given initial value does not parse for the given syntax." };
+ HashSet<CSSPropertyID> dependencies;
+ primitiveVal->collectDirectComputationalDependencies(dependencies);
+ primitiveVal->collectDirectRootComputationalDependencies(dependencies);
+
+ if (!dependencies.isEmpty())
+ return Exception { SyntaxError, "The given initial value must be computationally independent." };
+
initialValue->setResolvedTypedValue(StyleBuilderConverter::convertLength(styleResolver, *primitiveVal));
}