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

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

Issue 106503002: Let Node.textContent never throw (Closed) Base URL: svn://svn.chromium.org/blink/trunk
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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/Node.idl » ('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 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 } 1587 }
1588 1588
1589 String Node::textContent(bool convertBRsToNewlines) const 1589 String Node::textContent(bool convertBRsToNewlines) const
1590 { 1590 {
1591 StringBuilder content; 1591 StringBuilder content;
1592 bool isNullString = true; 1592 bool isNullString = true;
1593 appendTextContent(this, convertBRsToNewlines, isNullString, content); 1593 appendTextContent(this, convertBRsToNewlines, isNullString, content);
1594 return isNullString ? String() : content.toString(); 1594 return isNullString ? String() : content.toString();
1595 } 1595 }
1596 1596
1597 void Node::setTextContent(const String& text, ExceptionState& exceptionState) 1597 void Node::setTextContent(const String& text)
1598 { 1598 {
1599 switch (nodeType()) { 1599 switch (nodeType()) {
1600 case TEXT_NODE: 1600 case TEXT_NODE:
1601 case CDATA_SECTION_NODE: 1601 case CDATA_SECTION_NODE:
1602 case COMMENT_NODE: 1602 case COMMENT_NODE:
1603 case PROCESSING_INSTRUCTION_NODE: 1603 case PROCESSING_INSTRUCTION_NODE:
1604 setNodeValue(text); 1604 setNodeValue(text);
1605 return; 1605 return;
1606 case ELEMENT_NODE: 1606 case ELEMENT_NODE:
1607 case ATTRIBUTE_NODE: 1607 case ATTRIBUTE_NODE:
1608 case ENTITY_NODE: 1608 case ENTITY_NODE:
1609 case DOCUMENT_FRAGMENT_NODE: { 1609 case DOCUMENT_FRAGMENT_NODE: {
1610 RefPtr<ContainerNode> container = toContainerNode(this); 1610 RefPtr<ContainerNode> container = toContainerNode(this);
1611 ChildListMutationScope mutation(*this); 1611 ChildListMutationScope mutation(*this);
1612 container->removeChildren(); 1612 container->removeChildren();
1613 if (!text.isEmpty()) 1613 if (!text.isEmpty())
1614 container->appendChild(document().createTextNode(text), exceptio nState); 1614 container->appendChild(document().createTextNode(text), ASSERT_N O_EXCEPTION);
1615 return; 1615 return;
1616 } 1616 }
1617 case DOCUMENT_NODE: 1617 case DOCUMENT_NODE:
1618 case DOCUMENT_TYPE_NODE: 1618 case DOCUMENT_TYPE_NODE:
1619 case NOTATION_NODE: 1619 case NOTATION_NODE:
1620 case XPATH_NAMESPACE_NODE: 1620 case XPATH_NAMESPACE_NODE:
1621 // Do nothing. 1621 // Do nothing.
1622 return; 1622 return;
1623 } 1623 }
1624 ASSERT_NOT_REACHED(); 1624 ASSERT_NOT_REACHED();
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 node->showTreeForThis(); 2670 node->showTreeForThis();
2671 } 2671 }
2672 2672
2673 void showNodePath(const WebCore::Node* node) 2673 void showNodePath(const WebCore::Node* node)
2674 { 2674 {
2675 if (node) 2675 if (node)
2676 node->showNodePathForThis(); 2676 node->showNodePathForThis();
2677 } 2677 }
2678 2678
2679 #endif 2679 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/dom/Node.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698