diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp index 4973f2c4aff..0e85492e8b0 100644 --- a/mozilla/content/base/src/nsRange.cpp +++ b/mozilla/content/base/src/nsRange.cpp @@ -345,11 +345,10 @@ void nsRange::ParentChainChanged(nsIContent *aContent) { NS_ASSERTION(mRoot == aContent, "Wrong ParentChainChanged notification?"); - nsINode* newRoot = mRoot; - nsINode* tmp; - while ((tmp = newRoot->GetNodeParent())) { - newRoot = tmp; - } + nsINode* newRoot = IsValidBoundary(mStartParent); + NS_ASSERTION(newRoot, "No valid boundary or root found!"); + NS_ASSERTION(newRoot == IsValidBoundary(mEndParent), + "Start parent and end parent give different root!"); DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset, newRoot); } diff --git a/mozilla/content/base/test/Makefile.in b/mozilla/content/base/test/Makefile.in index 9a4757f03bd..8d2ef8908f3 100644 --- a/mozilla/content/base/test/Makefile.in +++ b/mozilla/content/base/test/Makefile.in @@ -174,6 +174,7 @@ _TEST_FILES = test_bug5141.html \ test_bug417255.html \ test_bug417384.html \ test_bug418214.html \ + test_bug419527.xhtml \ test_bug420609.xhtml \ test_bug420700.html \ $(NULL) diff --git a/mozilla/content/base/test/test_bug419527.xhtml b/mozilla/content/base/test/test_bug419527.xhtml new file mode 100644 index 00000000000..33d5d84e7a4 --- /dev/null +++ b/mozilla/content/base/test/test_bug419527.xhtml @@ -0,0 +1,66 @@ + + + + + Test for Bug 419527 + + + + + + Foo + + + + var span = document.getAnonymousNodes(this)[0]; + ok(span.localName == "span", "Wrong anon node!"); + var range = document.createRange(); + range.selectNode(span.firstChild); + ok(range.startContainer == span, "Wrong start container!"); + ok(range.endContainer == span, "Wrong end container!"); + window.newSubTree.appendChild(this); + range.setStart(window.newSubTree.firstChild, 0); + ok(range.startContainer == window.newSubTree.firstChild, + "Range should have been collapsed to newSubTree.firstChild!"); + ok(range.endContainer == window.newSubTree.firstChild, + "Range should have been collapsed to newSubTree.firstChild!"); + SimpleTest.finish(); + + + + + + +Mozilla Bug 419527 +

+ +
+
+
+ + +