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

Unified Diff: Source/core/dom/Node.cpp

Issue 200763006: Node::setTextContent should avoid work when nothing changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index 7279f0162b99c7de545c988f7f261a37a6a04faf..09dad25fc81f22313941c74156c01e7c0dd55d46 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -59,6 +59,7 @@
#include "core/dom/shadow/InsertionPoint.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/editing/htmlediting.h"
+#include "core/editing/markup.h"
#include "core/events/BeforeLoadEvent.h"
#include "core/events/Event.h"
#include "core/events/EventDispatchMediator.h"
@@ -1497,11 +1498,7 @@ void Node::setTextContent(const String& text)
case ELEMENT_NODE:
case ATTRIBUTE_NODE:
case DOCUMENT_FRAGMENT_NODE: {
- RefPtr<ContainerNode> container = toContainerNode(this);
- ChildListMutationScope mutation(*this);
- container->removeChildren();
- if (!text.isEmpty())
- container->appendChild(document().createTextNode(text), ASSERT_NO_EXCEPTION);
+ replaceChildrenWithText(toContainerNode(this), text, ASSERT_NO_EXCEPTION);
return;
}
case DOCUMENT_NODE:

Powered by Google App Engine
This is Rietveld 408576698