| 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 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" |
| 13 #include "wtf/Noncopyable.h" | 14 #include "wtf/Noncopyable.h" |
| 14 #include "wtf/RefPtr.h" | 15 #include "wtf/RefPtr.h" |
| 16 #include "wtf/text/AtomicString.h" |
| 17 #include "wtf/text/AtomicStringHash.h" |
| 15 | 18 |
| 16 namespace blink { | 19 namespace blink { |
| 17 | 20 |
| 18 class CustomElementDescriptor; | 21 class CustomElementDescriptor; |
| 19 class CustomElementsRegistry; | 22 class CustomElementsRegistry; |
| 20 | 23 |
| 21 class CORE_EXPORT ScriptCustomElementDefinition final : | 24 class CORE_EXPORT ScriptCustomElementDefinition final : |
| 22 public CustomElementDefinition { | 25 public CustomElementDefinition { |
| 23 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition); | 26 WTF_MAKE_NONCOPYABLE(ScriptCustomElementDefinition); |
| 24 public: | 27 public: |
| 25 static ScriptCustomElementDefinition* forConstructor( | 28 static ScriptCustomElementDefinition* forConstructor( |
| 26 ScriptState*, | 29 ScriptState*, |
| 27 CustomElementsRegistry*, | 30 CustomElementsRegistry*, |
| 28 const v8::Local<v8::Value>& constructor); | 31 const v8::Local<v8::Value>& constructor); |
| 29 | 32 |
| 30 static ScriptCustomElementDefinition* create( | 33 static ScriptCustomElementDefinition* create( |
| 31 ScriptState*, | 34 ScriptState*, |
| 32 CustomElementsRegistry*, | 35 CustomElementsRegistry*, |
| 33 const CustomElementDescriptor&, | 36 const CustomElementDescriptor&, |
| 34 const v8::Local<v8::Object>& constructor, | 37 const v8::Local<v8::Object>& constructor, |
| 35 const v8::Local<v8::Object>& prototype, | 38 const v8::Local<v8::Object>& prototype, |
| 36 const v8::Local<v8::Function>& connectedCallback, | 39 const v8::Local<v8::Object>& connectedCallback, |
| 37 const v8::Local<v8::Function>& disconnectedCallback, | 40 const v8::Local<v8::Object>& disconnectedCallback, |
| 38 const v8::Local<v8::Function>& attributeChangedCallback, | 41 const v8::Local<v8::Object>& attributeChangedCallback, |
| 39 const HashSet<AtomicString>& observedAttributes); | 42 const HashSet<AtomicString>& observedAttributes); |
| 40 | 43 |
| 41 virtual ~ScriptCustomElementDefinition() = default; | 44 virtual ~ScriptCustomElementDefinition() = default; |
| 42 | 45 |
| 43 v8::Local<v8::Object> constructor() const; | 46 v8::Local<v8::Object> constructor() const; |
| 44 v8::Local<v8::Object> prototype() const; | 47 v8::Local<v8::Object> prototype() const; |
| 45 | 48 |
| 46 HTMLElement* createElementSync(Document&, const QualifiedName&) override; | 49 HTMLElement* createElementSync(Document&, const QualifiedName&) override; |
| 47 HTMLElement* createElementSync(Document&, const QualifiedName&, ExceptionSta
te&) override; | 50 HTMLElement* createElementSync(Document&, const QualifiedName&, ExceptionSta
te&) override; |
| 48 | 51 |
| 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 | |
| 57 private: | 52 private: |
| 58 ScriptCustomElementDefinition( | 53 ScriptCustomElementDefinition( |
| 59 ScriptState*, | 54 ScriptState*, |
| 60 const CustomElementDescriptor&, | 55 const CustomElementDescriptor&, |
| 61 const v8::Local<v8::Object>& constructor, | 56 const v8::Local<v8::Object>& constructor, |
| 62 const v8::Local<v8::Object>& prototype, | 57 const v8::Local<v8::Object>& prototype, |
| 63 const v8::Local<v8::Function>& connectedCallback, | 58 const v8::Local<v8::Object>& connectedCallback, |
| 64 const v8::Local<v8::Function>& disconnectedCallback, | 59 const v8::Local<v8::Object>& disconnectedCallback, |
| 65 const v8::Local<v8::Function>& attributeChangedCallback, | 60 const v8::Local<v8::Object>& attributeChangedCallback, |
| 66 const HashSet<AtomicString>& observedAttributes); | 61 const HashSet<AtomicString>& observedAttributes); |
| 67 | 62 |
| 68 // Implementations of |CustomElementDefinition| | 63 // Implementations of |CustomElementDefinition| |
| 69 ScriptValue getConstructorForScript() final; | 64 ScriptValue getConstructorForScript() final; |
| 70 bool runConstructor(Element*) override; | 65 bool runConstructor(Element*) override; |
| 71 Element* runConstructor(); | 66 Element* runConstructor(); |
| 72 | 67 |
| 73 void runCallback(v8::Local<v8::Function>, Element*, | |
| 74 int argc = 0, v8::Local<v8::Value> argv[] = nullptr); | |
| 75 | |
| 76 RefPtr<ScriptState> m_scriptState; | 68 RefPtr<ScriptState> m_scriptState; |
| 77 ScopedPersistent<v8::Object> m_constructor; | 69 ScopedPersistent<v8::Object> m_constructor; |
| 78 ScopedPersistent<v8::Object> m_prototype; | 70 ScopedPersistent<v8::Object> m_prototype; |
| 79 ScopedPersistent<v8::Function> m_connectedCallback; | 71 ScopedPersistent<v8::Object> m_connectedCallback; |
| 80 ScopedPersistent<v8::Function> m_disconnectedCallback; | 72 ScopedPersistent<v8::Object> m_disconnectedCallback; |
| 81 ScopedPersistent<v8::Function> m_attributeChangedCallback; | 73 ScopedPersistent<v8::Object> m_attributeChangedCallback; |
| 74 HashSet<AtomicString> m_observedAttributes; |
| 82 }; | 75 }; |
| 83 | 76 |
| 84 } // namespace blink | 77 } // namespace blink |
| 85 | 78 |
| 86 #endif // ScriptCustomElementDefinition_h | 79 #endif // ScriptCustomElementDefinition_h |
| OLD | NEW |