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

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

Issue 2277713002: Rename CustomElementsRegistry to CustomElementRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CustomElementsRegistry_h
6 #define CustomElementsRegistry_h
7
8 #include "base/gtest_prod_util.h"
9 #include "bindings/core/v8/ScriptPromise.h"
10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "core/CoreExport.h"
12 #include "platform/heap/Handle.h"
13 #include "wtf/HashSet.h"
14 #include "wtf/Noncopyable.h"
15 #include "wtf/text/AtomicString.h"
16 #include "wtf/text/AtomicStringHash.h"
17
18 namespace blink {
19
20 class CustomElementDefinition;
21 class CustomElementDefinitionBuilder;
22 class CustomElementDescriptor;
23 class Element;
24 class ElementRegistrationOptions;
25 class ExceptionState;
26 class LocalDOMWindow;
27 class ScriptPromiseResolver;
28 class ScriptState;
29 class ScriptValue;
30 class V0CustomElementRegistrationContext;
31
32 class CORE_EXPORT CustomElementsRegistry final
33 : public GarbageCollectedFinalized<CustomElementsRegistry>
34 , public ScriptWrappable {
35 DEFINE_WRAPPERTYPEINFO();
36 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry);
37 public:
38 static CustomElementsRegistry* create(const LocalDOMWindow*);
39
40 virtual ~CustomElementsRegistry() = default;
41
42 void define(
43 ScriptState*,
44 const AtomicString& name,
45 const ScriptValue& constructor,
46 const ElementRegistrationOptions&,
47 ExceptionState&);
48
49 void define(
50 const AtomicString& name,
51 CustomElementDefinitionBuilder&,
52 const ElementRegistrationOptions&,
53 ExceptionState&);
54
55 ScriptValue get(const AtomicString& name);
56 bool nameIsDefined(const AtomicString& name) const;
57 CustomElementDefinition* definitionForName(const AtomicString& name) const;
58
59 // TODO(dominicc): Switch most callers of definitionForName to
60 // definitionFor when implementing type extensions.
61 CustomElementDefinition* definitionFor(const CustomElementDescriptor&) const ;
62
63 // TODO(dominicc): Consider broadening this API when type extensions are
64 // implemented.
65 void addCandidate(Element*);
66 ScriptPromise whenDefined(
67 ScriptState*,
68 const AtomicString& name,
69 ExceptionState&);
70
71 void entangle(V0CustomElementRegistrationContext*);
72
73 DECLARE_TRACE();
74
75 private:
76 friend class CustomElementsRegistryTest;
77
78 CustomElementsRegistry(const LocalDOMWindow*);
79
80 bool v0NameIsDefined(const AtomicString& name);
81
82 void collectCandidates(
83 const CustomElementDescriptor&,
84 HeapVector<Member<Element>>*);
85
86 class NameIsBeingDefined;
87
88 HashSet<AtomicString> m_namesBeingDefined;
89 using DefinitionMap =
90 HeapHashMap<AtomicString, Member<CustomElementDefinition>>;
91 DefinitionMap m_definitions;
92
93 Member<const LocalDOMWindow> m_owner;
94
95 using V0RegistrySet = HeapHashSet<WeakMember<V0CustomElementRegistrationCont ext>>;
96 Member<V0RegistrySet> m_v0;
97
98 using UpgradeCandidateSet = HeapHashSet<WeakMember<Element>>;
99 using UpgradeCandidateMap = HeapHashMap<
100 AtomicString,
101 Member<UpgradeCandidateSet>>;
102 Member<UpgradeCandidateMap> m_upgradeCandidates;
103
104 using WhenDefinedPromiseMap =
105 HeapHashMap<AtomicString, Member<ScriptPromiseResolver>>;
106 WhenDefinedPromiseMap m_whenDefinedPromiseMap;
107 };
108
109 } // namespace blink
110
111 #endif // CustomElementsRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698