diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp
index 6252fb92336..a6936b323cc 100644
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -6771,19 +6771,21 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection,
NS_PRECONDITION(PR_TRUE == nsHTMLEditUtils::IsListItem(aListItem),
"expected a list item and didn't get one");
+ // get the listitem parent and the active editing host.
+ nsIContent* rootContent = mHTMLEditor->GetActiveEditingHost();
+ nsCOMPtr rootNode = do_QueryInterface(rootContent);
+ nsCOMPtr list;
+ PRInt32 itemOffset;
+ res = nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset);
+ NS_ENSURE_SUCCESS(res, res);
+
// if we are in an empty listitem, then we want to pop up out of the list
+ // but only if prefs says it's ok and if the parent isn't the active editing host.
PRBool isEmpty;
res = IsEmptyBlock(aListItem, &isEmpty, PR_TRUE, PR_FALSE);
NS_ENSURE_SUCCESS(res, res);
- if (isEmpty && mReturnInEmptyLIKillsList) // but only if prefs says it's ok
+ if (isEmpty && (rootNode != list) && mReturnInEmptyLIKillsList)
{
- nsCOMPtr list, listparent;
- PRInt32 offset, itemOffset;
- res = nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset);
- NS_ENSURE_SUCCESS(res, res);
- res = nsEditor::GetNodeLocation(list, address_of(listparent), &offset);
- NS_ENSURE_SUCCESS(res, res);
-
// are we the last list item in the list?
PRBool bIsLast;
res = mHTMLEditor->IsLastEditableChild(aListItem, &bIsLast);
@@ -6795,7 +6797,12 @@ nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection,
res = mHTMLEditor->SplitNode(list, itemOffset, getter_AddRefs(tempNode));
NS_ENSURE_SUCCESS(res, res);
}
+
// are we in a sublist?
+ nsCOMPtr listparent;
+ PRInt32 offset;
+ res = nsEditor::GetNodeLocation(list, address_of(listparent), &offset);
+ NS_ENSURE_SUCCESS(res, res);
if (nsHTMLEditUtils::IsList(listparent)) //in a sublist
{
// if so, move this list item out of this list and into the grandparent list
diff --git a/editor/libeditor/html/tests/Makefile.in b/editor/libeditor/html/tests/Makefile.in
index 4933c6f3f3f..f0c53fd6c6e 100644
--- a/editor/libeditor/html/tests/Makefile.in
+++ b/editor/libeditor/html/tests/Makefile.in
@@ -55,7 +55,7 @@ _TEST_FILES = \
test_bug417418.html \
test_bug432225.html \
test_bug439808.html \
- test_bug449243.html \
+ test_bug449243.html \
test_bug455992.html \
test_bug456244.html \
test_bug460740.html \
@@ -81,6 +81,7 @@ _TEST_FILES = \
test_bug629845.html \
test_bug640321.html \
test_bug668599.html \
+ test_bug674861.html \
test_CF_HTML_clipboard.html \
test_contenteditable_focus.html \
test_htmleditor_keyevent_handling.html \
diff --git a/editor/libeditor/html/tests/test_bug674861.html b/editor/libeditor/html/tests/test_bug674861.html
new file mode 100644
index 00000000000..4f57557d9ed
--- /dev/null
+++ b/editor/libeditor/html/tests/test_bug674861.html
@@ -0,0 +1,120 @@
+
+
+
+
+ Test for Bug 674861
+
+
+
+
+
+
+Mozilla Bug 674861
+
+