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

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

Issue 2415923003: Fix setting textContent to empty string (Closed)
Patch Set: Remove test Created 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent-expected.txt ('k') | no next file » | 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 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 return; 1296 return;
1297 case kElementNode: 1297 case kElementNode:
1298 case kDocumentFragmentNode: { 1298 case kDocumentFragmentNode: {
1299 // FIXME: Merge this logic into replaceChildrenWithText. 1299 // FIXME: Merge this logic into replaceChildrenWithText.
1300 ContainerNode* container = toContainerNode(this); 1300 ContainerNode* container = toContainerNode(this);
1301 1301
1302 // Note: This is an intentional optimization. 1302 // Note: This is an intentional optimization.
1303 // See crbug.com/352836 also. 1303 // See crbug.com/352836 also.
1304 // No need to do anything if the text is identical. 1304 // No need to do anything if the text is identical.
1305 if (container->hasOneTextChild() && 1305 if (container->hasOneTextChild() &&
1306 toText(container->firstChild())->data() == text) 1306 toText(container->firstChild())->data() == text && !text.isEmpty())
1307 return; 1307 return;
1308 1308
1309 ChildListMutationScope mutation(*this); 1309 ChildListMutationScope mutation(*this);
1310 // Note: This API will not insert empty text nodes: 1310 // Note: This API will not insert empty text nodes:
1311 // https://dom.spec.whatwg.org/#dom-node-textcontent 1311 // https://dom.spec.whatwg.org/#dom-node-textcontent
1312 if (text.isEmpty()) { 1312 if (text.isEmpty()) {
1313 container->removeChildren(DispatchSubtreeModifiedEvent); 1313 container->removeChildren(DispatchSubtreeModifiedEvent);
1314 } else { 1314 } else {
1315 container->removeChildren(OmitSubtreeModifiedEvent); 1315 container->removeChildren(OmitSubtreeModifiedEvent);
1316 container->appendChild(document().createTextNode(text), 1316 container->appendChild(document().createTextNode(text),
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 if (node) { 2467 if (node) {
2468 std::stringstream stream; 2468 std::stringstream stream;
2469 node->printNodePathTo(stream); 2469 node->printNodePathTo(stream);
2470 LOG(INFO) << stream.str(); 2470 LOG(INFO) << stream.str();
2471 } else { 2471 } else {
2472 LOG(INFO) << "Cannot showNodePath for <null>"; 2472 LOG(INFO) << "Cannot showNodePath for <null>";
2473 } 2473 }
2474 } 2474 }
2475 2475
2476 #endif 2476 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-textContent-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698