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

Unified Diff: Source/bindings/tests/results/V8TestEventTarget.cpp

Issue 18778002: Inherit EventTarget interface instead of duplicating its code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/tests/results/V8TestEventTarget.h ('k') | Source/bindings/tests/results/V8TestException.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/tests/results/V8TestEventTarget.cpp
diff --git a/Source/bindings/tests/results/V8TestEventTarget.cpp b/Source/bindings/tests/results/V8TestEventTarget.cpp
index 8cc16e3f74015685df4ee9f5c20ea36fc8449ab6..d3371f3b56dc46fdac6f61c29bbeca8af42bfee5 100644
--- a/Source/bindings/tests/results/V8TestEventTarget.cpp
+++ b/Source/bindings/tests/results/V8TestEventTarget.cpp
@@ -22,13 +22,12 @@
#include "V8TestEventTarget.h"
#include "RuntimeEnabledFeatures.h"
-#include "V8Event.h"
+#include "V8EventTarget.h"
#include "V8Node.h"
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8DOMConfiguration.h"
#include "bindings/v8/V8DOMWrapper.h"
-#include "bindings/v8/V8EventListenerList.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
@@ -58,7 +57,7 @@ void webCoreInitializeScriptWrappableForInterface(WebCore::TestEventTarget* obje
}
namespace WebCore {
-WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, V8TestEventTarget::toEventTarget, 0, V8TestEventTarget::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
+WrapperTypeInfo V8TestEventTarget::info = { V8TestEventTarget::GetTemplate, V8TestEventTarget::derefObject, 0, V8TestEventTarget::toEventTarget, 0, V8TestEventTarget::installPerContextPrototypeProperties, &V8EventTarget::info, WrapperTypeObjectPrototype };
namespace TestEventTargetV8Internal {
@@ -107,65 +106,6 @@ static void namedItemMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& a
TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
}
-static void addEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[1], false, ListenerFindOrCreate);
- if (listener) {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, stringResource, args[0]);
- V8TestEventTarget::toNative(args.Holder())->addEventListener(stringResource, listener, args[2]->BooleanValue());
- createHiddenDependency(args.Holder(), args[1], V8TestEventTarget::eventListenerCacheIndex, args.GetIsolate());
- }
-}
-
-static void addEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestEventTargetV8Internal::addEventListenerMethod(args);
- TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
-}
-
-static void removeEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- RefPtr<EventListener> listener = V8EventListenerList::getEventListener(args[1], false, ListenerFindOnly);
- if (listener) {
- V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, stringResource, args[0]);
- V8TestEventTarget::toNative(args.Holder())->removeEventListener(stringResource, listener.get(), args[2]->BooleanValue());
- removeHiddenDependency(args.Holder(), args[1], V8TestEventTarget::eventListenerCacheIndex, args.GetIsolate());
- }
-}
-
-static void removeEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestEventTargetV8Internal::removeEventListenerMethod(args);
- TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
-}
-
-static void dispatchEventMethod(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- if (args.Length() < 1) {
- throwNotEnoughArgumentsError(args.GetIsolate());
- return;
- }
- TestEventTarget* imp = V8TestEventTarget::toNative(args.Holder());
- ExceptionCode ec = 0;
- V8TRYCATCH_VOID(Event*, evt, V8Event::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate())) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
- bool result = imp->dispatchEvent(evt, ec);
- if (UNLIKELY(ec)) {
- setDOMException(ec, args.GetIsolate());
- return;
- }
- v8SetReturnValueBool(args, result);
- return;
-}
-
-static void dispatchEventMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
-{
- TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod");
- TestEventTargetV8Internal::dispatchEventMethod(args);
- TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
-}
-
static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
{
ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
@@ -337,8 +277,6 @@ static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
static const V8DOMConfiguration::BatchedMethod V8TestEventTargetMethods[] = {
{"item", TestEventTargetV8Internal::itemMethodCallback, 0, 1},
{"namedItem", TestEventTargetV8Internal::namedItemMethodCallback, 0, 1},
- {"addEventListener", TestEventTargetV8Internal::addEventListenerMethodCallback, 0, 2},
- {"removeEventListener", TestEventTargetV8Internal::removeEventListenerMethodCallback, 0, 2},
};
static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType)
@@ -346,7 +284,7 @@ static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::H
desc->ReadOnlyPrototype();
v8::Local<v8::Signature> defaultSignature;
- defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventTarget", v8::Local<v8::FunctionTemplate>(), V8TestEventTarget::internalFieldCount,
+ defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventTarget", V8EventTarget::GetTemplate(isolate, currentWorldType), V8TestEventTarget::internalFieldCount,
0, 0,
V8TestEventTargetMethods, WTF_ARRAY_LENGTH(V8TestEventTargetMethods), isolate, currentWorldType);
UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
@@ -358,12 +296,6 @@ static v8::Handle<v8::FunctionTemplate> ConfigureV8TestEventTargetTemplate(v8::H
desc->InstanceTemplate()->SetNamedPropertyHandler(TestEventTargetV8Internal::namedPropertyGetterCallback, TestEventTargetV8Internal::namedPropertySetterCallback, TestEventTargetV8Internal::namedPropertyQueryCallback, TestEventTargetV8Internal::namedPropertyDeleterCallback, TestEventTargetV8Internal::namedPropertyEnumeratorCallback);
desc->InstanceTemplate()->MarkAsUndetectable();
- // Custom Signature 'dispatchEvent'
- const int dispatchEventArgc = 1;
- v8::Handle<v8::FunctionTemplate> dispatchEventArgv[dispatchEventArgc] = { V8PerIsolateData::from(isolate)->rawTemplate(&V8Event::info, currentWorldType) };
- v8::Handle<v8::Signature> dispatchEventSignature = v8::Signature::New(desc, dispatchEventArgc, dispatchEventArgv);
- proto->Set(v8::String::NewSymbol("dispatchEvent"), v8::FunctionTemplate::New(TestEventTargetV8Internal::dispatchEventMethodCallback, v8Undefined(), dispatchEventSignature, 1));
-
// Custom toString template
desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate());
return desc;
@@ -405,18 +337,18 @@ EventTarget* V8TestEventTarget::toEventTarget(v8::Handle<v8::Object> object)
v8::Handle<v8::Object> V8TestEventTarget::createWrapper(PassRefPtr<TestEventTarget> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ASSERT(impl.get());
- ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
+ ASSERT(DOMDataStore::getWrapper<V8TestEventTarget>(impl.get(), isolate).IsEmpty());
- v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, impl.get(), isolate);
+ v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate);
if (UNLIKELY(wrapper.IsEmpty()))
return wrapper;
installPerContextProperties(wrapper, impl.get(), isolate);
- V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, WrapperConfiguration::Independent);
+ V8DOMWrapper::associateObjectWithWrapper<V8TestEventTarget>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent);
return wrapper;
}
void V8TestEventTarget::derefObject(void* object)
{
- static_cast<TestEventTarget*>(object)->deref();
+ fromInternalPointer(object)->deref();
}
} // namespace WebCore
« no previous file with comments | « Source/bindings/tests/results/V8TestEventTarget.h ('k') | Source/bindings/tests/results/V8TestException.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698