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

Side by Side Diff: Source/core/dom/custom/CustomElementRegistrationContext.cpp

Issue 106903007: Let unresolved custom element go through CustomElementCallbackQueue. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 /*
dominicc (has gone to gerrit) 2013/12/13 05:11:16 I think this isn't quite right. resolvePoppedEleme
Hajime Morrita 2013/12/13 07:02:29 OK, I cut the first resolution and let it done aft
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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
11 * notice, this list of conditions and the following disclaimer 11 * notice, this list of conditions and the following disclaimer
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) { 67 if (HTMLNames::xhtmlNamespaceURI == tagName.namespaceURI()) {
68 element = HTMLElement::create(tagName, document); 68 element = HTMLElement::create(tagName, document);
69 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) { 69 } else if (SVGNames::svgNamespaceURI == tagName.namespaceURI()) {
70 element = SVGUnknownElement::create(tagName, document); 70 element = SVGUnknownElement::create(tagName, document);
71 } else { 71 } else {
72 // XML elements are not custom elements, so return early. 72 // XML elements are not custom elements, so return early.
73 return Element::create(tagName, &document); 73 return Element::create(tagName, &document);
74 } 74 }
75 75
76 element->setCustomElementState(Element::WaitingForUpgrade); 76 element->setCustomElementState(Element::WaitingForUpgrade);
77 resolve(element.get(), nullAtom); 77 resolveNewElement(element.get(), nullAtom);
78 return element.release(); 78 return element.release();
79 } 79 }
80 80
81 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co nst AtomicString& type) 81 void CustomElementRegistrationContext::didGiveTypeExtension(Element* element, co nst AtomicString& type)
82 { 82 {
83 resolve(element, type); 83 resolveNewElement(element, type);
84 } 84 }
85 85
86 void CustomElementRegistrationContext::resolve(Element* element, const AtomicStr ing& typeExtension) 86 void CustomElementRegistrationContext::resolveNewElement(Element* element, const AtomicString& typeExtension)
87 { 87 {
88 // If an element has a custom tag name it takes precedence over 88 // If an element has a custom tag name it takes precedence over
89 // the "is" attribute (if any). 89 // the "is" attribute (if any).
90 const AtomicString& type = CustomElement::isValidName(element->localName()) 90 const AtomicString& type = CustomElement::isValidName(element->localName())
91 ? element->localName() 91 ? element->localName()
92 : typeExtension; 92 : typeExtension;
93 ASSERT(!type.isNull()); 93 ASSERT(!type.isNull());
94 94
95 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l ocalName()); 95 CustomElementDescriptor descriptor(type, element->namespaceURI(), element->l ocalName());
96 CustomElementDefinition* definition = m_registry.find(descriptor); 96 CustomElementDefinition* definition = m_registry.find(descriptor);
97 if (definition) 97 if (definition)
98 didResolveElement(definition, element); 98 didResolveElement(definition, element);
99 else 99 else
100 didCreateUnresolvedElement(descriptor, element); 100 didCreateUnresolvedElement(descriptor, element);
101 } 101 }
102 102
103 void CustomElementRegistrationContext::resolvePoppedElement(Element* element, co nst CustomElementDescriptor& descriptor)
104 {
105 CustomElementDefinition* definition = m_registry.find(descriptor);
106 if (definition)
107 didResolveElement(definition, element);
108 else
109 didFailResolution(descriptor, element);
110 }
111
103 void CustomElementRegistrationContext::didResolveElement(CustomElementDefinition * definition, Element* element) 112 void CustomElementRegistrationContext::didResolveElement(CustomElementDefinition * definition, Element* element)
104 { 113 {
105 CustomElement::define(element, definition); 114 CustomElement::define(element, definition);
106 } 115 }
107 116
108 void CustomElementRegistrationContext::didCreateUnresolvedElement(const CustomEl ementDescriptor& descriptor, Element* element) 117 void CustomElementRegistrationContext::didCreateUnresolvedElement(const CustomEl ementDescriptor& descriptor, Element* element)
109 { 118 {
110 ASSERT(element->customElementState() == Element::WaitingForUpgrade); 119 ASSERT(element->customElementState() == Element::WaitingForUpgrade);
120 CustomElementCallbackScheduler::scheduleResolutionCallback(descriptor, eleme nt);
121 }
122
123 void CustomElementRegistrationContext::didFailResolution(const CustomElementDesc riptor& descriptor, Element* element)
124 {
125 ASSERT(element->customElementState() == Element::WaitingForUpgrade);
111 m_candidates.add(descriptor, element); 126 m_candidates.add(descriptor, element);
112 } 127 }
113 128
114 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::c reate() 129 PassRefPtr<CustomElementRegistrationContext> CustomElementRegistrationContext::c reate()
115 { 130 {
116 return adoptRef(new CustomElementRegistrationContext()); 131 return adoptRef(new CustomElementRegistrationContext());
117 } 132 }
118 133
119 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type) 134 void CustomElementRegistrationContext::setIsAttributeAndTypeExtension(Element* e lement, const AtomicString& type)
120 { 135 {
(...skipping 20 matching lines...) Expand all
141 // Custom tags take precedence over type extensions 156 // Custom tags take precedence over type extensions
142 ASSERT(!CustomElement::isValidName(element->localName())); 157 ASSERT(!CustomElement::isValidName(element->localName()));
143 158
144 element->setCustomElementState(Element::WaitingForUpgrade); 159 element->setCustomElementState(Element::WaitingForUpgrade);
145 160
146 if (CustomElementRegistrationContext* context = element->document().registra tionContext()) 161 if (CustomElementRegistrationContext* context = element->document().registra tionContext())
147 context->didGiveTypeExtension(element, type); 162 context->didGiveTypeExtension(element, type);
148 } 163 }
149 164
150 } // namespace WebCore 165 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698