| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 if (type.isNull()) | 199 if (type.isNull()) |
| 200 return 0; | 200 return 0; |
| 201 DefinitionMap::const_iterator it = m_definitions.find(type); | 201 DefinitionMap::const_iterator it = m_definitions.find(type); |
| 202 if (it == m_definitions.end()) | 202 if (it == m_definitions.end()) |
| 203 return 0; | 203 return 0; |
| 204 if (it->value->namespaceURI() != namespaceURI) | 204 if (it->value->namespaceURI() != namespaceURI) |
| 205 return 0; | 205 return 0; |
| 206 return it->value; | 206 return it->value; |
| 207 } | 207 } |
| 208 | 208 |
| 209 PassRefPtr<Element> CustomElementRegistry::tryToCreateCustomTagElement(const Qua
lifiedName& tagName) | 209 PassRefPtr<Element> CustomElementRegistry::createCustomTagElement(const Qualifie
dName& tagName) |
| 210 { | 210 { |
| 211 if (!document() || !isValidName(tagName.localName())) | 211 if (!document()) |
| 212 return 0; | 212 return 0; |
| 213 | 213 |
| 214 ASSERT(isCustomTagName(tagName.localName())); |
| 215 |
| 214 RefPtr<Element> element; | 216 RefPtr<Element> element; |
| 215 | 217 |
| 216 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) | 218 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) |
| 217 element = HTMLElement::create(tagName, document()); | 219 element = HTMLElement::create(tagName, document()); |
| 218 #if ENABLE(SVG) | 220 #if ENABLE(SVG) |
| 219 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) | 221 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) |
| 220 element = SVGElement::create(tagName, document()); | 222 element = SVGElement::create(tagName, document()); |
| 221 #endif | 223 #endif |
| 222 else | 224 else |
| 223 element = Element::create(tagName, document()); | 225 element = Element::create(tagName, document()); |
| 224 | 226 |
| 225 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l
ocalName(), tagName.namespaceURI()); | 227 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l
ocalName(), tagName.namespaceURI()); |
| 226 if (!definition || definition->isTypeExtension()) | 228 if (definition && !definition->isTypeExtension()) |
| 227 return 0; | 229 didCreateCustomTagElement(element.get()); |
| 228 | 230 |
| 229 didCreateElement(element.get()); | |
| 230 return element.release(); | 231 return element.release(); |
| 231 } | 232 } |
| 232 | 233 |
| 233 void CustomElementRegistry::didGiveTypeExtension(Element* element) | 234 void CustomElementRegistry::didGiveTypeExtension(Element* element) |
| 234 { | 235 { |
| 235 RefPtr<CustomElementDefinition> definition = findFor(element); | 236 RefPtr<CustomElementDefinition> definition = findFor(element); |
| 236 if (!definition || !definition->isTypeExtension()) | 237 if (!definition || !definition->isTypeExtension()) |
| 237 return; | 238 return; |
| 238 activate(CustomElementInvocation(element)); | 239 activate(CustomElementInvocation(element)); |
| 239 } | 240 } |
| 240 | 241 |
| 241 void CustomElementRegistry::didCreateElement(Element* element) | 242 void CustomElementRegistry::didCreateCustomTagElement(Element* element) |
| 242 { | 243 { |
| 243 activate(CustomElementInvocation(element)); | 244 activate(CustomElementInvocation(element)); |
| 244 } | 245 } |
| 245 | 246 |
| 246 void CustomElementRegistry::activate(const CustomElementInvocation& invocation) | 247 void CustomElementRegistry::activate(const CustomElementInvocation& invocation) |
| 247 { | 248 { |
| 248 bool wasInactive = m_invocations.isEmpty(); | 249 bool wasInactive = m_invocations.isEmpty(); |
| 249 m_invocations.append(invocation); | 250 m_invocations.append(invocation); |
| 250 if (wasInactive) | 251 if (wasInactive) |
| 251 activeCustomElementRegistries().add(this); | 252 activeCustomElementRegistries().add(this); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 282 while (!activeCustomElementRegistries().isEmpty()) { | 283 while (!activeCustomElementRegistries().isEmpty()) { |
| 283 Vector<RefPtr<CustomElementRegistry> > registries; | 284 Vector<RefPtr<CustomElementRegistry> > registries; |
| 284 copyToVector(activeCustomElementRegistries(), registries); | 285 copyToVector(activeCustomElementRegistries(), registries); |
| 285 activeCustomElementRegistries().clear(); | 286 activeCustomElementRegistries().clear(); |
| 286 for (size_t i = 0; i < registries.size(); ++i) | 287 for (size_t i = 0; i < registries.size(); ++i) |
| 287 registries[i]->deliverLifecycleCallbacks(); | 288 registries[i]->deliverLifecycleCallbacks(); |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 | 291 |
| 291 } | 292 } |
| OLD | NEW |