| OLD | NEW |
| (Empty) |
| 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 "V8TestEventTarget.h" | |
| 9 | |
| 10 #include "RuntimeEnabledFeatures.h" | |
| 11 #include "V8Node.h" | |
| 12 #include "bindings/v8/ExceptionState.h" | |
| 13 #include "bindings/v8/V8DOMConfiguration.h" | |
| 14 #include "bindings/v8/V8HiddenValue.h" | |
| 15 #include "bindings/v8/V8ObjectConstructor.h" | |
| 16 #include "core/dom/ContextFeatures.h" | |
| 17 #include "core/dom/Document.h" | |
| 18 #include "platform/TraceEvent.h" | |
| 19 #include "wtf/GetPtr.h" | |
| 20 #include "wtf/RefPtr.h" | |
| 21 | |
| 22 namespace WebCore { | |
| 23 | |
| 24 static void initializeScriptWrappableForInterface(TestEventTarget* object) | |
| 25 { | |
| 26 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
| 27 ScriptWrappable::setTypeInfoInObject(object, &V8TestEventTarget::wrapper
TypeInfo); | |
| 28 else | |
| 29 ASSERT_NOT_REACHED(); | |
| 30 } | |
| 31 | |
| 32 } // namespace WebCore | |
| 33 | |
| 34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestEventTarget* obje
ct) | |
| 35 { | |
| 36 WebCore::initializeScriptWrappableForInterface(object); | |
| 37 } | |
| 38 | |
| 39 namespace WebCore { | |
| 40 const WrapperTypeInfo V8TestEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink
, V8TestEventTarget::domTemplate, V8TestEventTarget::derefObject, 0, V8TestEvent
Target::toEventTarget, 0, V8TestEventTarget::installPerContextEnabledMethods, &V
8EventTarget::wrapperTypeInfo, WrapperTypeObjectPrototype, false }; | |
| 41 | |
| 42 namespace TestEventTargetV8Internal { | |
| 43 | |
| 44 template <typename T> void V8_USE(T) { } | |
| 45 | |
| 46 static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 47 { | |
| 48 ExceptionState exceptionState(ExceptionState::ExecutionContext, "item", "Tes
tEventTarget", info.Holder(), info.GetIsolate()); | |
| 49 if (UNLIKELY(info.Length() < 1)) { | |
| 50 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | |
| 51 exceptionState.throwIfNeeded(); | |
| 52 return; | |
| 53 } | |
| 54 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 55 V8TRYCATCH_EXCEPTION_VOID(unsigned, index, toUInt32(info[0], exceptionState)
, exceptionState); | |
| 56 v8SetReturnValue(info, impl->item(index)); | |
| 57 } | |
| 58 | |
| 59 static void itemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 60 { | |
| 61 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 62 TestEventTargetV8Internal::itemMethod(info); | |
| 63 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 64 } | |
| 65 | |
| 66 static void namedItemMethod(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 67 { | |
| 68 if (UNLIKELY(info.Length() < 1)) { | |
| 69 throwTypeError(ExceptionMessages::failedToExecute("namedItem", "TestEven
tTarget", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsol
ate()); | |
| 70 return; | |
| 71 } | |
| 72 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 73 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]); | |
| 74 v8SetReturnValue(info, impl->namedItem(name)); | |
| 75 } | |
| 76 | |
| 77 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | |
| 78 { | |
| 79 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 80 TestEventTargetV8Internal::namedItemMethod(info); | |
| 81 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 82 } | |
| 83 | |
| 84 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | |
| 85 { | |
| 86 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 87 RefPtr<Node> result = impl->item(index); | |
| 88 if (!result) | |
| 89 return; | |
| 90 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | |
| 91 } | |
| 92 | |
| 93 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) | |
| 94 { | |
| 95 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | |
| 96 TestEventTargetV8Internal::indexedPropertyGetter(index, info); | |
| 97 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 98 } | |
| 99 | |
| 100 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> v8Value,
const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 101 { | |
| 102 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 103 V8TRYCATCH_VOID(Node*, propertyValue, V8Node::toNativeWithTypeCheck(info.Get
Isolate(), v8Value)); | |
| 104 if (!isUndefinedOrNull(v8Value) && !V8Node::hasInstance(v8Value, info.GetIso
late())) { | |
| 105 exceptionState.throwTypeError("The provided value is not of type 'Node'.
"); | |
| 106 exceptionState.throwIfNeeded(); | |
| 107 return; | |
| 108 } | |
| 109 bool result = impl->anonymousIndexedSetter(index, propertyValue); | |
| 110 if (!result) | |
| 111 return; | |
| 112 v8SetReturnValue(info, v8Value); | |
| 113 } | |
| 114 | |
| 115 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> v
8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 116 { | |
| 117 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | |
| 118 TestEventTargetV8Internal::indexedPropertySetter(index, v8Value, info); | |
| 119 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 120 } | |
| 121 | |
| 122 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) | |
| 123 { | |
| 124 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 125 ExceptionState exceptionState(ExceptionState::IndexedDeletionContext, "TestE
ventTarget", info.Holder(), info.GetIsolate()); | |
| 126 DeleteResult result = impl->anonymousIndexedDeleter(index, exceptionState); | |
| 127 if (exceptionState.throwIfNeeded()) | |
| 128 return; | |
| 129 if (result != DeleteUnknownProperty) | |
| 130 return v8SetReturnValueBool(info, result == DeleteSuccess); | |
| 131 } | |
| 132 | |
| 133 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) | |
| 134 { | |
| 135 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | |
| 136 TestEventTargetV8Internal::indexedPropertyDeleter(index, info); | |
| 137 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 138 } | |
| 139 | |
| 140 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) | |
| 141 { | |
| 142 if (info.Holder()->HasRealNamedProperty(name)) | |
| 143 return; | |
| 144 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | |
| 145 return; | |
| 146 | |
| 147 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 148 AtomicString propertyName = toCoreAtomicString(name); | |
| 149 RefPtr<Node> result = impl->namedItem(propertyName); | |
| 150 if (!result) | |
| 151 return; | |
| 152 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl); | |
| 153 } | |
| 154 | |
| 155 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) | |
| 156 { | |
| 157 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 158 TestEventTargetV8Internal::namedPropertyGetter(name, info); | |
| 159 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 160 } | |
| 161 | |
| 162 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 163 { | |
| 164 if (info.Holder()->HasRealNamedProperty(name)) | |
| 165 return; | |
| 166 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | |
| 167 return; | |
| 168 | |
| 169 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 170 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; | |
| 171 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, v8Va
lue); | |
| 172 bool result = impl->anonymousNamedSetter(propertyName, propertyValue); | |
| 173 if (!result) | |
| 174 return; | |
| 175 v8SetReturnValue(info, v8Value); | |
| 176 } | |
| 177 | |
| 178 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> v8Value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
| 179 { | |
| 180 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 181 TestEventTargetV8Internal::namedPropertySetter(name, v8Value, info); | |
| 182 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 183 } | |
| 184 | |
| 185 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | |
| 186 { | |
| 187 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 188 AtomicString propertyName = toCoreAtomicString(name); | |
| 189 v8::String::Utf8Value namedProperty(name); | |
| 190 ExceptionState exceptionState(ExceptionState::GetterContext, *namedProperty,
"TestEventTarget", info.Holder(), info.GetIsolate()); | |
| 191 bool result = impl->namedPropertyQuery(propertyName, exceptionState); | |
| 192 if (exceptionState.throwIfNeeded()) | |
| 193 return; | |
| 194 if (!result) | |
| 195 return; | |
| 196 v8SetReturnValueInt(info, v8::None); | |
| 197 } | |
| 198 | |
| 199 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) | |
| 200 { | |
| 201 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 202 TestEventTargetV8Internal::namedPropertyQuery(name, info); | |
| 203 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 204 } | |
| 205 | |
| 206 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) | |
| 207 { | |
| 208 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 209 AtomicString propertyName = toCoreAtomicString(name); | |
| 210 DeleteResult result = impl->anonymousNamedDeleter(propertyName); | |
| 211 if (result != DeleteUnknownProperty) | |
| 212 return v8SetReturnValueBool(info, result == DeleteSuccess); | |
| 213 } | |
| 214 | |
| 215 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) | |
| 216 { | |
| 217 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 218 TestEventTargetV8Internal::namedPropertyDeleter(name, info); | |
| 219 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 220 } | |
| 221 | |
| 222 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | |
| 223 { | |
| 224 TestEventTarget* impl = V8TestEventTarget::toNative(info.Holder()); | |
| 225 v8::Isolate* isolate = info.GetIsolate(); | |
| 226 Vector<String> names; | |
| 227 ExceptionState exceptionState(ExceptionState::EnumerationContext, "TestEvent
Target", info.Holder(), isolate); | |
| 228 impl->namedPropertyEnumerator(names, exceptionState); | |
| 229 if (exceptionState.throwIfNeeded()) | |
| 230 return; | |
| 231 v8::Handle<v8::Array> v8names = v8::Array::New(isolate, names.size()); | |
| 232 for (size_t i = 0; i < names.size(); ++i) | |
| 233 v8names->Set(v8::Integer::New(isolate, i), v8String(isolate, names[i])); | |
| 234 v8SetReturnValue(info, v8names); | |
| 235 } | |
| 236 | |
| 237 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) | |
| 238 { | |
| 239 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | |
| 240 TestEventTargetV8Internal::namedPropertyEnumerator(info); | |
| 241 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
| 242 } | |
| 243 | |
| 244 } // namespace TestEventTargetV8Internal | |
| 245 | |
| 246 static const V8DOMConfiguration::MethodConfiguration V8TestEventTargetMethods[]
= { | |
| 247 {"item", TestEventTargetV8Internal::itemMethodCallback, 0, 1}, | |
| 248 {"namedItem", TestEventTargetV8Internal::namedItemMethodCallback, 0, 1}, | |
| 249 }; | |
| 250 | |
| 251 static void configureV8TestEventTargetTemplate(v8::Handle<v8::FunctionTemplate>
functionTemplate, v8::Isolate* isolate) | |
| 252 { | |
| 253 functionTemplate->ReadOnlyPrototype(); | |
| 254 | |
| 255 v8::Local<v8::Signature> defaultSignature; | |
| 256 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestEventTarget", V8EventTarget::domTemplate(isolate), V8TestEventTarget::
internalFieldCount, | |
| 257 0, 0, | |
| 258 0, 0, | |
| 259 V8TestEventTargetMethods, WTF_ARRAY_LENGTH(V8TestEventTargetMethods), | |
| 260 isolate); | |
| 261 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | |
| 262 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | |
| 263 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestEventTar
getV8Internal::indexedPropertyGetterCallback, TestEventTargetV8Internal::indexed
PropertySetterCallback, 0, TestEventTargetV8Internal::indexedPropertyDeleterCall
back, indexedPropertyEnumerator<TestEventTarget>); | |
| 264 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestEventTarge
tV8Internal::namedPropertyGetterCallback, TestEventTargetV8Internal::namedProper
tySetterCallback, TestEventTargetV8Internal::namedPropertyQueryCallback, TestEve
ntTargetV8Internal::namedPropertyDeleterCallback, TestEventTargetV8Internal::nam
edPropertyEnumeratorCallback); | |
| 265 | |
| 266 // Custom toString template | |
| 267 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | |
| 268 } | |
| 269 | |
| 270 v8::Handle<v8::FunctionTemplate> V8TestEventTarget::domTemplate(v8::Isolate* iso
late) | |
| 271 { | |
| 272 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 273 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cas
t<WrapperTypeInfo*>(&wrapperTypeInfo)); | |
| 274 if (!result.IsEmpty()) | |
| 275 return result; | |
| 276 | |
| 277 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
| 278 result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidCons
tructorMode); | |
| 279 configureV8TestEventTargetTemplate(result, isolate); | |
| 280 data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result)
; | |
| 281 return result; | |
| 282 } | |
| 283 | |
| 284 bool V8TestEventTarget::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate*
isolate) | |
| 285 { | |
| 286 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 287 } | |
| 288 | |
| 289 v8::Handle<v8::Object> V8TestEventTarget::findInstanceInPrototypeChain(v8::Handl
e<v8::Value> v8Value, v8::Isolate* isolate) | |
| 290 { | |
| 291 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 292 } | |
| 293 | |
| 294 TestEventTarget* V8TestEventTarget::toNativeWithTypeCheck(v8::Isolate* isolate,
v8::Handle<v8::Value> value) | |
| 295 { | |
| 296 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje
ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) :
0; | |
| 297 } | |
| 298 | |
| 299 EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object) | |
| 300 { | |
| 301 return toNative(object); | |
| 302 } | |
| 303 | |
| 304 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
et> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 305 { | |
| 306 ASSERT(impl); | |
| 307 ASSERT(!DOMDataStore::containsWrapper<V8TestEventTarget>(impl.get(), isolate
)); | |
| 308 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
| 309 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
| 310 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | |
| 311 // the same object de-ref functions, though, so use that as the basis of
the check. | |
| 312 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | |
| 313 } | |
| 314 | |
| 315 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | |
| 316 if (UNLIKELY(wrapper.IsEmpty())) | |
| 317 return wrapper; | |
| 318 | |
| 319 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | |
| 320 V8DOMWrapper::associateObjectWithWrapper<V8TestEventTarget>(impl, &wrapperTy
peInfo, wrapper, isolate, WrapperConfiguration::Independent); | |
| 321 return wrapper; | |
| 322 } | |
| 323 | |
| 324 void V8TestEventTarget::derefObject(void* object) | |
| 325 { | |
| 326 fromInternalPointer(object)->deref(); | |
| 327 } | |
| 328 | |
| 329 template<> | |
| 330 v8::Handle<v8::Value> toV8NoInline(TestEventTarget* impl, v8::Handle<v8::Object>
creationContext, v8::Isolate* isolate) | |
| 331 { | |
| 332 return toV8(impl, creationContext, isolate); | |
| 333 } | |
| 334 | |
| 335 } // namespace WebCore | |
| OLD | NEW |