| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 #include "config.h" | 31 #ifndef CustomElementUpgradeCandidateMap_h |
| 32 #define CustomElementUpgradeCandidateMap_h |
| 32 | 33 |
| 33 #include "core/dom/CustomElementConstructor.h" | 34 #include "core/dom/CustomElementDefinition.h" |
| 34 | |
| 35 #include "core/dom/Document.h" | |
| 36 #include "core/dom/Element.h" | 35 #include "core/dom/Element.h" |
| 36 #include "wtf/HashMap.h" |
| 37 #include "wtf/HashSet.h" |
| 38 #include "wtf/Noncopyable.h" |
| 39 #include "wtf/text/AtomicString.h" |
| 40 #include "wtf/text/AtomicStringHash.h" |
| 37 | 41 |
| 38 namespace WebCore { | 42 namespace WebCore { |
| 39 | 43 |
| 40 PassRefPtr<CustomElementConstructor> CustomElementConstructor::create(Document*
document, const QualifiedName& tag, const AtomicString& typeExtension) { | 44 class CustomElementUpgradeCandidateMap { |
| 41 return adoptRef(new CustomElementConstructor(document, tag, typeExtension)); | 45 WTF_MAKE_NONCOPYABLE(CustomElementUpgradeCandidateMap); |
| 46 public: |
| 47 CustomElementUpgradeCandidateMap() { } |
| 48 |
| 49 typedef HashSet<Element*> ElementSet; |
| 50 |
| 51 void add(CustomElementDefinition::CustomElementKind, const AtomicString& typ
e, Element*); |
| 52 bool contains(Element*) const; |
| 53 void remove(Element*); |
| 54 ElementSet takeUpgradeCandidatesFor(CustomElementDefinition* definition); |
| 55 |
| 56 private: |
| 57 typedef std::pair<CustomElementDefinition::CustomElementKind, AtomicString>
RequiredDefinition; |
| 58 typedef HashMap<Element*, RequiredDefinition> UnresolvedElementMap; |
| 59 typedef HashMap<AtomicString, ElementSet> UnresolvedDefinitionMap; |
| 60 |
| 61 bool matches(CustomElementDefinition*, Element*); |
| 62 |
| 63 UnresolvedElementMap m_unresolvedElements; |
| 64 UnresolvedDefinitionMap m_unresolvedDefinitions; |
| 65 }; |
| 66 |
| 42 } | 67 } |
| 43 | 68 |
| 44 CustomElementConstructor::CustomElementConstructor(Document* document, const Qua
lifiedName& tag, const AtomicString& typeExtension) | 69 #endif // CustomElementUpgradeCandidateMap_h |
| 45 : ContextDestructionObserver(document) | |
| 46 , m_tag(tag) | |
| 47 , m_typeExtension(typeExtension) | |
| 48 { | |
| 49 } | |
| 50 | 70 |
| 51 Document* CustomElementConstructor::document() const { | |
| 52 return toDocument(m_scriptExecutionContext); | |
| 53 } | |
| 54 | |
| 55 PassRefPtr<Element> CustomElementConstructor::createElement(ExceptionCode& ec) { | |
| 56 if (!document()) | |
| 57 return 0; | |
| 58 return document()->createElementNS(m_tag.namespaceURI(), m_tag.localName(),
m_typeExtension, ec); | |
| 59 } | |
| 60 | |
| 61 } | |
| OLD | NEW |