| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 v8::HandleScope handleScope; | 85 v8::HandleScope handleScope; |
| 86 | 86 |
| 87 v8::Local<v8::Context> v8Context = toV8Context(context, world()); | 87 v8::Local<v8::Context> v8Context = toV8Context(context, world()); |
| 88 if (v8Context.IsEmpty()) | 88 if (v8Context.IsEmpty()) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 // Enter the V8 context in which to perform the event handling. | 91 // Enter the V8 context in which to perform the event handling. |
| 92 v8::Context::Scope scope(v8Context); | 92 v8::Context::Scope scope(v8Context); |
| 93 | 93 |
| 94 // Get the V8 wrapper for the event object. | 94 // Get the V8 wrapper for the event object. |
| 95 v8::Handle<v8::Value> jsEvent = toV8(event, v8::Handle<v8::Object>(), v8Cont
ext->GetIsolate()); | 95 v8::Isolate* isolate = v8Context->GetIsolate(); |
| 96 v8::Handle<v8::Value> jsEvent = toV8(event, v8::Handle<v8::Object>(), isolat
e); |
| 96 if (jsEvent.IsEmpty()) | 97 if (jsEvent.IsEmpty()) |
| 97 return; | 98 return; |
| 98 invokeEventHandler(context, event, jsEvent); | 99 invokeEventHandler(context, event, v8::Local<v8::Value>::New(isolate, jsEven
t)); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void V8AbstractEventListener::setListenerObject(v8::Handle<v8::Object> listener) | 102 void V8AbstractEventListener::setListenerObject(v8::Handle<v8::Object> listener) |
| 102 { | 103 { |
| 103 m_listener.set(listener); | 104 m_listener.set(listener); |
| 104 WeakHandleListener<V8AbstractEventListener>::makeWeak(m_isolate, m_listener.
get(), this); | 105 WeakHandleListener<V8AbstractEventListener>::makeWeak(m_isolate, m_listener.
get(), this); |
| 105 } | 106 } |
| 106 | 107 |
| 107 void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context
, Event* event, v8::Handle<v8::Value> jsEvent) | 108 void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context
, Event* event, v8::Local<v8::Value> jsEvent) |
| 108 { | 109 { |
| 109 // If jsEvent is empty, attempt to set it as a hidden value would crash v8. | 110 // If jsEvent is empty, attempt to set it as a hidden value would crash v8. |
| 110 if (jsEvent.IsEmpty()) | 111 if (jsEvent.IsEmpty()) |
| 111 return; | 112 return; |
| 112 | 113 |
| 113 v8::Local<v8::Context> v8Context = toV8Context(context, world()); | 114 v8::Local<v8::Context> v8Context = toV8Context(context, world()); |
| 114 if (v8Context.IsEmpty()) | 115 if (v8Context.IsEmpty()) |
| 115 return; | 116 return; |
| 116 | 117 |
| 117 // We push the event being processed into the global object, so that it can
be exposed by DOMWindow's bindings. | 118 // We push the event being processed into the global object, so that it can
be exposed by DOMWindow's bindings. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return v8::Local<v8::Object>::New(m_listener.get()); | 183 return v8::Local<v8::Object>::New(m_listener.get()); |
| 183 | 184 |
| 184 EventTarget* target = event->currentTarget(); | 185 EventTarget* target = event->currentTarget(); |
| 185 v8::Handle<v8::Value> value = toV8(target, v8::Handle<v8::Object>(), toV8Con
text(context, world())->GetIsolate()); | 186 v8::Handle<v8::Value> value = toV8(target, v8::Handle<v8::Object>(), toV8Con
text(context, world())->GetIsolate()); |
| 186 if (value.IsEmpty()) | 187 if (value.IsEmpty()) |
| 187 return v8::Local<v8::Object>(); | 188 return v8::Local<v8::Object>(); |
| 188 return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value)); | 189 return v8::Local<v8::Object>::New(v8::Handle<v8::Object>::Cast(value)); |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace WebCore | 192 } // namespace WebCore |
| OLD | NEW |