diff --git a/editor/base/nsHTMLEditRules.cpp b/editor/base/nsHTMLEditRules.cpp index badcde06628..07338e6adca 100644 --- a/editor/base/nsHTMLEditRules.cpp +++ b/editor/base/nsHTMLEditRules.cpp @@ -138,7 +138,7 @@ nsHTMLEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags) mDocChangeRange->SelectNode(bodyNode); res = ReplaceNewlines(mDocChangeRange); if (NS_FAILED(res)) return res; - res = AdjustSpecialBreaks(); + res = AdjustSpecialBreaks(PR_TRUE); if (NS_FAILED(res)) return res; } @@ -4198,7 +4198,7 @@ nsHTMLEditRules::GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr nsresult -nsHTMLEditRules::AdjustSpecialBreaks() +nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames) { nsCOMPtr iter; nsCOMPtr arrayOfNodes; @@ -4231,7 +4231,7 @@ nsHTMLEditRules::AdjustSpecialBreaks() if (!node) return NS_ERROR_FAILURE; PRBool bIsEmptyNode; - res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE); + res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE, aSafeToAskFrames); if (NS_FAILED(res)) return res; if (bIsEmptyNode && (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node))) diff --git a/editor/base/nsHTMLEditRules.h b/editor/base/nsHTMLEditRules.h index dbb5ecf9521..af551bb2ea4 100644 --- a/editor/base/nsHTMLEditRules.h +++ b/editor/base/nsHTMLEditRules.h @@ -164,7 +164,7 @@ protected: nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr *aOutCiteNode); nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList); - nsresult AdjustSpecialBreaks(); + nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE); nsresult AdjustWhitespace(nsIDOMSelection *aSelection); nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction); nsresult FindNearSelectableNode(nsIDOMNode *aSelNode, diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index 0701409ee0e..c13cb817e10 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -7099,7 +7099,8 @@ nsresult nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode, PRBool *outIsEmptyNode, PRBool aMozBRDoesntCount, - PRBool aListOrCellNotEmpty) + PRBool aListOrCellNotEmpty, + PRBool aSafeToAskFrames) { if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER; *outIsEmptyNode = PR_TRUE; @@ -7160,27 +7161,32 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode, nsCOMPtrnodeAsText; nodeAsText = do_QueryInterface(node); nodeAsText->GetLength(&length); -#ifdef NOT_QUITE_READY_FOR_PRIMETIME - nsCOMPtr selCon; - res = GetSelectionController(getter_AddRefs(selCon)); - if (NS_FAILED(res)) return res; - if (!selCon) return NS_ERROR_FAILURE; - PRBool isVisible = PR_FALSE; + if (aSafeToAskFrames) + { + nsCOMPtr selCon; + res = GetSelectionController(getter_AddRefs(selCon)); + if (NS_FAILED(res)) return res; + if (!selCon) return NS_ERROR_FAILURE; + PRBool isVisible = PR_FALSE; // ask the selection controller for information about whether any // of the data in the node is really rendered. This is really // something that frames know about, but we aren't supposed to talk to frames. // So we put a call in the selection controller interface, since it's already - // in bed with frames anyway. (this is a fix for bug 46209) - res = selCon->CheckVisibility(node, 0, length, &isVisible); - if (NS_FAILED(res)) return res; - if (isVisible) + // in bed with frames anyway. (this is a fix for bug 22227, and a + // partial fix for bug 46209) + res = selCon->CheckVisibility(node, 0, length, &isVisible); + if (NS_FAILED(res)) return res; + if (isVisible) + { + *outIsEmptyNode = PR_FALSE; + break; + } + } + else if (length) { *outIsEmptyNode = PR_FALSE; break; } -#else - if (length) *outIsEmptyNode = PR_FALSE; -#endif } else // an editable, non-text node. we aren't an empty block { diff --git a/editor/base/nsHTMLEditor.h b/editor/base/nsHTMLEditor.h index d387a15348f..83d1fb45310 100644 --- a/editor/base/nsHTMLEditor.h +++ b/editor/base/nsHTMLEditor.h @@ -563,7 +563,8 @@ protected: nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr *aOutLastChild); nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, - PRBool aListOrCellNotEmpty = PR_FALSE); + PRBool aListOrCellNotEmpty = PR_FALSE, + PRBool aSafeToAskFrames = PR_FALSE); nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index badcde06628..07338e6adca 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -138,7 +138,7 @@ nsHTMLEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags) mDocChangeRange->SelectNode(bodyNode); res = ReplaceNewlines(mDocChangeRange); if (NS_FAILED(res)) return res; - res = AdjustSpecialBreaks(); + res = AdjustSpecialBreaks(PR_TRUE); if (NS_FAILED(res)) return res; } @@ -4198,7 +4198,7 @@ nsHTMLEditRules::GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr nsresult -nsHTMLEditRules::AdjustSpecialBreaks() +nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames) { nsCOMPtr iter; nsCOMPtr arrayOfNodes; @@ -4231,7 +4231,7 @@ nsHTMLEditRules::AdjustSpecialBreaks() if (!node) return NS_ERROR_FAILURE; PRBool bIsEmptyNode; - res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE); + res = mEditor->IsEmptyNode(node, &bIsEmptyNode, PR_FALSE, PR_FALSE, aSafeToAskFrames); if (NS_FAILED(res)) return res; if (bIsEmptyNode && (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node))) diff --git a/editor/libeditor/html/nsHTMLEditRules.h b/editor/libeditor/html/nsHTMLEditRules.h index dbb5ecf9521..af551bb2ea4 100644 --- a/editor/libeditor/html/nsHTMLEditRules.h +++ b/editor/libeditor/html/nsHTMLEditRules.h @@ -164,7 +164,7 @@ protected: nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr *aOutCiteNode); nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList); - nsresult AdjustSpecialBreaks(); + nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE); nsresult AdjustWhitespace(nsIDOMSelection *aSelection); nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction); nsresult FindNearSelectableNode(nsIDOMNode *aSelNode, diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 0701409ee0e..c13cb817e10 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -7099,7 +7099,8 @@ nsresult nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode, PRBool *outIsEmptyNode, PRBool aMozBRDoesntCount, - PRBool aListOrCellNotEmpty) + PRBool aListOrCellNotEmpty, + PRBool aSafeToAskFrames) { if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER; *outIsEmptyNode = PR_TRUE; @@ -7160,27 +7161,32 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode, nsCOMPtrnodeAsText; nodeAsText = do_QueryInterface(node); nodeAsText->GetLength(&length); -#ifdef NOT_QUITE_READY_FOR_PRIMETIME - nsCOMPtr selCon; - res = GetSelectionController(getter_AddRefs(selCon)); - if (NS_FAILED(res)) return res; - if (!selCon) return NS_ERROR_FAILURE; - PRBool isVisible = PR_FALSE; + if (aSafeToAskFrames) + { + nsCOMPtr selCon; + res = GetSelectionController(getter_AddRefs(selCon)); + if (NS_FAILED(res)) return res; + if (!selCon) return NS_ERROR_FAILURE; + PRBool isVisible = PR_FALSE; // ask the selection controller for information about whether any // of the data in the node is really rendered. This is really // something that frames know about, but we aren't supposed to talk to frames. // So we put a call in the selection controller interface, since it's already - // in bed with frames anyway. (this is a fix for bug 46209) - res = selCon->CheckVisibility(node, 0, length, &isVisible); - if (NS_FAILED(res)) return res; - if (isVisible) + // in bed with frames anyway. (this is a fix for bug 22227, and a + // partial fix for bug 46209) + res = selCon->CheckVisibility(node, 0, length, &isVisible); + if (NS_FAILED(res)) return res; + if (isVisible) + { + *outIsEmptyNode = PR_FALSE; + break; + } + } + else if (length) { *outIsEmptyNode = PR_FALSE; break; } -#else - if (length) *outIsEmptyNode = PR_FALSE; -#endif } else // an editable, non-text node. we aren't an empty block { diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h index d387a15348f..83d1fb45310 100644 --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -563,7 +563,8 @@ protected: nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr *aOutLastChild); nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, - PRBool aListOrCellNotEmpty = PR_FALSE); + PRBool aListOrCellNotEmpty = PR_FALSE, + PRBool aSafeToAskFrames = PR_FALSE); nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);