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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { | 67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { |
68 element = HTMLElement::create(tagName, document); | 68 element = HTMLElement::create(tagName, document); |
69 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { | 69 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { |
70 element = SVGUnknownElement::create(tagName, document); | 70 element = SVGUnknownElement::create(tagName, document); |
71 } else { | 71 } else { |
72 // XML elements are not custom elements, so return early. | 72 // XML elements are not custom elements, so return early. |
73 return Element::create(tagName, &document); | 73 return Element::create(tagName, &document); |
74 } | 74 } |
75 | 75 |
76 element->setCustomElementState(Element::WaitingForUpgrade); | 76 element->setCustomElementState(Element::WaitingForUpgrade); |
77 scheduleResolution(element.get(), nullAtom); | 77 resolveOrScheduleResolution(element.get(), nullAtom); |
78 return element.release(); | 78 return element.release(); |
79 } | 79 } |
80 | 80 |
81 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co
nst AtomicString& type) | 81 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co
nst AtomicString& type) |
82 { | 82 { |
83 scheduleResolution(element, type); | 83 resolveOrScheduleResolution(element, type); |
84 } | 84 } |
85 | 85 |
86 void CustomElementRegistrationContext::scheduleResolution(Element* element, cons
t AtomicString& typeExtension) | 86 void CustomElementRegistrationContext::resolveOrScheduleResolution(Element* elem
ent, const AtomicString& typeExtension) |
87 { | 87 { |
88 // If an element has a custom tag name it takes precedence over | 88 // If an element has a custom tag name it takes precedence over |
89 // the "is" attribute (if any). | 89 // the "is" attribute (if any). |
90 const AtomicString& type = CustomElement::isValidName(element->localName()) | 90 const AtomicString& type = CustomElement::isValidName(element->localName()) |
91 ? element->localName() | 91 ? element->localName() |
92 : typeExtension; | 92 : typeExtension; |
93 ASSERT(!type.isNull()); | 93 ASSERT(!type.isNull()); |
94 | 94 |
95 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l
ocalName()); | 95 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l
ocalName()); |
96 ASSERT(element->customElementState() == Element::WaitingForUpgrade); | 96 ASSERT(element->customElementState() == Element::WaitingForUpgrade); |
97 CustomElementScheduler::scheduleResolutionStep(descriptor, element); | 97 |
| 98 CustomElementScheduler::resolveOrScheduleResolution(this, element, descripto
r); |
98 } | 99 } |
99 | 100 |
100 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle
mentDescriptor& descriptor) | 101 void CustomElementRegistrationContext::resolve(Element* element, const CustomEle
mentDescriptor& descriptor) |
101 { | 102 { |
102 CustomElementDefinition* definition = m_registry.find(descriptor); | 103 CustomElementDefinition* definition = m_registry.find(descriptor); |
103 if (definition) { | 104 if (definition) { |
104 CustomElement::define(element, definition); | 105 CustomElement::define(element, definition); |
105 } else { | 106 } else { |
106 ASSERT(element->customElementState() == Element::WaitingForUpgrade); | 107 ASSERT(element->customElementState() == Element::WaitingForUpgrade); |
107 m_candidates.add(descriptor, element); | 108 m_candidates.add(descriptor, element); |
(...skipping 30 matching lines...) Expand all Loading... |
138 // Custom tags take precedence over type extensions | 139 // Custom tags take precedence over type extensions |
139 ASSERT(!CustomElement::isValidName(element->localName())); | 140 ASSERT(!CustomElement::isValidName(element->localName())); |
140 | 141 |
141 element->setCustomElementState(Element::WaitingForUpgrade); | 142 element->setCustomElementState(Element::WaitingForUpgrade); |
142 | 143 |
143 if (CustomElementRegistrationContext* context = element->document().registra
tionContext()) | 144 if (CustomElementRegistrationContext* context = element->document().registra
tionContext()) |
144 context->didGiveTypeExtension(element, type); | 145 context->didGiveTypeExtension(element, type); |
145 } | 146 } |
146 | 147 |
147 } // namespace WebCore | 148 } // namespace WebCore |
OLD | NEW |