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

Unified Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp

Issue 1896893004: Hook up style invalidation for CSS Paint API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@css-paint-register
Patch Set: . Created 4 years, 8 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/modules/csspaint/PaintWorkletGlobalScope.cpp
diff --git a/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
index d109ce44b898fe112fc6a20069194f3d500ff0b4..eefcb39e774329b57463449d659f11bfc6c2dd13 100644
--- a/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
+++ b/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp
@@ -6,6 +6,8 @@
#include "bindings/core/v8/V8BindingMacros.h"
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
+#include "core/CSSPropertyNames.h"
+#include "core/css/parser/CSSVariableParser.h"
#include "core/dom/ExceptionCode.h"
#include "core/inspector/MainThreadDebugger.h"
#include "modules/csspaint/CSSPaintDefinition.h"
@@ -62,13 +64,29 @@ void PaintWorkletGlobalScope::registerPaint(const String& name, const ScriptValu
if (!v8Call(constructor->Get(context, v8String(isolate, "inputProperties")), inputPropertiesValue))
return;
+ Vector<CSSPropertyID> nativeInvalidationProperties;
+ Vector<AtomicString> customInvalidationProperties;
+
if (!isUndefinedOrNull(inputPropertiesValue)) {
- toImplArray<Vector<String>>(inputPropertiesValue, 0, isolate, exceptionState);
+ Vector<String> properties = toImplArray<Vector<String>>(inputPropertiesValue, 0, isolate, exceptionState);
if (exceptionState.hadException())
return;
- // TODO(ikilpatrick): Hook up invalidation based on these inputProperties.
+ for (const auto& property : properties) {
+ CSSPropertyID propertyID = cssPropertyID(property);
+ if (propertyID == CSSPropertyInvalid) {
chrishtr 2016/04/27 19:52:40 It seems weird that custom properties are identifi
ikilpatrick 2016/04/28 22:30:16 Right, not sure of the history here. Would have to
chrishtr 2016/04/29 00:24:58 Ok. Please ask him about it.
Timothy Loh 2016/04/29 01:20:25 I don't recall exactly. I think it was so that whi
+ if (CSSVariableParser::isValidVariableName(property))
+ customInvalidationProperties.append(property);
+ } else {
+ // Disallow prefixes.
+ if (property[0] == '-') {
+ addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, property + " is a prefixed property which is not supported."));
+ } else {
+ nativeInvalidationProperties.append(propertyID);
+ }
+ }
+ }
}
v8::Local<v8::Value> prototypeValue;
@@ -103,7 +121,7 @@ void PaintWorkletGlobalScope::registerPaint(const String& name, const ScriptValu
v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue);
- CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController()->getScriptState(), constructor, paint);
+ CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController()->getScriptState(), constructor, paint, nativeInvalidationProperties, customInvalidationProperties);
m_paintDefinitions.set(name, definition);
// Set the definition on any pending generators.

Powered by Google App Engine
This is Rietveld 408576698