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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementDefinition.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 CustomElementDefinition_h 5 #ifndef CustomElementDefinition_h
6 #define CustomElementDefinition_h 6 #define CustomElementDefinition_h
7 7
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "core/dom/custom/CustomElementDescriptor.h" 10 #include "core/dom/custom/CustomElementDescriptor.h"
11 #include "platform/heap/Handle.h" 11 #include "platform/heap/Handle.h"
12 #include "wtf/HashSet.h"
12 #include "wtf/Noncopyable.h" 13 #include "wtf/Noncopyable.h"
14 #include "wtf/text/AtomicString.h"
15 #include "wtf/text/AtomicStringHash.h"
13 16
14 namespace blink { 17 namespace blink {
15 18
16 class Element; 19 class Element;
17 class ExceptionState; 20 class ExceptionState;
18 class HTMLElement; 21 class HTMLElement;
19 class QualifiedName; 22 class QualifiedName;
20 23
21 class CORE_EXPORT CustomElementDefinition 24 class CORE_EXPORT CustomElementDefinition
22 : public GarbageCollectedFinalized<CustomElementDefinition> { 25 : public GarbageCollectedFinalized<CustomElementDefinition> {
23 WTF_MAKE_NONCOPYABLE(CustomElementDefinition); 26 WTF_MAKE_NONCOPYABLE(CustomElementDefinition);
24 public: 27 public:
25 CustomElementDefinition(const CustomElementDescriptor&); 28 CustomElementDefinition(const CustomElementDescriptor&);
29 CustomElementDefinition(const CustomElementDescriptor&,
30 const HashSet<AtomicString>&);
26 virtual ~CustomElementDefinition(); 31 virtual ~CustomElementDefinition();
27 32
28 DECLARE_VIRTUAL_TRACE(); 33 DECLARE_VIRTUAL_TRACE();
29 34
30 const CustomElementDescriptor& descriptor() { return m_descriptor; } 35 const CustomElementDescriptor& descriptor() { return m_descriptor; }
31 36
32 // TODO(yosin): To support Web Modules, introduce an abstract 37 // TODO(yosin): To support Web Modules, introduce an abstract
33 // class |CustomElementConstructor| to allow us to have JavaScript 38 // class |CustomElementConstructor| to allow us to have JavaScript
34 // and C++ constructors and ask the binding layer to convert 39 // and C++ constructors and ask the binding layer to convert
35 // |CustomElementConstructor| to |ScriptValue|. Replace 40 // |CustomElementConstructor| to |ScriptValue|. Replace
36 // |getConstructorForScript()| by |getConstructor() -> 41 // |getConstructorForScript()| by |getConstructor() ->
37 // CustomElementConstructor|. 42 // CustomElementConstructor|.
38 virtual ScriptValue getConstructorForScript() = 0; 43 virtual ScriptValue getConstructorForScript() = 0;
39 44
40 using ConstructionStack = HeapVector<Member<Element>, 1>; 45 using ConstructionStack = HeapVector<Member<Element>, 1>;
41 ConstructionStack& constructionStack() 46 ConstructionStack& constructionStack()
42 { 47 {
43 return m_constructionStack; 48 return m_constructionStack;
44 } 49 }
45 50
46 virtual HTMLElement* createElementSync(Document&, const QualifiedName&) = 0; 51 virtual HTMLElement* createElementSync(Document&, const QualifiedName&) = 0;
47 virtual HTMLElement* createElementSync(Document&, const QualifiedName&, Exce ptionState&) = 0; 52 virtual HTMLElement* createElementSync(Document&, const QualifiedName&, Exce ptionState&) = 0;
48 HTMLElement* createElementAsync(Document&, const QualifiedName&); 53 HTMLElement* createElementAsync(Document&, const QualifiedName&);
49 54
50 void upgrade(Element*); 55 void upgrade(Element*);
51 56
52 // TODO(kojii): Change these methods to pure when script-side is implemented . 57 virtual bool hasConnectedCallback() const = 0;
53 virtual bool hasConnectedCallback() const { return true; } 58 virtual bool hasDisconnectedCallback() const = 0;
54 virtual bool hasDisconnectedCallback() const { return true; } 59 bool hasAttributeChangedCallback(const QualifiedName&);
55 virtual bool hasAttributeChangedCallback(const QualifiedName&) const { retur n true; }
56 60
57 virtual void runConnectedCallback(Element*) {} 61 virtual void runConnectedCallback(Element*) = 0;
58 virtual void runDisconnectedCallback(Element*) {} 62 virtual void runDisconnectedCallback(Element*) = 0;
59 virtual void runAttributeChangedCallback(Element*, const QualifiedName&, 63 virtual void runAttributeChangedCallback(Element*, const QualifiedName&,
60 const AtomicString& oldValue, const AtomicString& newValue) {} 64 const AtomicString& oldValue, const AtomicString& newValue) = 0;
61 65
62 void enqueueUpgradeReaction(Element*); 66 void enqueueUpgradeReaction(Element*);
63 void enqueueConnectedCallback(Element*); 67 void enqueueConnectedCallback(Element*);
64 void enqueueDisconnectedCallback(Element*); 68 void enqueueDisconnectedCallback(Element*);
65 void enqueueAttributeChangedCallback(Element*, const QualifiedName&, 69 void enqueueAttributeChangedCallback(Element*, const QualifiedName&,
66 const AtomicString& oldValue, const AtomicString& newValue); 70 const AtomicString& oldValue, const AtomicString& newValue);
67 71
68 protected: 72 protected:
69 virtual bool runConstructor(Element*) = 0; 73 virtual bool runConstructor(Element*) = 0;
70 74
71 static void checkConstructorResult(Element*, Document&, const QualifiedName& , ExceptionState&); 75 static void checkConstructorResult(Element*, Document&, const QualifiedName& , ExceptionState&);
72 76
77 HashSet<AtomicString> m_observedAttributes;
78
73 private: 79 private:
74 const CustomElementDescriptor m_descriptor; 80 const CustomElementDescriptor m_descriptor;
75 ConstructionStack m_constructionStack; 81 ConstructionStack m_constructionStack;
82
83 void enqueueAttributeChangedCallbackForAllAttributes(Element*);
76 }; 84 };
77 85
78 } // namespace blink 86 } // namespace blink
79 87
80 #endif // CustomElementDefinition_h 88 #endif // CustomElementDefinition_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698