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

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

Issue 72363002: Rename es => exceptionState in other than bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Retry 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.get()); 508 node = NodeTraversal::nextPostOrder(node.get());
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 { 1232 {
1233 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(th is, ClassNodeListType, classNames); 1233 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(th is, ClassNodeListType, classNames);
1234 } 1234 }
1235 1235
1236 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name) 1236 PassRefPtr<RadioNodeList> Node::radioNodeList(const AtomicString& name)
1237 { 1237 {
1238 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag)); 1238 ASSERT(hasTagName(formTag) || hasTagName(fieldsetTag));
1239 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeLi st>(this, RadioNodeListType, name); 1239 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeLi st>(this, RadioNodeListType, name);
1240 } 1240 }
1241 1241
1242 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception State& es) 1242 PassRefPtr<Element> Node::querySelector(const AtomicString& selectors, Exception State& exceptionState)
1243 { 1243 {
1244 if (selectors.isEmpty()) { 1244 if (selectors.isEmpty()) {
1245 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu erySelector", "Node", "The provided selector is empty.")); 1245 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute("querySelector", "Node", "The provided selector is empty."));
1246 return 0; 1246 return 0;
1247 } 1247 }
1248 1248
1249 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), es); 1249 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1250 if (!selectorQuery) 1250 if (!selectorQuery)
1251 return 0; 1251 return 0;
1252 return selectorQuery->queryFirst(*this); 1252 return selectorQuery->queryFirst(*this);
1253 } 1253 }
1254 1254
1255 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep tionState& es) 1255 PassRefPtr<NodeList> Node::querySelectorAll(const AtomicString& selectors, Excep tionState& exceptionState)
1256 { 1256 {
1257 if (selectors.isEmpty()) { 1257 if (selectors.isEmpty()) {
1258 es.throwDOMException(SyntaxError, ExceptionMessages::failedToExecute("qu erySelectorAll", "Node", "The provided selector is empty.")); 1258 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute("querySelectorAll", "Node", "The provided selector is empty."));
1259 return 0; 1259 return 0;
1260 } 1260 }
1261 1261
1262 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), es); 1262 SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors , document(), exceptionState);
1263 if (!selectorQuery) 1263 if (!selectorQuery)
1264 return 0; 1264 return 0;
1265 return selectorQuery->queryAll(*this); 1265 return selectorQuery->queryAll(*this);
1266 } 1266 }
1267 1267
1268 Document* Node::ownerDocument() const 1268 Document* Node::ownerDocument() const
1269 { 1269 {
1270 Document* doc = &document(); 1270 Document* doc = &document();
1271 return doc == this ? 0 : doc; 1271 return doc == this ? 0 : doc;
1272 } 1272 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 } 1543 }
1544 1544
1545 String Node::textContent(bool convertBRsToNewlines) const 1545 String Node::textContent(bool convertBRsToNewlines) const
1546 { 1546 {
1547 StringBuilder content; 1547 StringBuilder content;
1548 bool isNullString = true; 1548 bool isNullString = true;
1549 appendTextContent(this, convertBRsToNewlines, isNullString, content); 1549 appendTextContent(this, convertBRsToNewlines, isNullString, content);
1550 return isNullString ? String() : content.toString(); 1550 return isNullString ? String() : content.toString();
1551 } 1551 }
1552 1552
1553 void Node::setTextContent(const String& text, ExceptionState& es) 1553 void Node::setTextContent(const String& text, ExceptionState& exceptionState)
1554 { 1554 {
1555 switch (nodeType()) { 1555 switch (nodeType()) {
1556 case TEXT_NODE: 1556 case TEXT_NODE:
1557 case CDATA_SECTION_NODE: 1557 case CDATA_SECTION_NODE:
1558 case COMMENT_NODE: 1558 case COMMENT_NODE:
1559 case PROCESSING_INSTRUCTION_NODE: 1559 case PROCESSING_INSTRUCTION_NODE:
1560 setNodeValue(text); 1560 setNodeValue(text);
1561 return; 1561 return;
1562 case ELEMENT_NODE: 1562 case ELEMENT_NODE:
1563 case ATTRIBUTE_NODE: 1563 case ATTRIBUTE_NODE:
1564 case ENTITY_NODE: 1564 case ENTITY_NODE:
1565 case DOCUMENT_FRAGMENT_NODE: { 1565 case DOCUMENT_FRAGMENT_NODE: {
1566 RefPtr<ContainerNode> container = toContainerNode(this); 1566 RefPtr<ContainerNode> container = toContainerNode(this);
1567 ChildListMutationScope mutation(*this); 1567 ChildListMutationScope mutation(*this);
1568 container->removeChildren(); 1568 container->removeChildren();
1569 if (!text.isEmpty()) 1569 if (!text.isEmpty())
1570 container->appendChild(document().createTextNode(text), es); 1570 container->appendChild(document().createTextNode(text), exceptio nState);
1571 return; 1571 return;
1572 } 1572 }
1573 case DOCUMENT_NODE: 1573 case DOCUMENT_NODE:
1574 case DOCUMENT_TYPE_NODE: 1574 case DOCUMENT_TYPE_NODE:
1575 case NOTATION_NODE: 1575 case NOTATION_NODE:
1576 case XPATH_NAMESPACE_NODE: 1576 case XPATH_NAMESPACE_NODE:
1577 // Do nothing. 1577 // Do nothing.
1578 return; 1578 return;
1579 } 1579 }
1580 ASSERT_NOT_REACHED(); 1580 ASSERT_NOT_REACHED();
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 node->showTreeForThis(); 2630 node->showTreeForThis();
2631 } 2631 }
2632 2632
2633 void showNodePath(const WebCore::Node* node) 2633 void showNodePath(const WebCore::Node* node)
2634 { 2634 {
2635 if (node) 2635 if (node)
2636 node->showNodePathForThis(); 2636 node->showNodePathForThis();
2637 } 2637 }
2638 2638
2639 #endif 2639 #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