| 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 , m_world(world) | 51 , m_world(world) |
| 52 , m_isolate(isolate) | 52 , m_isolate(isolate) |
| 53 { | 53 { |
| 54 ThreadLocalInspectorCounters::current().incrementCounter(ThreadLocalInspecto
rCounters::JSEventListenerCounter); | 54 ThreadLocalInspectorCounters::current().incrementCounter(ThreadLocalInspecto
rCounters::JSEventListenerCounter); |
| 55 } | 55 } |
| 56 | 56 |
| 57 V8AbstractEventListener::~V8AbstractEventListener() | 57 V8AbstractEventListener::~V8AbstractEventListener() |
| 58 { | 58 { |
| 59 if (!m_listener.isEmpty()) { | 59 if (!m_listener.isEmpty()) { |
| 60 v8::HandleScope scope(m_isolate); | 60 v8::HandleScope scope(m_isolate); |
| 61 V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAt
tribute); | 61 V8EventListenerList::clearWrapper(m_listener.newLocal(m_isolate), m_isAt
tribute, m_isolate); |
| 62 } | 62 } |
| 63 ThreadLocalInspectorCounters::current().decrementCounter(ThreadLocalInspecto
rCounters::JSEventListenerCounter); | 63 ThreadLocalInspectorCounters::current().decrementCounter(ThreadLocalInspecto
rCounters::JSEventListenerCounter); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event
* event) | 66 void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event
* event) |
| 67 { | 67 { |
| 68 // Don't reenter V8 if execution was terminated in this instance of V8. | 68 // Don't reenter V8 if execution was terminated in this instance of V8. |
| 69 if (context->isJSExecutionForbidden()) | 69 if (context->isJSExecutionForbidden()) |
| 70 return; | 70 return; |
| 71 | 71 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 102 { | 102 { |
| 103 // If jsEvent is empty, attempt to set it as a hidden value would crash v8. | 103 // If jsEvent is empty, attempt to set it as a hidden value would crash v8. |
| 104 if (jsEvent.IsEmpty()) | 104 if (jsEvent.IsEmpty()) |
| 105 return; | 105 return; |
| 106 | 106 |
| 107 v8::Local<v8::Context> v8Context = toV8Context(context, world()); | 107 v8::Local<v8::Context> v8Context = toV8Context(context, world()); |
| 108 if (v8Context.IsEmpty()) | 108 if (v8Context.IsEmpty()) |
| 109 return; | 109 return; |
| 110 | 110 |
| 111 // We push the event being processed into the global object, so that it can
be exposed by DOMWindow's bindings. | 111 // We push the event being processed into the global object, so that it can
be exposed by DOMWindow's bindings. |
| 112 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(); | 112 v8::Handle<v8::String> eventSymbol = V8HiddenPropertyName::event(v8Context->
GetIsolate()); |
| 113 v8::Local<v8::Value> returnValue; | 113 v8::Local<v8::Value> returnValue; |
| 114 | 114 |
| 115 // In beforeunload/unload handlers, we want to avoid sleeps which do tight l
oops of calling Date.getTime(). | 115 // In beforeunload/unload handlers, we want to avoid sleeps which do tight l
oops of calling Date.getTime(). |
| 116 if (event->type() == eventNames().beforeunloadEvent || event->type() == even
tNames().unloadEvent) | 116 if (event->type() == eventNames().beforeunloadEvent || event->type() == even
tNames().unloadEvent) |
| 117 DateExtension::get()->setAllowSleep(false, v8Context->GetIsolate()); | 117 DateExtension::get()->setAllowSleep(false, v8Context->GetIsolate()); |
| 118 | 118 |
| 119 { | 119 { |
| 120 // Catch exceptions thrown in the event handler so they do not propagate
to javascript code that caused the event to fire. | 120 // Catch exceptions thrown in the event handler so they do not propagate
to javascript code that caused the event to fire. |
| 121 v8::TryCatch tryCatch; | 121 v8::TryCatch tryCatch; |
| 122 tryCatch.SetVerbose(true); | 122 tryCatch.SetVerbose(true); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return v8::Local<v8::Object>(); | 185 return v8::Local<v8::Object>(); |
| 186 return v8::Local<v8::Object>::New(isolate, v8::Handle<v8::Object>::Cast(valu
e)); | 186 return v8::Local<v8::Object>::New(isolate, v8::Handle<v8::Object>::Cast(valu
e)); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void V8AbstractEventListener::makeWeakCallback(v8::Isolate*, v8::Persistent<v8::
Object>*, V8AbstractEventListener* listener) | 189 void V8AbstractEventListener::makeWeakCallback(v8::Isolate*, v8::Persistent<v8::
Object>*, V8AbstractEventListener* listener) |
| 190 { | 190 { |
| 191 listener->m_listener.clear(); | 191 listener->m_listener.clear(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 } // namespace WebCore | 194 } // namespace WebCore |
| OLD | NEW |