Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.h

Issue 2060753002: Implement script-side of callback reactions for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callback-ce
Patch Set: dominicc review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ScriptCustomElementDefinition_h 5 #ifndef ScriptCustomElementDefinition_h
6 #define ScriptCustomElementDefinition_h 6 #define ScriptCustomElementDefinition_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/CoreExport.h" 10 #include "core/CoreExport.h"
11 #include "core/dom/custom/CustomElementDefinition.h" 11 #include "core/dom/custom/CustomElementDefinition.h"
12 #include "v8.h" 12 #include "v8.h"
13 #include "wtf/HashSet.h"
14 #include "wtf/Noncopyable.h" 13 #include "wtf/Noncopyable.h"
15 #include "wtf/RefPtr.h" 14 #include "wtf/RefPtr.h"
16 #include "wtf/text/AtomicString.h"
17 #include "wtf/text/AtomicStringHash.h"
18 15
19 namespace blink { 16 namespace blink {
20 17
21 class CustomElementDescriptor; 18 class CustomElementDescriptor;
22 class CustomElementsRegistry; 19 class CustomElementsRegistry;
23 20
24 class CORE_EXPORT ScriptCustomElementDefinition final : 21 class CORE_EXPORT ScriptCustomElementDefinition final :
25 public CustomElementDefinition { 22 public CustomElementDefinition {
26 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition); 23 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition);
27 public: 24 public:
28 static ScriptCustomElementDefinition* forConstructor( 25 static ScriptCustomElementDefinition* forConstructor(
29 ScriptState*, 26 ScriptState*,
30 CustomElementsRegistry*, 27 CustomElementsRegistry*,
31 const v8::Local<v8::Value>& constructor); 28 const v8::Local<v8::Value>& constructor);
32 29
33 static ScriptCustomElementDefinition* create( 30 static ScriptCustomElementDefinition* create(
34 ScriptState*, 31 ScriptState*,
35 CustomElementsRegistry*, 32 CustomElementsRegistry*,
36 const CustomElementDescriptor&, 33 const CustomElementDescriptor&,
37 const v8::Local<v8::Object>& constructor, 34 const v8::Local<v8::Object>& constructor,
38 const v8::Local<v8::Object>& prototype, 35 const v8::Local<v8::Object>& prototype,
39 const v8::Local<v8::Object>& connectedCallback, 36 const v8::Local<v8::Function>& connectedCallback,
40 const v8::Local<v8::Object>& disconnectedCallback, 37 const v8::Local<v8::Function>& disconnectedCallback,
41 const v8::Local<v8::Object>& attributeChangedCallback, 38 const v8::Local<v8::Function>& attributeChangedCallback,
42 const HashSet<AtomicString>& observedAttributes); 39 const HashSet<AtomicString>& observedAttributes);
43 40
44 virtual ~ScriptCustomElementDefinition() = default; 41 virtual ~ScriptCustomElementDefinition() = default;
45 42
46 v8::Local<v8::Object> constructor() const; 43 v8::Local<v8::Object> constructor() const;
47 v8::Local<v8::Object> prototype() const; 44 v8::Local<v8::Object> prototype() const;
48 45
46 bool hasConnectedCallback() const override;
47 bool hasDisconnectedCallback() const override;
48
49 void runConnectedCallback(Element*) override;
50 void runDisconnectedCallback(Element*) override;
51 void runAttributeChangedCallback(Element*, const QualifiedName&,
52 const AtomicString& oldValue, const AtomicString& newValue) override;
53
49 private: 54 private:
50 ScriptCustomElementDefinition( 55 ScriptCustomElementDefinition(
51 ScriptState*, 56 ScriptState*,
52 const CustomElementDescriptor&, 57 const CustomElementDescriptor&,
53 const v8::Local<v8::Object>& constructor, 58 const v8::Local<v8::Object>& constructor,
54 const v8::Local<v8::Object>& prototype, 59 const v8::Local<v8::Object>& prototype,
55 const v8::Local<v8::Object>& connectedCallback, 60 const v8::Local<v8::Function>& connectedCallback,
56 const v8::Local<v8::Object>& disconnectedCallback, 61 const v8::Local<v8::Function>& disconnectedCallback,
57 const v8::Local<v8::Object>& attributeChangedCallback, 62 const v8::Local<v8::Function>& attributeChangedCallback,
58 const HashSet<AtomicString>& observedAttributes); 63 const HashSet<AtomicString>& observedAttributes);
59 64
60 // Implementations of |CustomElementDefinition| 65 // Implementations of |CustomElementDefinition|
61 ScriptValue getConstructorForScript() final; 66 ScriptValue getConstructorForScript() final;
62 bool runConstructor(Element*) override; 67 bool runConstructor(Element*) override;
63 68
69 void runCallback(ScopedPersistent<v8::Function>&, Element*,
haraken 2016/06/14 11:39:24 Nit: Change the parameter type to v8::Local<v8::Fu
70 int argc = 0, v8::Local<v8::Value> argv[] = nullptr);
71
64 RefPtr<ScriptState> m_scriptState; 72 RefPtr<ScriptState> m_scriptState;
65 ScopedPersistent<v8::Object> m_constructor; 73 ScopedPersistent<v8::Object> m_constructor;
66 ScopedPersistent<v8::Object> m_prototype; 74 ScopedPersistent<v8::Object> m_prototype;
67 ScopedPersistent<v8::Object> m_connectedCallback; 75 ScopedPersistent<v8::Function> m_connectedCallback;
68 ScopedPersistent<v8::Object> m_disconnectedCallback; 76 ScopedPersistent<v8::Function> m_disconnectedCallback;
69 ScopedPersistent<v8::Object> m_attributeChangedCallback; 77 ScopedPersistent<v8::Function> m_attributeChangedCallback;
70 HashSet<AtomicString> m_observedAttributes;
71 }; 78 };
72 79
73 } // namespace blink 80 } // namespace blink
74 81
75 #endif // ScriptCustomElementDefinition_h 82 #endif // ScriptCustomElementDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698