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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // |getConstructorForScript()| by |getConstructor() -> | 41 // |getConstructorForScript()| by |getConstructor() -> |
42 // CustomElementConstructor|. | 42 // CustomElementConstructor|. |
43 virtual ScriptValue getConstructorForScript() = 0; | 43 virtual ScriptValue getConstructorForScript() = 0; |
44 | 44 |
45 using ConstructionStack = HeapVector<Member<Element>, 1>; | 45 using ConstructionStack = HeapVector<Member<Element>, 1>; |
46 ConstructionStack& constructionStack() | 46 ConstructionStack& constructionStack() |
47 { | 47 { |
48 return m_constructionStack; | 48 return m_constructionStack; |
49 } | 49 } |
50 | 50 |
| 51 HTMLElement* createElementForConstructor(Document&); |
51 virtual HTMLElement* createElementSync(Document&, const QualifiedName&) = 0; | 52 virtual HTMLElement* createElementSync(Document&, const QualifiedName&) = 0; |
52 virtual HTMLElement* createElementSync(Document&, const QualifiedName&, Exce
ptionState&) = 0; | 53 virtual HTMLElement* createElementSync(Document&, const QualifiedName&, Exce
ptionState&) = 0; |
53 HTMLElement* createElementAsync(Document&, const QualifiedName&); | 54 HTMLElement* createElementAsync(Document&, const QualifiedName&); |
54 | 55 |
55 void upgrade(Element*); | 56 void upgrade(Element*); |
56 | 57 |
57 virtual bool hasConnectedCallback() const = 0; | 58 virtual bool hasConnectedCallback() const = 0; |
58 virtual bool hasDisconnectedCallback() const = 0; | 59 virtual bool hasDisconnectedCallback() const = 0; |
59 virtual bool hasAdoptedCallback() const = 0; | 60 virtual bool hasAdoptedCallback() const = 0; |
60 bool hasAttributeChangedCallback(const QualifiedName&) const; | 61 bool hasAttributeChangedCallback(const QualifiedName&) const; |
61 bool hasStyleAttributeChangedCallback() const; | 62 bool hasStyleAttributeChangedCallback() const; |
62 | 63 |
63 virtual void runConnectedCallback(Element*) = 0; | 64 virtual void runConnectedCallback(Element*) = 0; |
64 virtual void runDisconnectedCallback(Element*) = 0; | 65 virtual void runDisconnectedCallback(Element*) = 0; |
65 virtual void runAdoptedCallback(Element*) = 0; | 66 virtual void runAdoptedCallback(Element*) = 0; |
66 virtual void runAttributeChangedCallback(Element*, const QualifiedName&, | 67 virtual void runAttributeChangedCallback(Element*, const QualifiedName&, |
67 const AtomicString& oldValue, const AtomicString& newValue) = 0; | 68 const AtomicString& oldValue, const AtomicString& newValue) = 0; |
68 | 69 |
69 void enqueueUpgradeReaction(Element*); | 70 void enqueueUpgradeReaction(Element*); |
70 void enqueueConnectedCallback(Element*); | 71 void enqueueConnectedCallback(Element*); |
71 void enqueueDisconnectedCallback(Element*); | 72 void enqueueDisconnectedCallback(Element*); |
72 void enqueueAdoptedCallback(Element*); | 73 void enqueueAdoptedCallback(Element*); |
73 void enqueueAttributeChangedCallback(Element*, const QualifiedName&, | 74 void enqueueAttributeChangedCallback(Element*, const QualifiedName&, |
74 const AtomicString& oldValue, const AtomicString& newValue); | 75 const AtomicString& oldValue, const AtomicString& newValue); |
75 | 76 |
| 77 class CORE_EXPORT ConstructionStackScope final { |
| 78 STACK_ALLOCATED(); |
| 79 DISALLOW_COPY_AND_ASSIGN(ConstructionStackScope); |
| 80 public: |
| 81 ConstructionStackScope(CustomElementDefinition*, Element*); |
| 82 ~ConstructionStackScope(); |
| 83 |
| 84 private: |
| 85 ConstructionStack& m_constructionStack; |
| 86 Member<Element> m_element; |
| 87 size_t m_depth; |
| 88 }; |
76 protected: | 89 protected: |
77 virtual bool runConstructor(Element*) = 0; | 90 virtual bool runConstructor(Element*) = 0; |
78 | 91 |
79 static void checkConstructorResult(Element*, Document&, const QualifiedName&
, ExceptionState&); | 92 static void checkConstructorResult(Element*, Document&, const QualifiedName&
, ExceptionState&); |
80 | 93 |
81 private: | 94 private: |
82 const CustomElementDescriptor m_descriptor; | 95 const CustomElementDescriptor m_descriptor; |
83 ConstructionStack m_constructionStack; | 96 ConstructionStack m_constructionStack; |
84 HashSet<AtomicString> m_observedAttributes; | 97 HashSet<AtomicString> m_observedAttributes; |
85 bool m_hasStyleAttributeChangedCallback; | 98 bool m_hasStyleAttributeChangedCallback; |
86 | 99 |
87 void enqueueAttributeChangedCallbackForAllAttributes(Element*); | 100 void enqueueAttributeChangedCallbackForAllAttributes(Element*); |
88 }; | 101 }; |
89 | 102 |
90 } // namespace blink | 103 } // namespace blink |
91 | 104 |
92 #endif // CustomElementDefinition_h | 105 #endif // CustomElementDefinition_h |
OLD | NEW |