Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: Source/core/dom/CustomElementRegistry.cpp

Issue 14776002: Create wrappers for unresolved Custom Elements at the correct type (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (type.isNull()) 198 if (type.isNull())
199 return 0; 199 return 0;
200 DefinitionMap::const_iterator it = m_definitions.find(type); 200 DefinitionMap::const_iterator it = m_definitions.find(type);
201 if (it == m_definitions.end()) 201 if (it == m_definitions.end())
202 return 0; 202 return 0;
203 if (it->value->namespaceURI() != namespaceURI) 203 if (it->value->namespaceURI() != namespaceURI)
204 return 0; 204 return 0;
205 return it->value; 205 return it->value;
206 } 206 }
207 207
208 PassRefPtr<Element> CustomElementRegistry::tryToCreateCustomTagElement(const Qua lifiedName& tagName) 208 PassRefPtr<Element> CustomElementRegistry::createCustomTagElement(const Qualifie dName& tagName)
209 { 209 {
210 if (!document() || !isValidName(tagName.localName())) 210 if (!document())
211 return 0; 211 return 0;
212 212
213 ASSERT(isCustomTagName(tagName.localName()));
214
213 RefPtr<Element> element; 215 RefPtr<Element> element;
214 216
215 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) 217 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI())
216 element = HTMLElement::create(tagName, document()); 218 element = HTMLElement::create(tagName, document());
217 #if ENABLE(SVG) 219 #if ENABLE(SVG)
218 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) 220 else if (SVGNames::svgNamespaceURI == tagName.namespaceURI())
219 element = SVGElement::create(tagName, document()); 221 element = SVGElement::create(tagName, document());
220 #endif 222 #endif
221 else 223 else
222 element = Element::create(tagName, document()); 224 element = Element::create(tagName, document());
223 225
224 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l ocalName(), tagName.namespaceURI()); 226 RefPtr<CustomElementDefinition> definition = findAndCheckNamespace(tagName.l ocalName(), tagName.namespaceURI());
225 if (!definition || definition->isTypeExtension()) 227 if (definition && !definition->isTypeExtension())
226 return 0; 228 didCreateCustomTagElement(element.get());
227 229
228 didCreateElement(element.get());
229 return element.release(); 230 return element.release();
haraken 2013/05/01 18:49:12 This will change behavior. Previously 0 was return
dominicc (has gone to gerrit) 2013/05/02 01:29:56 Absolutely. That is what we're going for here, hen
230 } 231 }
231 232
232 void CustomElementRegistry::didGiveTypeExtension(Element* element) 233 void CustomElementRegistry::didGiveTypeExtension(Element* element)
233 { 234 {
234 RefPtr<CustomElementDefinition> definition = findFor(element); 235 RefPtr<CustomElementDefinition> definition = findFor(element);
235 if (!definition || !definition->isTypeExtension()) 236 if (!definition || !definition->isTypeExtension())
236 return; 237 return;
237 activate(CustomElementInvocation(element)); 238 activate(CustomElementInvocation(element));
238 } 239 }
239 240
240 void CustomElementRegistry::didCreateElement(Element* element) 241 void CustomElementRegistry::didCreateCustomTagElement(Element* element)
241 { 242 {
242 activate(CustomElementInvocation(element)); 243 activate(CustomElementInvocation(element));
243 } 244 }
244 245
245 void CustomElementRegistry::activate(const CustomElementInvocation& invocation) 246 void CustomElementRegistry::activate(const CustomElementInvocation& invocation)
246 { 247 {
247 bool wasInactive = m_invocations.isEmpty(); 248 bool wasInactive = m_invocations.isEmpty();
248 m_invocations.append(invocation); 249 m_invocations.append(invocation);
249 if (wasInactive) 250 if (wasInactive)
250 activeCustomElementRegistries().add(this); 251 activeCustomElementRegistries().add(this);
(...skipping 30 matching lines...) Expand all
281 while (!activeCustomElementRegistries().isEmpty()) { 282 while (!activeCustomElementRegistries().isEmpty()) {
282 Vector<RefPtr<CustomElementRegistry> > registries; 283 Vector<RefPtr<CustomElementRegistry> > registries;
283 copyToVector(activeCustomElementRegistries(), registries); 284 copyToVector(activeCustomElementRegistries(), registries);
284 activeCustomElementRegistries().clear(); 285 activeCustomElementRegistries().clear();
285 for (size_t i = 0; i < registries.size(); ++i) 286 for (size_t i = 0; i < registries.size(); ++i)
286 registries[i]->deliverLifecycleCallbacks(); 287 registries[i]->deliverLifecycleCallbacks();
287 } 288 }
288 } 289 }
289 290
290 } 291 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698