Bug 813532 - Part a: Some cleanup for GetPriorHTMLNode; r=ehsan

This commit is contained in:
Ms2ger 2012-12-22 09:17:05 +01:00
parent 962b5131ac
commit 5ebe7ea292
2 changed files with 38 additions and 30 deletions

View File

@ -4062,34 +4062,42 @@ nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPt
// GetPriorHTMLNode: returns the previous editable leaf node, if there is
// one within the <body>
//
nsresult
nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing)
nsIContent*
nsHTMLEditor::GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
MOZ_ASSERT(aNode);
nsIContent* activeEditingHost = GetActiveEditingHost();
if (!activeEditingHost) {
*outNode = nullptr;
return NS_OK;
if (!GetActiveEditingHost()) {
return nullptr;
}
nsresult res = GetPriorNode(inNode, true, address_of(*outNode),
bNoBlockCrossing);
NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
"GetPriorNode screwed up");
return res;
return GetPriorNode(aNode, true, aNoBlockCrossing);
}
nsresult
nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode,
nsCOMPtr<nsIDOMNode>* aResultNode,
bool aNoBlockCrossing)
{
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorHTMLNode(node, aNoBlockCrossing));
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////
// GetPriorHTMLNode: same as above but takes {parent,offset} instead of node
//
//
nsIContent*
nsHTMLEditor::GetPriorHTMLNode(nsINode* aParent, int32_t aOffset,
bool aNoBlockCrossing)
{
MOZ_ASSERT(aParent);
if (!GetActiveEditingHost()) {
return nullptr;
}
@ -4098,23 +4106,18 @@ nsHTMLEditor::GetPriorHTMLNode(nsINode* aParent, int32_t aOffset,
}
nsresult
nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing)
nsHTMLEditor::GetPriorHTMLNode(nsIDOMNode* aNode, int32_t aOffset,
nsCOMPtr<nsIDOMNode>* aResultNode,
bool aNoBlockCrossing)
{
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
nsIContent* activeEditingHost = GetActiveEditingHost();
if (!activeEditingHost) {
*outNode = nullptr;
return NS_OK;
}
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
nsresult res = GetPriorNode(inParent, inOffset, true, address_of(*outNode),
bNoBlockCrossing);
NS_ENSURE_SUCCESS(res, res);
NS_ASSERTION(!*outNode || IsDescendantOfEditorRoot(*outNode),
"GetPriorNode screwed up");
return res;
*aResultNode = do_QueryInterface(GetPriorHTMLNode(node, aOffset,
aNoBlockCrossing));
return NS_OK;
}

View File

@ -676,18 +676,23 @@ protected:
bool IsOnlyAttribute(const nsIContent* aElement, const nsAString& aAttribute);
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
nsIContent* GetPriorHTMLSibling(nsINode* aNode);
nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
nsIContent* GetPriorHTMLSibling(nsINode* aParent, int32_t aOffset);
nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode);
nsIContent* GetNextHTMLSibling(nsINode* aNode);
nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
nsIContent* GetNextHTMLSibling(nsINode* aParent, int32_t aOffset);
nsresult GetNextHTMLSibling(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode);
nsIContent* GetPriorHTMLNode(nsINode* aNode, bool aNoBlockCrossing = false);
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
nsIContent* GetPriorHTMLNode(nsINode* aParent, int32_t aOffset,
bool aNoBlockCrossing = false);
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, int32_t inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
nsresult GetNextHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
nsIContent* GetNextHTMLNode(nsINode* aParent, int32_t aOffset,
bool aNoBlockCrossing = false);