Bug 722419 - Part a: Introduce another version of GetNextNode; r=ehsan

This commit is contained in:
Ms2ger 2012-02-01 11:54:22 +01:00
parent 73cd8e7960
commit a06e96e533
2 changed files with 33 additions and 16 deletions

View File

@ -3320,30 +3320,43 @@ nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
return nsnull;
}
nsresult
nsEditor::GetNextNode(nsIDOMNode *aCurrentNode,
bool aEditableNode,
nsresult
nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing,
nsIContent *aActiveEditorRoot)
bool bNoBlockCrossing,
nsIContent* aActiveEditorRoot)
{
if (!aCurrentNode || !aResultNode) { return NS_ERROR_NULL_POINTER; }
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
if (!IsDescendantOfBody(currentNode) ||
(aActiveEditorRoot &&
!nsContentUtils::ContentIsDescendantOf(currentNode,
aActiveEditorRoot))) {
*aResultNode = nsnull;
return NS_OK;
if (!currentNode || !aResultNode) {
return NS_ERROR_NULL_POINTER;
}
*aResultNode =
do_QueryInterface(FindNode(currentNode, true, aEditableNode,
bNoBlockCrossing, aActiveEditorRoot));
*aResultNode = do_QueryInterface(GetNextNode(currentNode, aEditableNode,
bNoBlockCrossing,
aActiveEditorRoot));
return NS_OK;
}
nsIContent*
nsEditor::GetNextNode(nsINode* aCurrentNode,
bool aEditableNode,
bool bNoBlockCrossing,
nsIContent* aActiveEditorRoot)
{
MOZ_ASSERT(aCurrentNode);
if (!IsDescendantOfBody(aCurrentNode) ||
(aActiveEditorRoot &&
!nsContentUtils::ContentIsDescendantOf(aCurrentNode,
aActiveEditorRoot))) {
return nsnull;
}
return FindNode(aCurrentNode, true, aEditableNode, bNoBlockCrossing,
aActiveEditorRoot);
}
nsIContent*
nsEditor::FindNode(nsINode *aCurrentNode,
bool aGoForward,

View File

@ -505,6 +505,10 @@ public:
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false,
nsIContent *aActiveEditorRoot = nsnull);
nsIContent* GetNextNode(nsINode* aCurrentNode,
bool aEditableNode,
bool bNoBlockCrossing = false,
nsIContent* aActiveEditorRoot = nsnull);
// and another version that takes a {parent,offset} pair rather than a node
nsresult GetNextNode(nsIDOMNode *aParentNode,