| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 167 |
| 168 m_definitions.add(definition->type(), definition); | 168 m_definitions.add(definition->type(), definition); |
| 169 | 169 |
| 170 return constructor.release(); | 170 return constructor.release(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* elem
ent) const | 173 PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* elem
ent) const |
| 174 { | 174 { |
| 175 ASSERT(element->document()->registry() == this); | 175 ASSERT(element->document()->registry() == this); |
| 176 | 176 |
| 177 if (!element->isCustomElement()) | 177 // Most elements can be rejected with this quick screening. |
| 178 if (!nameIncludesHyphen(element->tagName()) && !element->hasAttribute(HTMLNa
mes::isAttr)) |
| 178 return 0; | 179 return 0; |
| 179 | 180 |
| 180 // When a custom tag and a type extension are provided as element | 181 // When a custom tag and a type extension are provided as element |
| 181 // names at the same time, the custom tag takes precedence. | 182 // names at the same time, the custom tag takes precedence. |
| 182 if (isCustomTagName(element->localName())) { | 183 if (isValidName(element->localName())) { |
| 183 if (RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(e
lement->localName(), element->namespaceURI())) | 184 if (RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(e
lement->localName(), element->namespaceURI())) |
| 184 return definition->isTypeExtension() ? 0 : definition.release(); | 185 return definition->isTypeExtension() ? 0 : definition.release(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 // FIXME: Casually consulting the "is" attribute is dangerous if | 188 // FIXME: Casually consulting the "is" attribute is dangerous if |
| 188 // it could have changed since element creation. | 189 // it could have changed since element creation. |
| 189 const AtomicString& isValue = element->getAttribute(HTMLNames::isAttr); | 190 const AtomicString& isValue = element->getAttribute(HTMLNames::isAttr); |
| 190 if (RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(isVal
ue, element->namespaceURI())) | 191 if (RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(isVal
ue, element->namespaceURI())) |
| 191 return definition->isTypeExtension() && definition->name() == element->l
ocalName() ? definition.release() : 0; | 192 return definition->isTypeExtension() && definition->name() == element->l
ocalName() ? definition.release() : 0; |
| 192 | 193 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 216 | 217 |
| 217 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) | 218 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) |
| 218 element = HTMLElement::create(tagName, document()); | 219 element = HTMLElement::create(tagName, document()); |
| 219 #if ENABLE(SVG) | 220 #if ENABLE(SVG) |
| 220 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) | 221 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) |
| 221 element = SVGElement::create(tagName, document()); | 222 element = SVGElement::create(tagName, document()); |
| 222 #endif | 223 #endif |
| 223 else | 224 else |
| 224 element = Element::create(tagName, document()); | 225 element = Element::create(tagName, document()); |
| 225 | 226 |
| 226 element->setIsCustomElement(); | |
| 227 | |
| 228 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l
ocalName(), tagName.namespaceURI()); | 227 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l
ocalName(), tagName.namespaceURI()); |
| 229 if (definition && !definition->isTypeExtension()) | 228 if (definition && !definition->isTypeExtension()) |
| 230 didCreateCustomTagElement(element.get()); | 229 didCreateCustomTagElement(element.get()); |
| 231 | 230 |
| 232 return element.release(); | 231 return element.release(); |
| 233 } | 232 } |
| 234 | 233 |
| 235 void CustomElementRegistry::didGiveTypeExtension(Element* element) | 234 void CustomElementRegistry::didGiveTypeExtension(Element* element) |
| 236 { | 235 { |
| 237 element->setIsCustomElement(); | |
| 238 RefPtr<CustomElementDefinition> definition = findFor(element); | 236 RefPtr<CustomElementDefinition> definition = findFor(element); |
| 239 if (!definition || !definition->isTypeExtension()) | 237 if (!definition || !definition->isTypeExtension()) |
| 240 return; | 238 return; |
| 241 activate(CustomElementInvocation(element)); | 239 activate(CustomElementInvocation(element)); |
| 242 } | 240 } |
| 243 | 241 |
| 244 void CustomElementRegistry::didCreateCustomTagElement(Element* element) | 242 void CustomElementRegistry::didCreateCustomTagElement(Element* element) |
| 245 { | 243 { |
| 246 activate(CustomElementInvocation(element)); | 244 activate(CustomElementInvocation(element)); |
| 247 } | 245 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 while (!activeCustomElementRegistries().isEmpty()) { | 283 while (!activeCustomElementRegistries().isEmpty()) { |
| 286 Vector<RefPtr<CustomElementRegistry> > registries; | 284 Vector<RefPtr<CustomElementRegistry> > registries; |
| 287 copyToVector(activeCustomElementRegistries(), registries); | 285 copyToVector(activeCustomElementRegistries(), registries); |
| 288 activeCustomElementRegistries().clear(); | 286 activeCustomElementRegistries().clear(); |
| 289 for (size_t i = 0; i < registries.size(); ++i) | 287 for (size_t i = 0; i < registries.size(); ++i) |
| 290 registries[i]->deliverLifecycleCallbacks(); | 288 registries[i]->deliverLifecycleCallbacks(); |
| 291 } | 289 } |
| 292 } | 290 } |
| 293 | 291 |
| 294 } | 292 } |
| OLD | NEW |