| OLD | NEW |
| 1 /* | 1 /* |
| 2 This file is part of the Blink open source project. | 2 This file is part of the Blink open source project. |
| 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! | 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! |
| 4 | 4 |
| 5 This library is free software; you can redistribute it and/or | 5 This library is free software; you can redistribute it and/or |
| 6 modify it under the terms of the GNU Library General Public | 6 modify it under the terms of the GNU Library General Public |
| 7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
| 8 version 2 of the License, or (at your option) any later version. | 8 version 2 of the License, or (at your option) any later version. |
| 9 | 9 |
| 10 This library is distributed in the hope that it will be useful, | 10 This library is distributed in the hope that it will be useful, |
| 11 but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 Library General Public License for more details. | 13 Library General Public License for more details. |
| 14 | 14 |
| 15 You should have received a copy of the GNU Library General Public License | 15 You should have received a copy of the GNU Library General Public License |
| 16 along with this library; see the file COPYING.LIB. If not, write to | 16 along with this library; see the file COPYING.LIB. If not, write to |
| 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 18 Boston, MA 02111-1307, USA. | 18 Boston, MA 02111-1307, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "V8TestEventTarget.h" | 22 #include "V8TestEventTarget.h" |
| 23 | 23 |
| 24 #include "RuntimeEnabledFeatures.h" | 24 #include "RuntimeEnabledFeatures.h" |
| 25 #include "V8Event.h" | 25 #include "V8EventTarget.h" |
| 26 #include "V8Node.h" | 26 #include "V8Node.h" |
| 27 #include "bindings/v8/ScriptController.h" | 27 #include "bindings/v8/ScriptController.h" |
| 28 #include "bindings/v8/V8Binding.h" | 28 #include "bindings/v8/V8Binding.h" |
| 29 #include "bindings/v8/V8DOMConfiguration.h" | 29 #include "bindings/v8/V8DOMConfiguration.h" |
| 30 #include "bindings/v8/V8DOMWrapper.h" | 30 #include "bindings/v8/V8DOMWrapper.h" |
| 31 #include "bindings/v8/V8EventListenerList.h" | |
| 32 #include "core/dom/ContextFeatures.h" | 31 #include "core/dom/ContextFeatures.h" |
| 33 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 34 #include "core/dom/ExceptionCode.h" | 33 #include "core/dom/ExceptionCode.h" |
| 35 #include "core/page/Frame.h" | 34 #include "core/page/Frame.h" |
| 36 #include "core/platform/chromium/TraceEvent.h" | 35 #include "core/platform/chromium/TraceEvent.h" |
| 37 #include "wtf/UnusedParam.h" | 36 #include "wtf/UnusedParam.h" |
| 38 | 37 |
| 39 namespace WebCore { | 38 namespace WebCore { |
| 40 | 39 |
| 41 static void initializeScriptWrappableForInterface(TestEventTarget* object) | 40 static void initializeScriptWrappableForInterface(TestEventTarget* object) |
| 42 { | 41 { |
| 43 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 42 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| 44 ScriptWrappable::setTypeInfoInObject(object, &V8TestEventTarget::info); | 43 ScriptWrappable::setTypeInfoInObject(object, &V8TestEventTarget::info); |
| 45 else | 44 else |
| 46 ASSERT_NOT_REACHED(); | 45 ASSERT_NOT_REACHED(); |
| 47 } | 46 } |
| 48 | 47 |
| 49 } // namespace WebCore | 48 } // namespace WebCore |
| 50 | 49 |
| 51 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: | 50 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: |
| 52 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function | 51 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function |
| 53 // in the global namespace. | 52 // in the global namespace. |
| 54 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) | 53 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) |
| 55 void webCoreInitializeScriptWrappableForInterface(WebCore::TestEventTarget* obje
ct) | 54 void webCoreInitializeScriptWrappableForInterface(WebCore::TestEventTarget* obje
ct) |
| 56 { | 55 { |
| 57 WebCore::initializeScriptWrappableForInterface(object); | 56 WebCore::initializeScriptWrappableForInterface(object); |
| 58 } | 57 } |
| 59 | 58 |
| 60 namespace WebCore { | 59 namespace WebCore { |
| 61 WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8Te
stEventTarget::derefObject, 0, V8TestEventTarget::toEventTarget, 0, V8TestEventT
arget::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype }; | 60 WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8Te
stEventTarget::derefObject, 0, V8TestEventTarget::toEventTarget, 0, V8TestEventT
arget::installPerContextPrototypeProperties, &V8EventTarget::info, WrapperTypeOb
jectPrototype }; |
| 62 | 61 |
| 63 namespace TestEventTargetV8Internal { | 62 namespace TestEventTargetV8Internal { |
| 64 | 63 |
| 65 template <typename T> void V8_USE(T) { } | 64 template <typename T> void V8_USE(T) { } |
| 66 | 65 |
| 67 static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& args) | 66 static void itemMethod(const v8::FunctionCallbackInfo<v8::Value>& args) |
| 68 { | 67 { |
| 69 if (args.Length() < 1) { | 68 if (args.Length() < 1) { |
| 70 throwNotEnoughArgumentsError(args.GetIsolate()); | 69 throwNotEnoughArgumentsError(args.GetIsolate()); |
| 71 return; | 70 return; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 100 return; | 99 return; |
| 101 } | 100 } |
| 102 | 101 |
| 103 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& a
rgs) | 102 static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& a
rgs) |
| 104 { | 103 { |
| 105 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 104 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
| 106 TestEventTargetV8Internal::namedItemMethod(args); | 105 TestEventTargetV8Internal::namedItemMethod(args); |
| 107 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 106 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 108 } | 107 } |
| 109 | 108 |
| 110 static void addEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>& ar
gs) | |
| 111 { | |
| 112 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[
1], false, ListenerFindOrCreate); | |
| 113 if (listener) { | |
| 114 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, st
ringResource, args[0]); | |
| 115 V8TestEventTarget::toNative(args.Holder())->addEventListener(stringResou
rce, listener, args[2]->BooleanValue()); | |
| 116 createHiddenDependency(args.Holder(), args[1], V8TestEventTarget::eventL
istenerCacheIndex, args.GetIsolate()); | |
| 117 } | |
| 118 } | |
| 119 | |
| 120 static void addEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& args) | |
| 121 { | |
| 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 123 TestEventTargetV8Internal::addEventListenerMethod(args); | |
| 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
| 125 } | |
| 126 | |
| 127 static void removeEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>&
args) | |
| 128 { | |
| 129 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[
1], false, ListenerFindOnly); | |
| 130 if (listener) { | |
| 131 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, st
ringResource, args[0]); | |
| 132 V8TestEventTarget::toNative(args.Holder())->removeEventListener(stringRe
source, listener.get(), args[2]->BooleanValue()); | |
| 133 removeHiddenDependency(args.Holder(), args[1], V8TestEventTarget::eventL
istenerCacheIndex, args.GetIsolate()); | |
| 134 } | |
| 135 } | |
| 136 | |
| 137 static void removeEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& args) | |
| 138 { | |
| 139 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 140 TestEventTargetV8Internal::removeEventListenerMethod(args); | |
| 141 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
| 142 } | |
| 143 | |
| 144 static void dispatchEventMethod(const v8::FunctionCallbackInfo<v8::Value>& args) | |
| 145 { | |
| 146 if (args.Length() < 1) { | |
| 147 throwNotEnoughArgumentsError(args.GetIsolate()); | |
| 148 return; | |
| 149 } | |
| 150 TestEventTarget* imp = V8TestEventTarget::toNative(args.Holder()); | |
| 151 ExceptionCode ec = 0; | |
| 152 V8TRYCATCH_VOID(Event*, evt, V8Event::HasInstance(args[0], args.GetIsolate()
, worldType(args.GetIsolate())) ? V8Event::toNative(v8::Handle<v8::Object>::Cast
(args[0])) : 0); | |
| 153 bool result = imp->dispatchEvent(evt, ec); | |
| 154 if (UNLIKELY(ec)) { | |
| 155 setDOMException(ec, args.GetIsolate()); | |
| 156 return; | |
| 157 } | |
| 158 v8SetReturnValueBool(args, result); | |
| 159 return; | |
| 160 } | |
| 161 | |
| 162 static void dispatchEventMethodCallback(const v8::FunctionCallbackInfo<v8::Value
>& args) | |
| 163 { | |
| 164 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
| 165 TestEventTargetV8Internal::dispatchEventMethod(args); | |
| 166 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
| 167 } | |
| 168 | |
| 169 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 109 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
| 170 { | 110 { |
| 171 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); | 111 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); |
| 172 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); | 112 TestEventTarget* collection = V8TestEventTarget::toNative(info.Holder()); |
| 173 RefPtr<Node> element = collection->item(index); | 113 RefPtr<Node> element = collection->item(index); |
| 174 if (!element) | 114 if (!element) |
| 175 return; | 115 return; |
| 176 v8SetReturnValue(info, toV8Fast(element.release(), info, collection)); | 116 v8SetReturnValue(info, toV8Fast(element.release(), info, collection)); |
| 177 } | 117 } |
| 178 | 118 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 270 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
| 331 TestEventTargetV8Internal::namedPropertyQuery(name, info); | 271 TestEventTargetV8Internal::namedPropertyQuery(name, info); |
| 332 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 272 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 333 } | 273 } |
| 334 | 274 |
| 335 } // namespace TestEventTargetV8Internal | 275 } // namespace TestEventTargetV8Internal |
| 336 | 276 |
| 337 static const V8DOMConfiguration::BatchedMethod V8TestEventTargetMethods[] = { | 277 static const V8DOMConfiguration::BatchedMethod V8TestEventTargetMethods[] = { |
| 338 {"item", TestEventTargetV8Internal::itemMethodCallback, 0, 1}, | 278 {"item", TestEventTargetV8Internal::itemMethodCallback, 0, 1}, |
| 339 {"namedItem", TestEventTargetV8Internal::namedItemMethodCallback, 0, 1}, | 279 {"namedItem", TestEventTargetV8Internal::namedItemMethodCallback, 0, 1}, |
| 340 {"addEventListener", TestEventTargetV8Internal::addEventListenerMethodCallba
ck, 0, 2}, | |
| 341 {"removeEventListener", TestEventTargetV8Internal::removeEventListenerMethod
Callback, 0, 2}, | |
| 342 }; | 280 }; |
| 343 | 281 |
| 344 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::H
andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current
WorldType) | 282 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::H
andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current
WorldType) |
| 345 { | 283 { |
| 346 desc->ReadOnlyPrototype(); | 284 desc->ReadOnlyPrototype(); |
| 347 | 285 |
| 348 v8::Local<v8::Signature> defaultSignature; | 286 v8::Local<v8::Signature> defaultSignature; |
| 349 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventTar
get", v8::Local<v8::FunctionTemplate>(), V8TestEventTarget::internalFieldCount, | 287 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventTar
get", V8EventTarget::GetTemplate(isolate, currentWorldType), V8TestEventTarget::
internalFieldCount, |
| 350 0, 0, | 288 0, 0, |
| 351 V8TestEventTargetMethods, WTF_ARRAY_LENGTH(V8TestEventTargetMethods), is
olate, currentWorldType); | 289 V8TestEventTargetMethods, WTF_ARRAY_LENGTH(V8TestEventTargetMethods), is
olate, currentWorldType); |
| 352 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 290 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| 353 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | 291 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); |
| 354 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | 292 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); |
| 355 UNUSED_PARAM(instance); // In some cases, it will not be used. | 293 UNUSED_PARAM(instance); // In some cases, it will not be used. |
| 356 UNUSED_PARAM(proto); // In some cases, it will not be used. | 294 UNUSED_PARAM(proto); // In some cases, it will not be used. |
| 357 desc->InstanceTemplate()->SetIndexedPropertyHandler(TestEventTargetV8Interna
l::indexedPropertyGetterCallback, TestEventTargetV8Internal::indexedPropertySett
erCallback, 0, TestEventTargetV8Internal::indexedPropertyDeleterCallback, indexe
dPropertyEnumerator<TestEventTarget>); | 295 desc->InstanceTemplate()->SetIndexedPropertyHandler(TestEventTargetV8Interna
l::indexedPropertyGetterCallback, TestEventTargetV8Internal::indexedPropertySett
erCallback, 0, TestEventTargetV8Internal::indexedPropertyDeleterCallback, indexe
dPropertyEnumerator<TestEventTarget>); |
| 358 desc->InstanceTemplate()->SetNamedPropertyHandler(TestEventTargetV8Internal:
:namedPropertyGetterCallback, TestEventTargetV8Internal::namedPropertySetterCall
back, TestEventTargetV8Internal::namedPropertyQueryCallback, TestEventTargetV8In
ternal::namedPropertyDeleterCallback, TestEventTargetV8Internal::namedPropertyEn
umeratorCallback); | 296 desc->InstanceTemplate()->SetNamedPropertyHandler(TestEventTargetV8Internal:
:namedPropertyGetterCallback, TestEventTargetV8Internal::namedPropertySetterCall
back, TestEventTargetV8Internal::namedPropertyQueryCallback, TestEventTargetV8In
ternal::namedPropertyDeleterCallback, TestEventTargetV8Internal::namedPropertyEn
umeratorCallback); |
| 359 desc->InstanceTemplate()->MarkAsUndetectable(); | 297 desc->InstanceTemplate()->MarkAsUndetectable(); |
| 360 | 298 |
| 361 // Custom Signature 'dispatchEvent' | |
| 362 const int dispatchEventArgc = 1; | |
| 363 v8::Handle<v8::FunctionTemplate> dispatchEventArgv[dispatchEventArgc] = { V8
PerIsolateData::from(isolate)->rawTemplate(&V8Event::info, currentWorldType) }; | |
| 364 v8::Handle<v8::Signature> dispatchEventSignature = v8::Signature::New(desc,
dispatchEventArgc, dispatchEventArgv); | |
| 365 proto->Set(v8::String::NewSymbol("dispatchEvent"), v8::FunctionTemplate::New
(TestEventTargetV8Internal::dispatchEventMethodCallback, v8Undefined(), dispatch
EventSignature, 1)); | |
| 366 | |
| 367 // Custom toString template | 299 // Custom toString template |
| 368 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); | 300 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); |
| 369 return desc; | 301 return desc; |
| 370 } | 302 } |
| 371 | 303 |
| 372 v8::Handle<v8::FunctionTemplate> V8TestEventTarget::GetTemplate(v8::Isolate* iso
late, WrapperWorldType currentWorldType) | 304 v8::Handle<v8::FunctionTemplate> V8TestEventTarget::GetTemplate(v8::Isolate* iso
late, WrapperWorldType currentWorldType) |
| 373 { | 305 { |
| 374 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 306 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 375 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); | 307 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); |
| 376 if (result != data->templateMap(currentWorldType).end()) | 308 if (result != data->templateMap(currentWorldType).end()) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 398 | 330 |
| 399 EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object) | 331 EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object) |
| 400 { | 332 { |
| 401 return toNative(object); | 333 return toNative(object); |
| 402 } | 334 } |
| 403 | 335 |
| 404 | 336 |
| 405 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
et> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 337 v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarg
et> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 406 { | 338 { |
| 407 ASSERT(impl.get()); | 339 ASSERT(impl.get()); |
| 408 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); | 340 ASSERT(DOMDataStore::getWrapper<V8TestEventTarget>(impl.get(), isolate).IsEm
pty()); |
| 409 | 341 |
| 410 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, impl.get(), isolate); | 342 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, toInternalPointer(impl.get()), isolate); |
| 411 if (UNLIKELY(wrapper.IsEmpty())) | 343 if (UNLIKELY(wrapper.IsEmpty())) |
| 412 return wrapper; | 344 return wrapper; |
| 413 installPerContextProperties(wrapper, impl.get(), isolate); | 345 installPerContextProperties(wrapper, impl.get(), isolate); |
| 414 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, Wrap
perConfiguration::Independent); | 346 V8DOMWrapper::associateObjectWithWrapper<V8TestEventTarget>(impl, &info, wra
pper, isolate, WrapperConfiguration::Independent); |
| 415 return wrapper; | 347 return wrapper; |
| 416 } | 348 } |
| 417 void V8TestEventTarget::derefObject(void* object) | 349 void V8TestEventTarget::derefObject(void* object) |
| 418 { | 350 { |
| 419 static_cast<TestEventTarget*>(object)->deref(); | 351 fromInternalPointer(object)->deref(); |
| 420 } | 352 } |
| 421 | 353 |
| 422 } // namespace WebCore | 354 } // namespace WebCore |
| OLD | NEW |