1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 6 7 #include "config.h" 8 #include "V8TestInterfaceEventConstructor.h" 9 10 #include "bindings/tests/v8/V8TestInterfaceEmpty.h" 11 #include "bindings/v8/Dictionary.h" 12 #include "bindings/v8/ExceptionState.h" 13 #include "bindings/v8/ScriptValue.h" 14 #include "bindings/v8/SerializedScriptValue.h" 15 #include "bindings/v8/V8DOMConfiguration.h" 16 #include "bindings/v8/V8HiddenValue.h" 17 #include "bindings/v8/V8ObjectConstructor.h" 18 #include "bindings/v8/custom/V8Uint8ArrayCustom.h" 19 #include "core/dom/ContextFeatures.h" 20 #include "core/dom/Document.h" 21 #include "core/frame/LocalDOMWindow.h" 22 #include "core/frame/UseCounter.h" 23 #include "platform/RuntimeEnabledFeatures.h" 24 #include "platform/TraceEvent.h" 25 #include "wtf/GetPtr.h" 26 #include "wtf/RefPtr.h" 27 28 namespace WebCore { 29 30 static void initializeScriptWrappableForInterface(TestInterfaceEventConstructor* object) 31 { 32 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 33 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceEventConstructor::wrapperTypeInfo); 34 else 35 ASSERT_NOT_REACHED(); 36 } 37 38 } // namespace WebCore 39 40 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceEventConstructor* object) 41 { 42 WebCore::initializeScriptWrappableForInterface(object); 43 } 44 45 namespace WebCore { 46 const WrapperTypeInfo V8TestInterfaceEventConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventConstructor::domTemplate, V8TestInterfaceEventConstructor::derefObject, 0, 0, 0, V8TestInterfaceEventConstructor::installPerContextEnabledMethods, &V8Event::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject }; 47 48 namespace TestInterfaceEventConstructorV8Internal { 49 50 template <typename T> void V8_USE(T) { } 51 52 static void readonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 53 { 54 v8::Handle<v8::Object> holder = info.Holder(); 55 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 56 v8SetReturnValueString(info, impl->readonlyStringAttribute(), info.GetIsolate()); 57 } 58 59 static void readonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 60 { 61 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 62 TestInterfaceEventConstructorV8Internal::readonlyStringAttributeAttributeGetter(info); 63 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 64 } 65 66 static void initializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 67 { 68 v8::Handle<v8::Object> holder = info.Holder(); 69 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 70 v8SetReturnValueString(info, impl->initializedByEventConstructorReadonlyStringAttribute(), info.GetIsolate()); 71 } 72 73 static void initializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 74 { 75 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 76 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyStringAttributeAttributeGetter(info); 77 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 78 } 79 80 static void initializedByEventConstructorReadonlyAnyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 81 { 82 v8::Handle<v8::Object> holder = info.Holder(); 83 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 84 v8SetReturnValue(info, impl->initializedByEventConstructorReadonlyAnyAttribute().v8Value()); 85 } 86 87 static void initializedByEventConstructorReadonlyAnyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 88 { 89 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 90 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyAnyAttributeAttributeGetter(info); 91 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 92 } 93 94 static void initializedByEventConstructorReadonlyBooleanAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 95 { 96 v8::Handle<v8::Object> holder = info.Holder(); 97 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 98 v8SetReturnValueBool(info, impl->initializedByEventConstructorReadonlyBooleanAttribute()); 99 } 100 101 static void initializedByEventConstructorReadonlyBooleanAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 102 { 103 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 104 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyBooleanAttributeAttributeGetter(info); 105 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 106 } 107 108 static void initializedByEventConstructorReadonlyLongAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 109 { 110 v8::Handle<v8::Object> holder = info.Holder(); 111 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 112 v8SetReturnValueInt(info, impl->initializedByEventConstructorReadonlyLongAttribute()); 113 } 114 115 static void initializedByEventConstructorReadonlyLongAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 116 { 117 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 118 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyLongAttributeAttributeGetter(info); 119 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 120 } 121 122 static void initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 123 { 124 v8::Handle<v8::Object> holder = info.Holder(); 125 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 126 RefPtr<Uint8Array> result(impl->initializedByEventConstructorReadonlyUint8ArrayAttribute()); 127 if (result && DOMDataStore::setReturnValueFromWrapper<V8Uint8Array>(info.GetReturnValue(), result.get())) 128 return; 129 v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate()); 130 if (!wrapper.IsEmpty()) { 131 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "initializedByEventConstructorReadonlyUint8ArrayAttribute"), wrapper); 132 v8SetReturnValue(info, wrapper); 133 } 134 } 135 136 static void initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 137 { 138 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 139 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetter(info); 140 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 141 } 142 143 static void initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 144 { 145 v8::Handle<v8::Object> holder = info.Holder(); 146 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 147 RefPtr<TestInterfaceEmpty> result(impl->initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute()); 148 if (result && DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceEmpty>(info.GetReturnValue(), result.get())) 149 return; 150 v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate()); 151 if (!wrapper.IsEmpty()) { 152 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute"), wrapper); 153 v8SetReturnValue(info, wrapper); 154 } 155 } 156 157 static void initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 158 { 159 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 160 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetter(info); 161 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 162 } 163 164 static void initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 165 { 166 v8::Handle<v8::Object> holder = info.Holder(); 167 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 168 v8SetReturnValue(info, v8Array(impl->initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute(), info.Holder(), info.GetIsolate())); 169 } 170 171 static void initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 172 { 173 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 174 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetter(info); 175 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 176 } 177 178 static void initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 179 { 180 v8::Handle<v8::Object> holder = info.Holder(); 181 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 182 bool isNull = false; 183 RefPtr<TestInterfaceEmpty> v8Value = impl->initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute(isNull); 184 if (isNull) { 185 v8SetReturnValueNull(info); 186 return; 187 } 188 RefPtr<TestInterfaceEmpty> result(v8Value); 189 if (result && DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceEmpty>(info.GetReturnValue(), result.get())) 190 return; 191 v8::Handle<v8::Value> wrapper = toV8(result.get(), holder, info.GetIsolate()); 192 if (!wrapper.IsEmpty()) { 193 V8HiddenValue::setHiddenValue(info.GetIsolate(), holder, v8AtomicString(info.GetIsolate(), "initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute"), wrapper); 194 v8SetReturnValue(info, wrapper); 195 } 196 } 197 198 static void initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 199 { 200 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 201 TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetter(info); 202 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 203 } 204 205 static void deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 206 { 207 v8::Handle<v8::Object> holder = info.Holder(); 208 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 209 v8SetReturnValueString(info, impl->deprecatedInitializedByEventConstructorReadonlyStringAttribute(), info.GetIsolate()); 210 } 211 212 static void deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 213 { 214 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 215 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute); 216 TestInterfaceEventConstructorV8Internal::deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info); 217 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 218 } 219 220 static void implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 221 { 222 v8::Handle<v8::Object> holder = info.Holder(); 223 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 224 v8SetReturnValueString(info, impl->implementedAsName(), info.GetIsolate()); 225 } 226 227 static void implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 228 { 229 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 230 TestInterfaceEventConstructorV8Internal::implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info); 231 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 232 } 233 234 static void deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 235 { 236 v8::Handle<v8::Object> holder = info.Holder(); 237 TestInterfaceEventConstructor* impl = V8TestInterfaceEventConstructor::toNative(holder); 238 v8SetReturnValueString(info, impl->deprecatedImplementedAsName(), info.GetIsolate()); 239 } 240 241 static void deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 242 { 243 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 244 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute); 245 TestInterfaceEventConstructorV8Internal::deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetter(info); 246 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); 247 } 248 249 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 250 { 251 v8::Isolate* isolate = info.GetIsolate(); 252 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceEventConstructor", info.Holder(), isolate); 253 if (info.Length() < 1) { 254 exceptionState.throwTypeError("An event name must be provided."); 255 exceptionState.throwIfNeeded(); 256 return; 257 } 258 259 TOSTRING_VOID(V8StringResource<>, type, info[0]); 260 v8::Local<v8::Value> initializedByEventConstructorReadonlyAnyAttribute; 261 TestInterfaceEventConstructorInit eventInit; 262 if (info.Length() >= 2) { 263 TONATIVE_VOID(Dictionary, options, Dictionary(info[1], isolate)); 264 if (!initializeTestInterfaceEventConstructor(eventInit, options, exceptionState, info)) { 265 exceptionState.throwIfNeeded(); 266 return; 267 } 268 options.get("initializedByEventConstructorReadonlyAnyAttribute", initializedByEventConstructorReadonlyAnyAttribute); 269 if (!initializedByEventConstructorReadonlyAnyAttribute.IsEmpty()) 270 V8HiddenValue::setHiddenValue(isolate, info.Holder(), v8AtomicString(isolate, "initializedByEventConstructorReadonlyAnyAttribute"), initializedByEventConstructorReadonlyAnyAttribute); 271 } 272 RefPtrWillBeRawPtr<TestInterfaceEventConstructor> event = TestInterfaceEventConstructor::create(type, eventInit, exceptionState); 273 if (exceptionState.throwIfNeeded()) 274 return; 275 if (DOMWrapperWorld::current(isolate).isIsolatedWorld()) { 276 if (!initializedByEventConstructorReadonlyAnyAttribute.IsEmpty()) 277 event->setSerializedInitializedByEventConstructorReadonlyAnyAttribute(SerializedScriptValue::createAndSwallowExceptions(initializedByEventConstructorReadonlyAnyAttribute, isolate)); 278 } 279 280 v8::Handle<v8::Object> wrapper = info.Holder(); 281 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(event.release(), &V8TestInterfaceEventConstructor::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); 282 v8SetReturnValue(info, wrapper); 283 } 284 285 } // namespace TestInterfaceEventConstructorV8Internal 286 287 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceEventConstructorAttributes[] = { 288 {"readonlyStringAttribute", TestInterfaceEventConstructorV8Internal::readonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 289 {"initializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 290 {"initializedByEventConstructorReadonlyAnyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyAnyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 291 {"initializedByEventConstructorReadonlyBooleanAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyBooleanAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 292 {"initializedByEventConstructorReadonlyLongAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 293 {"initializedByEventConstructorReadonlyUint8ArrayAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyUint8ArrayAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 294 {"initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 295 {"initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 296 {"initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute", TestInterfaceEventConstructorV8Internal::initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 297 {"deprecatedInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::deprecatedInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 298 {"implementedAsInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::implementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 299 {"deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute", TestInterfaceEventConstructorV8Internal::deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 300 }; 301 302 bool initializeTestInterfaceEventConstructor(TestInterfaceEventConstructorInit& eventInit, const Dictionary& options, ExceptionState& exceptionState, const v8::FunctionCallbackInfo<v8::Value>& info, const String& forEventName) 303 { 304 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? String("TestInterfaceEventConstructor") : forEventName, "", exceptionState); 305 if (!initializeEvent(eventInit, options, exceptionState, info, forEventName.isEmpty() ? String("TestInterfaceEventConstructor") : forEventName)) 306 return false; 307 308 if (!options.convert(conversionContext.setConversionType("DOMString", false), "initializedByEventConstructorReadonlyStringAttribute", eventInit.initializedByEventConstructorReadonlyStringAttribute)) 309 return false; 310 if (!options.convert(conversionContext.setConversionType("boolean", false), "initializedByEventConstructorReadonlyBooleanAttribute", eventInit.initializedByEventConstructorReadonlyBooleanAttribute)) 311 return false; 312 if (!options.convert(conversionContext.setConversionType("long", false), "initializedByEventConstructorReadonlyLongAttribute", eventInit.initializedByEventConstructorReadonlyLongAttribute)) 313 return false; 314 if (!options.convert(conversionContext.setConversionType("Uint8Array", false), "initializedByEventConstructorReadonlyUint8ArrayAttribute", eventInit.initializedByEventConstructorReadonlyUint8ArrayAttribute)) 315 return false; 316 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty", false), "initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute", eventInit.initializedByEventConstructorReadonlyTestInterfaceEmptyAttribute)) 317 return false; 318 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty[]", false), "initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute", eventInit.initializedByEventConstructorReadonlyTestInterfaceEmptyArrayAttribute)) 319 return false; 320 if (!options.convert(conversionContext.setConversionType("TestInterfaceEmpty", true), "initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute", eventInit.initializedByEventConstructorReadonlyNullableTestInterfaceEmptyAttribute)) 321 return false; 322 if (options.convert(conversionContext.setConversionType("DOMString", false), "deprecatedInitializedByEventConstructorReadonlyStringAttribute", eventInit.deprecatedInitializedByEventConstructorReadonlyStringAttribute)) { 323 if (options.hasProperty("deprecatedInitializedByEventConstructorReadonlyStringAttribute")) 324 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute); 325 } else { 326 return false; 327 } 328 if (!options.convert(conversionContext.setConversionType("DOMString", false), "implementedAsInitializedByEventConstructorReadonlyStringAttribute", eventInit.implementedAsName)) 329 return false; 330 if (options.convert(conversionContext.setConversionType("DOMString", false), "deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute", eventInit.deprecatedImplementedAsName)) { 331 if (options.hasProperty("deprecatedImplementedAsInitializedByEventConstructorReadonlyStringAttribute")) 332 UseCounter::countDeprecation(callingExecutionContext(info.GetIsolate()), UseCounter::initializedByEventConstructorReadonlyStringAttribute); 333 } else { 334 return false; 335 } 336 return true; 337 } 338 339 void V8TestInterfaceEventConstructor::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 340 { 341 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); 342 if (!info.IsConstructCall()) { 343 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceEventConstructor"), info.GetIsolate()); 344 return; 345 } 346 347 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) { 348 v8SetReturnValue(info, info.Holder()); 349 return; 350 } 351 352 TestInterfaceEventConstructorV8Internal::constructor(info); 353 } 354 355 static void configureV8TestInterfaceEventConstructorTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate) 356 { 357 functionTemplate->ReadOnlyPrototype(); 358 359 v8::Local<v8::Signature> defaultSignature; 360 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventConstructor", V8Event::domTemplate(isolate), V8TestInterfaceEventConstructor::internalFieldCount, 361 V8TestInterfaceEventConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceEventConstructorAttributes), 362 0, 0, 363 0, 0, 364 isolate); 365 functionTemplate->SetCallHandler(V8TestInterfaceEventConstructor::constructorCallback); 366 functionTemplate->SetLength(1); 367 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate(); 368 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate(); 369 370 // Custom toString template 371 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate()); 372 } 373 374 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventConstructor::domTemplate(v8::Isolate* isolate) 375 { 376 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceEventConstructorTemplate); 377 } 378 379 bool V8TestInterfaceEventConstructor::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 380 { 381 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value); 382 } 383 384 v8::Handle<v8::Object> V8TestInterfaceEventConstructor::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 385 { 386 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value); 387 } 388 389 TestInterfaceEventConstructor* V8TestInterfaceEventConstructor::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value) 390 { 391 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 392 } 393 394 v8::Handle<v8::Object> wrap(TestInterfaceEventConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 395 { 396 ASSERT(impl); 397 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventConstructor>(impl, isolate)); 398 return V8TestInterfaceEventConstructor::createWrapper(impl, creationContext, isolate); 399 } 400 401 v8::Handle<v8::Object> V8TestInterfaceEventConstructor::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceEventConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 402 { 403 ASSERT(impl); 404 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventConstructor>(impl.get(), isolate)); 405 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 406 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo(); 407 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have 408 // the same object de-ref functions, though, so use that as the basis of the check. 409 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 410 } 411 412 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 413 if (UNLIKELY(wrapper.IsEmpty())) 414 return wrapper; 415 416 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 417 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventConstructor>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); 418 return wrapper; 419 } 420 421 void V8TestInterfaceEventConstructor::derefObject(void* object) 422 { 423 #if !ENABLE(OILPAN) 424 fromInternalPointer(object)->deref(); 425 #endif // !ENABLE(OILPAN) 426 } 427 428 template<> 429 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventConstructor* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 430 { 431 return toV8(impl, creationContext, isolate); 432 } 433 434 } // namespace WebCore 435