From cce6bfcc93062e896a97e7019d3e2e457c4b6440 Mon Sep 17 00:00:00 2001 From: "jfrancis%netscape.com" Date: Tue, 26 Jun 2001 23:13:01 +0000 Subject: [PATCH] bug fix 84744: insert br after user creates table if table is last node in block. r=brade; sr=kin; a=blizzard git-svn-id: svn://10.0.0.236/trunk@97993 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsHTMLEditor.cpp | 17 ++++++++++++++++- mozilla/editor/libeditor/html/nsHTMLEditor.cpp | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index bbe18ce0cfd..1b109d0090f 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -1784,8 +1784,23 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSe // Set caret after element, but check for special case // of inserting table-related elements: set in first cell instead if (!SetCaretInTableCell(aElement)) + { res = SetCaretAfterElement(aElement); - + if (NS_FAILED(res)) return res; + } + // check for inserting a whole table at the end of a block. If so insert a br after it. + if (nsHTMLEditUtils::IsTable(node)) + { + PRBool isLast; + res = IsLastEditableChild(node, &isLast); + if (NS_FAILED(res)) return res; + if (isLast) + { + nsCOMPtr brNode; + res = CreateBR(parentSelectedNode, offsetForInsert+1, address_of(brNode)); + if (NS_FAILED(res)) return res; + } + } } } res = mRules->DidDoAction(selection, &ruleInfo, res); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index bbe18ce0cfd..1b109d0090f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -1784,8 +1784,23 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSe // Set caret after element, but check for special case // of inserting table-related elements: set in first cell instead if (!SetCaretInTableCell(aElement)) + { res = SetCaretAfterElement(aElement); - + if (NS_FAILED(res)) return res; + } + // check for inserting a whole table at the end of a block. If so insert a br after it. + if (nsHTMLEditUtils::IsTable(node)) + { + PRBool isLast; + res = IsLastEditableChild(node, &isLast); + if (NS_FAILED(res)) return res; + if (isLast) + { + nsCOMPtr brNode; + res = CreateBR(parentSelectedNode, offsetForInsert+1, address_of(brNode)); + if (NS_FAILED(res)) return res; + } + } } } res = mRules->DidDoAction(selection, &ruleInfo, res);