| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/V8CustomElementLifecycleCallbacks.h" | 32 #include "bindings/v8/V8CustomElementLifecycleCallbacks.h" |
| 33 | 33 |
| 34 #include "V8Element.h" | 34 #include "V8Element.h" |
| 35 #include "bindings/v8/CustomElementBinding.h" | 35 #include "bindings/v8/CustomElementBinding.h" |
| 36 #include "bindings/v8/DOMDataStore.h" | 36 #include "bindings/v8/DOMDataStore.h" |
| 37 #include "bindings/v8/ScriptController.h" | 37 #include "bindings/v8/ScriptController.h" |
| 38 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
| 39 #include "bindings/v8/V8HiddenPropertyName.h" | |
| 40 #include "bindings/v8/V8PerContextData.h" | 39 #include "bindings/v8/V8PerContextData.h" |
| 41 #include "core/dom/ExecutionContext.h" | 40 #include "core/dom/ExecutionContext.h" |
| 42 #include "core/inspector/InspectorInstrumentation.h" | 41 #include "core/inspector/InspectorInstrumentation.h" |
| 43 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PassOwnPtr.h" |
| 44 | 43 |
| 45 namespace WebCore { | 44 namespace WebCore { |
| 46 | 45 |
| 47 #define CALLBACK_LIST(V) \ | 46 #define CALLBACK_LIST(V) \ |
| 48 V(created, Created) \ | 47 V(created, Created) \ |
| 49 V(attached, Attached) \ | 48 V(attached, Attached) \ |
| 50 V(detached, Detached) \ | 49 V(detached, Detached) \ |
| 51 V(attributeChanged, AttributeChanged) | 50 V(attributeChanged, AttributeChanged) |
| 52 | 51 |
| 53 PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks:
:create(ExecutionContext* executionContext, v8::Handle<v8::Object> prototype, v8
::Handle<v8::Function> created, v8::Handle<v8::Function> attached, v8::Handle<v8
::Function> detached, v8::Handle<v8::Function> attributeChanged) | 52 PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks:
:create(ExecutionContext* executionContext, v8::Handle<v8::Object> prototype, v8
::Handle<v8::Function> created, v8::Handle<v8::Function> attached, v8::Handle<v8
::Function> detached, v8::Handle<v8::Function> attributeChanged) |
| 54 { | 53 { |
| 55 v8::Isolate* isolate = toIsolate(executionContext); | 54 v8::Isolate* isolate = toIsolate(executionContext); |
| 56 // A given object can only be used as a Custom Element prototype | 55 // A given object can only be used as a Custom Element prototype |
| 57 // once; see customElementIsInterfacePrototypeObject | 56 // once; see customElementIsInterfacePrototypeObject |
| 58 #define SET_HIDDEN_PROPERTY(Value, Name) \ | 57 #define SET_HIDDEN_PROPERTY(Value, Name) \ |
| 59 ASSERT(prototype->GetHiddenValue(V8HiddenPropertyName::customElement##Name(i
solate)).IsEmpty()); \ | 58 ASSERT(getHiddenValue(isolate, prototype, "customElement" #Name).IsEmpty());
\ |
| 60 if (!Value.IsEmpty()) \ | 59 if (!Value.IsEmpty()) \ |
| 61 prototype->SetHiddenValue(V8HiddenPropertyName::customElement##Name(isol
ate), Value); | 60 setHiddenValue(isolate, prototype, "customElement" #Name, Value); |
| 62 | 61 |
| 63 CALLBACK_LIST(SET_HIDDEN_PROPERTY) | 62 CALLBACK_LIST(SET_HIDDEN_PROPERTY) |
| 64 #undef SET_HIDDEN_PROPERTY | 63 #undef SET_HIDDEN_PROPERTY |
| 65 | 64 |
| 66 return adoptRef(new V8CustomElementLifecycleCallbacks(executionContext, prot
otype, created, attached, detached, attributeChanged)); | 65 return adoptRef(new V8CustomElementLifecycleCallbacks(executionContext, prot
otype, created, attached, detached, attributeChanged)); |
| 67 } | 66 } |
| 68 | 67 |
| 69 static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Func
tion> attached, v8::Handle<v8::Function> detached, v8::Handle<v8::Function> attr
ibuteChanged) | 68 static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Func
tion> attached, v8::Handle<v8::Function> detached, v8::Handle<v8::Function> attr
ibuteChanged) |
| 70 { | 69 { |
| 71 // V8 Custom Elements always run created to swizzle prototypes. | 70 // V8 Custom Elements always run created to swizzle prototypes. |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 ASSERT(!receiver.IsEmpty()); | 262 ASSERT(!receiver.IsEmpty()); |
| 264 | 263 |
| 265 InspectorInstrumentation::willExecuteCustomElementCallback(element); | 264 InspectorInstrumentation::willExecuteCustomElementCallback(element); |
| 266 | 265 |
| 267 v8::TryCatch exceptionCatcher; | 266 v8::TryCatch exceptionCatcher; |
| 268 exceptionCatcher.SetVerbose(true); | 267 exceptionCatcher.SetVerbose(true); |
| 269 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); | 268 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0,
isolate); |
| 270 } | 269 } |
| 271 | 270 |
| 272 } // namespace WebCore | 271 } // namespace WebCore |
| OLD | NEW |