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

Unified Diff: Source/core/editing/markup.cpp

Issue 200763006: Node::setTextContent should avoid work when nothing changes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated to actually wokr 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/markup.cpp
diff --git a/Source/core/editing/markup.cpp b/Source/core/editing/markup.cpp
index f7240ebcdd02b76de91fe266e63a858ff9c5b6e0..e29f2ca9cc010433129589d80b4043c508d2d9e2 100644
--- a/Source/core/editing/markup.cpp
+++ b/Source/core/editing/markup.cpp
@@ -1006,11 +1006,13 @@ void replaceChildrenWithFragment(ContainerNode* container, PassRefPtr<DocumentFr
return;
}
+ // FIXME: This is wrong if containerNode->firstChild() has more than one ref!
Julien - ping for review 2014/03/18 22:55:55 I am not sure I understand this comment. All refer
if (containerNode->hasOneTextChild() && fragment->hasOneTextChild()) {
toText(containerNode->firstChild())->setData(toText(fragment->firstChild())->data());
return;
}
+ // FIXME: No need to replace the child it is a text node and its contents are already == text.
if (containerNode->hasOneChild()) {
containerNode->replaceChild(fragment, containerNode->firstChild(), exceptionState);
return;
@@ -1027,13 +1029,16 @@ void replaceChildrenWithText(ContainerNode* container, const String& text, Excep
ChildListMutationScope mutation(*containerNode);
+ // FIXME: This is wrong if containerNode->firstChild() has more than one ref!
if (containerNode->hasOneTextChild()) {
toText(containerNode->firstChild())->setData(text);
return;
}
+ // NOTE: This method currently always creates a text node, even if that text node will be empty.
RefPtr<Text> textNode = Text::create(containerNode->document(), text);
+ // FIXME: No need to replace the child it is a text node and its contents are already == text.
if (containerNode->hasOneChild()) {
containerNode->replaceChild(textNode.release(), containerNode->firstChild(), exceptionState);
return;
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698