| OLD | NEW |
| 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 16 matching lines...) Expand all Loading... |
| 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 "bindings/v8/ScriptState.h" | 34 #include "bindings/v8/ScriptState.h" |
| 35 #include "core/dom/ContextDestructionObserver.h" | 35 #include "core/dom/ContextDestructionObserver.h" |
| 36 #include "core/dom/CustomElementConstructor.h" | 36 #include "core/dom/CustomElementConstructor.h" |
| 37 #include "core/dom/CustomElementUpgradeCandidateMap.h" |
| 37 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
| 38 #include "core/dom/QualifiedName.h" | 39 #include "core/dom/QualifiedName.h" |
| 39 #include <wtf/HashSet.h> | 40 #include <wtf/HashSet.h> |
| 40 #include <wtf/ListHashSet.h> | 41 #include <wtf/ListHashSet.h> |
| 41 #include <wtf/PassRefPtr.h> | 42 #include <wtf/PassRefPtr.h> |
| 42 #include <wtf/RefCounted.h> | 43 #include <wtf/RefCounted.h> |
| 43 #include <wtf/RefPtr.h> | 44 #include <wtf/RefPtr.h> |
| 44 #include <wtf/Vector.h> | 45 #include <wtf/Vector.h> |
| 45 #include <wtf/text/AtomicString.h> | 46 #include <wtf/text/AtomicString.h> |
| 46 #include <wtf/text/AtomicStringHash.h> | 47 #include <wtf/text/AtomicStringHash.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 PassRefPtr<CustomElementConstructor> registerElement(WebCore::ScriptState*,
const AtomicString& name, const Dictionary& options, ExceptionCode&); | 81 PassRefPtr<CustomElementConstructor> registerElement(WebCore::ScriptState*,
const AtomicString& name, const Dictionary& options, ExceptionCode&); |
| 81 | 82 |
| 82 bool isUnresolved(Element*) const; | 83 bool isUnresolved(Element*) const; |
| 83 PassRefPtr<CustomElementDefinition> findFor(Element*) const; | 84 PassRefPtr<CustomElementDefinition> findFor(Element*) const; |
| 84 PassRefPtr<CustomElementDefinition> findAndCheckNamespace(const AtomicString
& type, const AtomicString& namespaceURI) const; | 85 PassRefPtr<CustomElementDefinition> findAndCheckNamespace(const AtomicString
& type, const AtomicString& namespaceURI) const; |
| 85 | 86 |
| 86 PassRefPtr<Element> createCustomTagElement(const QualifiedName& localName); | 87 PassRefPtr<Element> createCustomTagElement(const QualifiedName& localName); |
| 87 | 88 |
| 88 Document* document() const; | 89 Document* document() const; |
| 89 | 90 |
| 90 void didGiveTypeExtension(Element*); | 91 void didGiveTypeExtension(Element*, const AtomicString&); |
| 91 void customElementWasDestroyed(Element*); | 92 void customElementWasDestroyed(Element*); |
| 92 | 93 |
| 93 static bool isCustomTagName(const AtomicString& name) { return isValidName(n
ame); } | 94 static bool isCustomTagName(const AtomicString& name) { return isValidName(n
ame); } |
| 94 | 95 |
| 95 static void deliverAllLifecycleCallbacks(); | 96 static void deliverAllLifecycleCallbacks(); |
| 96 static void deliverAllLifecycleCallbacksIfNeeded(); | 97 static void deliverAllLifecycleCallbacksIfNeeded(); |
| 97 | 98 |
| 98 private: | 99 private: |
| 99 typedef HashMap<AtomicString, RefPtr<CustomElementDefinition> > DefinitionMa
p; | 100 typedef HashMap<AtomicString, RefPtr<CustomElementDefinition> > DefinitionMa
p; |
| 100 typedef HashSet<AtomicString> NameSet; | |
| 101 typedef ListHashSet<CustomElementRegistry*> InstanceSet; | 101 typedef ListHashSet<CustomElementRegistry*> InstanceSet; |
| 102 typedef HashSet<Element*> ElementSet; | |
| 103 | 102 |
| 104 static bool isValidName(const AtomicString&); | 103 static bool isValidName(const AtomicString&); |
| 105 | 104 |
| 106 static InstanceSet& activeCustomElementRegistries(); | 105 static InstanceSet& activeCustomElementRegistries(); |
| 107 void activate(const CustomElementInvocation&); | 106 void activate(const CustomElementInvocation&); |
| 108 void deactivate(); | 107 void deactivate(); |
| 109 void deliverLifecycleCallbacks(); | 108 void deliverLifecycleCallbacks(); |
| 110 | 109 |
| 111 void didCreateCustomTagElement(Element*); | 110 void didCreateCustomTagElement(Element*); |
| 112 void didCreateUnresolvedElement(Element*); | 111 void didCreateUnresolvedElement(CustomElementDefinition::CustomElementKind,
const AtomicString& type, Element*); |
| 113 | 112 |
| 114 DefinitionMap m_definitions; | 113 DefinitionMap m_definitions; |
| 114 CustomElementUpgradeCandidateMap m_candidates; |
| 115 |
| 115 Vector<CustomElementInvocation> m_invocations; | 116 Vector<CustomElementInvocation> m_invocations; |
| 116 ElementSet m_unresolvedElements; | |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 inline void CustomElementRegistry::deliverAllLifecycleCallbacksIfNeeded() | 119 inline void CustomElementRegistry::deliverAllLifecycleCallbacksIfNeeded() |
| 120 { | 120 { |
| 121 if (!activeCustomElementRegistries().isEmpty()) | 121 if (!activeCustomElementRegistries().isEmpty()) |
| 122 deliverAllLifecycleCallbacks(); | 122 deliverAllLifecycleCallbacks(); |
| 123 ASSERT(activeCustomElementRegistries().isEmpty()); | 123 ASSERT(activeCustomElementRegistries().isEmpty()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 inline CustomElementRegistry::InstanceSet& CustomElementRegistry::activeCustomEl
ementRegistries() | 126 inline CustomElementRegistry::InstanceSet& CustomElementRegistry::activeCustomEl
ementRegistries() |
| 127 { | 127 { |
| 128 DEFINE_STATIC_LOCAL(InstanceSet, activeInstances, ()); | 128 DEFINE_STATIC_LOCAL(InstanceSet, activeInstances, ()); |
| 129 return activeInstances; | 129 return activeInstances; |
| 130 } | 130 } |
| 131 | 131 |
| 132 | 132 |
| 133 } // namespace WebCore | 133 } // namespace WebCore |
| 134 | 134 |
| 135 #endif | 135 #endif |
| OLD | NEW |