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

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

Issue 18258003: Pow __proto__, sock :unresolved, and clunk the created callback at once. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Try to be nicer to MSVC. Created 7 years, 5 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 22 matching lines...) Expand all
33 33
34 #include "HTMLNames.h" 34 #include "HTMLNames.h"
35 #include "SVGNames.h" 35 #include "SVGNames.h"
36 #include "bindings/v8/CustomElementConstructorBuilder.h" 36 #include "bindings/v8/CustomElementConstructorBuilder.h"
37 #include "core/dom/CustomElementCallbackDispatcher.h" 37 #include "core/dom/CustomElementCallbackDispatcher.h"
38 #include "core/dom/CustomElementDefinition.h" 38 #include "core/dom/CustomElementDefinition.h"
39 #include "core/dom/Document.h" 39 #include "core/dom/Document.h"
40 #include "core/dom/Element.h" 40 #include "core/dom/Element.h"
41 #include "core/html/HTMLElement.h" 41 #include "core/html/HTMLElement.h"
42 #include "core/svg/SVGElement.h" 42 #include "core/svg/SVGElement.h"
43 #include "wtf/Vector.h"
43 44
44 namespace WebCore { 45 namespace WebCore {
45 46
46 void setTypeExtension(Element* element, const AtomicString& typeExtension) 47 void setTypeExtension(Element* element, const AtomicString& typeExtension)
47 { 48 {
48 ASSERT(element); 49 ASSERT(element);
49 if (!typeExtension.isEmpty()) 50 if (!typeExtension.isEmpty())
50 element->setAttribute(HTMLNames::isAttr, typeExtension); 51 element->setAttribute(HTMLNames::isAttr, typeExtension);
51 } 52 }
52 53
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 125
125 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create (type, tagName.localName(), tagName.namespaceURI(), lifecycleCallbacks); 126 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create (type, tagName.localName(), tagName.namespaceURI(), lifecycleCallbacks);
126 127
127 if (!constructorBuilder->createConstructor(document(), definition.get())) { 128 if (!constructorBuilder->createConstructor(document(), definition.get())) {
128 ec = NOT_SUPPORTED_ERR; 129 ec = NOT_SUPPORTED_ERR;
129 return; 130 return;
130 } 131 }
131 132
132 m_definitions.add(definition->type(), definition); 133 m_definitions.add(definition->type(), definition);
133 134
134 // Upgrade elements that were waiting for this definition. 135 if (!constructorBuilder->didRegisterDefinition(definition.get())) {
135 CustomElementUpgradeCandidateMap::ElementSet upgradeCandidates = m_candidate s.takeUpgradeCandidatesFor(definition.get());
136 if (!constructorBuilder->didRegisterDefinition(definition.get(), upgradeCand idates)) {
137 ec = NOT_SUPPORTED_ERR; 136 ec = NOT_SUPPORTED_ERR;
138 return; 137 return;
139 } 138 }
140 139
141 for (CustomElementUpgradeCandidateMap::ElementSet::iterator it = upgradeCand idates.begin(); it != upgradeCandidates.end(); ++it) { 140 // Upgrade elements that were waiting for this definition.
142 (*it)->setNeedsStyleRecalc(); // :unresolved has changed 141 const Vector<Element*>& upgradeCandidates = m_candidates.takeUpgradeCandidat esFor(definition.get());
143 142
143 for (Vector<Element*>::const_iterator it = upgradeCandidates.begin(); it != upgradeCandidates.end(); ++it) {
144 CustomElementCallbackDispatcher::instance().enqueueCreatedCallback(lifec ycleCallbacks.get(), *it); 144 CustomElementCallbackDispatcher::instance().enqueueCreatedCallback(lifec ycleCallbacks.get(), *it);
145 } 145 }
146 } 146 }
147 147
148 bool CustomElementRegistry::isUnresolved(Element* element) const
149 {
150 return m_candidates.contains(element);
151 }
152
153 PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* elem ent) const 148 PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* elem ent) const
154 { 149 {
155 ASSERT(element->document()->registry() == this); 150 ASSERT(element->document()->registry() == this);
156 151
157 if (!element->isCustomElement()) 152 if (!element->isCustomElement())
158 return 0; 153 return 0;
159 154
160 // When a custom tag and a type extension are provided as element 155 // When a custom tag and a type extension are provided as element
161 // names at the same time, the custom tag takes precedence. 156 // names at the same time, the custom tag takes precedence.
162 if (isCustomTagName(element->localName())) { 157 if (isCustomTagName(element->localName())) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 ASSERT(element->isCustomElement()); 240 ASSERT(element->isCustomElement());
246 m_candidates.remove(element); 241 m_candidates.remove(element);
247 } 242 }
248 243
249 inline Document* CustomElementRegistry::document() const 244 inline Document* CustomElementRegistry::document() const
250 { 245 {
251 return toDocument(m_scriptExecutionContext); 246 return toDocument(m_scriptExecutionContext);
252 } 247 }
253 248
254 } 249 }
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementRegistry.h ('k') | Source/core/dom/CustomElementUpgradeCandidateMap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698