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 | 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 21 matching lines...) Expand all Loading... |
32 #include "core/dom/CustomElementRegistrationContext.h" | 32 #include "core/dom/CustomElementRegistrationContext.h" |
33 | 33 |
34 #include "HTMLNames.h" | 34 #include "HTMLNames.h" |
35 #include "MathMLNames.h" | 35 #include "MathMLNames.h" |
36 #include "SVGNames.h" | 36 #include "SVGNames.h" |
37 #include "core/dom/CustomElement.h" | 37 #include "core/dom/CustomElement.h" |
38 #include "core/dom/CustomElementDefinition.h" | 38 #include "core/dom/CustomElementDefinition.h" |
39 #include "core/dom/Element.h" | 39 #include "core/dom/Element.h" |
40 #include "core/html/HTMLElement.h" | 40 #include "core/html/HTMLElement.h" |
41 #include "core/html/HTMLUnknownElement.h" | 41 #include "core/html/HTMLUnknownElement.h" |
42 #include "core/svg/SVGElement.h" | 42 #include "core/svg/SVGUnknownElement.h" |
43 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
44 | 44 |
45 namespace WebCore { | 45 namespace WebCore { |
46 | 46 |
47 void CustomElementRegistrationContext::registerElement(Document* document, Custo
mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Except
ionCode& ec) | 47 void CustomElementRegistrationContext::registerElement(Document* document, Custo
mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Except
ionCode& ec) |
48 { | 48 { |
49 CustomElementDefinition* definition = m_registry.registerElement(document, c
onstructorBuilder, type, ec); | 49 CustomElementDefinition* definition = m_registry.registerElement(document, c
onstructorBuilder, type, ec); |
50 | 50 |
51 if (!definition) | 51 if (!definition) |
52 return; | 52 return; |
53 | 53 |
54 // Upgrade elements that were waiting for this definition. | 54 // Upgrade elements that were waiting for this definition. |
55 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca
ndidates.takeUpgradeCandidatesFor(definition->descriptor()); | 55 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca
ndidates.takeUpgradeCandidatesFor(definition->descriptor()); |
56 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra
deCandidates.begin(); it != upgradeCandidates.end(); ++it) | 56 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra
deCandidates.begin(); it != upgradeCandidates.end(); ++it) |
57 didResolveElement(definition, *it); | 57 didResolveElement(definition, *it); |
58 } | 58 } |
59 | 59 |
60 PassRefPtr<Element> CustomElementRegistrationContext::createCustomTagElement(Doc
ument* document, const QualifiedName& tagName) | 60 PassRefPtr<Element> CustomElementRegistrationContext::createCustomTagElement(Doc
ument* document, const QualifiedName& tagName) |
61 { | 61 { |
62 ASSERT(isCustomTagName(tagName.localName())); | 62 ASSERT(isCustomTagName(tagName.localName())); |
63 | 63 |
64 if (!document) | 64 if (!document) |
65 return 0; | 65 return 0; |
66 | 66 |
67 RefPtr<Element> element; | 67 RefPtr<Element> element; |
68 | 68 |
69 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { | 69 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { |
70 element = HTMLElement::create(tagName, document); | 70 element = HTMLElement::create(tagName, document); |
71 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { | 71 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { |
72 element = SVGElement::create(tagName, document); | 72 element = SVGUnknownElement::create(tagName, document); |
73 } else { | 73 } else { |
74 // XML elements are not custom elements, so return early. | 74 // XML elements are not custom elements, so return early. |
75 return Element::create(tagName, document); | 75 return Element::create(tagName, document); |
76 } | 76 } |
77 | 77 |
78 resolve(element.get(), nullAtom); | 78 resolve(element.get(), nullAtom); |
79 return element.release(); | 79 return element.release(); |
80 } | 80 } |
81 | 81 |
82 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co
nst AtomicString& type) | 82 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co
nst AtomicString& type) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return; | 163 return; |
164 | 164 |
165 if (isCustomTagName(element->localName())) | 165 if (isCustomTagName(element->localName())) |
166 return; // custom tags take precedence over type extensions | 166 return; // custom tags take precedence over type extensions |
167 | 167 |
168 if (CustomElementRegistrationContext* context = element->document()->registr
ationContext()) | 168 if (CustomElementRegistrationContext* context = element->document()->registr
ationContext()) |
169 context->didGiveTypeExtension(element, type); | 169 context->didGiveTypeExtension(element, type); |
170 } | 170 } |
171 | 171 |
172 } // namespace WebCore | 172 } // namespace WebCore |
OLD | NEW |