splitting mail cites in replies now gives you the caret where you want it.

git-svn-id: svn://10.0.0.236/trunk@68428 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jfrancis%netscape.com
2000-05-05 21:22:09 +00:00
parent ceb1878df9
commit 289b75d564
2 changed files with 40 additions and 10 deletions

View File

@@ -652,12 +652,19 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P
if (citeNode)
{
nsCOMPtr<nsIDOMNode> brNode;
res = mEditor->SplitNodeDeep(citeNode, selNode, selOffset, &newOffset);
if (NS_FAILED(res)) return res;
res = citeNode->GetParentNode(getter_AddRefs(selNode));
if (NS_FAILED(res)) return res;
res = mEditor->CreateBR(selNode, newOffset, &brNode);
if (NS_FAILED(res)) return res;
// want selection before the break, and on same line
aSelection->SetHint(PR_TRUE);
res = aSelection->Collapse(selNode, newOffset);
if (NS_FAILED(res)) return res;
*aHandled = PR_TRUE;
return NS_OK;
}
}
@@ -709,11 +716,19 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P
if (NS_FAILED(res)) return res;
res = nsEditor::GetNodeLocation(brNode, &node, &offset);
if (NS_FAILED(res)) return res;
// SetHint(PR_TRUE) means we want the caret to stick to the content on the "right".
// We want the caret to stick to whatever is past the break. This is
// because the break is on the same line we were on, but the next content
// will be on the following line.
aSelection->SetHint(PR_TRUE);
// SetHint(PR_TRUE) means we want the caret to stick to the content on the "right".
// We want the caret to stick to whatever is past the break. This is
// because the break is on the same line we were on, but the next content
// will be on the following line.
// An exception to this is if the break has a next sibling that is a block node.
// Then we stick to the left to aviod an uber caret.
nsCOMPtr<nsIDOMNode> siblingNode;
brNode->GetNextSibling(getter_AddRefs(siblingNode));
if (siblingNode && mEditor->IsBlockNode(siblingNode))
aSelection->SetHint(PR_FALSE);
else
aSelection->SetHint(PR_TRUE);
res = aSelection->Collapse(node, offset+1);
if (NS_FAILED(res)) return res;
*aHandled = PR_TRUE;

View File

@@ -652,12 +652,19 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P
if (citeNode)
{
nsCOMPtr<nsIDOMNode> brNode;
res = mEditor->SplitNodeDeep(citeNode, selNode, selOffset, &newOffset);
if (NS_FAILED(res)) return res;
res = citeNode->GetParentNode(getter_AddRefs(selNode));
if (NS_FAILED(res)) return res;
res = mEditor->CreateBR(selNode, newOffset, &brNode);
if (NS_FAILED(res)) return res;
// want selection before the break, and on same line
aSelection->SetHint(PR_TRUE);
res = aSelection->Collapse(selNode, newOffset);
if (NS_FAILED(res)) return res;
*aHandled = PR_TRUE;
return NS_OK;
}
}
@@ -709,11 +716,19 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P
if (NS_FAILED(res)) return res;
res = nsEditor::GetNodeLocation(brNode, &node, &offset);
if (NS_FAILED(res)) return res;
// SetHint(PR_TRUE) means we want the caret to stick to the content on the "right".
// We want the caret to stick to whatever is past the break. This is
// because the break is on the same line we were on, but the next content
// will be on the following line.
aSelection->SetHint(PR_TRUE);
// SetHint(PR_TRUE) means we want the caret to stick to the content on the "right".
// We want the caret to stick to whatever is past the break. This is
// because the break is on the same line we were on, but the next content
// will be on the following line.
// An exception to this is if the break has a next sibling that is a block node.
// Then we stick to the left to aviod an uber caret.
nsCOMPtr<nsIDOMNode> siblingNode;
brNode->GetNextSibling(getter_AddRefs(siblingNode));
if (siblingNode && mEditor->IsBlockNode(siblingNode))
aSelection->SetHint(PR_FALSE);
else
aSelection->SetHint(PR_TRUE);
res = aSelection->Collapse(node, offset+1);
if (NS_FAILED(res)) return res;
*aHandled = PR_TRUE;