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

Side by Side 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: fix component build. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/csspaint/PaintWorkletGlobalScope.h" 5 #include "modules/csspaint/PaintWorkletGlobalScope.h"
6 6
7 #include "bindings/core/v8/V8BindingMacros.h" 7 #include "bindings/core/v8/V8BindingMacros.h"
8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
9 #include "core/CSSPropertyNames.h"
10 #include "core/css/parser/CSSVariableParser.h"
9 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
10 #include "core/inspector/MainThreadDebugger.h" 12 #include "core/inspector/MainThreadDebugger.h"
11 #include "modules/csspaint/CSSPaintDefinition.h" 13 #include "modules/csspaint/CSSPaintDefinition.h"
12 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h" 14 #include "modules/csspaint/CSSPaintImageGeneratorImpl.h"
13 15
14 namespace blink { 16 namespace blink {
15 17
16 // static 18 // static
17 PaintWorkletGlobalScope* PaintWorkletGlobalScope::create(LocalFrame* frame, cons t KURL& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isolate) 19 PaintWorkletGlobalScope* PaintWorkletGlobalScope::create(LocalFrame* frame, cons t KURL& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isolate)
18 { 20 {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 v8::Isolate* isolate = scriptController()->getScriptState()->isolate(); 57 v8::Isolate* isolate = scriptController()->getScriptState()->isolate();
56 v8::Local<v8::Context> context = scriptController()->context(); 58 v8::Local<v8::Context> context = scriptController()->context();
57 59
58 ASSERT(ctorValue.v8Value()->IsFunction()); 60 ASSERT(ctorValue.v8Value()->IsFunction());
59 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(ctorValu e.v8Value()); 61 v8::Local<v8::Function> constructor = v8::Local<v8::Function>::Cast(ctorValu e.v8Value());
60 62
61 v8::Local<v8::Value> inputPropertiesValue; 63 v8::Local<v8::Value> inputPropertiesValue;
62 if (!v8Call(constructor->Get(context, v8String(isolate, "inputProperties")), inputPropertiesValue)) 64 if (!v8Call(constructor->Get(context, v8String(isolate, "inputProperties")), inputPropertiesValue))
63 return; 65 return;
64 66
67 Vector<CSSPropertyID> nativeInvalidationProperties;
68 Vector<AtomicString> customInvalidationProperties;
69
65 if (!isUndefinedOrNull(inputPropertiesValue)) { 70 if (!isUndefinedOrNull(inputPropertiesValue)) {
66 toImplArray<Vector<String>>(inputPropertiesValue, 0, isolate, exceptionS tate); 71 Vector<String> properties = toImplArray<Vector<String>>(inputPropertiesV alue, 0, isolate, exceptionState);
67 72
68 if (exceptionState.hadException()) 73 if (exceptionState.hadException())
69 return; 74 return;
70 75
71 // TODO(ikilpatrick): Hook up invalidation based on these inputPropertie s. 76 for (const auto& property : properties) {
77 CSSPropertyID propertyID = cssPropertyID(property);
78 if (propertyID == CSSPropertyInvalid) {
79 if (CSSVariableParser::isValidVariableName(property)) {
80 customInvalidationProperties.append(property);
81 }
82 } else {
83 nativeInvalidationProperties.append(propertyID);
84 }
85 }
72 } 86 }
73 87
74 v8::Local<v8::Value> prototypeValue; 88 v8::Local<v8::Value> prototypeValue;
75 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue)) 89 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue))
76 return; 90 return;
77 91
78 if (isUndefinedOrNull(prototypeValue)) { 92 if (isUndefinedOrNull(prototypeValue)) {
79 exceptionState.throwTypeError("The 'prototype' object on the class does not exist."); 93 exceptionState.throwTypeError("The 'prototype' object on the class does not exist.");
80 return; 94 return;
81 } 95 }
(...skipping 14 matching lines...) Expand all
96 return; 110 return;
97 } 111 }
98 112
99 if (!paintValue->IsFunction()) { 113 if (!paintValue->IsFunction()) {
100 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function."); 114 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function.");
101 return; 115 return;
102 } 116 }
103 117
104 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); 118 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue);
105 119
106 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint); 120 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn validationProperties);
107 m_paintDefinitions.set(name, definition); 121 m_paintDefinitions.set(name, definition);
108 122
109 // Set the definition on any pending generators. 123 // Set the definition on any pending generators.
110 GeneratorHashSet* set = m_pendingGenerators.get(name); 124 GeneratorHashSet* set = m_pendingGenerators.get(name);
111 if (set) { 125 if (set) {
112 for (const auto& generator : *set) { 126 for (const auto& generator : *set) {
113 if (generator) { 127 if (generator) {
114 generator->setDefinition(definition); 128 generator->setDefinition(definition);
115 } 129 }
116 } 130 }
(...skipping 15 matching lines...) Expand all
132 } 146 }
133 147
134 DEFINE_TRACE(PaintWorkletGlobalScope) 148 DEFINE_TRACE(PaintWorkletGlobalScope)
135 { 149 {
136 visitor->trace(m_paintDefinitions); 150 visitor->trace(m_paintDefinitions);
137 visitor->trace(m_pendingGenerators); 151 visitor->trace(m_pendingGenerators);
138 WorkletGlobalScope::trace(visitor); 152 WorkletGlobalScope::trace(visitor);
139 } 153 }
140 154
141 } // namespace blink 155 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698