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