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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 if (exceptionState.hadException()) 732 if (exceptionState.hadException())
733 return 0; 733 return 0;
734 } 734 }
735 735
736 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isEmpt y()) 736 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isEmpt y())
737 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 737 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
738 738
739 return element; 739 return element;
740 } 740 }
741 741
742 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
743 {
744 AtomicString prefix, localName;
745 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
746 return 0;
747
748 QualifiedName qName(prefix, localName, namespaceURI);
749 if (!hasValidNamespaceForElements(qName)) {
750 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
751 return 0;
752 }
753
754 return createElement(qName, false);
755 }
756
742 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState) 757 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState)
743 { 758 {
744 AtomicString prefix, localName; 759 AtomicString prefix, localName;
745 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) 760 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
746 return 0; 761 return 0;
747 762
748 QualifiedName qName(prefix, localName, namespaceURI); 763 QualifiedName qName(prefix, localName, namespaceURI);
749 if (!hasValidNamespaceForElements(qName)) { 764 if (!hasValidNamespaceForElements(qName)) {
750 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 765 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
751 return 0; 766 return 0;
752 } 767 }
753 768
754 RefPtr<Element> element; 769 RefPtr<Element> element;
755 if (CustomElement::isValidName(qName.localName()) && registrationContext()) { 770 if (CustomElement::isValidName(qName.localName()) && registrationContext())
756 element = registrationContext()->createCustomTagElement(*this, qName); 771 element = registrationContext()->createCustomTagElement(*this, qName);
757 } else { 772 else
758 element = createElementNS(namespaceURI, qualifiedName, exceptionState); 773 element = createElement(qName, false);
dominicc (has gone to gerrit) 2014/02/13 04:02:42 Could you factor the checks for createElementNS in
759 if (exceptionState.hadException())
760 return 0;
761 }
762 774
763 if (!typeExtension.isEmpty()) 775 if (!typeExtension.isEmpty())
764 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 776 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
765 777
766 return element; 778 return element;
767 } 779 }
768 780
769 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& exceptionState) 781 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& exceptionState)
770 { 782 {
771 return registerElement(state, name, Dictionary(), exceptionState); 783 return registerElement(state, name, Dictionary(), exceptionState);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 } 1060 }
1049 1061
1050 NamedFlowCollection* Document::namedFlows() 1062 NamedFlowCollection* Document::namedFlows()
1051 { 1063 {
1052 if (!m_namedFlows) 1064 if (!m_namedFlows)
1053 m_namedFlows = NamedFlowCollection::create(this); 1065 m_namedFlows = NamedFlowCollection::create(this);
1054 1066
1055 return m_namedFlows.get(); 1067 return m_namedFlows.get();
1056 } 1068 }
1057 1069
1058 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
1059 {
1060 AtomicString prefix, localName;
1061 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
1062 return 0;
1063
1064 QualifiedName qName(prefix, localName, namespaceURI);
1065 if (!hasValidNamespaceForElements(qName)) {
1066 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
1067 return 0;
1068 }
1069
1070 return createElement(qName, false);
1071 }
1072
1073 String Document::readyState() const 1070 String Document::readyState() const
1074 { 1071 {
1075 DEFINE_STATIC_LOCAL(const String, loading, ("loading")); 1072 DEFINE_STATIC_LOCAL(const String, loading, ("loading"));
1076 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive")); 1073 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive"));
1077 DEFINE_STATIC_LOCAL(const String, complete, ("complete")); 1074 DEFINE_STATIC_LOCAL(const String, complete, ("complete"));
1078 1075
1079 switch (m_readyState) { 1076 switch (m_readyState) {
1080 case Loading: 1077 case Loading:
1081 return loading; 1078 return loading;
1082 case Interactive: 1079 case Interactive:
(...skipping 4365 matching lines...) Expand 10 before | Expand all | Expand 10 after
5448 void Document::defaultEventHandler(Event* event) 5445 void Document::defaultEventHandler(Event* event)
5449 { 5446 {
5450 if (frame() && frame()->remotePlatformLayer()) { 5447 if (frame() && frame()->remotePlatformLayer()) {
5451 frame()->chromeClient().forwardInputEvent(this, event); 5448 frame()->chromeClient().forwardInputEvent(this, event);
5452 return; 5449 return;
5453 } 5450 }
5454 Node::defaultEventHandler(event); 5451 Node::defaultEventHandler(event);
5455 } 5452 }
5456 5453
5457 } // namespace WebCore 5454 } // namespace WebCore
OLDNEW
« 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