OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 void V8WorkerGlobalScopeEventListener::handleEvent(ScriptExecutionContext* conte
xt, Event* event) | 52 void V8WorkerGlobalScopeEventListener::handleEvent(ScriptExecutionContext* conte
xt, Event* event) |
53 { | 53 { |
54 if (!context) | 54 if (!context) |
55 return; | 55 return; |
56 | 56 |
57 // The callback function on XMLHttpRequest can clear the event listener and
destroys 'this' object. Keep a local reference to it. | 57 // The callback function on XMLHttpRequest can clear the event listener and
destroys 'this' object. Keep a local reference to it. |
58 // See issue 889829. | 58 // See issue 889829. |
59 RefPtr<V8AbstractEventListener> protect(this); | 59 RefPtr<V8AbstractEventListener> protect(this); |
60 | 60 |
61 v8::Isolate* isolate = isolateForScriptExecutionContext(context); | 61 v8::Isolate* isolate = toIsolate(context); |
62 v8::HandleScope handleScope(isolate); | 62 v8::HandleScope handleScope(isolate); |
63 | 63 |
64 WorkerScriptController* script = toWorkerGlobalScope(context)->script(); | 64 WorkerScriptController* script = toWorkerGlobalScope(context)->script(); |
65 if (!script) | 65 if (!script) |
66 return; | 66 return; |
67 | 67 |
68 v8::Handle<v8::Context> v8Context = script->context(); | 68 v8::Handle<v8::Context> v8Context = script->context(); |
69 if (v8Context.IsEmpty()) | 69 if (v8Context.IsEmpty()) |
70 return; | 70 return; |
71 | 71 |
(...skipping 18 matching lines...) Expand all Loading... |
90 String resourceName("undefined"); | 90 String resourceName("undefined"); |
91 int lineNumber = 1; | 91 int lineNumber = 1; |
92 v8::ScriptOrigin origin = handlerFunction->GetScriptOrigin(); | 92 v8::ScriptOrigin origin = handlerFunction->GetScriptOrigin(); |
93 if (!origin.ResourceName().IsEmpty()) { | 93 if (!origin.ResourceName().IsEmpty()) { |
94 resourceName = toWebCoreString(origin.ResourceName()); | 94 resourceName = toWebCoreString(origin.ResourceName()); |
95 lineNumber = handlerFunction->GetScriptLineNumber() + 1; | 95 lineNumber = handlerFunction->GetScriptLineNumber() + 1; |
96 } | 96 } |
97 cookie = InspectorInstrumentation::willCallFunction(context, resourceNam
e, lineNumber); | 97 cookie = InspectorInstrumentation::willCallFunction(context, resourceNam
e, lineNumber); |
98 } | 98 } |
99 | 99 |
100 v8::Isolate* isolate = isolateForScriptExecutionContext(context); | 100 v8::Isolate* isolate = toIsolate(context); |
101 v8::Handle<v8::Value> parameters[1] = { jsEvent }; | 101 v8::Handle<v8::Value> parameters[1] = { jsEvent }; |
102 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(handlerFunction,
context, receiver, WTF_ARRAY_LENGTH(parameters), parameters, isolate); | 102 v8::Local<v8::Value> result = V8ScriptRunner::callFunction(handlerFunction,
context, receiver, WTF_ARRAY_LENGTH(parameters), parameters, isolate); |
103 | 103 |
104 InspectorInstrumentation::didCallFunction(cookie); | 104 InspectorInstrumentation::didCallFunction(cookie); |
105 | 105 |
106 return result; | 106 return result; |
107 } | 107 } |
108 | 108 |
109 v8::Local<v8::Object> V8WorkerGlobalScopeEventListener::getReceiverObject(Script
ExecutionContext* context, Event* event) | 109 v8::Local<v8::Object> V8WorkerGlobalScopeEventListener::getReceiverObject(Script
ExecutionContext* context, Event* event) |
110 { | 110 { |
111 v8::Local<v8::Object> listener = getListenerObject(context); | 111 v8::Local<v8::Object> listener = getListenerObject(context); |
112 | 112 |
113 if (!listener.IsEmpty() && !listener->IsFunction()) | 113 if (!listener.IsEmpty() && !listener->IsFunction()) |
114 return listener; | 114 return listener; |
115 | 115 |
116 EventTarget* target = event->currentTarget(); | 116 EventTarget* target = event->currentTarget(); |
117 v8::Isolate* isolate = isolateForScriptExecutionContext(context); | 117 v8::Isolate* isolate = toIsolate(context); |
118 v8::Handle<v8::Value> value = toV8(target, v8::Handle<v8::Object>(), isolate
); | 118 v8::Handle<v8::Value> value = toV8(target, v8::Handle<v8::Object>(), isolate
); |
119 if (value.IsEmpty()) | 119 if (value.IsEmpty()) |
120 return v8::Local<v8::Object>(); | 120 return v8::Local<v8::Object>(); |
121 return v8::Local<v8::Object>::New(isolate, v8::Handle<v8::Object>::Cast(valu
e)); | 121 return v8::Local<v8::Object>::New(isolate, v8::Handle<v8::Object>::Cast(valu
e)); |
122 } | 122 } |
123 | 123 |
124 } // namespace WebCore | 124 } // namespace WebCore |
OLD | NEW |