Chromium Code Reviews| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 | 124 |
| 125 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create (type, tagName.localName(), tagName.namespaceURI(), lifecycleCallbacks); | 125 RefPtr<CustomElementDefinition> definition = CustomElementDefinition::create (type, tagName.localName(), tagName.namespaceURI(), lifecycleCallbacks); |
| 126 | 126 |
| 127 if (!constructorBuilder->createConstructor(document(), definition.get())) { | 127 if (!constructorBuilder->createConstructor(document(), definition.get())) { |
| 128 ec = NOT_SUPPORTED_ERR; | 128 ec = NOT_SUPPORTED_ERR; |
| 129 return; | 129 return; |
| 130 } | 130 } |
| 131 | 131 |
| 132 m_definitions.add(definition->type(), definition); | 132 m_definitions.add(definition->type(), definition); |
| 133 | 133 |
| 134 // Upgrade elements that were waiting for this definition. | 134 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; | 135 ec = NOT_SUPPORTED_ERR; |
| 138 return; | 136 return; |
| 139 } | 137 } |
| 140 | 138 |
| 139 // Upgrade elements that were waiting for this definition. | |
| 140 CustomElementUpgradeCandidateMap::ElementSet upgradeCandidates = m_candidate s.takeUpgradeCandidatesFor(definition.get()); | |
|
esprehn
2013/07/04 00:54:58
Why does this use an HashSet? takeUpgradeCandidate
| |
| 141 | |
| 141 for (CustomElementUpgradeCandidateMap::ElementSet::iterator it = upgradeCand idates.begin(); it != upgradeCandidates.end(); ++it) { | 142 for (CustomElementUpgradeCandidateMap::ElementSet::iterator it = upgradeCand idates.begin(); it != upgradeCandidates.end(); ++it) { |
| 142 (*it)->setNeedsStyleRecalc(); // :unresolved has changed | |
| 143 | |
| 144 CustomElementCallbackDispatcher::instance().enqueueCreatedCallback(lifec ycleCallbacks.get(), *it); | 143 CustomElementCallbackDispatcher::instance().enqueueCreatedCallback(lifec ycleCallbacks.get(), *it); |
| 145 } | 144 } |
| 146 } | 145 } |
| 147 | 146 |
| 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 | 147 PassRefPtr<CustomElementDefinition> CustomElementRegistry::findFor(Element* elem ent) const |
| 154 { | 148 { |
| 155 ASSERT(element->document()->registry() == this); | 149 ASSERT(element->document()->registry() == this); |
| 156 | 150 |
| 157 if (!element->isCustomElement()) | 151 if (!element->isCustomElement()) |
| 158 return 0; | 152 return 0; |
| 159 | 153 |
| 160 // When a custom tag and a type extension are provided as element | 154 // When a custom tag and a type extension are provided as element |
| 161 // names at the same time, the custom tag takes precedence. | 155 // names at the same time, the custom tag takes precedence. |
| 162 if (isCustomTagName(element->localName())) { | 156 if (isCustomTagName(element->localName())) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 ASSERT(element->isCustomElement()); | 239 ASSERT(element->isCustomElement()); |
| 246 m_candidates.remove(element); | 240 m_candidates.remove(element); |
| 247 } | 241 } |
| 248 | 242 |
| 249 inline Document* CustomElementRegistry::document() const | 243 inline Document* CustomElementRegistry::document() const |
| 250 { | 244 { |
| 251 return toDocument(m_scriptExecutionContext); | 245 return toDocument(m_scriptExecutionContext); |
| 252 } | 246 } |
| 253 | 247 |
| 254 } | 248 } |
| OLD | NEW |