| 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" | 9 #include "core/CSSPropertyNames.h" |
| 10 #include "core/css/parser/CSSVariableParser.h" | 10 #include "core/css/parser/CSSVariableParser.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 CSSPropertyID propertyID = cssPropertyID(property); | 77 CSSPropertyID propertyID = cssPropertyID(property); |
| 78 if (propertyID == CSSPropertyInvalid) { | 78 if (propertyID == CSSPropertyInvalid) { |
| 79 if (CSSVariableParser::isValidVariableName(property)) | 79 if (CSSVariableParser::isValidVariableName(property)) |
| 80 customInvalidationProperties.append(property); | 80 customInvalidationProperties.append(property); |
| 81 } else { | 81 } else { |
| 82 nativeInvalidationProperties.append(propertyID); | 82 nativeInvalidationProperties.append(propertyID); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Parse 'alpha' AKA hasAlpha property. |
| 88 v8::Local<v8::Value> alphaValue; |
| 89 if (!v8Call(constructor->Get(context, v8String(isolate, "alpha")), alphaValu
e)) |
| 90 return; |
| 91 if (!isUndefinedOrNull(alphaValue) && !alphaValue->IsBoolean()) { |
| 92 exceptionState.throwTypeError("The 'alpha' property on the class is not
a boolean."); |
| 93 return; |
| 94 } |
| 95 bool hasAlpha = alphaValue->IsBoolean() ? v8::Local<v8::Boolean>::Cast(alpha
Value)->Value() : true; |
| 96 |
| 87 v8::Local<v8::Value> prototypeValue; | 97 v8::Local<v8::Value> prototypeValue; |
| 88 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto
typeValue)) | 98 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto
typeValue)) |
| 89 return; | 99 return; |
| 90 | 100 |
| 91 if (isUndefinedOrNull(prototypeValue)) { | 101 if (isUndefinedOrNull(prototypeValue)) { |
| 92 exceptionState.throwTypeError("The 'prototype' object on the class does
not exist."); | 102 exceptionState.throwTypeError("The 'prototype' object on the class does
not exist."); |
| 93 return; | 103 return; |
| 94 } | 104 } |
| 95 | 105 |
| 96 if (!prototypeValue->IsObject()) { | 106 if (!prototypeValue->IsObject()) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 109 return; | 119 return; |
| 110 } | 120 } |
| 111 | 121 |
| 112 if (!paintValue->IsFunction()) { | 122 if (!paintValue->IsFunction()) { |
| 113 exceptionState.throwTypeError("The 'paint' property on the prototype is
not a function."); | 123 exceptionState.throwTypeError("The 'paint' property on the prototype is
not a function."); |
| 114 return; | 124 return; |
| 115 } | 125 } |
| 116 | 126 |
| 117 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); | 127 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); |
| 118 | 128 |
| 119 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController
()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn
validationProperties); | 129 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController
()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn
validationProperties, hasAlpha); |
| 120 m_paintDefinitions.set(name, definition); | 130 m_paintDefinitions.set(name, definition); |
| 121 | 131 |
| 122 // Set the definition on any pending generators. | 132 // Set the definition on any pending generators. |
| 123 GeneratorHashSet* set = m_pendingGenerators.get(name); | 133 GeneratorHashSet* set = m_pendingGenerators.get(name); |
| 124 if (set) { | 134 if (set) { |
| 125 for (const auto& generator : *set) { | 135 for (const auto& generator : *set) { |
| 126 if (generator) { | 136 if (generator) { |
| 127 generator->setDefinition(definition); | 137 generator->setDefinition(definition); |
| 128 } | 138 } |
| 129 } | 139 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 145 } | 155 } |
| 146 | 156 |
| 147 DEFINE_TRACE(PaintWorkletGlobalScope) | 157 DEFINE_TRACE(PaintWorkletGlobalScope) |
| 148 { | 158 { |
| 149 visitor->trace(m_paintDefinitions); | 159 visitor->trace(m_paintDefinitions); |
| 150 visitor->trace(m_pendingGenerators); | 160 visitor->trace(m_pendingGenerators); |
| 151 MainThreadWorkletGlobalScope::trace(visitor); | 161 MainThreadWorkletGlobalScope::trace(visitor); |
| 152 } | 162 } |
| 153 | 163 |
| 154 } // namespace blink | 164 } // namespace blink |
| OLD | NEW |