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

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: rebase 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
49 HTMLElement* createElementSync(Document&, const QualifiedName&) override; 46 HTMLElement* createElementSync(Document&, const QualifiedName&) override;
50 HTMLElement* createElementSync(Document&, const QualifiedName&, ExceptionSta te&) override; 47 HTMLElement* createElementSync(Document&, const QualifiedName&, ExceptionSta te&) override;
51 48
49 bool hasConnectedCallback() const override;
50 bool hasDisconnectedCallback() const override;
51
52 void runConnectedCallback(Element*) override;
53 void runDisconnectedCallback(Element*) override;
54 void runAttributeChangedCallback(Element*, const QualifiedName&,
55 const AtomicString& oldValue, const AtomicString& newValue) override;
56
52 private: 57 private:
53 ScriptCustomElementDefinition( 58 ScriptCustomElementDefinition(
54 ScriptState*, 59 ScriptState*,
55 const CustomElementDescriptor&, 60 const CustomElementDescriptor&,
56 const v8::Local<v8::Object>& constructor, 61 const v8::Local<v8::Object>& constructor,
57 const v8::Local<v8::Object>& prototype, 62 const v8::Local<v8::Object>& prototype,
58 const v8::Local<v8::Object>& connectedCallback, 63 const v8::Local<v8::Function>& connectedCallback,
59 const v8::Local<v8::Object>& disconnectedCallback, 64 const v8::Local<v8::Function>& disconnectedCallback,
60 const v8::Local<v8::Object>& attributeChangedCallback, 65 const v8::Local<v8::Function>& attributeChangedCallback,
61 const HashSet<AtomicString>& observedAttributes); 66 const HashSet<AtomicString>& observedAttributes);
62 67
63 // Implementations of |CustomElementDefinition| 68 // Implementations of |CustomElementDefinition|
64 ScriptValue getConstructorForScript() final; 69 ScriptValue getConstructorForScript() final;
65 bool runConstructor(Element*) override; 70 bool runConstructor(Element*) override;
66 Element* runConstructor(); 71 Element* runConstructor();
67 72
73 void runCallback(v8::Local<v8::Function>, Element*,
74 int argc = 0, v8::Local<v8::Value> argv[] = nullptr);
75
68 RefPtr<ScriptState> m_scriptState; 76 RefPtr<ScriptState> m_scriptState;
69 ScopedPersistent<v8::Object> m_constructor; 77 ScopedPersistent<v8::Object> m_constructor;
70 ScopedPersistent<v8::Object> m_prototype; 78 ScopedPersistent<v8::Object> m_prototype;
71 ScopedPersistent<v8::Object> m_connectedCallback; 79 ScopedPersistent<v8::Function> m_connectedCallback;
72 ScopedPersistent<v8::Object> m_disconnectedCallback; 80 ScopedPersistent<v8::Function> m_disconnectedCallback;
73 ScopedPersistent<v8::Object> m_attributeChangedCallback; 81 ScopedPersistent<v8::Function> m_attributeChangedCallback;
74 HashSet<AtomicString> m_observedAttributes;
75 }; 82 };
76 83
77 } // namespace blink 84 } // namespace blink
78 85
79 #endif // ScriptCustomElementDefinition_h 86 #endif // ScriptCustomElementDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698