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

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

Issue 2258023003: Remove first argument for shoudCreateCustomElement() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/CustomElement.h" 5 #include "core/dom/custom/CustomElement.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/QualifiedName.h" 8 #include "core/dom/QualifiedName.h"
9 #include "core/dom/custom/CEReactionsScope.h" 9 #include "core/dom/custom/CEReactionsScope.h"
10 #include "core/dom/custom/CustomElementDefinition.h" 10 #include "core/dom/custom/CustomElementDefinition.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 "font-face", 71 "font-face",
72 "font-face-src", 72 "font-face-src",
73 "font-face-uri", 73 "font-face-uri",
74 "font-face-format", 74 "font-face-format",
75 "font-face-name", 75 "font-face-name",
76 "missing-glyph", 76 "missing-glyph",
77 })); 77 }));
78 return !hyphenContainingElementNames.contains(name); 78 return !hyphenContainingElementNames.contains(name);
79 } 79 }
80 80
81 bool CustomElement::shouldCreateCustomElement(Document& document, const AtomicSt ring& localName) 81 bool CustomElement::shouldCreateCustomElement(const AtomicString& localName)
82 { 82 {
83 return RuntimeEnabledFeatures::customElementsV1Enabled() 83 return RuntimeEnabledFeatures::customElementsV1Enabled()
84 && isValidName(localName); 84 && isValidName(localName);
85 } 85 }
86 86
87 bool CustomElement::shouldCreateCustomElement(Document& document, const Qualifie dName& tagName) 87 bool CustomElement::shouldCreateCustomElement(const QualifiedName& tagName)
88 { 88 {
89 return shouldCreateCustomElement(document, tagName.localName()) 89 return shouldCreateCustomElement(tagName.localName())
90 && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI; 90 && tagName.namespaceURI() == HTMLNames::xhtmlNamespaceURI;
91 } 91 }
92 92
93 static CustomElementDefinition* definitionForName(const Document& document, cons t QualifiedName& name) 93 static CustomElementDefinition* definitionForName(const Document& document, cons t QualifiedName& name)
94 { 94 {
95 if (CustomElementsRegistry* registry = CustomElement::registry(document)) 95 if (CustomElementsRegistry* registry = CustomElement::registry(document))
96 return registry->definitionForName(name.localName()); 96 return registry->definitionForName(name.localName());
97 return nullptr; 97 return nullptr;
98 } 98 }
99 99
100 HTMLElement* CustomElement::createCustomElementSync(Document& document, const At omicString& localName, ExceptionState& exceptionState) 100 HTMLElement* CustomElement::createCustomElementSync(Document& document, const At omicString& localName, ExceptionState& exceptionState)
101 { 101 {
102 return createCustomElementSync(document, 102 return createCustomElementSync(document,
103 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI), 103 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI),
104 exceptionState); 104 exceptionState);
105 } 105 }
106 106
107 HTMLElement* CustomElement::createCustomElementSync(Document& document, const Qu alifiedName& tagName, ExceptionState& exceptionState) 107 HTMLElement* CustomElement::createCustomElementSync(Document& document, const Qu alifiedName& tagName, ExceptionState& exceptionState)
108 { 108 {
109 CHECK(shouldCreateCustomElement(document, tagName)); 109 CHECK(shouldCreateCustomElement(tagName));
110 110
111 // To create an element: 111 // To create an element:
112 // https://dom.spec.whatwg.org/#concept-create-element 112 // https://dom.spec.whatwg.org/#concept-create-element
113 // 6. If definition is non-null, then: 113 // 6. If definition is non-null, then:
114 // 6.1. If the synchronous custom elements flag is set: 114 // 6.1. If the synchronous custom elements flag is set:
115 if (CustomElementDefinition* definition = definitionForName(document, tagNam e)) 115 if (CustomElementDefinition* definition = definitionForName(document, tagNam e))
116 return definition->createElementSync(document, tagName, exceptionState); 116 return definition->createElementSync(document, tagName, exceptionState);
117 117
118 return createUndefinedElement(document, tagName); 118 return createUndefinedElement(document, tagName);
119 } 119 }
120 120
121 HTMLElement* CustomElement::createCustomElementSync(Document& document, const Qu alifiedName& tagName) 121 HTMLElement* CustomElement::createCustomElementSync(Document& document, const Qu alifiedName& tagName)
122 { 122 {
123 CHECK(shouldCreateCustomElement(document, tagName)); 123 CHECK(shouldCreateCustomElement(tagName));
124 124
125 // When invoked from "create an element for a token": 125 // When invoked from "create an element for a token":
126 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for- the-token 126 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for- the-token
127 // 7. If this step throws an exception, then report the exception, 127 // 7. If this step throws an exception, then report the exception,
128 // and let element be instead a new element that implements 128 // and let element be instead a new element that implements
129 // HTMLUnknownElement. 129 // HTMLUnknownElement.
130 if (CustomElementDefinition* definition = definitionForName(document, tagNam e)) 130 if (CustomElementDefinition* definition = definitionForName(document, tagNam e))
131 return definition->createElementSync(document, tagName); 131 return definition->createElementSync(document, tagName);
132 132
133 return createUndefinedElement(document, tagName); 133 return createUndefinedElement(document, tagName);
134 } 134 }
135 135
136 HTMLElement* CustomElement::createCustomElementAsync(Document& document, const Q ualifiedName& tagName) 136 HTMLElement* CustomElement::createCustomElementAsync(Document& document, const Q ualifiedName& tagName)
137 { 137 {
138 CHECK(shouldCreateCustomElement(document, tagName)); 138 CHECK(shouldCreateCustomElement(tagName));
139 139
140 // To create an element: 140 // To create an element:
141 // https://dom.spec.whatwg.org/#concept-create-element 141 // https://dom.spec.whatwg.org/#concept-create-element
142 // 6. If definition is non-null, then: 142 // 6. If definition is non-null, then:
143 // 6.2. If the synchronous custom elements flag is not set: 143 // 6.2. If the synchronous custom elements flag is not set:
144 if (CustomElementDefinition* definition = definitionForName(document, tagNam e)) 144 if (CustomElementDefinition* definition = definitionForName(document, tagNam e))
145 return definition->createElementAsync(document, tagName); 145 return definition->createElementAsync(document, tagName);
146 146
147 return createUndefinedElement(document, tagName); 147 return createUndefinedElement(document, tagName);
148 } 148 }
149 149
150 HTMLElement* CustomElement::createUndefinedElement(Document& document, const Qua lifiedName& tagName) 150 HTMLElement* CustomElement::createUndefinedElement(Document& document, const Qua lifiedName& tagName)
151 { 151 {
152 DCHECK(shouldCreateCustomElement(document, tagName)); 152 DCHECK(shouldCreateCustomElement(tagName));
153 153
154 HTMLElement* element; 154 HTMLElement* element;
155 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati onContext()) { 155 if (V0CustomElement::isValidName(tagName.localName()) && document.registrati onContext()) {
156 Element* v0element = document.registrationContext()->createCustomTagElem ent(document, tagName); 156 Element* v0element = document.registrationContext()->createCustomTagElem ent(document, tagName);
157 SECURITY_DCHECK(v0element->isHTMLElement()); 157 SECURITY_DCHECK(v0element->isHTMLElement());
158 element = toHTMLElement(v0element); 158 element = toHTMLElement(v0element);
159 } else { 159 } else {
160 element = HTMLElement::create(tagName, document); 160 element = HTMLElement::create(tagName, document);
161 } 161 }
162 162
163 element->setCustomElementState(CustomElementState::Undefined); 163 element->setCustomElementState(CustomElementState::Undefined);
164 164
165 return element; 165 return element;
166 } 166 }
167 167
168 HTMLElement* CustomElement::createFailedElement(Document& document, const Qualif iedName& tagName) 168 HTMLElement* CustomElement::createFailedElement(Document& document, const Qualif iedName& tagName)
169 { 169 {
170 DCHECK(shouldCreateCustomElement(document, tagName)); 170 DCHECK(shouldCreateCustomElement(tagName));
171 171
172 // "create an element for a token": 172 // "create an element for a token":
173 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for- the-token 173 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for- the-token
174 174
175 // 7. If this step throws an exception, let element be instead a new element 175 // 7. If this step throws an exception, let element be instead a new element
176 // that implements HTMLUnknownElement, with no attributes, namespace set to 176 // that implements HTMLUnknownElement, with no attributes, namespace set to
177 // given namespace, namespace prefix set to null, custom element state set 177 // given namespace, namespace prefix set to null, custom element state set
178 // to "failed", and node document set to document. 178 // to "failed", and node document set to document.
179 179
180 HTMLElement* element = HTMLUnknownElement::create(tagName, document); 180 HTMLElement* element = HTMLUnknownElement::create(tagName, document);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 CustomElementsRegistry* registry = CustomElement::registry(*element); 240 CustomElementsRegistry* registry = CustomElement::registry(*element);
241 if (!registry) 241 if (!registry)
242 return; 242 return;
243 if (CustomElementDefinition* definition = registry->definitionForName(elemen t->localName())) 243 if (CustomElementDefinition* definition = registry->definitionForName(elemen t->localName()))
244 definition->enqueueUpgradeReaction(element); 244 definition->enqueueUpgradeReaction(element);
245 else 245 else
246 registry->addCandidate(element); 246 registry->addCandidate(element);
247 } 247 }
248 248
249 } // namespace blink 249 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/custom/CustomElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698