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 21 matching lines...) Expand all Loading... |
32 #include "bindings/core/v8/V8CustomElementLifecycleCallbacks.h" | 32 #include "bindings/core/v8/V8CustomElementLifecycleCallbacks.h" |
33 | 33 |
34 #include "bindings/core/v8/CustomElementBinding.h" | 34 #include "bindings/core/v8/CustomElementBinding.h" |
35 #include "bindings/core/v8/DOMDataStore.h" | 35 #include "bindings/core/v8/DOMDataStore.h" |
36 #include "bindings/core/v8/ScriptController.h" | 36 #include "bindings/core/v8/ScriptController.h" |
37 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
38 #include "bindings/core/v8/V8Element.h" | 38 #include "bindings/core/v8/V8Element.h" |
39 #include "bindings/core/v8/V8HiddenValue.h" | 39 #include "bindings/core/v8/V8HiddenValue.h" |
40 #include "bindings/core/v8/V8PerContextData.h" | 40 #include "bindings/core/v8/V8PerContextData.h" |
41 #include "core/dom/ExecutionContext.h" | 41 #include "core/dom/ExecutionContext.h" |
42 #include "core/inspector/InspectorInstrumentation.h" | |
43 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
44 | 43 |
45 namespace blink { | 44 namespace blink { |
46 | 45 |
47 #define CALLBACK_LIST(V) \ | 46 #define CALLBACK_LIST(V) \ |
48 V(created, CreatedCallback) \ | 47 V(created, CreatedCallback) \ |
49 V(attached, AttachedCallback) \ | 48 V(attached, AttachedCallback) \ |
50 V(detached, DetachedCallback) \ | 49 V(detached, DetachedCallback) \ |
51 V(attributeChanged, AttributeChangedCallback) | 50 V(attributeChanged, AttributeChangedCallback) |
52 | 51 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 175 |
177 v8::Handle<v8::Function> callback = m_created.newLocal(isolate); | 176 v8::Handle<v8::Function> callback = m_created.newLocal(isolate); |
178 if (callback.IsEmpty()) | 177 if (callback.IsEmpty()) |
179 return; | 178 return; |
180 | 179 |
181 if (receiver.IsEmpty()) | 180 if (receiver.IsEmpty()) |
182 receiver = toV8(element, context->Global(), isolate).As<v8::Object>(); | 181 receiver = toV8(element, context->Global(), isolate).As<v8::Object>(); |
183 | 182 |
184 ASSERT(!receiver.IsEmpty()); | 183 ASSERT(!receiver.IsEmpty()); |
185 | 184 |
186 InspectorInstrumentation::willExecuteCustomElementCallback(element); | |
187 | |
188 v8::TryCatch exceptionCatcher; | 185 v8::TryCatch exceptionCatcher; |
189 exceptionCatcher.SetVerbose(true); | 186 exceptionCatcher.SetVerbose(true); |
190 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); | 187 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); |
191 } | 188 } |
192 | 189 |
193 void V8CustomElementLifecycleCallbacks::attached(Element* element) | 190 void V8CustomElementLifecycleCallbacks::attached(Element* element) |
194 { | 191 { |
195 call(m_attached, element); | 192 call(m_attached, element); |
196 } | 193 } |
197 | 194 |
(...skipping 21 matching lines...) Expand all Loading... |
219 v8::Handle<v8::Function> callback = m_attributeChanged.newLocal(isolate); | 216 v8::Handle<v8::Function> callback = m_attributeChanged.newLocal(isolate); |
220 if (callback.IsEmpty()) | 217 if (callback.IsEmpty()) |
221 return; | 218 return; |
222 | 219 |
223 v8::Handle<v8::Value> argv[] = { | 220 v8::Handle<v8::Value> argv[] = { |
224 v8String(isolate, name), | 221 v8String(isolate, name), |
225 oldValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl
e<v8::Value>(v8String(isolate, oldValue)), | 222 oldValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl
e<v8::Value>(v8String(isolate, oldValue)), |
226 newValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl
e<v8::Value>(v8String(isolate, newValue)) | 223 newValue.isNull() ? v8::Handle<v8::Value>(v8::Null(isolate)) : v8::Handl
e<v8::Value>(v8String(isolate, newValue)) |
227 }; | 224 }; |
228 | 225 |
229 InspectorInstrumentation::willExecuteCustomElementCallback(element); | |
230 | |
231 v8::TryCatch exceptionCatcher; | 226 v8::TryCatch exceptionCatcher; |
232 exceptionCatcher.SetVerbose(true); | 227 exceptionCatcher.SetVerbose(true); |
233 ScriptController::callFunction(executionContext(), callback, receiver, WTF_A
RRAY_LENGTH(argv), argv, isolate); | 228 ScriptController::callFunction(executionContext(), callback, receiver, WTF_A
RRAY_LENGTH(argv), argv, isolate); |
234 } | 229 } |
235 | 230 |
236 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function
>& weakCallback, Element* element) | 231 void V8CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Function
>& weakCallback, Element* element) |
237 { | 232 { |
238 // FIXME: callbacks while paused should be queued up for execution to | 233 // FIXME: callbacks while paused should be queued up for execution to |
239 // continue then be delivered in order rather than delivered immediately. | 234 // continue then be delivered in order rather than delivered immediately. |
240 // Bug 329665 tracks similar behavior for other synchronous events. | 235 // Bug 329665 tracks similar behavior for other synchronous events. |
241 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) | 236 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) |
242 return; | 237 return; |
243 | 238 |
244 if (!m_scriptState->contextIsValid()) | 239 if (!m_scriptState->contextIsValid()) |
245 return; | 240 return; |
246 ScriptState::Scope scope(m_scriptState.get()); | 241 ScriptState::Scope scope(m_scriptState.get()); |
247 v8::Isolate* isolate = m_scriptState->isolate(); | 242 v8::Isolate* isolate = m_scriptState->isolate(); |
248 v8::Handle<v8::Context> context = m_scriptState->context(); | 243 v8::Handle<v8::Context> context = m_scriptState->context(); |
249 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate); | 244 v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate); |
250 if (callback.IsEmpty()) | 245 if (callback.IsEmpty()) |
251 return; | 246 return; |
252 | 247 |
253 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); | 248 v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).
As<v8::Object>(); |
254 ASSERT(!receiver.IsEmpty()); | 249 ASSERT(!receiver.IsEmpty()); |
255 | 250 |
256 InspectorInstrumentation::willExecuteCustomElementCallback(element); | |
257 | |
258 v8::TryCatch exceptionCatcher; | 251 v8::TryCatch exceptionCatcher; |
259 exceptionCatcher.SetVerbose(true); | 252 exceptionCatcher.SetVerbose(true); |
260 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); | 253 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); |
261 } | 254 } |
262 | 255 |
263 } // namespace blink | 256 } // namespace blink |
OLD | NEW |