| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/dom/custom/CustomElementRegistry.h" | 5 #include "core/dom/custom/CustomElementRegistry.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.h" | 8 #include "bindings/core/v8/ScriptCustomElementDefinitionBuilder.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 bool CustomElementRegistry::v0NameIsDefined(const AtomicString& name) { | 245 bool CustomElementRegistry::v0NameIsDefined(const AtomicString& name) { |
| 246 for (const auto& v0 : *m_v0) { | 246 for (const auto& v0 : *m_v0) { |
| 247 if (v0->nameIsDefined(name)) | 247 if (v0->nameIsDefined(name)) |
| 248 return true; | 248 return true; |
| 249 } | 249 } |
| 250 return false; | 250 return false; |
| 251 } | 251 } |
| 252 | 252 |
| 253 CustomElementDefinition* CustomElementRegistry::definitionForName( | 253 CustomElementDefinition* CustomElementRegistry::definitionForName( |
| 254 const AtomicString& name) const { | 254 const AtomicString& name) const { |
| 255 return m_definitions.get(name); | 255 return m_definitions.at(name); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void CustomElementRegistry::addCandidate(Element* candidate) { | 258 void CustomElementRegistry::addCandidate(Element* candidate) { |
| 259 const AtomicString& name = candidate->localName(); | 259 const AtomicString& name = candidate->localName(); |
| 260 if (nameIsDefined(name) || v0NameIsDefined(name)) | 260 if (nameIsDefined(name) || v0NameIsDefined(name)) |
| 261 return; | 261 return; |
| 262 UpgradeCandidateMap::iterator it = m_upgradeCandidates->find(name); | 262 UpgradeCandidateMap::iterator it = m_upgradeCandidates->find(name); |
| 263 UpgradeCandidateSet* set; | 263 UpgradeCandidateSet* set; |
| 264 if (it != m_upgradeCandidates->end()) { | 264 if (it != m_upgradeCandidates->end()) { |
| 265 set = it->value; | 265 set = it->value; |
| 266 } else { | 266 } else { |
| 267 set = m_upgradeCandidates->insert(name, new UpgradeCandidateSet()) | 267 set = m_upgradeCandidates->insert(name, new UpgradeCandidateSet()) |
| 268 .storedValue->value; | 268 .storedValue->value; |
| 269 } | 269 } |
| 270 set->insert(candidate); | 270 set->insert(candidate); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregis
try-whendefined | 273 // https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregis
try-whendefined |
| 274 ScriptPromise CustomElementRegistry::whenDefined( | 274 ScriptPromise CustomElementRegistry::whenDefined( |
| 275 ScriptState* scriptState, | 275 ScriptState* scriptState, |
| 276 const AtomicString& name, | 276 const AtomicString& name, |
| 277 ExceptionState& exceptionState) { | 277 ExceptionState& exceptionState) { |
| 278 if (throwIfInvalidName(name, exceptionState)) | 278 if (throwIfInvalidName(name, exceptionState)) |
| 279 return ScriptPromise(); | 279 return ScriptPromise(); |
| 280 CustomElementDefinition* definition = definitionForName(name); | 280 CustomElementDefinition* definition = definitionForName(name); |
| 281 if (definition) | 281 if (definition) |
| 282 return ScriptPromise::castUndefined(scriptState); | 282 return ScriptPromise::castUndefined(scriptState); |
| 283 ScriptPromiseResolver* resolver = m_whenDefinedPromiseMap.get(name); | 283 ScriptPromiseResolver* resolver = m_whenDefinedPromiseMap.at(name); |
| 284 if (resolver) | 284 if (resolver) |
| 285 return resolver->promise(); | 285 return resolver->promise(); |
| 286 ScriptPromiseResolver* newResolver = | 286 ScriptPromiseResolver* newResolver = |
| 287 ScriptPromiseResolver::create(scriptState); | 287 ScriptPromiseResolver::create(scriptState); |
| 288 m_whenDefinedPromiseMap.insert(name, newResolver); | 288 m_whenDefinedPromiseMap.insert(name, newResolver); |
| 289 return newResolver->promise(); | 289 return newResolver->promise(); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void CustomElementRegistry::collectCandidates( | 292 void CustomElementRegistry::collectCandidates( |
| 293 const CustomElementDescriptor& desc, | 293 const CustomElementDescriptor& desc, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 305 m_upgradeCandidates->remove(it); | 305 m_upgradeCandidates->remove(it); |
| 306 | 306 |
| 307 Document* document = m_owner->document(); | 307 Document* document = m_owner->document(); |
| 308 if (!document) | 308 if (!document) |
| 309 return; | 309 return; |
| 310 | 310 |
| 311 sorter.sorted(elements, document); | 311 sorter.sorted(elements, document); |
| 312 } | 312 } |
| 313 | 313 |
| 314 } // namespace blink | 314 } // namespace blink |
| OLD | NEW |