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

Side by Side Diff: Source/bindings/v8/V8EventListener.cpp

Issue 293053007: V8AbstractEventListener should hold a ScriptState (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 20 matching lines...) Expand all
31 #include "config.h" 31 #include "config.h"
32 #include "bindings/v8/V8EventListener.h" 32 #include "bindings/v8/V8EventListener.h"
33 33
34 #include "bindings/v8/ScriptController.h" 34 #include "bindings/v8/ScriptController.h"
35 #include "bindings/v8/V8Binding.h" 35 #include "bindings/v8/V8Binding.h"
36 #include "core/dom/Document.h" 36 #include "core/dom/Document.h"
37 #include "core/frame/LocalFrame.h" 37 #include "core/frame/LocalFrame.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribut e, v8::Isolate* isolate) 41 V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribut e, ScriptState* scriptState)
42 : V8AbstractEventListener(isAttribute, DOMWrapperWorld::current(isolate), is olate) 42 : V8AbstractEventListener(isAttribute, scriptState)
43 { 43 {
44 setListenerObject(listener); 44 setListenerObject(listener);
45 } 45 }
46 46
47 v8::Local<v8::Function> V8EventListener::getListenerFunction(ExecutionContext* c ontext) 47 v8::Local<v8::Function> V8EventListener::getListenerFunction(ExecutionContext* c ontext)
48 { 48 {
49 v8::Local<v8::Object> listener = getListenerObject(context); 49 v8::Local<v8::Object> listener = getListenerObject(context);
50 50
51 // Has the listener been disposed? 51 // Has the listener been disposed?
52 if (listener.IsEmpty()) 52 if (listener.IsEmpty())
(...skipping 11 matching lines...) Expand all
64 return v8::Local<v8::Function>::Cast(property); 64 return v8::Local<v8::Function>::Cast(property);
65 } 65 }
66 66
67 return v8::Local<v8::Function>(); 67 return v8::Local<v8::Function>();
68 } 68 }
69 69
70 v8::Local<v8::Value> V8EventListener::callListenerFunction(ExecutionContext* con text, v8::Handle<v8::Value> jsEvent, Event* event) 70 v8::Local<v8::Value> V8EventListener::callListenerFunction(ExecutionContext* con text, v8::Handle<v8::Value> jsEvent, Event* event)
71 { 71 {
72 72
73 v8::Local<v8::Function> handlerFunction = getListenerFunction(context); 73 v8::Local<v8::Function> handlerFunction = getListenerFunction(context);
74 v8::Local<v8::Object> receiver = getReceiverObject(context, event); 74 v8::Local<v8::Object> receiver = getReceiverObject(event);
75 if (handlerFunction.IsEmpty() || receiver.IsEmpty()) 75 if (handlerFunction.IsEmpty() || receiver.IsEmpty())
76 return v8::Local<v8::Value>(); 76 return v8::Local<v8::Value>();
77 77
78 // FIXME: Can |context| be 0 here? 78 // FIXME: Can |context| be 0 here?
79 if (!context) 79 if (!context)
80 return v8::Local<v8::Value>(); 80 return v8::Local<v8::Value>();
81 81
82 if (!context->isDocument()) 82 if (!context->isDocument())
83 return v8::Local<v8::Value>(); 83 return v8::Local<v8::Value>();
84 84
85 LocalFrame* frame = toDocument(context)->frame(); 85 LocalFrame* frame = toDocument(context)->frame();
86 if (!frame) 86 if (!frame)
87 return v8::Local<v8::Value>(); 87 return v8::Local<v8::Value>();
88 88
89 if (!frame->script().canExecuteScripts(AboutToExecuteScript)) 89 if (!frame->script().canExecuteScripts(AboutToExecuteScript))
90 return v8::Local<v8::Value>(); 90 return v8::Local<v8::Value>();
91 91
92 v8::Handle<v8::Value> parameters[1] = { jsEvent }; 92 v8::Handle<v8::Value> parameters[1] = { jsEvent };
93 return frame->script().callFunction(handlerFunction, receiver, WTF_ARRAY_LEN GTH(parameters), parameters); 93 return frame->script().callFunction(handlerFunction, receiver, WTF_ARRAY_LEN GTH(parameters), parameters);
94 } 94 }
95 95
96 } // namespace WebCore 96 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698