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

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

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use DCHECK, revert RuntimeEnabledFeatures.in. Created 4 years, 7 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/ScriptWrappable.h" 8 #include "bindings/core/v8/ScriptWrappable.h"
9 #include "core/CoreExport.h" 9 #include "core/CoreExport.h"
10 #include "platform/heap/Handle.h"
11 #include "v8.h"
12 #include "wtf/HashSet.h"
13 #include "wtf/text/AtomicString.h"
14 #include "wtf/text/AtomicStringHash.h"
10 15
11 namespace blink { 16 namespace blink {
12 17
18 class CustomElementDefinition;
13 class ElementRegistrationOptions; 19 class ElementRegistrationOptions;
14 class ExceptionState; 20 class ExceptionState;
15 class ScriptState; 21 class ScriptState;
16 class ScriptValue; 22 class ScriptValue;
17 23
18 class CORE_EXPORT CustomElementsRegistry final 24 class CORE_EXPORT CustomElementsRegistry final
19 : public GarbageCollected<CustomElementsRegistry> 25 : public GarbageCollectedFinalized<CustomElementsRegistry>
20 , public ScriptWrappable { 26 , public ScriptWrappable {
21 DEFINE_WRAPPERTYPEINFO(); 27 DEFINE_WRAPPERTYPEINFO();
22 public: 28 public:
23 static CustomElementsRegistry* create() 29 static CustomElementsRegistry* create(ScriptState*);
24 {
25 return new CustomElementsRegistry();
26 }
27 30
28 void define(ScriptState*, const AtomicString& name, 31 void define(
29 const ScriptValue& constructor, const ElementRegistrationOptions&, 32 ScriptState*,
33 const AtomicString& name,
34 const ScriptValue& constructor,
35 const ElementRegistrationOptions&,
30 ExceptionState&); 36 ExceptionState&);
31 37
38 CustomElementDefinition* definitionForConstructor(
39 v8::Handle<v8::Context>,
40 v8::Handle<v8::Value>);
41
42 // TODO(dominicc): Remove this when V0CustomElements are removed.
43 bool nameIsDefined(const AtomicString&) const;
44
45 void setWrapperReferences(
46 v8::Isolate*,
47 const v8::Persistent<v8::Object>& wrapper) const;
48
32 DECLARE_TRACE(); 49 DECLARE_TRACE();
33 50
34 private: 51 private:
35 CustomElementsRegistry(); 52 CustomElementsRegistry(v8::Isolate*);
53
54 // This maps Custom Element constructors to an index in the list
55 // of defined elements. This handle is not weak because it does
56 // not keep user-accessible objects alive: the keys are already
57 // weak (it is a weak map) and the values are numbers (not
58 // NumberObjects) which don't refer to anything else.
59 v8::Persistent<v8::NativeWeakMap> m_constructorIdMap;
60
61 HeapVector<Member<CustomElementDefinition>> m_definitions;
62 HashSet<AtomicString> m_names;
36 }; 63 };
37 64
38 } // namespace blink 65 } // namespace blink
39 66
40 #endif // CustomElementsRegistry_h 67 #endif // CustomElementsRegistry_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698