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

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

Issue 64113006: Rename es => exceptionState in core/dom (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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/NamedNodeMap.cpp ('k') | Source/core/dom/NodeIterator.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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return last; 441 return last;
442 last = currentElement->lastChild(); 442 last = currentElement->lastChild();
443 if (!last) 443 if (!last)
444 last = currentElement->pseudoElement(BEFORE); 444 last = currentElement->pseudoElement(BEFORE);
445 return last; 445 return last;
446 } 446 }
447 447
448 return lastChild(); 448 return lastChild();
449 } 449 }
450 450
451 void Node::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionStat e& es) 451 void Node::insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionStat e& exceptionState)
452 { 452 {
453 if (isContainerNode()) 453 if (isContainerNode())
454 toContainerNode(this)->insertBefore(newChild, refChild, es); 454 toContainerNode(this)->insertBefore(newChild, refChild, exceptionState);
455 else 455 else
456 es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToE xecute("insertBefore", "Node", "This node type does not support this method.")); 456 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::failedToExecute("insertBefore", "Node", "This node type does not support this method."));
457 } 457 }
458 458
459 void Node::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionStat e& es) 459 void Node::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionStat e& exceptionState)
460 { 460 {
461 if (isContainerNode()) 461 if (isContainerNode())
462 toContainerNode(this)->replaceChild(newChild, oldChild, es); 462 toContainerNode(this)->replaceChild(newChild, oldChild, exceptionState);
463 else 463 else
464 es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToE xecute("replaceChild", "Node", "This node type does not support this method.")); 464 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::failedToExecute("replaceChild", "Node", "This node type does not support this method."));
465 } 465 }
466 466
467 void Node::removeChild(Node* oldChild, ExceptionState& es) 467 void Node::removeChild(Node* oldChild, ExceptionState& exceptionState)
468 { 468 {
469 if (isContainerNode()) 469 if (isContainerNode())
470 toContainerNode(this)->removeChild(oldChild, es); 470 toContainerNode(this)->removeChild(oldChild, exceptionState);
471 else 471 else
472 es.throwDOMException(NotFoundError, ExceptionMessages::failedToExecute(" removeChild", "Node", "This node type does not support this method.")); 472 exceptionState.throwDOMException(NotFoundError, ExceptionMessages::faile dToExecute("removeChild", "Node", "This node type does not support this method." ));
473 } 473 }
474 474
475 void Node::appendChild(PassRefPtr<Node> newChild, ExceptionState& es) 475 void Node::appendChild(PassRefPtr<Node> newChild, ExceptionState& exceptionState )
476 { 476 {
477 if (isContainerNode()) 477 if (isContainerNode())
478 toContainerNode(this)->appendChild(newChild, es); 478 toContainerNode(this)->appendChild(newChild, exceptionState);
479 else 479 else
480 es.throwDOMException(HierarchyRequestError, ExceptionMessages::failedToE xecute("appendChild", "Node", "This node type does not support this method.")); 480 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::failedToExecute("appendChild", "Node", "This node type does not support this method."));
481 } 481 }
482 482
483 void Node::remove(ExceptionState& es) 483 void Node::remove(ExceptionState& exceptionState)
484 { 484 {
485 if (ContainerNode* parent = parentNode()) 485 if (ContainerNode* parent = parentNode())
486 parent->removeChild(this, es); 486 parent->removeChild(this, exceptionState);
487 } 487 }
488 488
489 void Node::normalize() 489 void Node::normalize()
490 { 490 {
491 // Go through the subtree beneath us, normalizing all nodes. This means that 491 // Go through the subtree beneath us, normalizing all nodes. This means that
492 // any two adjacent text nodes are merged and any empty text nodes are remov ed. 492 // any two adjacent text nodes are merged and any empty text nodes are remov ed.
493 493
494 RefPtr<Node> node = this; 494 RefPtr<Node> node = this;
495 while (Node* firstChild = node->firstChild()) 495 while (Node* firstChild = node->firstChild())
496 node = firstChild; 496 node = firstChild;
(...skipping 11 matching lines...) Expand all
508 node = NodeTraversal::nextPostOrder(*node); 508 node = NodeTraversal::nextPostOrder(*node);
509 } 509 }
510 } 510 }
511 511
512 const AtomicString& Node::prefix() const 512 const AtomicString& Node::prefix() const
513 { 513 {
514 // For nodes other than elements and attributes, the prefix is always null 514 // For nodes other than elements and attributes, the prefix is always null
515 return nullAtom; 515 return nullAtom;
516 } 516 }
517 517
518 void Node::setPrefix(const AtomicString& /*prefix*/, ExceptionState& es) 518 void Node::setPrefix(const AtomicString& /*prefix*/, ExceptionState& exceptionSt ate)
519 { 519 {
520 // The spec says that for nodes other than elements and attributes, prefix i s always null. 520 // The spec says that for nodes other than elements and attributes, prefix i s always null.
521 // It does not say what to do when the user tries to set the prefix on anoth er type of 521 // It does not say what to do when the user tries to set the prefix on anoth er type of
522 // node, however Mozilla throws a NamespaceError exception. 522 // node, however Mozilla throws a NamespaceError exception.
523 es.throwDOMException(NamespaceError, ExceptionMessages::failedToSet("prefix" , "Node", "Prefixes are only supported on element and attribute nodes.")); 523 exceptionState.throwDOMException(NamespaceError, ExceptionMessages::failedTo Set("prefix", "Node", "Prefixes are only supported on element and attribute node s."));
524 } 524 }
525 525
526 const AtomicString& Node::localName() const 526 const AtomicString& Node::localName() const
527 { 527 {
528 return nullAtom; 528 return nullAtom;
529 } 529 }
530 530
531 const AtomicString& Node::namespaceURI() const 531 const AtomicString& Node::namespaceURI() const
532 { 532 {
533 return nullAtom; 533 return nullAtom;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 NodeListsNodeData* Node::nodeLists() 824 NodeListsNodeData* Node::nodeLists()
825 { 825 {
826 return hasRareData() ? rareData()->nodeLists() : 0; 826 return hasRareData() ? rareData()->nodeLists() : 0;
827 } 827 }
828 828
829 void Node::clearNodeLists() 829 void Node::clearNodeLists()
830 { 830 {
831 rareData()->clearNodeLists(); 831 rareData()->clearNodeLists();
832 } 832 }
833 833
834 void Node::checkSetPrefix(const AtomicString& prefix, ExceptionState& es) 834 void Node::checkSetPrefix(const AtomicString& prefix, ExceptionState& exceptionS tate)
835 { 835 {
836 // Perform error checking as required by spec for setting Node.prefix. Used by 836 // Perform error checking as required by spec for setting Node.prefix. Used by
837 // Element::setPrefix() and Attr::setPrefix() 837 // Element::setPrefix() and Attr::setPrefix()
838 838
839 if (!prefix.isEmpty() && !Document::isValidName(prefix)) { 839 if (!prefix.isEmpty() && !Document::isValidName(prefix)) {
840 es.throwDOMException(InvalidCharacterError, ExceptionMessages::failedToS et("prefix", "Node", "The prefix '" + prefix + "' is not a valid name.")); 840 exceptionState.throwDOMException(InvalidCharacterError, ExceptionMessage s::failedToSet("prefix", "Node", "The prefix '" + prefix + "' is not a valid nam e."));
841 return; 841 return;
842 } 842 }
843 843
844 // FIXME: Raise NamespaceError if prefix is malformed per the Namespaces in XML specification. 844 // FIXME: Raise NamespaceError if prefix is malformed per the Namespaces in XML specification.
845 845
846 const AtomicString& nodeNamespaceURI = namespaceURI(); 846 const AtomicString& nodeNamespaceURI = namespaceURI();
847 if (nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) { 847 if (nodeNamespaceURI.isEmpty() && !prefix.isEmpty()) {
848 es.throwDOMException(NamespaceError, ExceptionMessages::failedToSet("pre fix", "Node", "No namespace is set, so a namespace prefix may not be set.")); 848 exceptionState.throwDOMException(NamespaceError, ExceptionMessages::fail edToSet("prefix", "Node", "No namespace is set, so a namespace prefix may not be set."));
849 return; 849 return;
850 } 850 }
851 851
852 if (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI) { 852 if (prefix == xmlAtom && nodeNamespaceURI != XMLNames::xmlNamespaceURI) {
853 es.throwDOMException(NamespaceError, ExceptionMessages::failedToSet("pre fix", "Node", "The prefix '" + xmlAtom + "' may not be set on namespace '" + nod eNamespaceURI + "'.")); 853 exceptionState.throwDOMException(NamespaceError, ExceptionMessages::fail edToSet("prefix", "Node", "The prefix '" + xmlAtom + "' may not be set on namesp ace '" + nodeNamespaceURI + "'."));
854 return; 854 return;
855 } 855 }
856 // Attribute-specific checks are in Attr::setPrefix(). 856 // Attribute-specific checks are in Attr::setPrefix().
857 } 857 }
858 858
859 bool Node::isDescendantOf(const Node *other) const 859 bool Node::isDescendantOf(const Node *other) const
860 { 860 {
861 // Return true if other is an ancestor of this, otherwise false 861 // Return true if other is an ancestor of this, otherwise false
862 if (!other || !other->hasChildNodes() || inDocument() != other->inDocument() ) 862 if (!other || !other->hasChildNodes() || inDocument() != other->inDocument() )
863 return false; 863 return false;
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 { 1269 {
1270 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(th is, ClassNodeListType, classNames); 1270 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(th is, ClassNodeListType, classNames);
1271 } 1271 }
1272 1272
1273 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name) 1273 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name)
1274 { 1274 {
1275 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); 1275 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag));
1276 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeLi st>(this, RadioNodeListType, name); 1276 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeLi st>(this, RadioNodeListType, name);
1277 } 1277 }
1278 1278
1279 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception State& es) 1279 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception State& exceptionState)
1280 { 1280 {
1281 if (selectors.isEmpty()) { 1281 if (selectors.isEmpty()) {
1282 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu erySelector", "Node", "The provided selector is empty.")); 1282 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute("querySelector", "Node", "The provided selector is empty."));
1283 return 0; 1283 return 0;
1284 } 1284 }
1285 1285
1286 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), es); 1286 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1287 if (!selectorQuery) 1287 if (!selectorQuery)
1288 return 0; 1288 return 0;
1289 return selectorQuery->queryFirst(*this); 1289 return selectorQuery->queryFirst(*this);
1290 } 1290 }
1291 1291
1292 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep tionState& es) 1292 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep tionState& exceptionState)
1293 { 1293 {
1294 if (selectors.isEmpty()) { 1294 if (selectors.isEmpty()) {
1295 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu erySelectorAll", "Node", "The provided selector is empty.")); 1295 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute("querySelectorAll", "Node", "The provided selector is empty."));
1296 return 0; 1296 return 0;
1297 } 1297 }
1298 1298
1299 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), es); 1299 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1300 if (!selectorQuery) 1300 if (!selectorQuery)
1301 return 0; 1301 return 0;
1302 return selectorQuery->queryAll(*this); 1302 return selectorQuery->queryAll(*this);
1303 } 1303 }
1304 1304
1305 Document* Node::ownerDocument() const 1305 Document* Node::ownerDocument() const
1306 { 1306 {
1307 Document* doc = &document(); 1307 Document* doc = &document();
1308 return doc == this ? 0 : doc; 1308 return doc == this ? 0 : doc;
1309 } 1309 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 } 1580 }
1581 1581
1582 String Node::textContent(bool convertBRsToNewlines) const 1582 String Node::textContent(bool convertBRsToNewlines) const
1583 { 1583 {
1584 StringBuilder content; 1584 StringBuilder content;
1585 bool isNullString = true; 1585 bool isNullString = true;
1586 appendTextContent(this, convertBRsToNewlines, isNullString, content); 1586 appendTextContent(this, convertBRsToNewlines, isNullString, content);
1587 return isNullString ? String() : content.toString(); 1587 return isNullString ? String() : content.toString();
1588 } 1588 }
1589 1589
1590 void Node::setTextContent(const String& text, ExceptionState& es) 1590 void Node::setTextContent(const String& text, ExceptionState& exceptionState)
1591 { 1591 {
1592 switch (nodeType()) { 1592 switch (nodeType()) {
1593 case TEXT_NODE: 1593 case TEXT_NODE:
1594 case CDATA_SECTION_NODE: 1594 case CDATA_SECTION_NODE:
1595 case COMMENT_NODE: 1595 case COMMENT_NODE:
1596 case PROCESSING_INSTRUCTION_NODE: 1596 case PROCESSING_INSTRUCTION_NODE:
1597 setNodeValue(text); 1597 setNodeValue(text);
1598 return; 1598 return;
1599 case ELEMENT_NODE: 1599 case ELEMENT_NODE:
1600 case ATTRIBUTE_NODE: 1600 case ATTRIBUTE_NODE:
1601 case ENTITY_NODE: 1601 case ENTITY_NODE:
1602 case DOCUMENT_FRAGMENT_NODE: { 1602 case DOCUMENT_FRAGMENT_NODE: {
1603 RefPtr<ContainerNode> container = toContainerNode(this); 1603 RefPtr<ContainerNode> container = toContainerNode(this);
1604 ChildListMutationScope mutation(*this); 1604 ChildListMutationScope mutation(*this);
1605 container->removeChildren(); 1605 container->removeChildren();
1606 if (!text.isEmpty()) 1606 if (!text.isEmpty())
1607 container->appendChild(document().createTextNode(text), es); 1607 container->appendChild(document().createTextNode(text), exceptio nState);
1608 return; 1608 return;
1609 } 1609 }
1610 case DOCUMENT_NODE: 1610 case DOCUMENT_NODE:
1611 case DOCUMENT_TYPE_NODE: 1611 case DOCUMENT_TYPE_NODE:
1612 case NOTATION_NODE: 1612 case NOTATION_NODE:
1613 case XPATH_NAMESPACE_NODE: 1613 case XPATH_NAMESPACE_NODE:
1614 // Do nothing. 1614 // Do nothing.
1615 return; 1615 return;
1616 } 1616 }
1617 ASSERT_NOT_REACHED(); 1617 ASSERT_NOT_REACHED();
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2667 node->showTreeForThis(); 2667 node->showTreeForThis();
2668 } 2668 }
2669 2669
2670 void showNodePath(const WebCore::Node* node) 2670 void showNodePath(const WebCore::Node* node)
2671 { 2671 {
2672 if (node) 2672 if (node)
2673 node->showNodePathForThis(); 2673 node->showNodePathForThis();
2674 } 2674 }
2675 2675
2676 #endif 2676 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/NamedNodeMap.cpp ('k') | Source/core/dom/NodeIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698