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 27 matching lines...) Expand all Loading... |
38 #include "core/dom/custom/CustomElement.h" | 38 #include "core/dom/custom/CustomElement.h" |
39 #include "core/dom/custom/CustomElementDefinition.h" | 39 #include "core/dom/custom/CustomElementDefinition.h" |
40 #include "core/dom/custom/CustomElementScheduler.h" | 40 #include "core/dom/custom/CustomElementScheduler.h" |
41 #include "core/html/HTMLElement.h" | 41 #include "core/html/HTMLElement.h" |
42 #include "core/html/HTMLUnknownElement.h" | 42 #include "core/html/HTMLUnknownElement.h" |
43 #include "core/svg/SVGUnknownElement.h" | 43 #include "core/svg/SVGUnknownElement.h" |
44 #include "wtf/RefPtr.h" | 44 #include "wtf/RefPtr.h" |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
| 48 CustomElementRegistrationContext::CustomElementRegistrationContext() |
| 49 : m_candidates(CustomElementUpgradeCandidateMap::create()) |
| 50 { |
| 51 } |
| 52 |
48 void CustomElementRegistrationContext::registerElement(Document* document, Custo
mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom
Element::NameSet validNames, ExceptionState& exceptionState) | 53 void CustomElementRegistrationContext::registerElement(Document* document, Custo
mElementConstructorBuilder* constructorBuilder, const AtomicString& type, Custom
Element::NameSet validNames, ExceptionState& exceptionState) |
49 { | 54 { |
50 CustomElementDefinition* definition = m_registry.registerElement(document, c
onstructorBuilder, type, validNames, exceptionState); | 55 CustomElementDefinition* definition = m_registry.registerElement(document, c
onstructorBuilder, type, validNames, exceptionState); |
51 | 56 |
52 if (!definition) | 57 if (!definition) |
53 return; | 58 return; |
54 | 59 |
55 // Upgrade elements that were waiting for this definition. | 60 // Upgrade elements that were waiting for this definition. |
56 const CustomElementUpgradeCandidateMap::ElementSet& upgradeCandidates = m_ca
ndidates.takeUpgradeCandidatesFor(definition->descriptor()); | 61 const CustomElementUpgradeCandidateMap::ElementSet* upgradeCandidates = m_ca
ndidates->takeUpgradeCandidatesFor(definition->descriptor()); |
57 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra
deCandidates.begin(); it != upgradeCandidates.end(); ++it) | 62 if (!upgradeCandidates) |
| 63 return; |
| 64 |
| 65 for (CustomElementUpgradeCandidateMap::ElementSet::const_iterator it = upgra
deCandidates->begin(); it != upgradeCandidates->end(); ++it) |
58 CustomElement::define(*it, definition); | 66 CustomElement::define(*it, definition); |
59 } | 67 } |
60 | 68 |
61 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa
gElement(Document& document, const QualifiedName& tagName) | 69 PassRefPtrWillBeRawPtr<Element> CustomElementRegistrationContext::createCustomTa
gElement(Document& document, const QualifiedName& tagName) |
62 { | 70 { |
63 ASSERT(CustomElement::isValidName(tagName.localName())); | 71 ASSERT(CustomElement::isValidName(tagName.localName())); |
64 | 72 |
65 RefPtrWillBeRawPtr<Element> element; | 73 RefPtrWillBeRawPtr<Element> element; |
66 | 74 |
67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { | 75 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { |
(...skipping 30 matching lines...) Expand all Loading... |
98 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto
r); | 106 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto
r); |
99 } | 107 } |
100 | 108 |
101 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle
mentDescriptor& descriptor) | 109 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle
mentDescriptor& descriptor) |
102 { | 110 { |
103 CustomElementDefinition* definition = m_registry.find(descriptor); | 111 CustomElementDefinition* definition = m_registry.find(descriptor); |
104 if (definition) { | 112 if (definition) { |
105 CustomElement::define(element, definition); | 113 CustomElement::define(element, definition); |
106 } else { | 114 } else { |
107 ASSERT(element->customElementState() == Element::WaitingForUpgrade); | 115 ASSERT(element->customElementState() == Element::WaitingForUpgrade); |
108 m_candidates.add(descriptor, element); | 116 m_candidates->add(descriptor, element); |
109 } | 117 } |
110 } | 118 } |
111 | 119 |
112 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::c
reate() | |
113 { | |
114 return adoptRef(new CustomElementRegistrationContext()); | |
115 } | |
116 | |
117 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e
lement, const AtomicString& type) | 120 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e
lement, const AtomicString& type) |
118 { | 121 { |
119 ASSERT(element); | 122 ASSERT(element); |
120 ASSERT(!type.isEmpty()); | 123 ASSERT(!type.isEmpty()); |
121 element->setAttribute(HTMLNames::isAttr, type); | 124 element->setAttribute(HTMLNames::isAttr, type); |
122 setTypeExtension(element, type); | 125 setTypeExtension(element, type); |
123 } | 126 } |
124 | 127 |
125 void CustomElementRegistrationContext::setTypeExtension(Element* element, const
AtomicString& type) | 128 void CustomElementRegistrationContext::setTypeExtension(Element* element, const
AtomicString& type) |
126 { | 129 { |
(...skipping 16 matching lines...) Expand all Loading... |
143 // Custom tags take precedence over type extensions | 146 // Custom tags take precedence over type extensions |
144 ASSERT(!CustomElement::isValidName(element->localName())); | 147 ASSERT(!CustomElement::isValidName(element->localName())); |
145 | 148 |
146 if (!CustomElement::isValidName(type)) | 149 if (!CustomElement::isValidName(type)) |
147 return; | 150 return; |
148 | 151 |
149 element->setCustomElementState(Element::WaitingForUpgrade); | 152 element->setCustomElementState(Element::WaitingForUpgrade); |
150 context->didGiveTypeExtension(element, type); | 153 context->didGiveTypeExtension(element, type); |
151 } | 154 } |
152 | 155 |
| 156 void CustomElementRegistrationContext::trace(Visitor* visitor) |
| 157 { |
| 158 visitor->trace(m_candidates); |
| 159 } |
| 160 |
153 } // namespace WebCore | 161 } // namespace WebCore |
OLD | NEW |