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

Unified Diff: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp

Issue 2034533002: [DevTools] Add removeFunction to EventListener protocol object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
index 594e9b9fb1fbaeac2b3282253e9164856cc209a0..c5d64c31eced0d48a56fcbc4d2ec4f7634ec4a7d 100644
--- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
+++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp
@@ -258,34 +258,6 @@ void ThreadDebugger::unmonitorEventsCallback(const v8::FunctionCallbackInfo<v8::
setMonitorEventsCallback(info, false);
}
-static void removeEventListenerCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
- EventTarget* eventTarget = V8EventTarget::toImplWithTypeCheck(isolate, info.Data());
- if (!eventTarget)
- return;
- v8::Local<v8::Value> thisHandler;
- if (!info.Holder()->Get(context, v8String(isolate, "listener")).ToLocal(&thisHandler) || !thisHandler->IsObject())
- return;
- v8::Local<v8::Value> v8ThisType;
- if (!info.Holder()->Get(context, v8String(isolate, "type")).ToLocal(&v8ThisType) || !v8ThisType->IsString())
- return;
- AtomicString thisType = AtomicString(toCoreString(v8::Local<v8::String>::Cast(v8ThisType)));
- v8::Local<v8::Value> thisUseCapture;
- if (!info.Holder()->Get(context, v8String(isolate, "useCapture")).ToLocal(&thisUseCapture) || !thisUseCapture->IsBoolean())
- return;
-
- EventListener* eventListener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), thisHandler, false, ListenerFindOnly);
- if (!eventListener)
- eventListener = V8EventListenerList::getEventListener(ScriptState::current(info.GetIsolate()), thisHandler, true, ListenerFindOnly);
- if (!eventListener)
- return;
- EventListenerOptions options;
- options.setCapture(v8::Local<v8::Boolean>::Cast(thisUseCapture)->Value());
- eventTarget->removeEventListener(thisType, eventListener, options);
-}
-
// static
void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
@@ -295,7 +267,6 @@ void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8
ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::External>::Cast(info.Data())->Value());
DCHECK(debugger);
v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
V8EventListenerInfoList listenerInfo;
// eventListeners call can produce message on ErrorEvent during lazy event listener compilation.
@@ -304,12 +275,6 @@ void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8
debugger->unmuteWarningsAndDeprecations();
v8::Local<v8::Object> result = v8::Object::New(isolate);
-
- v8::Local<v8::Function> removeFunc = v8::Function::New(isolate, removeEventListenerCallback, info[0]);
- v8::Local<v8::Function> toStringFunction;
- if (v8::Function::New(context, returnDataCallback, v8String(isolate, "function remove() { [Command Line API] }")).ToLocal(&toStringFunction))
- removeFunc->Set(v8String(context->GetIsolate(), "toString"), toStringFunction);
-
AtomicString currentEventType;
v8::Local<v8::Array> listeners;
size_t outputIndex = 0;
@@ -326,7 +291,9 @@ void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8
listenerObject->Set(v8String(isolate, "useCapture"), v8::Boolean::New(isolate, info.useCapture));
listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isolate, info.passive));
listenerObject->Set(v8String(isolate, "type"), v8String(isolate, currentEventType));
- listenerObject->Set(v8String(isolate, "remove"), removeFunc);
+ v8::Local<v8::Function> removeFunction;
+ if (info.removeFunction.ToLocal(&removeFunction))
+ listenerObject->Set(v8String(isolate, "remove"), removeFunction);
listeners->Set(outputIndex++, listenerObject);
}
info.GetReturnValue().Set(result);

Powered by Google App Engine
This is Rietveld 408576698