From f40e264c613b21ed8b464033fda94fcf4eaad653 Mon Sep 17 00:00:00 2001 From: "reed@reedloden.com" Date: Tue, 2 Oct 2007 00:32:17 -0700 Subject: [PATCH] Bug 384147 - "tabbing out list item doesn't merge with next list item at same depth" [p=mfenniak-moz@mathieu.fenniak.net (Mathieu Fenniak) r=glazou sr+a1.9=roc] --- editor/composer/test/Makefile.in | 1 + editor/composer/test/test_bug384147.html | 207 ++++++++++++++++++++++ editor/libeditor/html/nsHTMLEditRules.cpp | 43 ++++- 3 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 editor/composer/test/test_bug384147.html diff --git a/editor/composer/test/Makefile.in b/editor/composer/test/Makefile.in index d416fa50c44..c6a0747a8e8 100644 --- a/editor/composer/test/Makefile.in +++ b/editor/composer/test/Makefile.in @@ -46,6 +46,7 @@ include $(topsrcdir)/config/rules.mk _TEST_FILES = \ test_bug348497.html \ + test_bug384147.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/editor/composer/test/test_bug384147.html b/editor/composer/test/test_bug384147.html new file mode 100644 index 00000000000..a3b22de6901 --- /dev/null +++ b/editor/composer/test/test_bug384147.html @@ -0,0 +1,207 @@ + + + + + Test for Bug 384147 + + + + + + +Mozilla Bug 384147 +

+
+
+
+
+
+
+ + + diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 15571df651c..c38997a5740 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -3744,14 +3744,49 @@ nsHTMLEditRules::WillHTMLIndent(nsISelection *aSelection, PRBool *aCancel, PRBoo // some logic for putting list items into nested lists... if (nsHTMLEditUtils::IsList(curParent)) { + sibling = nsnull; + + // Check for whether we should join a list that follows curNode. + // We do this if the next element is a list, and the list is of the + // same type (li/ol) as curNode was a part it. + mHTMLEditor->GetNextHTMLSibling(curNode, address_of(sibling)); + if (sibling && nsHTMLEditUtils::IsList(sibling)) + { + nsAutoString curListTag, siblingListTag; + nsEditor::GetTagString(curParent, curListTag); + nsEditor::GetTagString(sibling, siblingListTag); + if (curListTag == siblingListTag) + { + res = mHTMLEditor->MoveNode(curNode, sibling, 0); + if (NS_FAILED(res)) return res; + continue; + } + } + + // Check for whether we should join a list that preceeds curNode. + // We do this if the previous element is a list, and the list is of + // the same type (li/ol) as curNode was a part of. + mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling)); + if (sibling && nsHTMLEditUtils::IsList(sibling)) + { + nsAutoString curListTag, siblingListTag; + nsEditor::GetTagString(curParent, curListTag); + nsEditor::GetTagString(sibling, siblingListTag); + if (curListTag == siblingListTag) + { + res = mHTMLEditor->MoveNode(curNode, sibling, -1); + if (NS_FAILED(res)) return res; + continue; + } + } + + sibling = nsnull; + // check to see if curList is still appropriate. Which it is if // curNode is still right after it in the same list. if (curList) - { - sibling = nsnull; mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling)); - } - + if (!curList || (sibling && sibling != curList) ) { nsAutoString listTag;