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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 EventTarget* target = event->currentTarget(); | 191 EventTarget* target = event->currentTarget(); |
192 v8::Local<v8::Value> value = | 192 v8::Local<v8::Value> value = |
193 ToV8(target, script_state->GetContext()->Global(), GetIsolate()); | 193 ToV8(target, script_state->GetContext()->Global(), GetIsolate()); |
194 if (value.IsEmpty()) | 194 if (value.IsEmpty()) |
195 return v8::Local<v8::Object>(); | 195 return v8::Local<v8::Object>(); |
196 return v8::Local<v8::Object>::New(GetIsolate(), | 196 return v8::Local<v8::Object>::New(GetIsolate(), |
197 v8::Local<v8::Object>::Cast(value)); | 197 v8::Local<v8::Object>::Cast(value)); |
198 } | 198 } |
199 | 199 |
200 bool V8AbstractEventListener::BelongsToTheCurrentWorld( | 200 bool V8AbstractEventListener::BelongsToTheCurrentWorld( |
201 ExecutionContext* execution_context) const { | 201 Document* document) const { |
202 if (!GetIsolate()->GetCurrentContext().IsEmpty() && | 202 if (!GetIsolate()->GetCurrentContext().IsEmpty() && |
203 &World() == &DOMWrapperWorld::Current(GetIsolate())) | 203 &World() == &DOMWrapperWorld::Current(GetIsolate())) |
204 return true; | 204 return true; |
205 // If currently parsing, the parser could be accessing this listener | 205 // If currently parsing, the parser could be accessing this listener |
206 // outside of any v8 context; check if it belongs to the main world. | 206 // outside of any v8 context; check if it belongs to the main world. |
207 if (!GetIsolate()->InContext() && execution_context->IsDocument()) { | 207 if (!GetIsolate()->InContext() && document && document->Parser() && |
208 Document* document = ToDocument(execution_context); | 208 document->Parser()->IsParsing()) { |
209 if (document->Parser() && document->Parser()->IsParsing()) | 209 return World().IsMainWorld(); |
210 return World().IsMainWorld(); | |
211 } | 210 } |
212 return false; | 211 return false; |
213 } | 212 } |
214 | 213 |
215 void V8AbstractEventListener::ClearListenerObject() { | 214 void V8AbstractEventListener::ClearListenerObject() { |
216 if (!HasExistingListenerObject()) | 215 if (!HasExistingListenerObject()) |
217 return; | 216 return; |
218 listener_.Clear(); | 217 listener_.Clear(); |
219 if (worker_global_scope_) { | 218 if (worker_global_scope_) { |
220 worker_global_scope_->DeregisterEventListener(this); | 219 worker_global_scope_->DeregisterEventListener(this); |
(...skipping 10 matching lines...) Expand all Loading... |
231 DEFINE_TRACE(V8AbstractEventListener) { | 230 DEFINE_TRACE(V8AbstractEventListener) { |
232 visitor->Trace(worker_global_scope_); | 231 visitor->Trace(worker_global_scope_); |
233 EventListener::Trace(visitor); | 232 EventListener::Trace(visitor); |
234 } | 233 } |
235 | 234 |
236 DEFINE_TRACE_WRAPPERS(V8AbstractEventListener) { | 235 DEFINE_TRACE_WRAPPERS(V8AbstractEventListener) { |
237 visitor->TraceWrappers(listener_.Cast<v8::Value>()); | 236 visitor->TraceWrappers(listener_.Cast<v8::Value>()); |
238 } | 237 } |
239 | 238 |
240 } // namespace blink | 239 } // namespace blink |
OLD | NEW |