Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
|
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
| |
| 79 if (CSSVariableParser::isValidVariableName(property)) | |
| 80 customInvalidationProperties.append(property); | |
| 81 } else { | |
| 82 // Disallow prefixes. | |
| 83 if (property[0] == '-') { | |
| 84 addConsoleMessage(ConsoleMessage::create(JSMessageSource, Wa rningMessageLevel, property + " is a prefixed property which is not supported.") ); | |
| 85 } else { | |
| 86 nativeInvalidationProperties.append(propertyID); | |
| 87 } | |
| 88 } | |
| 89 } | |
| 72 } | 90 } |
| 73 | 91 |
| 74 v8::Local<v8::Value> prototypeValue; | 92 v8::Local<v8::Value> prototypeValue; |
| 75 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue)) | 93 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue)) |
| 76 return; | 94 return; |
| 77 | 95 |
| 78 if (isUndefinedOrNull(prototypeValue)) { | 96 if (isUndefinedOrNull(prototypeValue)) { |
| 79 exceptionState.throwTypeError("The 'prototype' object on the class does not exist."); | 97 exceptionState.throwTypeError("The 'prototype' object on the class does not exist."); |
| 80 return; | 98 return; |
| 81 } | 99 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 96 return; | 114 return; |
| 97 } | 115 } |
| 98 | 116 |
| 99 if (!paintValue->IsFunction()) { | 117 if (!paintValue->IsFunction()) { |
| 100 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function."); | 118 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function."); |
| 101 return; | 119 return; |
| 102 } | 120 } |
| 103 | 121 |
| 104 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); | 122 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); |
| 105 | 123 |
| 106 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint); | 124 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn validationProperties); |
| 107 m_paintDefinitions.set(name, definition); | 125 m_paintDefinitions.set(name, definition); |
| 108 | 126 |
| 109 // Set the definition on any pending generators. | 127 // Set the definition on any pending generators. |
| 110 GeneratorHashSet* set = m_pendingGenerators.get(name); | 128 GeneratorHashSet* set = m_pendingGenerators.get(name); |
| 111 if (set) { | 129 if (set) { |
| 112 for (const auto& generator : *set) { | 130 for (const auto& generator : *set) { |
| 113 if (generator) { | 131 if (generator) { |
| 114 generator->setDefinition(definition); | 132 generator->setDefinition(definition); |
| 115 } | 133 } |
| 116 } | 134 } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 132 } | 150 } |
| 133 | 151 |
| 134 DEFINE_TRACE(PaintWorkletGlobalScope) | 152 DEFINE_TRACE(PaintWorkletGlobalScope) |
| 135 { | 153 { |
| 136 visitor->trace(m_paintDefinitions); | 154 visitor->trace(m_paintDefinitions); |
| 137 visitor->trace(m_pendingGenerators); | 155 visitor->trace(m_pendingGenerators); |
| 138 WorkletGlobalScope::trace(visitor); | 156 WorkletGlobalScope::trace(visitor); |
| 139 } | 157 } |
| 140 | 158 |
| 141 } // namespace blink | 159 } // namespace blink |
| OLD | NEW |