зеркало из https://github.com/mozilla/pjs.git
take 2: fix for 22227 and partial fix for 46209; r=mjudge; a=beppe
This commit is contained in:
Родитель
153428d858
Коммит
fde5fabb60
|
@ -138,7 +138,7 @@ nsHTMLEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags)
|
||||||
mDocChangeRange->SelectNode(bodyNode);
|
mDocChangeRange->SelectNode(bodyNode);
|
||||||
res = ReplaceNewlines(mDocChangeRange);
|
res = ReplaceNewlines(mDocChangeRange);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
res = AdjustSpecialBreaks();
|
res = AdjustSpecialBreaks(PR_TRUE);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4198,7 +4198,7 @@ nsHTMLEditRules::GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode>
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditRules::AdjustSpecialBreaks()
|
nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIContentIterator> iter;
|
nsCOMPtr<nsIContentIterator> iter;
|
||||||
nsCOMPtr<nsISupportsArray> arrayOfNodes;
|
nsCOMPtr<nsISupportsArray> arrayOfNodes;
|
||||||
|
@ -4231,7 +4231,7 @@ nsHTMLEditRules::AdjustSpecialBreaks()
|
||||||
if (!node) return NS_ERROR_FAILURE;
|
if (!node) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRBool bIsEmptyNode;
|
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 (NS_FAILED(res)) return res;
|
||||||
if (bIsEmptyNode
|
if (bIsEmptyNode
|
||||||
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
|
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
|
||||||
|
|
|
@ -164,7 +164,7 @@ protected:
|
||||||
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutCiteNode);
|
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutCiteNode);
|
||||||
nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList);
|
nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList);
|
||||||
|
|
||||||
nsresult AdjustSpecialBreaks();
|
nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE);
|
||||||
nsresult AdjustWhitespace(nsIDOMSelection *aSelection);
|
nsresult AdjustWhitespace(nsIDOMSelection *aSelection);
|
||||||
nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction);
|
nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction);
|
||||||
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
||||||
|
|
|
@ -7099,7 +7099,8 @@ nsresult
|
||||||
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||||
PRBool *outIsEmptyNode,
|
PRBool *outIsEmptyNode,
|
||||||
PRBool aMozBRDoesntCount,
|
PRBool aMozBRDoesntCount,
|
||||||
PRBool aListOrCellNotEmpty)
|
PRBool aListOrCellNotEmpty,
|
||||||
|
PRBool aSafeToAskFrames)
|
||||||
{
|
{
|
||||||
if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER;
|
if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER;
|
||||||
*outIsEmptyNode = PR_TRUE;
|
*outIsEmptyNode = PR_TRUE;
|
||||||
|
@ -7160,27 +7161,32 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||||
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
|
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
|
||||||
nodeAsText = do_QueryInterface(node);
|
nodeAsText = do_QueryInterface(node);
|
||||||
nodeAsText->GetLength(&length);
|
nodeAsText->GetLength(&length);
|
||||||
#ifdef NOT_QUITE_READY_FOR_PRIMETIME
|
if (aSafeToAskFrames)
|
||||||
nsCOMPtr<nsISelectionController> selCon;
|
{
|
||||||
res = GetSelectionController(getter_AddRefs(selCon));
|
nsCOMPtr<nsISelectionController> selCon;
|
||||||
if (NS_FAILED(res)) return res;
|
res = GetSelectionController(getter_AddRefs(selCon));
|
||||||
if (!selCon) return NS_ERROR_FAILURE;
|
if (NS_FAILED(res)) return res;
|
||||||
PRBool isVisible = PR_FALSE;
|
if (!selCon) return NS_ERROR_FAILURE;
|
||||||
|
PRBool isVisible = PR_FALSE;
|
||||||
// ask the selection controller for information about whether any
|
// ask the selection controller for information about whether any
|
||||||
// of the data in the node is really rendered. This is really
|
// 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.
|
// 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
|
// 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)
|
// in bed with frames anyway. (this is a fix for bug 22227, and a
|
||||||
res = selCon->CheckVisibility(node, 0, length, &isVisible);
|
// partial fix for bug 46209)
|
||||||
if (NS_FAILED(res)) return res;
|
res = selCon->CheckVisibility(node, 0, length, &isVisible);
|
||||||
if (isVisible)
|
if (NS_FAILED(res)) return res;
|
||||||
|
if (isVisible)
|
||||||
|
{
|
||||||
|
*outIsEmptyNode = PR_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (length)
|
||||||
{
|
{
|
||||||
*outIsEmptyNode = PR_FALSE;
|
*outIsEmptyNode = PR_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (length) *outIsEmptyNode = PR_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else // an editable, non-text node. we aren't an empty block
|
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 GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild);
|
||||||
nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock,
|
nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock,
|
||||||
PRBool aMozBRDoesntCount = PR_FALSE,
|
PRBool aMozBRDoesntCount = PR_FALSE,
|
||||||
PRBool aListOrCellNotEmpty = PR_FALSE);
|
PRBool aListOrCellNotEmpty = PR_FALSE,
|
||||||
|
PRBool aSafeToAskFrames = PR_FALSE);
|
||||||
|
|
||||||
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);
|
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ nsHTMLEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags)
|
||||||
mDocChangeRange->SelectNode(bodyNode);
|
mDocChangeRange->SelectNode(bodyNode);
|
||||||
res = ReplaceNewlines(mDocChangeRange);
|
res = ReplaceNewlines(mDocChangeRange);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
res = AdjustSpecialBreaks();
|
res = AdjustSpecialBreaks(PR_TRUE);
|
||||||
if (NS_FAILED(res)) return res;
|
if (NS_FAILED(res)) return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4198,7 +4198,7 @@ nsHTMLEditRules::GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode>
|
||||||
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditRules::AdjustSpecialBreaks()
|
nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIContentIterator> iter;
|
nsCOMPtr<nsIContentIterator> iter;
|
||||||
nsCOMPtr<nsISupportsArray> arrayOfNodes;
|
nsCOMPtr<nsISupportsArray> arrayOfNodes;
|
||||||
|
@ -4231,7 +4231,7 @@ nsHTMLEditRules::AdjustSpecialBreaks()
|
||||||
if (!node) return NS_ERROR_FAILURE;
|
if (!node) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
PRBool bIsEmptyNode;
|
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 (NS_FAILED(res)) return res;
|
||||||
if (bIsEmptyNode
|
if (bIsEmptyNode
|
||||||
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
|
&& (nsHTMLEditUtils::IsListItem(node) || mEditor->IsTableCell(node)))
|
||||||
|
|
|
@ -164,7 +164,7 @@ protected:
|
||||||
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutCiteNode);
|
nsresult GetTopEnclosingMailCite(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutCiteNode);
|
||||||
nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList);
|
nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList);
|
||||||
|
|
||||||
nsresult AdjustSpecialBreaks();
|
nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE);
|
||||||
nsresult AdjustWhitespace(nsIDOMSelection *aSelection);
|
nsresult AdjustWhitespace(nsIDOMSelection *aSelection);
|
||||||
nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction);
|
nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction);
|
||||||
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
nsresult FindNearSelectableNode(nsIDOMNode *aSelNode,
|
||||||
|
|
|
@ -7099,7 +7099,8 @@ nsresult
|
||||||
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||||
PRBool *outIsEmptyNode,
|
PRBool *outIsEmptyNode,
|
||||||
PRBool aMozBRDoesntCount,
|
PRBool aMozBRDoesntCount,
|
||||||
PRBool aListOrCellNotEmpty)
|
PRBool aListOrCellNotEmpty,
|
||||||
|
PRBool aSafeToAskFrames)
|
||||||
{
|
{
|
||||||
if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER;
|
if (!aNode || !outIsEmptyNode) return NS_ERROR_NULL_POINTER;
|
||||||
*outIsEmptyNode = PR_TRUE;
|
*outIsEmptyNode = PR_TRUE;
|
||||||
|
@ -7160,27 +7161,32 @@ nsHTMLEditor::IsEmptyNode( nsIDOMNode *aNode,
|
||||||
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
|
nsCOMPtr<nsIDOMCharacterData>nodeAsText;
|
||||||
nodeAsText = do_QueryInterface(node);
|
nodeAsText = do_QueryInterface(node);
|
||||||
nodeAsText->GetLength(&length);
|
nodeAsText->GetLength(&length);
|
||||||
#ifdef NOT_QUITE_READY_FOR_PRIMETIME
|
if (aSafeToAskFrames)
|
||||||
nsCOMPtr<nsISelectionController> selCon;
|
{
|
||||||
res = GetSelectionController(getter_AddRefs(selCon));
|
nsCOMPtr<nsISelectionController> selCon;
|
||||||
if (NS_FAILED(res)) return res;
|
res = GetSelectionController(getter_AddRefs(selCon));
|
||||||
if (!selCon) return NS_ERROR_FAILURE;
|
if (NS_FAILED(res)) return res;
|
||||||
PRBool isVisible = PR_FALSE;
|
if (!selCon) return NS_ERROR_FAILURE;
|
||||||
|
PRBool isVisible = PR_FALSE;
|
||||||
// ask the selection controller for information about whether any
|
// ask the selection controller for information about whether any
|
||||||
// of the data in the node is really rendered. This is really
|
// 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.
|
// 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
|
// 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)
|
// in bed with frames anyway. (this is a fix for bug 22227, and a
|
||||||
res = selCon->CheckVisibility(node, 0, length, &isVisible);
|
// partial fix for bug 46209)
|
||||||
if (NS_FAILED(res)) return res;
|
res = selCon->CheckVisibility(node, 0, length, &isVisible);
|
||||||
if (isVisible)
|
if (NS_FAILED(res)) return res;
|
||||||
|
if (isVisible)
|
||||||
|
{
|
||||||
|
*outIsEmptyNode = PR_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (length)
|
||||||
{
|
{
|
||||||
*outIsEmptyNode = PR_FALSE;
|
*outIsEmptyNode = PR_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (length) *outIsEmptyNode = PR_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else // an editable, non-text node. we aren't an empty block
|
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 GetLastEditableChild( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastChild);
|
||||||
nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock,
|
nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock,
|
||||||
PRBool aMozBRDoesntCount = PR_FALSE,
|
PRBool aMozBRDoesntCount = PR_FALSE,
|
||||||
PRBool aListOrCellNotEmpty = PR_FALSE);
|
PRBool aListOrCellNotEmpty = PR_FALSE,
|
||||||
|
PRBool aSafeToAskFrames = PR_FALSE);
|
||||||
|
|
||||||
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);
|
nsresult GetDOMEventReceiver(nsIDOMEventReceiver **aEventReceiver);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче