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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 112353004: Add ExceptionState checks in Document::createElement*() methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 698
699 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& exceptionState) 699 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& exceptionState)
700 { 700 {
701 if (!isValidName(localName)) { 701 if (!isValidName(localName)) {
702 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter Error); 702 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter Error);
703 return 0; 703 return 0;
704 } 704 }
705 705
706 RefPtr<Element> element; 706 RefPtr<Element> element;
707 707
708 if (RuntimeEnabledFeatures::customElementsEnabled() && CustomElement::isVali dName(localName) && registrationContext()) 708 if (RuntimeEnabledFeatures::customElementsEnabled() && CustomElement::isVali dName(localName) && registrationContext()) {
709 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI)); 709 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI));
710 else 710 } else {
711 element = createElement(localName, exceptionState); 711 element = createElement(localName, exceptionState);
712 if (exceptionState.hadException())
713 return 0;
714 }
712 715
713 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isNull () && !typeExtension.isEmpty()) 716 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isNull () && !typeExtension.isEmpty())
714 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 717 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
715 718
716 return element; 719 return element;
717 } 720 }
718 721
719 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState) 722 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState)
720 { 723 {
721 AtomicString prefix, localName; 724 AtomicString prefix, localName;
722 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) 725 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
723 return 0; 726 return 0;
724 727
725 QualifiedName qName(prefix, localName, namespaceURI); 728 QualifiedName qName(prefix, localName, namespaceURI);
726 if (!hasValidNamespaceForElements(qName)) { 729 if (!hasValidNamespaceForElements(qName)) {
727 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError); 730 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError);
728 return 0; 731 return 0;
729 } 732 }
730 733
731 RefPtr<Element> element; 734 RefPtr<Element> element;
732 if (CustomElement::isValidName(qName.localName()) && registrationContext()) 735 if (CustomElement::isValidName(qName.localName()) && registrationContext()) {
733 element = registrationContext()->createCustomTagElement(*this, qName); 736 element = registrationContext()->createCustomTagElement(*this, qName);
734 else 737 } else {
735 element = createElementNS(namespaceURI, qualifiedName, exceptionState); 738 element = createElementNS(namespaceURI, qualifiedName, exceptionState);
739 if (exceptionState.hadException())
740 return 0;
741 }
736 742
737 if (!typeExtension.isNull() && !typeExtension.isEmpty()) 743 if (!typeExtension.isNull() && !typeExtension.isEmpty())
738 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 744 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
739 745
740 return element; 746 return element;
741 } 747 }
742 748
743 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& exceptionState) 749 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& exceptionState)
744 { 750 {
745 return registerElement(state, name, Dictionary(), exceptionState); 751 return registerElement(state, name, Dictionary(), exceptionState);
(...skipping 4506 matching lines...) Expand 10 before | Expand all | Expand 10 after
5252 } 5258 }
5253 5259
5254 FastTextAutosizer* Document::fastTextAutosizer() 5260 FastTextAutosizer* Document::fastTextAutosizer()
5255 { 5261 {
5256 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5262 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5257 m_fastTextAutosizer = FastTextAutosizer::create(this); 5263 m_fastTextAutosizer = FastTextAutosizer::create(this);
5258 return m_fastTextAutosizer.get(); 5264 return m_fastTextAutosizer.get();
5259 } 5265 }
5260 5266
5261 } // namespace WebCore 5267 } // 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