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

Side by Side Diff: Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp

Issue 1238083002: Oilpan: Move the EventListener hierarchy to Oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "bindings/core/v8/inspector/V8InjectedScriptHost.h" 6 #include "bindings/core/v8/inspector/V8InjectedScriptHost.h"
7 7
8 #include "bindings/core/v8/BindingSecurity.h" 8 #include "bindings/core/v8/BindingSecurity.h"
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(info[0]); 278 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(info[0]);
279 v8::MaybeLocal<v8::Array> properties = v8::Debug::GetInternalProperties(info .GetIsolate(), object); 279 v8::MaybeLocal<v8::Array> properties = v8::Debug::GetInternalProperties(info .GetIsolate(), object);
280 v8SetReturnValue(info, properties); 280 v8SetReturnValue(info, properties);
281 } 281 }
282 282
283 static v8::Local<v8::Array> getJSListenerFunctions(v8::Isolate* isolate, Executi onContext* executionContext, const EventListenerInfo& listenerInfo) 283 static v8::Local<v8::Array> getJSListenerFunctions(v8::Isolate* isolate, Executi onContext* executionContext, const EventListenerInfo& listenerInfo)
284 { 284 {
285 v8::Local<v8::Array> result = v8::Array::New(isolate); 285 v8::Local<v8::Array> result = v8::Array::New(isolate);
286 size_t handlersCount = listenerInfo.eventListenerVector.size(); 286 size_t handlersCount = listenerInfo.eventListenerVector.size();
287 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) { 287 for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
288 RefPtr<EventListener> listener = listenerInfo.eventListenerVector[i].lis tener; 288 EventListener* listener = listenerInfo.eventListenerVector[i].listener.g et();
289 RefPtrWillBeRawPtr<EventListener> protect(listener);
289 if (listener->type() != EventListener::JSEventListenerType) { 290 if (listener->type() != EventListener::JSEventListenerType) {
290 ASSERT_NOT_REACHED(); 291 ASSERT_NOT_REACHED();
291 continue; 292 continue;
292 } 293 }
293 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListene r*>(listener.get()); 294 V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListene r*>(listener);
294 v8::Local<v8::Context> context = toV8Context(executionContext, v8Listene r->world()); 295 v8::Local<v8::Context> context = toV8Context(executionContext, v8Listene r->world());
295 // Hide listeners from other contexts. 296 // Hide listeners from other contexts.
296 if (context != isolate->GetCurrentContext()) 297 if (context != isolate->GetCurrentContext())
297 continue; 298 continue;
298 v8::Local<v8::Object> function; 299 v8::Local<v8::Object> function;
299 { 300 {
300 // getListenerObject() may cause JS in the event attribute to get co mpiled, potentially unsuccessfully. 301 // getListenerObject() may cause JS in the event attribute to get co mpiled, potentially unsuccessfully.
301 v8::TryCatch block; 302 v8::TryCatch block;
302 function = v8Listener->getListenerObject(executionContext); 303 function = v8Listener->getListenerObject(executionContext);
303 if (block.HasCaught()) 304 if (block.HasCaught())
(...skipping 10 matching lines...) Expand all
314 315
315 void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI nfo<v8::Value>& info) 316 void V8InjectedScriptHost::getEventListenersCallback(const v8::FunctionCallbackI nfo<v8::Value>& info)
316 { 317 {
317 if (info.Length() < 1) 318 if (info.Length() < 1)
318 return; 319 return;
319 320
320 EventTarget* target = eventTargetFromScriptValue(info.GetIsolate(), info[0]) ; 321 EventTarget* target = eventTargetFromScriptValue(info.GetIsolate(), info[0]) ;
321 if (!target) 322 if (!target)
322 return; 323 return;
323 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.Holder()); 324 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(info.Holder());
324 Vector<EventListenerInfo> listenersArray; 325 WillBeHeapVector<EventListenerInfo> listenersArray;
325 host->getEventListenersImpl(target, listenersArray); 326 host->getEventListenersImpl(target, listenersArray);
326 327
327 v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate()); 328 v8::Local<v8::Object> result = v8::Object::New(info.GetIsolate());
328 for (size_t i = 0; i < listenersArray.size(); ++i) { 329 for (size_t i = 0; i < listenersArray.size(); ++i) {
329 v8::Local<v8::Array> listeners = getJSListenerFunctions(info.GetIsolate( ), target->executionContext(), listenersArray[i]); 330 v8::Local<v8::Array> listeners = getJSListenerFunctions(info.GetIsolate( ), target->executionContext(), listenersArray[i]);
330 if (!listeners->Length()) 331 if (!listeners->Length())
331 continue; 332 continue;
332 AtomicString eventType = listenersArray[i].eventType; 333 AtomicString eventType = listenersArray[i].eventType;
333 result->Set(v8String(info.GetIsolate(), eventType), listeners); 334 result->Set(v8String(info.GetIsolate(), eventType), listeners);
334 } 335 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 { 642 {
642 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); 643 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host);
643 } 644 }
644 645
645 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Object> object) 646 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Object> object)
646 { 647 {
647 return InjectedScriptHostWrapper::unwrap(object); 648 return InjectedScriptHostWrapper::unwrap(object);
648 } 649 }
649 650
650 } // namespace blink 651 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698