Chromium Code Reviews| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 public: | 72 public: |
| 73 CallbackDeliveryScope() { } | 73 CallbackDeliveryScope() { } |
| 74 ~CallbackDeliveryScope() { CustomElementRegistry::deliverAllLifecycleCal lbacksIfNeeded(); } | 74 ~CallbackDeliveryScope() { CustomElementRegistry::deliverAllLifecycleCal lbacksIfNeeded(); } |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 explicit CustomElementRegistry(Document*); | 77 explicit CustomElementRegistry(Document*); |
| 78 ~CustomElementRegistry(); | 78 ~CustomElementRegistry(); |
| 79 | 79 |
| 80 PassRefPtr<CustomElementConstructor> registerElement(WebCore::ScriptState*, const AtomicString& name, const Dictionary& options, ExceptionCode&); | 80 PassRefPtr<CustomElementConstructor> registerElement(WebCore::ScriptState*, const AtomicString& name, const Dictionary& options, ExceptionCode&); |
| 81 | 81 |
| 82 bool isUnresolved(Element*) const; | |
| 82 PassRefPtr<CustomElementDefinition> findFor(Element*) const; | 83 PassRefPtr<CustomElementDefinition> findFor(Element*) const; |
| 83 PassRefPtr<CustomElementDefinition> findAndCheckNamespace(const AtomicString & type, const AtomicString& namespaceURI) const; | 84 PassRefPtr<CustomElementDefinition> findAndCheckNamespace(const AtomicString & type, const AtomicString& namespaceURI) const; |
| 84 | 85 |
| 85 PassRefPtr<Element> createCustomTagElement(const QualifiedName& localName); | 86 PassRefPtr<Element> createCustomTagElement(const QualifiedName& localName); |
| 86 | 87 |
| 87 Document* document() const; | 88 Document* document() const; |
| 88 | 89 |
| 89 void didGiveTypeExtension(Element*); | 90 void didGiveTypeExtension(Element*); |
| 91 void customElementWasDestroyed(Element*); | |
| 90 | 92 |
| 91 static bool isCustomTagName(const AtomicString& name) { return isValidName(n ame); } | 93 static bool isCustomTagName(const AtomicString& name) { return isValidName(n ame); } |
| 92 | 94 |
| 93 static void deliverAllLifecycleCallbacks(); | 95 static void deliverAllLifecycleCallbacks(); |
| 94 static void deliverAllLifecycleCallbacksIfNeeded(); | 96 static void deliverAllLifecycleCallbacksIfNeeded(); |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 typedef HashMap<AtomicString, RefPtr<CustomElementDefinition> > DefinitionMa p; | 99 typedef HashMap<AtomicString, RefPtr<CustomElementDefinition> > DefinitionMa p; |
| 98 typedef HashSet<AtomicString> NameSet; | 100 typedef HashSet<AtomicString> NameSet; |
| 99 typedef ListHashSet<CustomElementRegistry*> InstanceSet; | 101 typedef ListHashSet<CustomElementRegistry*> InstanceSet; |
| 102 typedef HashSet<Element*> ElementSet; | |
| 100 | 103 |
| 101 static bool isValidName(const AtomicString&); | 104 static bool isValidName(const AtomicString&); |
| 102 | 105 |
| 103 static InstanceSet& activeCustomElementRegistries(); | 106 static InstanceSet& activeCustomElementRegistries(); |
| 104 void activate(const CustomElementInvocation&); | 107 void activate(const CustomElementInvocation&); |
| 105 void deactivate(); | 108 void deactivate(); |
| 106 void deliverLifecycleCallbacks(); | 109 void deliverLifecycleCallbacks(); |
| 107 | 110 |
| 108 void didCreateCustomTagElement(Element*); | 111 void didCreateCustomTagElement(Element*); |
| 112 void didCreateUnresolvedElement(Element*); | |
| 109 | 113 |
| 110 DefinitionMap m_definitions; | 114 DefinitionMap m_definitions; |
| 111 Vector<CustomElementInvocation> m_invocations; | 115 Vector<CustomElementInvocation> m_invocations; |
| 116 ElementSet m_unresolvedElements; | |
|
dglazkov
2013/05/02 16:36:28
So this is the candidates map?
| |
| 112 }; | 117 }; |
| 113 | 118 |
| 114 inline void CustomElementRegistry::deliverAllLifecycleCallbacksIfNeeded() | 119 inline void CustomElementRegistry::deliverAllLifecycleCallbacksIfNeeded() |
| 115 { | 120 { |
| 116 if (!activeCustomElementRegistries().isEmpty()) | 121 if (!activeCustomElementRegistries().isEmpty()) |
| 117 deliverAllLifecycleCallbacks(); | 122 deliverAllLifecycleCallbacks(); |
| 118 ASSERT(activeCustomElementRegistries().isEmpty()); | 123 ASSERT(activeCustomElementRegistries().isEmpty()); |
| 119 } | 124 } |
| 120 | 125 |
| 121 inline CustomElementRegistry::InstanceSet& CustomElementRegistry::activeCustomEl ementRegistries() | 126 inline CustomElementRegistry::InstanceSet& CustomElementRegistry::activeCustomEl ementRegistries() |
| 122 { | 127 { |
| 123 DEFINE_STATIC_LOCAL(InstanceSet, activeInstances, ()); | 128 DEFINE_STATIC_LOCAL(InstanceSet, activeInstances, ()); |
| 124 return activeInstances; | 129 return activeInstances; |
| 125 } | 130 } |
| 126 | 131 |
| 127 | 132 |
| 128 } // namespace WebCore | 133 } // namespace WebCore |
| 129 | 134 |
| 130 #endif | 135 #endif |
| OLD | NEW |