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

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

Issue 443103002: Range.insertNode should verify parent before setting end to it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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/Range.cpp
diff --git a/Source/core/dom/Range.cpp b/Source/core/dom/Range.cpp
index 0020d59410cc9e7d97e78678df1c14b96fb39b8b..eb1ef036103a84722028992973a2850e404e933e 100644
--- a/Source/core/dom/Range.cpp
+++ b/Source/core/dom/Range.cpp
@@ -894,8 +894,13 @@ void Range::insertNode(PassRefPtrWillBeRawPtr<Node> prpNewNode, ExceptionState&
if (exceptionState.hadException())
return;
- if (collapsed)
+ if (collapsed) {
+ if (!newText->parentNode()) {
Yuta Kitamura 2014/08/07 09:30:41 I wonder how newText->parentNode() becomes null.
kangil_ 2014/08/07 09:59:50 insertBefore() will trigger Container::insertBefor
Yuta Kitamura 2014/08/08 04:27:55 That's weird. We are within a scope of EventQueueS
kangil_ 2014/08/08 04:52:25 load event is fired. When range.surroundContents(
Yuta Kitamura 2014/08/08 05:25:07 I'm lost somewhere between ContainerNode::notifyNo
+ exceptionState.throwDOMException(HierarchyRequestError, "This operation would set range's end to parent with new offset, but there's no parent into which to continue.");
+ return;
+ }
m_end.setToBeforeChild(*newText);
+ }
} else {
RefPtrWillBeRawPtr<Node> lastChild = (newNodeType == Node::DOCUMENT_FRAGMENT_NODE) ? toDocumentFragment(newNode)->lastChild() : newNode.get();
if (lastChild && lastChild == m_start.childBefore()) {

Powered by Google App Engine
This is Rietveld 408576698