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

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

Issue 2003033004: Split custom element script use and move it into bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing CORE_EXPORT header. 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 "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
10 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
11 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
12 #include "v8.h"
13 #include "wtf/HashSet.h" 11 #include "wtf/HashSet.h"
12 #include "wtf/Noncopyable.h"
14 #include "wtf/text/AtomicString.h" 13 #include "wtf/text/AtomicString.h"
15 #include "wtf/text/AtomicStringHash.h" 14 #include "wtf/text/AtomicStringHash.h"
16 15
17 namespace blink { 16 namespace blink {
18 17
19 class CustomElementDefinition; 18 class CustomElementDefinition;
19 class CustomElementDefinitionBuilder;
20 class ElementRegistrationOptions; 20 class ElementRegistrationOptions;
21 class ExceptionState; 21 class ExceptionState;
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 WTF_MAKE_NONCOPYABLE(CustomElementsRegistry);
30 public: 31 public:
31 using Id = uint32_t;
32 static CustomElementsRegistry* create( 32 static CustomElementsRegistry* create(
33 ScriptState*,
34 V0CustomElementRegistrationContext*); 33 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 void define(
44 ScriptState*, 43 const AtomicString& name,
45 v8::Local<v8::Value> constructor); 44 CustomElementDefinitionBuilder&,
46 v8::Local<v8::Object> prototype( 45 const ElementRegistrationOptions&,
47 ScriptState*, 46 ExceptionState&);
48 const CustomElementDefinition&);
49 47
50 // TODO(dominicc): Remove this when V0CustomElements are removed. 48 bool nameIsDefined(const AtomicString& name) const
51 bool nameIsDefined(const AtomicString& name) const; 49 {
50 return m_names.contains(name);
51 }
52 52
53 DECLARE_TRACE(); 53 DECLARE_TRACE();
54 54
55 private: 55 private:
56 CustomElementsRegistry(const V0CustomElementRegistrationContext*); 56 CustomElementsRegistry(const V0CustomElementRegistrationContext*);
57 57 bool v0NameIsDefined(const AtomicString&) const;
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 58
71 Member<const V0CustomElementRegistrationContext> m_v0; 59 Member<const V0CustomElementRegistrationContext> m_v0;
72 HeapVector<Member<CustomElementDefinition>> m_definitions;
73 HashSet<AtomicString> m_names; 60 HashSet<AtomicString> m_names;
74 }; 61 };
75 62
76 } // namespace blink 63 } // namespace blink
77 64
78 #endif // CustomElementsRegistry_h 65 #endif // CustomElementsRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698