Chromium Code Reviews| 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 CustomElementsRegistry_h | 5 #ifndef CustomElementsRegistry_h |
| 6 #define CustomElementsRegistry_h | 6 #define CustomElementsRegistry_h |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | |
| 8 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 9 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| 10 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
| 11 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
| 12 #include "wtf/text/AtomicString.h" | 13 #include "wtf/text/AtomicString.h" |
| 13 #include "wtf/text/AtomicStringHash.h" | 14 #include "wtf/text/AtomicStringHash.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 class CustomElementDefinition; | 18 class CustomElementDefinition; |
| 18 class CustomElementDefinitionBuilder; | 19 class CustomElementDefinitionBuilder; |
| 20 class CustomElementDescriptor; | |
| 21 class Document; | |
| 22 class Element; | |
| 19 class ElementRegistrationOptions; | 23 class ElementRegistrationOptions; |
| 20 class ExceptionState; | 24 class ExceptionState; |
| 21 class ScriptState; | 25 class ScriptState; |
| 22 class ScriptValue; | 26 class ScriptValue; |
| 23 class V0CustomElementRegistrationContext; | 27 class V0CustomElementRegistrationContext; |
| 24 | 28 |
| 25 class CORE_EXPORT CustomElementsRegistry final | 29 class CORE_EXPORT CustomElementsRegistry final |
| 26 : public GarbageCollectedFinalized<CustomElementsRegistry> | 30 : public GarbageCollectedFinalized<CustomElementsRegistry> |
| 27 , public ScriptWrappable { | 31 , public ScriptWrappable { |
| 28 DEFINE_WRAPPERTYPEINFO(); | 32 DEFINE_WRAPPERTYPEINFO(); |
| 29 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry); | 33 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry); |
| 30 public: | 34 public: |
| 31 static CustomElementsRegistry* create( | 35 static CustomElementsRegistry* create(Document*); |
|
yosin_UTC9
2016/06/01 06:15:44
(^_^)b
dominicc (has gone to gerrit)
2016/06/01 23:30:57
Yeah, I feel a bit nervous about adding document,
| |
| 32 V0CustomElementRegistrationContext*); | |
| 33 | 36 |
| 34 void define( | 37 void define( |
| 35 ScriptState*, | 38 ScriptState*, |
| 36 const AtomicString& name, | 39 const AtomicString& name, |
| 37 const ScriptValue& constructor, | 40 const ScriptValue& constructor, |
| 38 const ElementRegistrationOptions&, | 41 const ElementRegistrationOptions&, |
| 39 ExceptionState&); | 42 ExceptionState&); |
| 40 | 43 |
| 41 void define( | 44 void define( |
| 42 const AtomicString& name, | 45 const AtomicString& name, |
| 43 CustomElementDefinitionBuilder&, | 46 CustomElementDefinitionBuilder&, |
| 44 const ElementRegistrationOptions&, | 47 const ElementRegistrationOptions&, |
| 45 ExceptionState&); | 48 ExceptionState&); |
| 46 | 49 |
| 47 bool nameIsDefined(const AtomicString& name) const | 50 bool nameIsDefined(const AtomicString& name) const; |
| 48 { | |
| 49 return m_definitions.contains(name); | |
| 50 } | |
| 51 | 51 |
| 52 CustomElementDefinition* definitionForName(const AtomicString& name) const; | 52 CustomElementDefinition* definitionForName(const AtomicString& name) const; |
| 53 | 53 |
| 54 // TODO(dominicc): Consider broadening this API when type extensions are | |
| 55 // implemented. | |
| 56 void addCandidate(Element*); | |
| 57 | |
| 54 DECLARE_TRACE(); | 58 DECLARE_TRACE(); |
| 55 | 59 |
| 56 private: | 60 private: |
| 57 CustomElementsRegistry(const V0CustomElementRegistrationContext*); | 61 friend class CustomElementsRegistryTestBase; |
| 58 bool v0NameIsDefined(const AtomicString&) const; | 62 |
| 63 CustomElementsRegistry(Document*); | |
| 64 | |
| 65 V0CustomElementRegistrationContext* v0(); | |
| 66 bool v0NameIsDefined(const AtomicString& name); | |
| 67 | |
| 68 void collectCandidates( | |
| 69 const CustomElementDescriptor&, | |
| 70 HeapVector<Member<Element>>*); | |
| 59 | 71 |
| 60 using DefinitionMap = | 72 using DefinitionMap = |
| 61 HeapHashMap<AtomicString, Member<CustomElementDefinition>>; | 73 HeapHashMap<AtomicString, Member<CustomElementDefinition>>; |
| 62 DefinitionMap m_definitions; | 74 DefinitionMap m_definitions; |
| 63 | 75 |
| 64 Member<const V0CustomElementRegistrationContext> m_v0; | 76 Member<Document> m_document; |
| 77 | |
| 78 using UpgradeCandidateSet = HeapHashSet<WeakMember<Element>>; | |
| 79 using UpgradeCandidateMap = HeapHashMap< | |
| 80 AtomicString, | |
| 81 Member<UpgradeCandidateSet>>; | |
| 82 Member<UpgradeCandidateMap> m_upgradeCandidates; | |
| 65 }; | 83 }; |
| 66 | 84 |
| 67 } // namespace blink | 85 } // namespace blink |
| 68 | 86 |
| 69 #endif // CustomElementsRegistry_h | 87 #endif // CustomElementsRegistry_h |
| OLD | NEW |