OLD | NEW |
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 ScriptState; | 19 class ScriptState; |
17 class Element; | 20 class Element; |
18 | 21 |
19 class CORE_EXPORT CustomElementDefinition | 22 class CORE_EXPORT CustomElementDefinition |
20 : public GarbageCollectedFinalized<CustomElementDefinition> { | 23 : public GarbageCollectedFinalized<CustomElementDefinition> { |
21 WTF_MAKE_NONCOPYABLE(CustomElementDefinition); | 24 WTF_MAKE_NONCOPYABLE(CustomElementDefinition); |
22 public: | 25 public: |
(...skipping 13 matching lines...) Expand all Loading... |
36 virtual ScriptValue getConstructorForScript() = 0; | 39 virtual ScriptValue getConstructorForScript() = 0; |
37 | 40 |
38 using ConstructionStack = HeapVector<Member<Element>, 1>; | 41 using ConstructionStack = HeapVector<Member<Element>, 1>; |
39 ConstructionStack& constructionStack() | 42 ConstructionStack& constructionStack() |
40 { | 43 { |
41 return m_constructionStack; | 44 return m_constructionStack; |
42 } | 45 } |
43 | 46 |
44 void upgrade(Element*); | 47 void upgrade(Element*); |
45 | 48 |
46 // TODO(kojii): Change these methods to pure when script-side is implemented
. | 49 virtual bool hasConnectedCallback() const = 0; |
47 virtual bool hasConnectedCallback() const { return true; } | 50 virtual bool hasDisconnectedCallback() const = 0; |
48 virtual bool hasDisconnectedCallback() const { return true; } | 51 bool hasAttributeChangedCallback(const QualifiedName&); |
49 virtual bool hasAttributeChangedCallback(const QualifiedName&) const { retur
n true; } | |
50 | 52 |
51 virtual void runConnectedCallback(Element*) {} | 53 virtual void runConnectedCallback(Element*) = 0; |
52 virtual void runDisconnectedCallback(Element*) {} | 54 virtual void runDisconnectedCallback(Element*) = 0; |
53 virtual void runAttributeChangedCallback(Element*, const QualifiedName&, | 55 virtual void runAttributeChangedCallback(Element*, const QualifiedName&, |
54 const AtomicString& oldValue, const AtomicString& newValue) {} | 56 const AtomicString& oldValue, const AtomicString& newValue) = 0; |
55 | 57 |
56 void enqueueUpgradeReaction(Element*); | 58 void enqueueUpgradeReaction(Element*); |
57 void enqueueConnectedCallback(Element*); | 59 void enqueueConnectedCallback(Element*); |
58 void enqueueDisconnectedCallback(Element*); | 60 void enqueueDisconnectedCallback(Element*); |
59 void enqueueAttributeChangedCallback(Element*, const QualifiedName&, | 61 void enqueueAttributeChangedCallback(Element*, const QualifiedName&, |
60 const AtomicString& oldValue, const AtomicString& newValue); | 62 const AtomicString& oldValue, const AtomicString& newValue); |
61 | 63 |
62 protected: | 64 protected: |
63 virtual bool runConstructor(Element*) = 0; | 65 virtual bool runConstructor(Element*) = 0; |
64 | 66 |
| 67 HashSet<AtomicString> m_observedAttributes; |
| 68 |
65 private: | 69 private: |
66 const CustomElementDescriptor m_descriptor; | 70 const CustomElementDescriptor m_descriptor; |
67 ConstructionStack m_constructionStack; | 71 ConstructionStack m_constructionStack; |
| 72 |
| 73 void enqueueAttributeChangedCallbackForAllAttributes(Element*); |
68 }; | 74 }; |
69 | 75 |
70 } // namespace blink | 76 } // namespace blink |
71 | 77 |
72 #endif // CustomElementDefinition_h | 78 #endif // CustomElementDefinition_h |
OLD | NEW |