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