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 "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" | 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 class ScriptState; | 22 class ScriptState; |
| 23 class ScriptValue; | 23 class ScriptValue; |
| 24 class V0CustomElementRegistrationContext; | 24 class V0CustomElementRegistrationContext; |
| 25 | 25 |
| 26 class CORE_EXPORT CustomElementsRegistry final | 26 class CORE_EXPORT CustomElementsRegistry final |
| 27 : public GarbageCollectedFinalized<CustomElementsRegistry> | 27 : public GarbageCollectedFinalized<CustomElementsRegistry> |
| 28 , public ScriptWrappable { | 28 , public ScriptWrappable { |
| 29 DEFINE_WRAPPERTYPEINFO(); | 29 DEFINE_WRAPPERTYPEINFO(); |
| 30 public: | 30 public: |
| 31 using Id = uint32_t; | 31 using Id = uint32_t; |
| 32 static CustomElementsRegistry* create( | 32 |
| 33 ScriptState*, | 33 static CustomElementsRegistry* create(V0CustomElementRegistrationContext*); |
| 34 V0CustomElementRegistrationContext*); | |
| 35 | 34 |
| 36 void define( | 35 void define( |
| 37 ScriptState*, | 36 ScriptState*, |
| 38 const AtomicString& name, | 37 const AtomicString& name, |
| 39 const ScriptValue& constructor, | 38 const ScriptValue& constructor, |
| 40 const ElementRegistrationOptions&, | 39 const ElementRegistrationOptions&, |
| 41 ExceptionState&); | 40 ExceptionState&); |
| 42 | 41 |
| 43 CustomElementDefinition* definitionForConstructor( | 42 CustomElementDefinition* definitionForConstructor( |
| 44 ScriptState*, | 43 ScriptState*, |
| 45 v8::Local<v8::Value> constructor); | 44 v8::Local<v8::Value> constructor); |
| 46 v8::Local<v8::Object> prototype( | 45 v8::Local<v8::Object> prototype( |
| 47 ScriptState*, | 46 ScriptState*, |
| 48 const CustomElementDefinition&); | 47 const CustomElementDefinition&); |
| 49 | 48 |
| 50 // TODO(dominicc): Remove this when V0CustomElements are removed. | 49 // TODO(dominicc): Remove this when V0CustomElements are removed. |
| 51 bool nameIsDefined(const AtomicString& name) const; | 50 bool nameIsDefined(const AtomicString& name) const; |
| 52 | 51 |
| 53 DECLARE_TRACE(); | 52 DECLARE_TRACE(); |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 CustomElementsRegistry(const V0CustomElementRegistrationContext*); | 55 CustomElementsRegistry(const V0CustomElementRegistrationContext*); |
| 57 | 56 |
| 57 // Initializes the state which is kept in the V8 heap. Initializes | |
| 58 // the map handle to the constructor->id, id->prototype map; see | |
| 59 // idMap. | |
| 60 void initializeScript(ScriptState*, v8::Local<v8::Map>&); | |
|
esprehn
2016/05/23 21:45:17
add variable name for the map, only leave off the
| |
| 61 | |
| 58 // Retrieves the Map which, given a constructor, contains the id | 62 // Retrieves the Map which, given a constructor, contains the id |
| 59 // of the definition; or given an id, contains the prototype. | 63 // 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*); | 64 v8::Local<v8::Map> idMap(ScriptState*); |
| 63 | 65 |
| 64 bool idForConstructor( | 66 bool idForConstructor( |
| 65 ScriptState*, | 67 ScriptState*, |
| 66 v8::Local<v8::Value> constructor, | 68 v8::Local<v8::Value> constructor, |
| 67 Id&) WARN_UNUSED_RETURN; | 69 Id&) WARN_UNUSED_RETURN; |
| 68 | 70 |
| 69 bool v0NameIsDefined(const AtomicString& name); | 71 bool v0NameIsDefined(const AtomicString& name); |
| 70 | 72 |
| 71 Member<const V0CustomElementRegistrationContext> m_v0; | 73 Member<const V0CustomElementRegistrationContext> m_v0; |
| 72 HeapVector<Member<CustomElementDefinition>> m_definitions; | 74 HeapVector<Member<CustomElementDefinition>> m_definitions; |
| 73 HashSet<AtomicString> m_names; | 75 HashSet<AtomicString> m_names; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 } // namespace blink | 78 } // namespace blink |
| 77 | 79 |
| 78 #endif // CustomElementsRegistry_h | 80 #endif // CustomElementsRegistry_h |
| OLD | NEW |