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

Unified Diff: third_party/WebKit/Source/core/dom/Range.cpp

Issue 2496133002: DOM: Remove standard-violating optimizations in appendChild, insertBefore, and replaceChild. (Closed)
Patch Set: . Created 3 years, 10 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 | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Range.cpp
diff --git a/third_party/WebKit/Source/core/dom/Range.cpp b/third_party/WebKit/Source/core/dom/Range.cpp
index fcc24003565722162929fd31f9b2eda301c7b44c..3187a1e9c746f3eef49a70065a484b4e3f5c92da 100644
--- a/third_party/WebKit/Source/core/dom/Range.cpp
+++ b/third_party/WebKit/Source/core/dom/Range.cpp
@@ -917,11 +917,15 @@ void Range::insertNode(Node* newNode, ExceptionState& exceptionState) {
}
container = m_start.container();
- container->insertBefore(
- newNode, NodeTraversal::childAt(*container, m_start.offset()),
- exceptionState);
- if (exceptionState.hadException())
- return;
+ Node* referenceNode = NodeTraversal::childAt(*container, m_start.offset());
+ // TODO(tkent): The following check must be unnecessary if we follow the
+ // algorithm defined in the specification.
+ // https://dom.spec.whatwg.org/#concept-range-insert
+ if (newNode != referenceNode) {
+ container->insertBefore(newNode, referenceNode, exceptionState);
+ if (exceptionState.hadException())
+ return;
+ }
// Note that m_start.offset() may have changed as a result of
// container->insertBefore, when the node we are inserting comes before the
« no previous file with comments | « third_party/WebKit/Source/core/dom/ContainerNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698