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 26 matching lines...) Expand all Loading... |
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" | 42 #include "core/inspector/InspectorInstrumentation.h" |
43 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 #define CALLBACK_LIST(V) \ | 47 #define CALLBACK_LIST(V) \ |
48 V(created, Created) \ | 48 V(created, CreatedCallback) \ |
49 V(attached, Attached) \ | 49 V(attached, AttachedCallback) \ |
50 V(detached, Detached) \ | 50 V(detached, DetachedCallback) \ |
51 V(attributeChanged, AttributeChanged) | 51 V(attributeChanged, AttributeChangedCallback) |
52 | 52 |
53 PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks:
:create(ScriptState* scriptState, v8::Handle<v8::Object> prototype, v8::Handle<v
8::Function> created, v8::Handle<v8::Function> attached, v8::Handle<v8::Function
> detached, v8::Handle<v8::Function> attributeChanged) | 53 PassRefPtr<V8CustomElementLifecycleCallbacks> V8CustomElementLifecycleCallbacks:
:create(ScriptState* scriptState, v8::Handle<v8::Object> prototype, v8::Handle<v
8::Function> created, v8::Handle<v8::Function> attached, v8::Handle<v8::Function
> detached, v8::Handle<v8::Function> attributeChanged) |
54 { | 54 { |
55 v8::Isolate* isolate = scriptState->isolate(); | 55 v8::Isolate* isolate = scriptState->isolate(); |
56 // A given object can only be used as a Custom Element prototype | 56 // A given object can only be used as a Custom Element prototype |
57 // once; see customElementIsInterfacePrototypeObject | 57 // once; see customElementIsInterfacePrototypeObject |
58 #define SET_HIDDEN_VALUE(Value, Name) \ | 58 #define SET_HIDDEN_VALUE(Value, Name) \ |
59 ASSERT(V8HiddenValue::getHiddenValue(isolate, prototype, V8HiddenValue::cust
omElement##Name(isolate)).IsEmpty()); \ | 59 ASSERT(V8HiddenValue::getHiddenValue(isolate, prototype, V8HiddenValue::cust
omElement##Name(isolate)).IsEmpty()); \ |
60 if (!Value.IsEmpty()) \ | 60 if (!Value.IsEmpty()) \ |
61 V8HiddenValue::setHiddenValue(isolate, prototype, V8HiddenValue::customE
lement##Name(isolate), Value); | 61 V8HiddenValue::setHiddenValue(isolate, prototype, V8HiddenValue::customE
lement##Name(isolate), Value); |
62 | 62 |
63 CALLBACK_LIST(SET_HIDDEN_VALUE) | 63 CALLBACK_LIST(SET_HIDDEN_VALUE) |
64 #undef SET_HIDDEN_VALUE | 64 #undef SET_HIDDEN_VALUE |
65 | 65 |
66 return adoptRef(new V8CustomElementLifecycleCallbacks(scriptState, prototype
, created, attached, detached, attributeChanged)); | 66 return adoptRef(new V8CustomElementLifecycleCallbacks(scriptState, prototype
, created, attached, detached, attributeChanged)); |
67 } | 67 } |
68 | 68 |
69 static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Func
tion> attached, v8::Handle<v8::Function> detached, v8::Handle<v8::Function> attr
ibuteChanged) | 69 static CustomElementLifecycleCallbacks::CallbackType flagSet(v8::Handle<v8::Func
tion> attached, v8::Handle<v8::Function> detached, v8::Handle<v8::Function> attr
ibuteChanged) |
70 { | 70 { |
71 // V8 Custom Elements always run created to swizzle prototypes. | 71 // V8 Custom Elements always run created to swizzle prototypes. |
72 int flags = CustomElementLifecycleCallbacks::Created; | 72 int flags = CustomElementLifecycleCallbacks::CreatedCallback; |
73 | 73 |
74 if (!attached.IsEmpty()) | 74 if (!attached.IsEmpty()) |
75 flags |= CustomElementLifecycleCallbacks::Attached; | 75 flags |= CustomElementLifecycleCallbacks::AttachedCallback; |
76 | 76 |
77 if (!detached.IsEmpty()) | 77 if (!detached.IsEmpty()) |
78 flags |= CustomElementLifecycleCallbacks::Detached; | 78 flags |= CustomElementLifecycleCallbacks::DetachedCallback; |
79 | 79 |
80 if (!attributeChanged.IsEmpty()) | 80 if (!attributeChanged.IsEmpty()) |
81 flags |= CustomElementLifecycleCallbacks::AttributeChanged; | 81 flags |= CustomElementLifecycleCallbacks::AttributeChangedCallback; |
82 | 82 |
83 return CustomElementLifecycleCallbacks::CallbackType(flags); | 83 return CustomElementLifecycleCallbacks::CallbackType(flags); |
84 } | 84 } |
85 | 85 |
86 template <typename T> | 86 template <typename T> |
87 static void weakCallback(const v8::WeakCallbackData<T, ScopedPersistent<T> >& da
ta) | 87 static void weakCallback(const v8::WeakCallbackData<T, ScopedPersistent<T> >& da
ta) |
88 { | 88 { |
89 data.GetParameter()->clear(); | 89 data.GetParameter()->clear(); |
90 } | 90 } |
91 | 91 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |