diff --git a/editor/libeditor/base/SplitElementTxn.cpp b/editor/libeditor/base/SplitElementTxn.cpp index 31d59e1b234..2f2ba693ae9 100644 --- a/editor/libeditor/base/SplitElementTxn.cpp +++ b/editor/libeditor/base/SplitElementTxn.cpp @@ -117,16 +117,21 @@ NS_IMETHODIMP SplitElementTxn::DoTransaction(void) // insert the new node result = mEditor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent); - if (NS_SUCCEEDED(result) && mNewLeftNode) - { - nsCOMPtrselection; - mEditor->GetSelection(getter_AddRefs(selection)); - NS_ENSURE_SUCCESS(result, result); - NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); - result = selection->Collapse(mNewLeftNode, mOffset); - } - else { - result = NS_ERROR_NOT_IMPLEMENTED; + if (mNewLeftNode) { + PRBool bAdjustSelection; + mEditor->ShouldTxnSetSelection(&bAdjustSelection); + if (bAdjustSelection) + { + nsCOMPtr selection; + result = mEditor->GetSelection(getter_AddRefs(selection)); + NS_ENSURE_SUCCESS(result, result); + NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER); + result = selection->Collapse(mNewLeftNode, mOffset); + } + else + { + // do nothing - dom range gravity will adjust selection + } } return result; } diff --git a/editor/libeditor/html/crashtests/615015-1.html b/editor/libeditor/html/crashtests/615015-1.html new file mode 100644 index 00000000000..a383f9e75b4 --- /dev/null +++ b/editor/libeditor/html/crashtests/615015-1.html @@ -0,0 +1,17 @@ + + + + + +T + diff --git a/editor/libeditor/html/crashtests/crashtests.list b/editor/libeditor/html/crashtests/crashtests.list index e52693a82c0..98857be735f 100644 --- a/editor/libeditor/html/crashtests/crashtests.list +++ b/editor/libeditor/html/crashtests/crashtests.list @@ -19,4 +19,5 @@ load 535632-1.xhtml load 574558-1.xhtml load 582138-1.xhtml load 612565-1.html +load 615015-1.html load 615450-1.html diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index e9614d44ccb..39a3f0eebb7 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -6055,10 +6055,15 @@ nsHTMLEditRules::GetListActionNodes(nsCOMArray &outArrayOfNodes, // selection spans multiple lists but with no common list parent. if (outArrayOfNodes.Count()) return NS_OK; } - - // contruct a list of nodes to act on. - res = GetNodesFromSelection(selection, kMakeList, outArrayOfNodes, aDontTouchContent); - NS_ENSURE_SUCCESS(res, res); + + { + // We don't like other people messing with our selection! + nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor); + + // contruct a list of nodes to act on. + res = GetNodesFromSelection(selection, kMakeList, outArrayOfNodes, aDontTouchContent); + NS_ENSURE_SUCCESS(res, res); + } // pre process our list of nodes... PRInt32 listCount = outArrayOfNodes.Count();