Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: third_party/WebKit/Source/core/css/PropertyRegistration.cpp

Issue 2354463002: CSS Properties and Values API: Implement computation / computational independence (Closed)
Patch Set: (no change) Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/PropertyRegistration.cpp
diff --git a/third_party/WebKit/Source/core/css/PropertyRegistration.cpp b/third_party/WebKit/Source/core/css/PropertyRegistration.cpp
index f7723db0ea2010a640cd791d3b25e0017872c474..bb319f72c687d4232acec0fbe469456887fa35a5 100644
--- a/third_party/WebKit/Source/core/css/PropertyRegistration.cpp
+++ b/third_party/WebKit/Source/core/css/PropertyRegistration.cpp
@@ -5,6 +5,7 @@
#include "core/css/PropertyRegistration.h"
#include "core/css/CSSSyntaxDescriptor.h"
+#include "core/css/CSSValueList.h"
#include "core/css/CSSVariableReferenceValue.h"
#include "core/css/PropertyDescriptor.h"
#include "core/css/PropertyRegistry.h"
@@ -15,9 +16,36 @@
namespace blink {
-static bool computationallyIdempotent(const CSSValue& value)
+static bool computationallyIndependent(const CSSValue& value)
alancutter (OOO until 2018) 2016/09/20 00:15:55 What happens to CSS wide keywords? Either check th
Timothy Loh 2016/09/21 01:12:04 This is tested in register-property-syntax-parsing
{
- // TODO(timloh): Implement this
+ if (value.isVariableReferenceValue())
+ return !toCSSVariableReferenceValue(value).variableDataValue()->needsVariableResolution();
sashab 2016/09/19 23:25:03 Can variables not have percentages etc in them? It
alancutter (OOO until 2018) 2016/09/20 00:15:55 It's very weird to be checking needsVariableResolu
Timothy Loh 2016/09/21 01:12:04 If there are variable references then this returns
Timothy Loh 2016/09/21 01:12:04 There's no CSSTokenStreamValue class -- CSSVariabl
+
+ // TODO(timloh): Images and transform-function values can also contain lengths.
sashab 2016/09/19 23:25:03 Are there tests that fail because of this?
Timothy Loh 2016/09/21 01:12:04 Nope I'll add them when I resolve the TODO.
+
+ if (value.isValueList()) {
+ for (const CSSValue* innerValue : toCSSValueList(value)) {
+ if (!computationallyIndependent(*innerValue))
+ return false;
+ }
+ return true;
+ }
+
+ if (!value.isPrimitiveValue())
sashab 2016/09/19 23:25:03 Just to prevent the kind of mess we currently have
alancutter (OOO until 2018) 2016/09/20 00:15:55 I think it's preferred to exit functions early on
Timothy Loh 2016/09/21 01:12:04 I'll change this, it probably made more sense befo
+ return true;
+
+ const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value);
+ if (!primitiveValue.isLength() && !primitiveValue.isCalculatedPercentageWithLength())
+ return true;
+
+ CSSPrimitiveValue::CSSLengthArray lengthArray;
+ primitiveValue.accumulateLengthArray(lengthArray);
+ for (size_t i = 0; i < lengthArray.values.size(); i++) {
+ if (lengthArray.typeFlags.get(i)
+ && i != CSSPrimitiveValue::UnitTypePixels
+ && i != CSSPrimitiveValue::UnitTypePercentage)
+ return false;
+ }
return true;
}
@@ -53,8 +81,8 @@ void PropertyRegistration::registerProperty(ExecutionContext* executionContext,
exceptionState.throwDOMException(SyntaxError, "The initial value provided does not parse for the given syntax.");
return;
}
- if (!computationallyIdempotent(*initial)) {
- exceptionState.throwDOMException(SyntaxError, "The initial value provided is not computationally idempotent.");
+ if (!computationallyIndependent(*initial)) {
+ exceptionState.throwDOMException(SyntaxError, "The initial value provided is not computationally independent.");
return;
}
registry.registerProperty(atomicName, syntaxDescriptor, descriptor.inherits(), initial);

Powered by Google App Engine
This is Rietveld 408576698