зеркало из https://github.com/mozilla/pjs.git
Bug 744507 - Part b: Add nsINode versions in GetPriorHTMLSibling/GetNextHTMLSibling; r=ehsan
This commit is contained in:
Родитель
b5f8e2ce51
Коммит
2e04964e1d
|
@ -4209,29 +4209,30 @@ nsHTMLEditor::RemoveBlockContainer(nsIDOMNode *inNode)
|
||||||
// GetPriorHTMLSibling: returns the previous editable sibling, if there is
|
// GetPriorHTMLSibling: returns the previous editable sibling, if there is
|
||||||
// one within the parent
|
// one within the parent
|
||||||
//
|
//
|
||||||
|
nsINode*
|
||||||
|
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aNode)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aNode);
|
||||||
|
|
||||||
|
nsIContent* node = aNode->GetPreviousSibling();
|
||||||
|
while (node && !IsEditable(node)) {
|
||||||
|
node = node->GetPreviousSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
|
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(outNode && inNode, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
|
||||||
nsresult res = NS_OK;
|
*outNode = NULL;
|
||||||
*outNode = nsnull;
|
|
||||||
nsCOMPtr<nsIDOMNode> temp, node = do_QueryInterface(inNode);
|
|
||||||
|
|
||||||
while (1)
|
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||||
{
|
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||||
res = node->GetPreviousSibling(getter_AddRefs(temp));
|
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
*outNode = do_QueryInterface(GetPriorHTMLSibling(node));
|
||||||
if (!temp) {
|
return NS_OK;
|
||||||
// return null sibling
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
// if it's editable, we're done
|
|
||||||
if (IsEditable(temp)) break;
|
|
||||||
// otherwise try again
|
|
||||||
node = temp;
|
|
||||||
}
|
|
||||||
*outNode = temp;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4241,22 +4242,30 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outN
|
||||||
// one within the parent. just like above routine but
|
// one within the parent. just like above routine but
|
||||||
// takes a parent/offset instead of a node.
|
// takes a parent/offset instead of a node.
|
||||||
//
|
//
|
||||||
|
nsINode*
|
||||||
|
nsHTMLEditor::GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aParent);
|
||||||
|
|
||||||
|
nsIContent* node = aParent->GetChildAt(aOffset - 1);
|
||||||
|
if (!node || IsEditable(node)) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetPriorHTMLSibling(node);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
|
nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(outNode && inParent, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
|
||||||
*outNode = nsnull;
|
*outNode = NULL;
|
||||||
nsCOMPtr<nsIDOMNode> node = nsEditor::GetChildAt(inParent,inOffset-1);
|
|
||||||
if (!node) {
|
nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
|
||||||
// return null sibling if no sibling
|
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
||||||
return NS_OK;
|
|
||||||
}
|
*outNode = do_QueryInterface(GetPriorHTMLSibling(parent, inOffset));
|
||||||
if (IsEditable(node)) {
|
return NS_OK;
|
||||||
*outNode = node;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
return GetPriorHTMLSibling(node, outNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4265,29 +4274,30 @@ nsHTMLEditor::GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMP
|
||||||
// GetNextHTMLSibling: returns the next editable sibling, if there is
|
// GetNextHTMLSibling: returns the next editable sibling, if there is
|
||||||
// one within the parent
|
// one within the parent
|
||||||
//
|
//
|
||||||
|
nsINode*
|
||||||
|
nsHTMLEditor::GetNextHTMLSibling(nsINode* aNode)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aNode);
|
||||||
|
|
||||||
|
nsIContent* node = aNode->GetNextSibling();
|
||||||
|
while (node && !IsEditable(node)) {
|
||||||
|
node = node->GetNextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
|
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
|
||||||
nsresult res = NS_OK;
|
|
||||||
*outNode = nsnull;
|
*outNode = nsnull;
|
||||||
nsCOMPtr<nsIDOMNode> temp, node = do_QueryInterface(inNode);
|
|
||||||
|
|
||||||
while (1)
|
nsCOMPtr<nsINode> node = do_QueryInterface(inNode);
|
||||||
{
|
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||||
res = node->GetNextSibling(getter_AddRefs(temp));
|
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
*outNode = do_QueryInterface(GetNextHTMLSibling(node));
|
||||||
if (!temp) {
|
return NS_OK;
|
||||||
// return null sibling
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
// if it's editable, we're done
|
|
||||||
if (IsEditable(temp)) break;
|
|
||||||
// otherwise try again
|
|
||||||
node = temp;
|
|
||||||
}
|
|
||||||
*outNode = temp;
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4296,23 +4306,30 @@ nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNo
|
||||||
// GetNextHTMLSibling: returns the next editable sibling, if there is
|
// GetNextHTMLSibling: returns the next editable sibling, if there is
|
||||||
// one within the parent. just like above routine but
|
// one within the parent. just like above routine but
|
||||||
// takes a parent/offset instead of a node.
|
// takes a parent/offset instead of a node.
|
||||||
//
|
nsINode*
|
||||||
|
nsHTMLEditor::GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aParent);
|
||||||
|
|
||||||
|
nsIContent* node = aParent->GetChildAt(aOffset + 1);
|
||||||
|
if (!node || IsEditable(node)) {
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetNextHTMLSibling(node);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
|
nsHTMLEditor::GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode)
|
||||||
{
|
{
|
||||||
NS_ENSURE_TRUE(outNode && inParent, NS_ERROR_NULL_POINTER);
|
NS_ENSURE_TRUE(outNode, NS_ERROR_NULL_POINTER);
|
||||||
*outNode = nsnull;
|
*outNode = NULL;
|
||||||
nsCOMPtr<nsIDOMNode> node = nsEditor::GetChildAt(inParent, inOffset + 1);
|
|
||||||
if (!node) {
|
nsCOMPtr<nsINode> parent = do_QueryInterface(inParent);
|
||||||
// return null sibling if no sibling
|
NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
||||||
return NS_OK;
|
|
||||||
}
|
*outNode = do_QueryInterface(GetNextHTMLSibling(parent, inOffset));
|
||||||
if (IsEditable(node)) {
|
return NS_OK;
|
||||||
*outNode = node;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
return GetNextHTMLSibling(node, outNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -720,9 +720,13 @@ protected:
|
||||||
bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
|
bool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute);
|
||||||
|
|
||||||
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
|
nsresult RemoveBlockContainer(nsIDOMNode *inNode);
|
||||||
|
nsINode* GetPriorHTMLSibling(nsINode* aNode);
|
||||||
nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
||||||
|
nsINode* GetPriorHTMLSibling(nsINode* aParent, PRInt32 aOffset);
|
||||||
nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
nsresult GetPriorHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
||||||
|
nsINode* GetNextHTMLSibling(nsINode* aNode);
|
||||||
nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
nsresult GetNextHTMLSibling(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode);
|
||||||
|
nsINode* GetNextHTMLSibling(nsINode* aParent, PRInt32 aOffset);
|
||||||
nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
nsresult GetNextHTMLSibling(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode);
|
||||||
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
nsresult GetPriorHTMLNode(nsIDOMNode *inNode, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
||||||
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
nsresult GetPriorHTMLNode(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr<nsIDOMNode> *outNode, bool bNoBlockCrossing = false);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче