take 2: fix for 22227 and partial fix for 46209; r=mjudge; a=beppe

This commit is contained in:
jfrancis%netscape.com 2000-07-27 01:03:16 +00:00
Родитель 153428d858
Коммит fde5fabb60
8 изменённых файлов: 52 добавлений и 38 удалений

Просмотреть файл

@ -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<nsIDOMNode>
nsresult
nsHTMLEditRules::AdjustSpecialBreaks()
nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
{
nsCOMPtr<nsIContentIterator> iter;
nsCOMPtr<nsISupportsArray> 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)))

Просмотреть файл

@ -164,7 +164,7 @@ protected:
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *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,

Просмотреть файл

@ -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,
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
nodeAsText = do_QueryInterface(node);
nodeAsText->GetLength(&length);
#ifdef NOT_QUITE_READY_FOR_PRIMETIME
nsCOMPtr<nsISelectionController> 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<nsISelectionController> 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
{

Просмотреть файл

@ -563,7 +563,8 @@ protected:
nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *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);

Просмотреть файл

@ -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<nsIDOMNode>
nsresult
nsHTMLEditRules::AdjustSpecialBreaks()
nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
{
nsCOMPtr<nsIContentIterator> iter;
nsCOMPtr<nsISupportsArray> 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)))

Просмотреть файл

@ -164,7 +164,7 @@ protected:
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *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,

Просмотреть файл

@ -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,
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
nodeAsText = do_QueryInterface(node);
nodeAsText->GetLength(&length);
#ifdef NOT_QUITE_READY_FOR_PRIMETIME
nsCOMPtr<nsISelectionController> 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<nsISelectionController> 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
{

Просмотреть файл

@ -563,7 +563,8 @@ protected:
nsresult GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *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);