Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/inspector/ThreadDebugger.h" | 5 #include "core/inspector/ThreadDebugger.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptCallStack.h" | 7 #include "bindings/core/v8/ScriptCallStack.h" |
| 8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
| 9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 10 #include "bindings/core/v8/V8DOMException.h" | 10 #include "bindings/core/v8/V8DOMException.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8 ::Value>& info) | 291 void ThreadDebugger::getEventListenersCallback(const v8::FunctionCallbackInfo<v8 ::Value>& info) |
| 292 { | 292 { |
| 293 if (info.Length() < 1) | 293 if (info.Length() < 1) |
| 294 return; | 294 return; |
| 295 | 295 |
| 296 ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::Extern al>::Cast(info.Data())->Value()); | 296 ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::Extern al>::Cast(info.Data())->Value()); |
| 297 DCHECK(debugger); | 297 DCHECK(debugger); |
| 298 v8::Isolate* isolate = info.GetIsolate(); | 298 v8::Isolate* isolate = info.GetIsolate(); |
| 299 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 299 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
| 300 | 300 |
| 301 EventListenerFilter filterMask = static_cast<EventListenerFilter>(EventListe nerFilter::ShowPassive | EventListenerFilter::ShowBlocking); | |
| 302 if (info.Length() > 1 && info[1]->IsObject()) { | |
| 303 v8::Local<v8::Object> options = v8::Local<v8::Object>::Cast(info[1]); | |
| 304 | |
| 305 v8::Local<v8::Value> setting; | |
| 306 if (options->Get(context, v8String(isolate, "descendants")).ToLocal(&set ting) && setting->IsTrue()) | |
| 307 filterMask = static_cast<EventListenerFilter>(filterMask | EventList enerFilter::ShowDescendants); | |
| 308 | |
| 309 if (options->Get(context, v8String(isolate, "passive")).ToLocal(&setting ) && !setting->IsUndefined()) { | |
| 310 if (setting->IsFalse()) | |
| 311 filterMask = static_cast<EventListenerFilter>(filterMask & ~Even tListenerFilter::ShowPassive); | |
| 312 else | |
| 313 filterMask = static_cast<EventListenerFilter>(filterMask & ~Even tListenerFilter::ShowBlocking); | |
| 314 } | |
| 315 } | |
| 316 | |
| 301 V8EventListenerInfoList listenerInfo; | 317 V8EventListenerInfoList listenerInfo; |
| 302 // eventListeners call can produce message on ErrorEvent during lazy event l istener compilation. | 318 // eventListeners call can produce message on ErrorEvent during lazy event l istener compilation. |
| 303 debugger->muteWarningsAndDeprecations(); | 319 debugger->muteWarningsAndDeprecations(); |
| 304 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(isolate, info[0], lis tenerInfo); | 320 InspectorDOMDebuggerAgent::eventListenersInfoForTarget(isolate, info[0], fil terMask, listenerInfo); |
| 305 debugger->unmuteWarningsAndDeprecations(); | 321 debugger->unmuteWarningsAndDeprecations(); |
| 306 | 322 |
| 307 v8::Local<v8::Object> result = v8::Object::New(isolate); | 323 v8::Local<v8::Object> result = v8::Object::New(isolate); |
| 308 | 324 |
| 309 v8::Local<v8::Function> removeFunc = v8::Function::New(isolate, removeEventL istenerCallback, info[0]); | 325 v8::Local<v8::Function> removeFunc = v8::Function::New(isolate, removeEventL istenerCallback, info[0]); |
| 310 v8::Local<v8::Function> toStringFunction; | 326 v8::Local<v8::Function> toStringFunction; |
| 311 if (v8::Function::New(context, returnDataCallback, v8String(isolate, "functi on remove() { [Command Line API] }")).ToLocal(&toStringFunction)) | 327 if (v8::Function::New(context, returnDataCallback, v8String(isolate, "functi on remove() { [Command Line API] }")).ToLocal(&toStringFunction)) |
| 312 removeFunc->Set(v8String(context->GetIsolate(), "toString"), toStringFun ction); | 328 removeFunc->Set(v8String(context->GetIsolate(), "toString"), toStringFun ction); |
| 313 | 329 |
| 314 AtomicString currentEventType; | 330 AtomicString currentEventType; |
| 315 v8::Local<v8::Array> listeners; | 331 v8::Local<v8::Array> listeners; |
| 316 size_t outputIndex = 0; | 332 size_t outputIndex = 0; |
| 317 for (auto& info : listenerInfo) { | 333 for (auto& info : listenerInfo) { |
| 334 // Skip contexts not associated with the current context. | |
| 335 if (info.handler->CreationContext() != context) | |
|
caseq
2016/05/31 21:36:49
I think this is the right places for this check to
| |
| 336 continue; | |
| 318 if (currentEventType != info.eventType) { | 337 if (currentEventType != info.eventType) { |
| 319 currentEventType = info.eventType; | 338 currentEventType = info.eventType; |
| 320 listeners = v8::Array::New(isolate); | 339 v8::Local<v8::Value> matchingList; |
| 321 outputIndex = 0; | 340 if (result->Get(context, v8String(isolate, currentEventType)).ToLoca l(&matchingList) && matchingList->IsArray()) { |
| 322 result->Set(v8String(isolate, currentEventType), listeners); | 341 listeners = v8::Local<v8::Array>::Cast(matchingList); |
| 342 outputIndex = listeners->Length(); | |
| 343 } else { | |
| 344 listeners = v8::Array::New(isolate); | |
| 345 outputIndex = 0; | |
| 346 result->Set(v8String(isolate, currentEventType), listeners); | |
| 347 } | |
| 323 } | 348 } |
| 324 | 349 |
| 325 v8::Local<v8::Object> listenerObject = v8::Object::New(isolate); | 350 v8::Local<v8::Object> listenerObject = v8::Object::New(isolate); |
| 326 listenerObject->Set(v8String(isolate, "listener"), info.handler); | 351 listenerObject->Set(v8String(isolate, "listener"), info.handler); |
| 327 listenerObject->Set(v8String(isolate, "useCapture"), v8::Boolean::New(is olate, info.useCapture)); | 352 listenerObject->Set(v8String(isolate, "useCapture"), v8::Boolean::New(is olate, info.useCapture)); |
| 328 listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isola te, info.passive)); | 353 listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isola te, info.passive)); |
| 329 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType)); | 354 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType)); |
| 330 listenerObject->Set(v8String(isolate, "remove"), removeFunc); | 355 listenerObject->Set(v8String(isolate, "remove"), removeFunc); |
| 331 listeners->Set(outputIndex++, listenerObject); | 356 listeners->Set(outputIndex++, listenerObject); |
| 332 } | 357 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 { | 415 { |
| 391 for (size_t index = 0; index < m_timers.size(); ++index) { | 416 for (size_t index = 0; index < m_timers.size(); ++index) { |
| 392 if (m_timers[index] == timer) { | 417 if (m_timers[index] == timer) { |
| 393 m_timerCallbacks[index](m_timerData[index]); | 418 m_timerCallbacks[index](m_timerData[index]); |
| 394 return; | 419 return; |
| 395 } | 420 } |
| 396 } | 421 } |
| 397 } | 422 } |
| 398 | 423 |
| 399 } // namespace blink | 424 } // namespace blink |
| OLD | NEW |