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

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

Issue 969363002: Add [TypeChecking=Interface] to Element interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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
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 1895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 void Element::removeAttrNodeList() 1906 void Element::removeAttrNodeList()
1907 { 1907 {
1908 ASSERT(hasSyntheticAttrChildNodes()); 1908 ASSERT(hasSyntheticAttrChildNodes());
1909 if (hasRareData()) 1909 if (hasRareData())
1910 elementRareData()->removeAttrNodeList(); 1910 elementRareData()->removeAttrNodeList();
1911 setHasSyntheticAttrChildNodes(false); 1911 setHasSyntheticAttrChildNodes(false);
1912 } 1912 }
1913 1913
1914 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNode(Attr* attrNode, Exception State& exceptionState) 1914 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNode(Attr* attrNode, Exception State& exceptionState)
1915 { 1915 {
1916 if (!attrNode) {
1917 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr"));
1918 return nullptr;
1919 }
1920
1921 RefPtrWillBeRawPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName( )); 1916 RefPtrWillBeRawPtr<Attr> oldAttrNode = attrIfExists(attrNode->qualifiedName( ));
1922 if (oldAttrNode.get() == attrNode) 1917 if (oldAttrNode.get() == attrNode)
1923 return attrNode; // This Attr is already attached to the element. 1918 return attrNode; // This Attr is already attached to the element.
1924 1919
1925 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object. 1920 // InUseAttributeError: Raised if node is an Attr that is already an attribu te of another Element object.
1926 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments. 1921 // The DOM user must explicitly clone Attr nodes to re-use them in other ele ments.
1927 if (attrNode->ownerElement()) { 1922 if (attrNode->ownerElement()) {
1928 exceptionState.throwDOMException(InUseAttributeError, "The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned."); 1923 exceptionState.throwDOMException(InUseAttributeError, "The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned.");
1929 return nullptr; 1924 return nullptr;
1930 } 1925 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 return oldAttrNode.release(); 1960 return oldAttrNode.release();
1966 } 1961 }
1967 1962
1968 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionSt ate& exceptionState) 1963 PassRefPtrWillBeRawPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionSt ate& exceptionState)
1969 { 1964 {
1970 return setAttributeNode(attr, exceptionState); 1965 return setAttributeNode(attr, exceptionState);
1971 } 1966 }
1972 1967
1973 PassRefPtrWillBeRawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionS tate& exceptionState) 1968 PassRefPtrWillBeRawPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionS tate& exceptionState)
1974 { 1969 {
1975 if (!attr) {
1976 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Attr"));
1977 return nullptr;
1978 }
1979 if (attr->ownerElement() != this) { 1970 if (attr->ownerElement() != this) {
1980 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element."); 1971 exceptionState.throwDOMException(NotFoundError, "The node provided is ow ned by another element.");
1981 return nullptr; 1972 return nullptr;
1982 } 1973 }
1983 1974
1984 ASSERT(document() == attr->document()); 1975 ASSERT(document() == attr->document());
1985 1976
1986 synchronizeAttribute(attr->qualifiedName()); 1977 synchronizeAttribute(attr->qualifiedName());
1987 1978
1988 size_t index = elementData()->attributes().findIndex(attr); 1979 size_t index = elementData()->attributes().findIndex(attr);
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 return parent; 2373 return parent;
2383 } 2374 }
2384 if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "befo reEnd")) 2375 if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "befo reEnd"))
2385 return element; 2376 return element;
2386 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ; 2377 exceptionState.throwDOMException(SyntaxError, "The value provided ('" + wher e + "') is not one of 'beforeBegin', 'afterBegin', 'beforeEnd', or 'afterEnd'.") ;
2387 return nullptr; 2378 return nullptr;
2388 } 2379 }
2389 2380
2390 Element* Element::insertAdjacentElement(const String& where, Element* newChild, ExceptionState& exceptionState) 2381 Element* Element::insertAdjacentElement(const String& where, Element* newChild, ExceptionState& exceptionState)
2391 { 2382 {
2392 if (!newChild) {
2393 // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
2394 exceptionState.throwTypeError("The node provided is null.");
2395 return nullptr;
2396 }
2397
2398 Node* returnValue = insertAdjacent(where, newChild, exceptionState); 2383 Node* returnValue = insertAdjacent(where, newChild, exceptionState);
2399 return toElement(returnValue); 2384 return toElement(returnValue);
2400 } 2385 }
2401 2386
2402 void Element::insertAdjacentText(const String& where, const String& text, Except ionState& exceptionState) 2387 void Element::insertAdjacentText(const String& where, const String& text, Except ionState& exceptionState)
2403 { 2388 {
2404 insertAdjacent(where, document().createTextNode(text).get(), exceptionState) ; 2389 insertAdjacent(where, document().createTextNode(text).get(), exceptionState) ;
2405 } 2390 }
2406 2391
2407 void Element::insertAdjacentHTML(const String& where, const String& markup, Exce ptionState& exceptionState) 2392 void Element::insertAdjacentHTML(const String& where, const String& markup, Exce ptionState& exceptionState)
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 { 3366 {
3382 #if ENABLE(OILPAN) 3367 #if ENABLE(OILPAN)
3383 if (hasRareData()) 3368 if (hasRareData())
3384 visitor->trace(elementRareData()); 3369 visitor->trace(elementRareData());
3385 visitor->trace(m_elementData); 3370 visitor->trace(m_elementData);
3386 #endif 3371 #endif
3387 ContainerNode::trace(visitor); 3372 ContainerNode::trace(visitor);
3388 } 3373 }
3389 3374
3390 } // namespace blink 3375 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/fast/dynamic/insertAdjacentElement-expected.txt ('k') | Source/core/dom/Element.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698