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

Side by Side Diff: third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScope.cpp

Issue 2077413005: Add "alpha" option to PaintWorklet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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" 9 #include "core/CSSPropertyNames.h"
10 #include "core/css/parser/CSSVariableParser.h" 10 #include "core/css/parser/CSSVariableParser.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // Disallow prefixes. 82 // Disallow prefixes.
83 if (property[0] == '-') { 83 if (property[0] == '-') {
84 addConsoleMessage(ConsoleMessage::create(JSMessageSource, Wa rningMessageLevel, property + " is a prefixed property which is not supported.") ); 84 addConsoleMessage(ConsoleMessage::create(JSMessageSource, Wa rningMessageLevel, property + " is a prefixed property which is not supported.") );
85 } else { 85 } else {
86 nativeInvalidationProperties.append(propertyID); 86 nativeInvalidationProperties.append(propertyID);
87 } 87 }
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 // Parse 'alpha' AKA hasAlphaChannel property.
93 v8::Local<v8::Value> alphaValue;
94 if (!v8Call(constructor->Get(context, v8String(isolate, "alpha")), alphaValu e))
95 return;
96 if (!isUndefinedOrNull(alphaValue) && !alphaValue->IsBoolean()) {
97 exceptionState.throwTypeError("The 'alpha' property on the class is not a boolean.");
98 return;
99 }
100 bool hasAlphaChannel = alphaValue->IsBoolean() && v8::Local<v8::Boolean>::Ca st(alphaValue)->Value();
haraken 2016/06/22 00:59:47 Drive-by: 'alphaValue->IsBoolean() &&' won't be ne
Gleb Lanbin 2016/06/22 04:27:46 Done. thanks.
101
92 v8::Local<v8::Value> prototypeValue; 102 v8::Local<v8::Value> prototypeValue;
93 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue)) 103 if (!v8Call(constructor->Get(context, v8String(isolate, "prototype")), proto typeValue))
94 return; 104 return;
95 105
96 if (isUndefinedOrNull(prototypeValue)) { 106 if (isUndefinedOrNull(prototypeValue)) {
97 exceptionState.throwTypeError("The 'prototype' object on the class does not exist."); 107 exceptionState.throwTypeError("The 'prototype' object on the class does not exist.");
98 return; 108 return;
99 } 109 }
100 110
101 if (!prototypeValue->IsObject()) { 111 if (!prototypeValue->IsObject()) {
(...skipping 12 matching lines...) Expand all
114 return; 124 return;
115 } 125 }
116 126
117 if (!paintValue->IsFunction()) { 127 if (!paintValue->IsFunction()) {
118 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function."); 128 exceptionState.throwTypeError("The 'paint' property on the prototype is not a function.");
119 return; 129 return;
120 } 130 }
121 131
122 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue); 132 v8::Local<v8::Function> paint = v8::Local<v8::Function>::Cast(paintValue);
123 133
124 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn validationProperties); 134 CSSPaintDefinition* definition = CSSPaintDefinition::create(scriptController ()->getScriptState(), constructor, paint, nativeInvalidationProperties, customIn validationProperties, hasAlphaChannel);
125 m_paintDefinitions.set(name, definition); 135 m_paintDefinitions.set(name, definition);
126 136
127 // Set the definition on any pending generators. 137 // Set the definition on any pending generators.
128 GeneratorHashSet* set = m_pendingGenerators.get(name); 138 GeneratorHashSet* set = m_pendingGenerators.get(name);
129 if (set) { 139 if (set) {
130 for (const auto& generator : *set) { 140 for (const auto& generator : *set) {
131 if (generator) { 141 if (generator) {
132 generator->setDefinition(definition); 142 generator->setDefinition(definition);
133 } 143 }
134 } 144 }
(...skipping 15 matching lines...) Expand all
150 } 160 }
151 161
152 DEFINE_TRACE(PaintWorkletGlobalScope) 162 DEFINE_TRACE(PaintWorkletGlobalScope)
153 { 163 {
154 visitor->trace(m_paintDefinitions); 164 visitor->trace(m_paintDefinitions);
155 visitor->trace(m_pendingGenerators); 165 visitor->trace(m_pendingGenerators);
156 MainThreadWorkletGlobalScope::trace(visitor); 166 MainThreadWorkletGlobalScope::trace(visitor);
157 } 167 }
158 168
159 } // namespace blink 169 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698