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

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

Issue 688933002: Make textContent trigger single DOMSubtreeModified event (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test Created 6 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
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 1383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 // FIXME: Merge this logic into replaceChildrenWithText. 1394 // FIXME: Merge this logic into replaceChildrenWithText.
1395 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this); 1395 RefPtrWillBeRawPtr<ContainerNode> container = toContainerNode(this);
1396 1396
1397 // Note: This is an intentional optimization. 1397 // Note: This is an intentional optimization.
1398 // See crbug.com/352836 also. 1398 // See crbug.com/352836 also.
1399 // No need to do anything if the text is identical. 1399 // No need to do anything if the text is identical.
1400 if (container->hasOneTextChild() && toText(container->firstChild())- >data() == text) 1400 if (container->hasOneTextChild() && toText(container->firstChild())- >data() == text)
1401 return; 1401 return;
1402 1402
1403 ChildListMutationScope mutation(*this); 1403 ChildListMutationScope mutation(*this);
1404 container->removeChildren(); 1404 bool emptyText = text.isEmpty();
1405 container->removeChildren(emptyText);
1405 // Note: This API will not insert empty text nodes: 1406 // Note: This API will not insert empty text nodes:
1406 // http://dom.spec.whatwg.org/#dom-node-textcontent 1407 // http://dom.spec.whatwg.org/#dom-node-textcontent
1407 if (!text.isEmpty()) 1408 if (!emptyText)
1408 container->appendChild(document().createTextNode(text), ASSERT_N O_EXCEPTION); 1409 container->appendChild(document().createTextNode(text), ASSERT_N O_EXCEPTION);
1409 return; 1410 return;
1410 } 1411 }
1411 case DOCUMENT_NODE: 1412 case DOCUMENT_NODE:
1412 case DOCUMENT_TYPE_NODE: 1413 case DOCUMENT_TYPE_NODE:
1413 // Do nothing. 1414 // Do nothing.
1414 return; 1415 return;
1415 } 1416 }
1416 ASSERT_NOT_REACHED(); 1417 ASSERT_NOT_REACHED();
1417 } 1418 }
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 node->showTreeForThis(); 2457 node->showTreeForThis();
2457 } 2458 }
2458 2459
2459 void showNodePath(const blink::Node* node) 2460 void showNodePath(const blink::Node* node)
2460 { 2461 {
2461 if (node) 2462 if (node)
2462 node->showNodePathForThis(); 2463 node->showNodePathForThis();
2463 } 2464 }
2464 2465
2465 #endif 2466 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698