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

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: Take review comment into consideration 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/08 06:20:58 OK, I understand that load event must be fired syn
kangil_ 2014/08/08 06:32:50 Done.
+ 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