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

Unified Diff: Source/core/dom/Document.cpp

Issue 137863004: Avoid checks in createElementNS overload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 90e8afb08463db1fc27d15d38f0514117fc655b1..a5b5ff5d3a011d247c967bf1ffaa355c2d21a03f 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -739,6 +739,21 @@ PassRefPtr<Element> Document::createElement(const AtomicString& localName, const
return element;
}
+PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
+{
+ AtomicString prefix, localName;
+ if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
+ return 0;
+
+ QualifiedName qName(prefix, localName, namespaceURI);
+ if (!hasValidNamespaceForElements(qName)) {
+ exceptionState.throwDOMException(NamespaceError, "The namespace URI provided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
+ return 0;
+ }
+
+ return createElement(qName, false);
+}
+
PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionState& exceptionState)
{
AtomicString prefix, localName;
@@ -752,13 +767,10 @@ PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI,
}
RefPtr<Element> element;
- if (CustomElement::isValidName(qName.localName()) && registrationContext()) {
+ if (CustomElement::isValidName(qName.localName()) && registrationContext())
element = registrationContext()->createCustomTagElement(*this, qName);
- } else {
- element = createElementNS(namespaceURI, qualifiedName, exceptionState);
- if (exceptionState.hadException())
- return 0;
- }
+ else
+ element = createElement(qName, false);
dominicc (has gone to gerrit) 2014/02/13 04:02:42 Could you factor the checks for createElementNS in
if (!typeExtension.isEmpty())
CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element.get(), typeExtension);
@@ -1055,21 +1067,6 @@ NamedFlowCollection* Document::namedFlows()
return m_namedFlows.get();
}
-PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
-{
- AtomicString prefix, localName;
- if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
- return 0;
-
- QualifiedName qName(prefix, localName, namespaceURI);
- if (!hasValidNamespaceForElements(qName)) {
- exceptionState.throwDOMException(NamespaceError, "The namespace URI provided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
- return 0;
- }
-
- return createElement(qName, false);
-}
-
String Document::readyState() const
{
DEFINE_STATIC_LOCAL(const String, loading, ("loading"));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698