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

Side by Side Diff: third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.cpp

Issue 1952893003: Implement custom element construction and some 'define' checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement feedback. Created 4 years, 7 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
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 13 matching lines...) Expand all
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
41 V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* do cument, V0CustomElementConstructorBuilder* constructorBuilder, const AtomicStrin g& userSuppliedName, V0CustomElement::NameSet validNames, ExceptionState& except ionState) 45 V0CustomElementDefinition* V0CustomElementRegistry::registerElement(Document* do cument, V0CustomElementConstructorBuilder* constructorBuilder, const AtomicStrin g& userSuppliedName, V0CustomElement::NameSet validNames, ExceptionState& except ionState)
42 { 46 {
43 AtomicString type = userSuppliedName.lower(); 47 AtomicString type = userSuppliedName.lower();
44 48
45 if (!constructorBuilder->isFeatureAllowed()) { 49 if (!constructorBuilder->isFeatureAllowed()) {
46 V0CustomElementException::throwException(V0CustomElementException::Canno tRegisterFromExtension, type, exceptionState); 50 V0CustomElementException::throwException(V0CustomElementException::Canno tRegisterFromExtension, type, exceptionState);
47 return 0; 51 return 0;
48 } 52 }
49 53
50 if (!V0CustomElement::isValidName(type, validNames)) { 54 if (!V0CustomElement::isValidName(type, validNames)) {
51 V0CustomElementException::throwException(V0CustomElementException::Inval idName, type, exceptionState); 55 V0CustomElementException::throwException(V0CustomElementException::Inval idName, type, exceptionState);
52 return 0; 56 return 0;
53 } 57 }
54 58
55 if (m_registeredTypeNames.contains(type)) { 59 if (m_registeredTypeNames.contains(type) || v1NameIsDefined(type)) {
56 V0CustomElementException::throwException(V0CustomElementException::TypeA lreadyRegistered, type, exceptionState); 60 V0CustomElementException::throwException(V0CustomElementException::TypeA lreadyRegistered, type, exceptionState);
57 return 0; 61 return 0;
58 } 62 }
59 63
60 QualifiedName tagName = QualifiedName::null(); 64 QualifiedName tagName = QualifiedName::null();
61 if (!constructorBuilder->validateOptions(type, tagName, exceptionState)) 65 if (!constructorBuilder->validateOptions(type, tagName, exceptionState))
62 return 0; 66 return 0;
63 67
64 DCHECK(tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI || tagName.nam espaceURI() == SVGNames::svgNamespaceURI); 68 DCHECK(tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI || tagName.nam espaceURI() == SVGNames::svgNamespaceURI);
65 69
(...skipping 23 matching lines...) Expand all
89 } 93 }
90 94
91 return definition; 95 return definition;
92 } 96 }
93 97
94 V0CustomElementDefinition* V0CustomElementRegistry::find(const V0CustomElementDe scriptor& descriptor) const 98 V0CustomElementDefinition* V0CustomElementRegistry::find(const V0CustomElementDe scriptor& descriptor) const
95 { 99 {
96 return m_definitions.get(descriptor); 100 return m_definitions.get(descriptor);
97 } 101 }
98 102
103 bool V0CustomElementRegistry::nameIsDefined(const AtomicString& name) const
104 {
105 return m_registeredTypeNames.contains(name);
106 }
107
108 void V0CustomElementRegistry::setV1(const CustomElementsRegistry* v1)
109 {
110 DCHECK(!m_v1.get());
111 m_v1 = v1;
112 }
113
114 bool V0CustomElementRegistry::v1NameIsDefined(const AtomicString& name) const
115 {
116 return m_v1.get() && m_v1->nameIsDefined(name);
117 }
118
99 DEFINE_TRACE(V0CustomElementRegistry) 119 DEFINE_TRACE(V0CustomElementRegistry)
100 { 120 {
101 visitor->trace(m_definitions); 121 visitor->trace(m_definitions);
122 visitor->trace(m_v1);
102 } 123 }
103 124
104 } // namespace blink 125 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/V0CustomElementRegistry.h ('k') | third_party/WebKit/Source/core/frame/DOMWindow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698