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 13 matching lines...) Expand all Loading... | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/dom/custom/V0CustomElementRegistry.h" | 31 #include "core/dom/custom/V0CustomElementRegistry.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" | 33 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" |
| 34 #include "bindings/core/v8/V8Binding.h" | |
| 34 #include "core/HTMLNames.h" | 35 #include "core/HTMLNames.h" |
| 35 #include "core/SVGNames.h" | 36 #include "core/SVGNames.h" |
| 37 #include "core/dom/Document.h" | |
| 38 #include "core/dom/custom/CustomElementsRegistry.h" | |
| 36 #include "core/dom/custom/V0CustomElementException.h" | 39 #include "core/dom/custom/V0CustomElementException.h" |
| 37 #include "core/dom/custom/V0CustomElementRegistrationContext.h" | 40 #include "core/dom/custom/V0CustomElementRegistrationContext.h" |
| 41 #include "core/frame/LocalDOMWindow.h" | |
| 38 | 42 |
| 39 namespace blink { | 43 namespace blink { |
| 40 | 44 |
| 45 static bool v1CustomElementIsDefined(const AtomicString& name) | |
| 46 { | |
| 47 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | |
|
haraken
2016/05/10 09:04:22
v8::Isolate::GetCurrent() is deprecated.
Can we p
| |
| 48 Document* doc = toDocument(currentExecutionContext(isolate)); | |
| 49 LocalDOMWindow* window = doc->domWindow(); | |
|
haraken
2016/05/10 09:04:22
We should use ScriptState::domWindow(), which does
| |
| 50 CustomElementsRegistry* registry = window->customElements(); | |
| 51 return registry && registry->nameIsDefined(name); | |
| 52 } | |
| 53 | |
| 54 bool V0CustomElementRegistry::nameIsDefined(const AtomicString& name) const | |
| 55 { | |
| 56 return m_registeredTypeNames.contains(name); | |
| 57 } | |
| 58 | |
| 41 V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* do cument, V0CustomElementConstructorBuilder* constructorBuilder, const AtomicStrin g& userSuppliedName, V0CustomElement::NameSet validNames, ExceptionState& except ionState) | 59 V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* do cument, V0CustomElementConstructorBuilder* constructorBuilder, const AtomicStrin g& userSuppliedName, V0CustomElement::NameSet validNames, ExceptionState& except ionState) |
| 42 { | 60 { |
| 43 AtomicString type = userSuppliedName.lower(); | 61 AtomicString type = userSuppliedName.lower(); |
| 44 | 62 |
| 45 if (!constructorBuilder->isFeatureAllowed()) { | 63 if (!constructorBuilder->isFeatureAllowed()) { |
| 46 V0CustomElementException::throwException(V0CustomElementException::Canno tRegisterFromExtension, type, exceptionState); | 64 V0CustomElementException::throwException(V0CustomElementException::Canno tRegisterFromExtension, type, exceptionState); |
| 47 return 0; | 65 return 0; |
| 48 } | 66 } |
| 49 | 67 |
| 50 if (!V0CustomElement::isValidName(type, validNames)) { | 68 if (!V0CustomElement::isValidName(type, validNames)) { |
| 51 V0CustomElementException::throwException(V0CustomElementException::Inval idName, type, exceptionState); | 69 V0CustomElementException::throwException(V0CustomElementException::Inval idName, type, exceptionState); |
| 52 return 0; | 70 return 0; |
| 53 } | 71 } |
| 54 | 72 |
| 55 if (m_registeredTypeNames.contains(type)) { | 73 if (m_registeredTypeNames.contains(type) || v1CustomElementIsDefined(type)) { |
| 56 V0CustomElementException::throwException(V0CustomElementException::TypeA lreadyRegistered, type, exceptionState); | 74 V0CustomElementException::throwException(V0CustomElementException::TypeA lreadyRegistered, type, exceptionState); |
| 57 return 0; | 75 return 0; |
| 58 } | 76 } |
| 59 | 77 |
| 60 QualifiedName tagName = QualifiedName::null(); | 78 QualifiedName tagName = QualifiedName::null(); |
| 61 if (!constructorBuilder->validateOptions(type, tagName, exceptionState)) | 79 if (!constructorBuilder->validateOptions(type, tagName, exceptionState)) |
| 62 return 0; | 80 return 0; |
| 63 | 81 |
| 64 DCHECK(tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI || tagName.nam espaceURI() == SVGNames::svgNamespaceURI); | 82 DCHECK(tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI || tagName.nam espaceURI() == SVGNames::svgNamespaceURI); |
| 65 | 83 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 95 { | 113 { |
| 96 return m_definitions.get(descriptor); | 114 return m_definitions.get(descriptor); |
| 97 } | 115 } |
| 98 | 116 |
| 99 DEFINE_TRACE(V0CustomElementRegistry) | 117 DEFINE_TRACE(V0CustomElementRegistry) |
| 100 { | 118 { |
| 101 visitor->trace(m_definitions); | 119 visitor->trace(m_definitions); |
| 102 } | 120 } |
| 103 | 121 |
| 104 } // namespace blink | 122 } // namespace blink |
| OLD | NEW |