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

Side by Side Diff: Source/core/dom/CustomElementRegistry.h

Issue 18332025: Split CustomElementRegistry into a registration context and a registry. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced to tip. Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef CustomElementRegistry_h 31 #ifndef CustomElementRegistry_h
32 #define CustomElementRegistry_h 32 #define CustomElementRegistry_h
33 33
34 #include "core/dom/CustomElementDefinition.h" 34 #include "core/dom/CustomElementDefinition.h"
35 #include "core/dom/CustomElementDescriptor.h" 35 #include "core/dom/CustomElementDescriptor.h"
36 #include "core/dom/CustomElementUpgradeCandidateMap.h" 36 #include "core/dom/CustomElementDescriptorHash.h"
37 #include "core/dom/ExceptionCode.h" 37 #include "core/dom/ExceptionCode.h"
38 #include "core/dom/QualifiedName.h"
39 #include "wtf/HashMap.h" 38 #include "wtf/HashMap.h"
40 #include "wtf/HashSet.h" 39 #include "wtf/HashSet.h"
41 #include "wtf/PassRefPtr.h"
42 #include "wtf/RefCounted.h"
43 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
44 #include "wtf/text/AtomicString.h" 41 #include "wtf/text/AtomicString.h"
45 #include "wtf/text/AtomicStringHash.h" 42 #include "wtf/text/AtomicStringHash.h"
46 43
47 namespace WebCore { 44 namespace WebCore {
48 45
49 class CustomElementConstructorBuilder; 46 class CustomElementConstructorBuilder;
50 class Document; 47 class Document;
51 class Element;
52 48
53 // Element creation 49 class CustomElementRegistry {
54 void setTypeExtension(Element*, const AtomicString& typeExtension); 50 WTF_MAKE_NONCOPYABLE(CustomElementRegistry);
51 protected:
52 friend class ActiveRegistrationContext;
55 53
56 class CustomElementRegistry : public RefCounted<CustomElementRegistry> {
57 WTF_MAKE_NONCOPYABLE(CustomElementRegistry); WTF_MAKE_FAST_ALLOCATED;
58 public:
59 CustomElementRegistry() { } 54 CustomElementRegistry() { }
60 virtual ~CustomElementRegistry() { } 55 virtual ~CustomElementRegistry() { }
61 56
62 // Model 57 CustomElementDefinition* registerElement(Document*, CustomElementConstructor Builder*, const AtomicString& name, ExceptionCode&);
63 static bool isCustomTagName(const AtomicString& name) { return isValidTypeNa me(name); } 58 CustomElementDefinition* find(const CustomElementDescriptor&) const;
64
65 // Registration and definitions
66 void registerElement(Document*, CustomElementConstructorBuilder*, const Atom icString& name, ExceptionCode&);
67 CustomElementDefinition* findFor(Element*) const;
68
69 // Element creation
70 PassRefPtr<Element> createCustomTagElement(Document*, const QualifiedName& l ocalName);
71 void didGiveTypeExtension(Element*, const AtomicString&);
72
73 // Lifecycle
74 void customElementWasDestroyed(Element*);
75 59
76 private: 60 private:
77 // Model
78 static bool isValidTypeName(const AtomicString&);
79 CustomElementDescriptor describe(Element*) const;
80
81 // Registration and definitions
82 CustomElementDefinition* find(const CustomElementDescriptor&) const;
83
84 // Lifecycle
85 void didCreateUnresolvedElement(const CustomElementDescriptor&, Element*);
86 void didResolveElement(CustomElementDefinition*, Element*) const;
87
88 // Registration and definitions
89 typedef HashMap<CustomElementDescriptor, RefPtr<CustomElementDefinition> > D efinitionMap; 61 typedef HashMap<CustomElementDescriptor, RefPtr<CustomElementDefinition> > D efinitionMap;
90 DefinitionMap m_definitions; 62 DefinitionMap m_definitions;
91 HashSet<AtomicString> m_registeredTypeNames; 63 HashSet<AtomicString> m_registeredTypeNames;
92
93 // Element creation
94 typedef HashMap<Element*, AtomicString> ElementTypeMap;
95 ElementTypeMap m_elementTypeMap; // Creation-time "is" attribute value.
96 CustomElementUpgradeCandidateMap m_candidates;
97 }; 64 };
98 65
99 } // namespace WebCore 66 } // namespace WebCore
100 67
101 #endif 68 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementRegistrationContext.cpp ('k') | Source/core/dom/CustomElementRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698