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

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

Issue 2443543002: createElement should not transmit exceptions but report them. (Closed)
Patch Set: Rebaseline tests. Created 4 years, 1 month 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 // 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 71
72 static CustomElementDefinition* definitionForName(const Document& document, 72 static CustomElementDefinition* definitionForName(const Document& document,
73 const QualifiedName& name) { 73 const QualifiedName& name) {
74 if (CustomElementRegistry* registry = CustomElement::registry(document)) 74 if (CustomElementRegistry* registry = CustomElement::registry(document))
75 return registry->definitionForName(name.localName()); 75 return registry->definitionForName(name.localName());
76 return nullptr; 76 return nullptr;
77 } 77 }
78 78
79 HTMLElement* CustomElement::createCustomElementSync( 79 HTMLElement* CustomElement::createCustomElementSync(
80 Document& document, 80 Document& document,
81 const AtomicString& localName, 81 const AtomicString& localName) {
82 ExceptionState& exceptionState) {
83 return createCustomElementSync( 82 return createCustomElementSync(
84 document, 83 document,
85 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI), 84 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI));
86 exceptionState);
87 }
88
89 HTMLElement* CustomElement::createCustomElementSync(
90 Document& document,
91 const QualifiedName& tagName,
92 ExceptionState& exceptionState) {
93 DCHECK(shouldCreateCustomElement(tagName));
94
95 // To create an element:
96 // https://dom.spec.whatwg.org/#concept-create-element
97 // 6. If definition is non-null, then:
98 // 6.1. If the synchronous custom elements flag is set:
99 if (CustomElementDefinition* definition =
100 definitionForName(document, tagName))
101 return definition->createElementSync(document, tagName, exceptionState);
102
103 return createUndefinedElement(document, tagName);
104 } 85 }
105 86
106 HTMLElement* CustomElement::createCustomElementSync( 87 HTMLElement* CustomElement::createCustomElementSync(
107 Document& document, 88 Document& document,
108 const QualifiedName& tagName) { 89 const QualifiedName& tagName) {
109 DCHECK(shouldCreateCustomElement(tagName)); 90 DCHECK(shouldCreateCustomElement(tagName));
110
111 // When invoked from "create an element for a token":
112 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-th e-token
113 // 7. If this step throws an exception, then report the exception,
114 // and let element be instead a new element that implements
115 // HTMLUnknownElement.
116 if (CustomElementDefinition* definition = 91 if (CustomElementDefinition* definition =
117 definitionForName(document, tagName)) 92 definitionForName(document, tagName))
118 return definition->createElementSync(document, tagName); 93 return definition->createElementSync(document, tagName);
119
120 return createUndefinedElement(document, tagName); 94 return createUndefinedElement(document, tagName);
121 } 95 }
122 96
123 HTMLElement* CustomElement::createCustomElementAsync( 97 HTMLElement* CustomElement::createCustomElementAsync(
124 Document& document, 98 Document& document,
125 const QualifiedName& tagName) { 99 const QualifiedName& tagName) {
126 DCHECK(shouldCreateCustomElement(tagName)); 100 DCHECK(shouldCreateCustomElement(tagName));
127 101
128 // To create an element: 102 // To create an element:
129 // https://dom.spec.whatwg.org/#concept-create-element 103 // https://dom.spec.whatwg.org/#concept-create-element
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (!registry) 210 if (!registry)
237 return; 211 return;
238 if (CustomElementDefinition* definition = 212 if (CustomElementDefinition* definition =
239 registry->definitionForName(element->localName())) 213 registry->definitionForName(element->localName()))
240 definition->enqueueUpgradeReaction(element); 214 definition->enqueueUpgradeReaction(element);
241 else 215 else
242 registry->addCandidate(element); 216 registry->addCandidate(element);
243 } 217 }
244 218
245 } // namespace blink 219 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698