OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 void V8CustomElementLifecycleCallbacks::created(Element* element) | 151 void V8CustomElementLifecycleCallbacks::created(Element* element) |
152 { | 152 { |
153 // FIXME: callbacks while paused should be queued up for execution to | 153 // FIXME: callbacks while paused should be queued up for execution to |
154 // continue then be delivered in order rather than delivered immediately. | 154 // continue then be delivered in order rather than delivered immediately. |
155 // Bug 329665 tracks similar behavior for other synchronous events. | 155 // Bug 329665 tracks similar behavior for other synchronous events. |
156 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) | 156 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) |
157 return; | 157 return; |
158 | 158 |
159 element->setCustomElementState(Element::Upgraded); | 159 element->setCustomElementState(Element::Upgraded); |
160 | 160 |
161 if (m_scriptState->contextIsValid()) | 161 if (!m_scriptState->contextIsValid()) |
162 return; | 162 return; |
163 ScriptState::Scope scope(m_scriptState.get()); | 163 ScriptState::Scope scope(m_scriptState.get()); |
164 v8::Isolate* isolate = m_scriptState->isolate(); | 164 v8::Isolate* isolate = m_scriptState->isolate(); |
165 v8::Handle<v8::Context> context = m_scriptState->context(); | 165 v8::Handle<v8::Context> context = m_scriptState->context(); |
166 v8::Handle<v8::Object> receiver = m_scriptState->world().domDataStore().get<
V8Element>(element, isolate); | 166 v8::Handle<v8::Object> receiver = m_scriptState->world().domDataStore().get<
V8Element>(element, isolate); |
167 if (!receiver.IsEmpty()) { | 167 if (!receiver.IsEmpty()) { |
168 // Swizzle the prototype of the existing wrapper. We don't need to | 168 // Swizzle the prototype of the existing wrapper. We don't need to |
169 // worry about non-existent wrappers; they will get the right | 169 // worry about non-existent wrappers; they will get the right |
170 // prototype when wrapped. | 170 // prototype when wrapped. |
171 v8::Handle<v8::Object> prototype = m_prototype.newLocal(isolate); | 171 v8::Handle<v8::Object> prototype = m_prototype.newLocal(isolate); |
(...skipping 29 matching lines...) Expand all Loading... |
201 } | 201 } |
202 | 202 |
203 void V8CustomElementLifecycleCallbacks::attributeChanged(Element* element, const
AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) | 203 void V8CustomElementLifecycleCallbacks::attributeChanged(Element* element, const
AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) |
204 { | 204 { |
205 // FIXME: callbacks while paused should be queued up for execution to | 205 // FIXME: callbacks while paused should be queued up for execution to |
206 // continue then be delivered in order rather than delivered immediately. | 206 // continue then be delivered in order rather than delivered immediately. |
207 // Bug 329665 tracks similar behavior for other synchronous events. | 207 // Bug 329665 tracks similar behavior for other synchronous events. |
208 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) | 208 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) |
209 return; | 209 return; |
210 | 210 |
211 if (m_scriptState->contextIsValid()) | 211 if (!m_scriptState->contextIsValid()) |
212 return; | 212 return; |
213 ScriptState::Scope scope(m_scriptState.get()); | 213 ScriptState::Scope scope(m_scriptState.get()); |
214 v8::Isolate* isolate = m_scriptState->isolate(); | 214 v8::Isolate* isolate = m_scriptState->isolate(); |
215 v8::Handle<v8::Context> context = m_scriptState->context(); | 215 v8::Handle<v8::Context> context = m_scriptState->context(); |
216 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); | 216 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); |
217 ASSERT(!receiver.IsEmpty()); | 217 ASSERT(!receiver.IsEmpty()); |
218 | 218 |
219 v8::Handle<v8::Function> callback = m_attributeChanged.newLocal(isolate); | 219 v8::Handle<v8::Function> callback = m_attributeChanged.newLocal(isolate); |
220 if (callback.IsEmpty()) | 220 if (callback.IsEmpty()) |
221 return; | 221 return; |
(...skipping 12 matching lines...) Expand all Loading... |
234 } | 234 } |
235 | 235 |
236 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function
>& weakCallback, Element* element) | 236 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function
>& weakCallback, Element* element) |
237 { | 237 { |
238 // FIXME: callbacks while paused should be queued up for execution to | 238 // FIXME: callbacks while paused should be queued up for execution to |
239 // continue then be delivered in order rather than delivered immediately. | 239 // continue then be delivered in order rather than delivered immediately. |
240 // Bug 329665 tracks similar behavior for other synchronous events. | 240 // Bug 329665 tracks similar behavior for other synchronous events. |
241 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) | 241 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) |
242 return; | 242 return; |
243 | 243 |
244 if (m_scriptState->contextIsValid()) | 244 if (!m_scriptState->contextIsValid()) |
245 return; | 245 return; |
246 ScriptState::Scope scope(m_scriptState.get()); | 246 ScriptState::Scope scope(m_scriptState.get()); |
247 v8::Isolate* isolate = m_scriptState->isolate(); | 247 v8::Isolate* isolate = m_scriptState->isolate(); |
248 v8::Handle<v8::Context> context = m_scriptState->context(); | 248 v8::Handle<v8::Context> context = m_scriptState->context(); |
249 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate); | 249 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate); |
250 if (callback.IsEmpty()) | 250 if (callback.IsEmpty()) |
251 return; | 251 return; |
252 | 252 |
253 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); | 253 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); |
254 ASSERT(!receiver.IsEmpty()); | 254 ASSERT(!receiver.IsEmpty()); |
255 | 255 |
256 InspectorInstrumentation::willExecuteCustomElementCallback(element); | 256 InspectorInstrumentation::willExecuteCustomElementCallback(element); |
257 | 257 |
258 v8::TryCatch exceptionCatcher; | 258 v8::TryCatch exceptionCatcher; |
259 exceptionCatcher.SetVerbose(true); | 259 exceptionCatcher.SetVerbose(true); |
260 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); | 260 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); |
261 } | 261 } |
262 | 262 |
263 } // namespace blink | 263 } // namespace blink |
OLD | NEW |