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

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: Use toV8 in the constructor. Remove unused variable. 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
« no previous file with comments | « Source/core/dom/CustomElementRegistry.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementRegistry.h ('k') | Source/core/dom/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698