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 "bindings/core/v8/ScopedPersistent.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" |
| 11 #include "platform/heap/Handle.h" |
| 12 #include "v8.h" |
| 13 #include "wtf/HashSet.h" |
| 14 #include "wtf/text/AtomicString.h" |
| 15 #include "wtf/text/AtomicStringHash.h" |
10 | 16 |
11 namespace blink { | 17 namespace blink { |
12 | 18 |
| 19 class CustomElementDefinition; |
13 class ElementRegistrationOptions; | 20 class ElementRegistrationOptions; |
14 class ExceptionState; | 21 class ExceptionState; |
15 class ScriptState; | 22 class ScriptState; |
16 class ScriptValue; | 23 class ScriptValue; |
17 | 24 |
18 class CORE_EXPORT CustomElementsRegistry final | 25 class CORE_EXPORT CustomElementsRegistry final |
19 : public GarbageCollected<CustomElementsRegistry> | 26 : public GarbageCollectedFinalized<CustomElementsRegistry> |
20 , public ScriptWrappable { | 27 , public ScriptWrappable { |
21 DEFINE_WRAPPERTYPEINFO(); | 28 DEFINE_WRAPPERTYPEINFO(); |
22 public: | 29 public: |
23 static CustomElementsRegistry* create() | 30 static CustomElementsRegistry* create(ScriptState*); |
24 { | |
25 return new CustomElementsRegistry(); | |
26 } | |
27 | 31 |
28 void define(ScriptState*, const AtomicString& name, | 32 void define( |
29 const ScriptValue& constructor, const ElementRegistrationOptions&, | 33 ScriptState*, |
| 34 const AtomicString& name, |
| 35 const ScriptValue& constructor, |
| 36 const ElementRegistrationOptions&, |
30 ExceptionState&); | 37 ExceptionState&); |
31 | 38 |
| 39 CustomElementDefinition* definitionForConstructor( |
| 40 ScriptState*, |
| 41 v8::Handle<v8::Value>); |
| 42 |
| 43 // TODO(dominicc): Remove this when V0CustomElements are removed. |
| 44 bool nameIsDefined(const AtomicString&) const; |
| 45 |
| 46 void setWrapperReferences( |
| 47 v8::Isolate*, |
| 48 const v8::Persistent<v8::Object>& wrapper) const; |
| 49 |
32 DECLARE_TRACE(); | 50 DECLARE_TRACE(); |
33 | 51 |
34 private: | 52 private: |
35 CustomElementsRegistry(); | 53 CustomElementsRegistry(v8::Isolate*); |
| 54 |
| 55 // This maps Custom Element constructors to an index in the list |
| 56 // of defined elements. This handle is weak so it does not keep |
| 57 // the constructor alive indefinitely; however the map is kept |
| 58 // alive by the CustomElementsRegistry wrapper using |
| 59 // visitDOMWrapper. |
| 60 ScopedPersistent<v8::Map> m_constructorIdMap; |
| 61 |
| 62 HeapVector<Member<CustomElementDefinition>> m_definitions; |
| 63 HashSet<AtomicString> m_names; |
36 }; | 64 }; |
37 | 65 |
38 } // namespace blink | 66 } // namespace blink |
39 | 67 |
40 #endif // CustomElementsRegistry_h | 68 #endif // CustomElementsRegistry_h |
OLD | NEW |