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

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

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/MessagePort.cpp » ('j') | 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 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
8 * (C) 2007 Eric Seidel (eric@webkit.org) 8 * (C) 2007 Eric Seidel (eric@webkit.org)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 824 }
825 825
826 const AtomicString& Element::getAttributeNS(const AtomicString& namespaceURI, co nst AtomicString& localName) const 826 const AtomicString& Element::getAttributeNS(const AtomicString& namespaceURI, co nst AtomicString& localName) const
827 { 827 {
828 return getAttribute(QualifiedName(nullAtom, localName, namespaceURI)); 828 return getAttribute(QualifiedName(nullAtom, localName, namespaceURI));
829 } 829 }
830 830
831 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& es) 831 void Element::setAttribute(const AtomicString& localName, const AtomicString& va lue, ExceptionState& es)
832 { 832 {
833 if (!Document::isValidName(localName)) { 833 if (!Document::isValidName(localName)) {
834 es.throwDOMException(InvalidCharacterError); 834 es.throwUninformativeAndGenericDOMException(InvalidCharacterError);
835 return; 835 return;
836 } 836 }
837 837
838 synchronizeAttribute(localName); 838 synchronizeAttribute(localName);
839 const AtomicString& caseAdjustedLocalName = shouldIgnoreAttributeCase(this) ? localName.lower() : localName; 839 const AtomicString& caseAdjustedLocalName = shouldIgnoreAttributeCase(this) ? localName.lower() : localName;
840 840
841 size_t index = elementData() ? elementData()->getAttributeItemIndex(caseAdju stedLocalName, false) : kNotFound; 841 size_t index = elementData() ? elementData()->getAttributeItemIndex(caseAdju stedLocalName, false) : kNotFound;
842 const QualifiedName& qName = index != kNotFound ? attributeItem(index)->name () : QualifiedName(nullAtom, caseAdjustedLocalName, nullAtom); 842 const QualifiedName& qName = index != kNotFound ? attributeItem(index)->name () : QualifiedName(nullAtom, caseAdjustedLocalName, nullAtom);
843 setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribut e); 843 setAttributeInternal(index, qName, value, NotInSynchronizationOfLazyAttribut e);
844 } 844 }
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 if (alwaysCreateUserAgentShadowRoot()) 1599 if (alwaysCreateUserAgentShadowRoot())
1600 ensureUserAgentShadowRoot(); 1600 ensureUserAgentShadowRoot();
1601 1601
1602 if (RuntimeEnabledFeatures::authorShadowDOMForAnyElementEnabled()) 1602 if (RuntimeEnabledFeatures::authorShadowDOMForAnyElementEnabled())
1603 return ensureShadow()->addShadowRoot(this, ShadowRoot::AuthorShadowRoot) ; 1603 return ensureShadow()->addShadowRoot(this, ShadowRoot::AuthorShadowRoot) ;
1604 1604
1605 // Since some elements recreates shadow root dynamically, multiple shadow 1605 // Since some elements recreates shadow root dynamically, multiple shadow
1606 // subtrees won't work well in that element. Until they are fixed, we disabl e 1606 // subtrees won't work well in that element. Until they are fixed, we disabl e
1607 // adding author shadow root for them. 1607 // adding author shadow root for them.
1608 if (!areAuthorShadowsAllowed()) { 1608 if (!areAuthorShadowsAllowed()) {
1609 es.throwDOMException(HierarchyRequestError); 1609 es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
1610 return 0; 1610 return 0;
1611 } 1611 }
1612 return ensureShadow()->addShadowRoot(this, ShadowRoot::AuthorShadowRoot); 1612 return ensureShadow()->addShadowRoot(this, ShadowRoot::AuthorShadowRoot);
1613 } 1613 }
1614 1614
1615 ShadowRoot* Element::shadowRoot() const 1615 ShadowRoot* Element::shadowRoot() const
1616 { 1616 {
1617 ElementShadow* elementShadow = shadow(); 1617 ElementShadow* elementShadow = shadow();
1618 if (!elementShadow) 1618 if (!elementShadow)
1619 return 0; 1619 return 0;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 1807
1808 const Vector<RefPtr<Attr> >& Element::attrNodeList() 1808 const Vector<RefPtr<Attr> >& Element::attrNodeList()
1809 { 1809 {
1810 ASSERT(hasSyntheticAttrChildNodes()); 1810 ASSERT(hasSyntheticAttrChildNodes());
1811 return *attrNodeListForElement(this); 1811 return *attrNodeListForElement(this);
1812 } 1812 }
1813 1813
1814 PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& es) 1814 PassRefPtr<Attr> Element::setAttributeNode(Attr* attrNode, ExceptionState& es)
1815 { 1815 {
1816 if (!attrNode) { 1816 if (!attrNode) {
1817 es.throwDOMException(TypeMismatchError); 1817 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
1818 return 0; 1818 return 0;
1819 } 1819 }
1820 1820
1821 RefPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName()); 1821 RefPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName());
1822 if (oldAttrNode.get() == attrNode) 1822 if (oldAttrNode.get() == attrNode)
1823 return attrNode; // This Attr is already attached to the element. 1823 return attrNode; // This Attr is already attached to the element.
1824 1824
1825 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object. 1825 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object.
1826 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments. 1826 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments.
1827 if (attrNode->ownerElement()) { 1827 if (attrNode->ownerElement()) {
1828 es.throwDOMException(InUseAttributeError); 1828 es.throwUninformativeAndGenericDOMException(InUseAttributeError);
1829 return 0; 1829 return 0;
1830 } 1830 }
1831 1831
1832 synchronizeAllAttributes(); 1832 synchronizeAllAttributes();
1833 UniqueElementData* elementData = ensureUniqueElementData(); 1833 UniqueElementData* elementData = ensureUniqueElementData();
1834 1834
1835 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase(this)); 1835 size_t index = elementData->getAttributeItemIndex(attrNode->qualifiedName(), shouldIgnoreAttributeCase(this));
1836 if (index != kNotFound) { 1836 if (index != kNotFound) {
1837 if (oldAttrNode) 1837 if (oldAttrNode)
1838 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value()); 1838 detachAttrNodeFromElementWithValue(oldAttrNode.get(), elementData->a ttributeItem(index)->value());
(...skipping 11 matching lines...) Expand all
1850 } 1850 }
1851 1851
1852 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es) 1852 PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState& es)
1853 { 1853 {
1854 return setAttributeNode(attr, es); 1854 return setAttributeNode(attr, es);
1855 } 1855 }
1856 1856
1857 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es) 1857 PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState& es)
1858 { 1858 {
1859 if (!attr) { 1859 if (!attr) {
1860 es.throwDOMException(TypeMismatchError); 1860 es.throwUninformativeAndGenericDOMException(TypeMismatchError);
1861 return 0; 1861 return 0;
1862 } 1862 }
1863 if (attr->ownerElement() != this) { 1863 if (attr->ownerElement() != this) {
1864 es.throwDOMException(NotFoundError); 1864 es.throwUninformativeAndGenericDOMException(NotFoundError);
1865 return 0; 1865 return 0;
1866 } 1866 }
1867 1867
1868 ASSERT(&document() == &attr->document()); 1868 ASSERT(&document() == &attr->document());
1869 1869
1870 synchronizeAttribute(attr->qualifiedName()); 1870 synchronizeAttribute(attr->qualifiedName());
1871 1871
1872 size_t index = elementData()->getAttrIndex(attr); 1872 size_t index = elementData()->getAttrIndex(attr);
1873 if (index == kNotFound) { 1873 if (index == kNotFound) {
1874 es.throwDOMException(NotFoundError); 1874 es.throwUninformativeAndGenericDOMException(NotFoundError);
1875 return 0; 1875 return 0;
1876 } 1876 }
1877 1877
1878 RefPtr<Attr> guard(attr); 1878 RefPtr<Attr> guard(attr);
1879 detachAttrNodeAtIndex(attr, index); 1879 detachAttrNodeAtIndex(attr, index);
1880 return guard.release(); 1880 return guard.release();
1881 } 1881 }
1882 1882
1883 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& es) 1883 bool Element::parseAttributeName(QualifiedName& out, const AtomicString& namespa ceURI, const AtomicString& qualifiedName, ExceptionState& es)
1884 { 1884 {
1885 String prefix, localName; 1885 String prefix, localName;
1886 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, es)) 1886 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, es))
1887 return false; 1887 return false;
1888 ASSERT(!es.hadException()); 1888 ASSERT(!es.hadException());
1889 1889
1890 QualifiedName qName(prefix, localName, namespaceURI); 1890 QualifiedName qName(prefix, localName, namespaceURI);
1891 1891
1892 if (!Document::hasValidNamespaceForAttributes(qName)) { 1892 if (!Document::hasValidNamespaceForAttributes(qName)) {
1893 es.throwDOMException(NamespaceError); 1893 es.throwUninformativeAndGenericDOMException(NamespaceError);
1894 return false; 1894 return false;
1895 } 1895 }
1896 1896
1897 out = qName; 1897 out = qName;
1898 return true; 1898 return true;
1899 } 1899 }
1900 1900
1901 void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicStrin g& qualifiedName, const AtomicString& value, ExceptionState& es) 1901 void Element::setAttributeNS(const AtomicString& namespaceURI, const AtomicStrin g& qualifiedName, const AtomicString& value, ExceptionState& es)
1902 { 1902 {
1903 QualifiedName parsedName = anyName; 1903 QualifiedName parsedName = anyName;
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2499 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const 2499 RenderObject* Element::pseudoElementRenderer(PseudoId pseudoId) const
2500 { 2500 {
2501 if (PseudoElement* element = pseudoElement(pseudoId)) 2501 if (PseudoElement* element = pseudoElement(pseudoId))
2502 return element->renderer(); 2502 return element->renderer();
2503 return 0; 2503 return 0;
2504 } 2504 }
2505 2505
2506 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es) 2506 bool Element::webkitMatchesSelector(const String& selector, ExceptionState& es)
2507 { 2507 {
2508 if (selector.isEmpty()) { 2508 if (selector.isEmpty()) {
2509 es.throwDOMException(SyntaxError); 2509 es.throwUninformativeAndGenericDOMException(SyntaxError);
2510 return false; 2510 return false;
2511 } 2511 }
2512 2512
2513 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector , document(), es); 2513 SelectorQuery* selectorQuery = document().selectorQueryCache()->add(selector , document(), es);
2514 if (!selectorQuery) 2514 if (!selectorQuery)
2515 return false; 2515 return false;
2516 return selectorQuery->matches(this); 2516 return selectorQuery->matches(this);
2517 } 2517 }
2518 2518
2519 DOMTokenList* Element::classList() 2519 DOMTokenList* Element::classList()
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3642 return 0; 3642 return 0;
3643 } 3643 }
3644 3644
3645 Attribute* UniqueElementData::attributeItem(unsigned index) 3645 Attribute* UniqueElementData::attributeItem(unsigned index)
3646 { 3646 {
3647 ASSERT_WITH_SECURITY_IMPLICATION(index < length()); 3647 ASSERT_WITH_SECURITY_IMPLICATION(index < length());
3648 return &m_attributeVector.at(index); 3648 return &m_attributeVector.at(index);
3649 } 3649 }
3650 3650
3651 } // namespace WebCore 3651 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/MessagePort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698