Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/CustomElementsRegistry.h

Issue 2048343002: Introduce CustomElementRegistry#whenDefined() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-06-10T19:03:11 Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/gtest_prod_util.h"
9 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 10 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/CoreExport.h" 11 #include "core/CoreExport.h"
11 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
12 #include "wtf/HashSet.h" 13 #include "wtf/HashSet.h"
13 #include "wtf/Noncopyable.h" 14 #include "wtf/Noncopyable.h"
14 #include "wtf/text/AtomicString.h" 15 #include "wtf/text/AtomicString.h"
15 #include "wtf/text/AtomicStringHash.h" 16 #include "wtf/text/AtomicStringHash.h"
16 17
17 namespace blink { 18 namespace blink {
18 19
19 class CustomElementDefinition; 20 class CustomElementDefinition;
20 class CustomElementDefinitionBuilder; 21 class CustomElementDefinitionBuilder;
21 class CustomElementDescriptor; 22 class CustomElementDescriptor;
22 class Document; 23 class Document;
23 class Element; 24 class Element;
24 class ElementRegistrationOptions; 25 class ElementRegistrationOptions;
25 class ExceptionState; 26 class ExceptionState;
27 class ScriptPromiseResolver;
26 class ScriptState; 28 class ScriptState;
27 class ScriptValue; 29 class ScriptValue;
28 class V0CustomElementRegistrationContext; 30 class V0CustomElementRegistrationContext;
29 31
30 class CORE_EXPORT CustomElementsRegistry final 32 class CORE_EXPORT CustomElementsRegistry final
31 : public GarbageCollectedFinalized<CustomElementsRegistry> 33 : public GarbageCollectedFinalized<CustomElementsRegistry>
32 , public ScriptWrappable { 34 , public ScriptWrappable {
33 DEFINE_WRAPPERTYPEINFO(); 35 DEFINE_WRAPPERTYPEINFO();
34 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry); 36 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry);
35 public: 37 public:
(...skipping 14 matching lines...) Expand all
50 const ElementRegistrationOptions&, 52 const ElementRegistrationOptions&,
51 ExceptionState&); 53 ExceptionState&);
52 54
53 ScriptValue get(const AtomicString& name); 55 ScriptValue get(const AtomicString& name);
54 bool nameIsDefined(const AtomicString& name) const; 56 bool nameIsDefined(const AtomicString& name) const;
55 CustomElementDefinition* definitionForName(const AtomicString& name) const; 57 CustomElementDefinition* definitionForName(const AtomicString& name) const;
56 58
57 // TODO(dominicc): Consider broadening this API when type extensions are 59 // TODO(dominicc): Consider broadening this API when type extensions are
58 // implemented. 60 // implemented.
59 void addCandidate(Element*); 61 void addCandidate(Element*);
62 ScriptPromise whenDefined(
63 ScriptState*,
64 const AtomicString& name,
65 ExceptionState&);
60 66
61 DECLARE_TRACE(); 67 DECLARE_TRACE();
62 68
63 private: 69 private:
64 friend class CustomElementsRegistryTestBase; 70 friend class CustomElementsRegistryTestBase;
65 71
66 CustomElementsRegistry(Document*); 72 CustomElementsRegistry(Document*);
67 73
68 V0CustomElementRegistrationContext* v0(); 74 V0CustomElementRegistrationContext* v0();
69 bool v0NameIsDefined(const AtomicString& name); 75 bool v0NameIsDefined(const AtomicString& name);
70 76
71 void collectCandidates( 77 void collectCandidates(
72 const CustomElementDescriptor&, 78 const CustomElementDescriptor&,
73 HeapVector<Member<Element>>*); 79 HeapVector<Member<Element>>*);
74 80
75 class NameIsBeingDefined; 81 class NameIsBeingDefined;
76 82
77 HashSet<AtomicString> m_namesBeingDefined; 83 HashSet<AtomicString> m_namesBeingDefined;
78 using DefinitionMap = 84 using DefinitionMap =
79 HeapHashMap<AtomicString, Member<CustomElementDefinition>>; 85 HeapHashMap<AtomicString, Member<CustomElementDefinition>>;
80 DefinitionMap m_definitions; 86 DefinitionMap m_definitions;
81 87
82 Member<Document> m_document; 88 Member<Document> m_document;
83 89
84 using UpgradeCandidateSet = HeapHashSet<WeakMember<Element>>; 90 using UpgradeCandidateSet = HeapHashSet<WeakMember<Element>>;
85 using UpgradeCandidateMap = HeapHashMap< 91 using UpgradeCandidateMap = HeapHashMap<
86 AtomicString, 92 AtomicString,
87 Member<UpgradeCandidateSet>>; 93 Member<UpgradeCandidateSet>>;
88 Member<UpgradeCandidateMap> m_upgradeCandidates; 94 Member<UpgradeCandidateMap> m_upgradeCandidates;
95
96 using WhenDefinedPromiseMap =
97 HeapHashMap<AtomicString, Member<ScriptPromiseResolver>>;
98 WhenDefinedPromiseMap m_whenDefinedPromiseMap;
89 }; 99 };
90 100
91 } // namespace blink 101 } // namespace blink
92 102
93 #endif // CustomElementsRegistry_h 103 #endif // CustomElementsRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698