| 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" |
| 11 #include "core/HTMLElementTypeHelpers.h" | 11 #include "core/HTMLElementTypeHelpers.h" |
| 12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
| 13 #include "core/dom/Element.h" | 13 #include "core/dom/Element.h" |
| 14 #include "core/dom/ElementDefinitionOptions.h" | 14 #include "core/dom/ElementDefinitionOptions.h" |
| 15 #include "core/dom/ExceptionCode.h" | 15 #include "core/dom/ExceptionCode.h" |
| 16 #include "core/dom/custom/CEReactionsScope.h" | 16 #include "core/dom/custom/CEReactionsScope.h" |
| 17 #include "core/dom/custom/CustomElement.h" | 17 #include "core/dom/custom/CustomElement.h" |
| 18 #include "core/dom/custom/CustomElementDefinition.h" | 18 #include "core/dom/custom/CustomElementDefinition.h" |
| 19 #include "core/dom/custom/CustomElementDefinitionBuilder.h" | 19 #include "core/dom/custom/CustomElementDefinitionBuilder.h" |
| 20 #include "core/dom/custom/CustomElementDescriptor.h" | 20 #include "core/dom/custom/CustomElementDescriptor.h" |
| 21 #include "core/dom/custom/CustomElementUpgradeReaction.h" | 21 #include "core/dom/custom/CustomElementUpgradeReaction.h" |
| 22 #include "core/dom/custom/CustomElementUpgradeSorter.h" | 22 #include "core/dom/custom/CustomElementUpgradeSorter.h" |
| 23 #include "core/dom/custom/V0CustomElementRegistrationContext.h" | 23 #include "core/dom/custom/V0CustomElementRegistrationContext.h" |
| 24 #include "core/frame/LocalDOMWindow.h" | 24 #include "core/frame/LocalDOMWindow.h" |
| 25 #include "platform/tracing/TraceEvent.h" |
| 25 #include "wtf/Allocator.h" | 26 #include "wtf/Allocator.h" |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 // Returns true if |name| is invalid. | 30 // Returns true if |name| is invalid. |
| 30 static bool throwIfInvalidName(const AtomicString& name, | 31 static bool throwIfInvalidName(const AtomicString& name, |
| 31 ExceptionState& exceptionState) { | 32 ExceptionState& exceptionState) { |
| 32 if (CustomElement::isValidName(name)) | 33 if (CustomElement::isValidName(name)) |
| 33 return false; | 34 return false; |
| 34 exceptionState.throwDOMException( | 35 exceptionState.throwDOMException( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ScriptCustomElementDefinitionBuilder builder(scriptState, this, constructor, | 98 ScriptCustomElementDefinitionBuilder builder(scriptState, this, constructor, |
| 98 exceptionState); | 99 exceptionState); |
| 99 define(name, builder, options, exceptionState); | 100 define(name, builder, options, exceptionState); |
| 100 } | 101 } |
| 101 | 102 |
| 102 // http://w3c.github.io/webcomponents/spec/custom/#dfn-element-definition | 103 // http://w3c.github.io/webcomponents/spec/custom/#dfn-element-definition |
| 103 void CustomElementRegistry::define(const AtomicString& name, | 104 void CustomElementRegistry::define(const AtomicString& name, |
| 104 CustomElementDefinitionBuilder& builder, | 105 CustomElementDefinitionBuilder& builder, |
| 105 const ElementDefinitionOptions& options, | 106 const ElementDefinitionOptions& options, |
| 106 ExceptionState& exceptionState) { | 107 ExceptionState& exceptionState) { |
| 108 TRACE_EVENT1("blink", "CustomElementRegistry::define", "name", name.utf8()); |
| 107 if (!builder.checkConstructorIntrinsics()) | 109 if (!builder.checkConstructorIntrinsics()) |
| 108 return; | 110 return; |
| 109 | 111 |
| 110 if (throwIfInvalidName(name, exceptionState)) | 112 if (throwIfInvalidName(name, exceptionState)) |
| 111 return; | 113 return; |
| 112 | 114 |
| 113 if (nameIsDefined(name) || v0NameIsDefined(name)) { | 115 if (nameIsDefined(name) || v0NameIsDefined(name)) { |
| 114 exceptionState.throwDOMException( | 116 exceptionState.throwDOMException( |
| 115 NotSupportedError, | 117 NotSupportedError, |
| 116 "this name has already been used with this registry"); | 118 "this name has already been used with this registry"); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 m_upgradeCandidates->remove(it); | 291 m_upgradeCandidates->remove(it); |
| 290 | 292 |
| 291 Document* document = m_owner->document(); | 293 Document* document = m_owner->document(); |
| 292 if (!document) | 294 if (!document) |
| 293 return; | 295 return; |
| 294 | 296 |
| 295 sorter.sorted(elements, document); | 297 sorter.sorted(elements, document); |
| 296 } | 298 } |
| 297 | 299 |
| 298 } // namespace blink | 300 } // namespace blink |
| OLD | NEW |