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; |
| 24 class V0CustomElementRegistrationContext; |
17 | 25 |
18 class CORE_EXPORT CustomElementsRegistry final | 26 class CORE_EXPORT CustomElementsRegistry final |
19 : public GarbageCollected<CustomElementsRegistry> | 27 : public GarbageCollectedFinalized<CustomElementsRegistry> |
20 , public ScriptWrappable { | 28 , public ScriptWrappable { |
21 DEFINE_WRAPPERTYPEINFO(); | 29 DEFINE_WRAPPERTYPEINFO(); |
22 public: | 30 public: |
23 static CustomElementsRegistry* create() | 31 using Id = uint32_t; |
24 { | 32 static CustomElementsRegistry* create( |
25 return new CustomElementsRegistry(); | 33 ScriptState*, |
26 } | 34 V0CustomElementRegistrationContext*); |
27 | 35 |
28 void define(ScriptState*, const AtomicString& name, | 36 void define( |
29 const ScriptValue& constructor, const ElementRegistrationOptions&, | 37 ScriptState*, |
| 38 const AtomicString& name, |
| 39 const ScriptValue& constructor, |
| 40 const ElementRegistrationOptions&, |
30 ExceptionState&); | 41 ExceptionState&); |
31 | 42 |
| 43 CustomElementDefinition* definitionForConstructor( |
| 44 ScriptState*, |
| 45 v8::Local<v8::Value> constructor); |
| 46 v8::Local<v8::Object> prototype( |
| 47 ScriptState*, |
| 48 const CustomElementDefinition&); |
| 49 |
| 50 // TODO(dominicc): Remove this when V0CustomElements are removed. |
| 51 bool nameIsDefined(const AtomicString& name) const; |
| 52 |
32 DECLARE_TRACE(); | 53 DECLARE_TRACE(); |
33 | 54 |
34 private: | 55 private: |
35 CustomElementsRegistry(); | 56 CustomElementsRegistry(const V0CustomElementRegistrationContext*); |
| 57 |
| 58 // Retrieves the Map which, given a constructor, contains the id |
| 59 // of the definition; or given an id, contains the prototype. |
| 60 // Returns true if the map was retrieved; false if the map was |
| 61 // not initialized yet. |
| 62 v8::Local<v8::Map> idMap(ScriptState*); |
| 63 |
| 64 bool idForConstructor( |
| 65 ScriptState*, |
| 66 v8::Local<v8::Value> constructor, |
| 67 Id&) WARN_UNUSED_RETURN; |
| 68 |
| 69 bool v0NameIsDefined(const AtomicString& name); |
| 70 |
| 71 Member<const V0CustomElementRegistrationContext> m_v0; |
| 72 HeapVector<Member<CustomElementDefinition>> m_definitions; |
| 73 HashSet<AtomicString> m_names; |
36 }; | 74 }; |
37 | 75 |
38 } // namespace blink | 76 } // namespace blink |
39 | 77 |
40 #endif // CustomElementsRegistry_h | 78 #endif // CustomElementsRegistry_h |
OLD | NEW |