Bug 1086349 part 6 - Remove old nsEditor::GetNextNode/GetPriorNode overloads; r=ehsan

This commit is contained in:
Aryeh Gregor 2014-11-02 14:04:13 +02:00
parent a813e52452
commit 5765b01b96
3 changed files with 12 additions and 99 deletions

View File

@ -2882,25 +2882,6 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, uint32_t &aCount)
}
nsresult
nsEditor::GetPriorNode(nsIDOMNode *aParentNode,
int32_t aOffset,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing)
{
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nullptr;
nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorNode(parentNode, aOffset,
aEditableNode,
bNoBlockCrossing));
return NS_OK;
}
nsIContent*
nsEditor::GetPriorNode(nsINode* aParentNode,
int32_t aOffset,
@ -2936,25 +2917,6 @@ nsEditor::GetPriorNode(nsINode* aParentNode,
}
nsresult
nsEditor::GetNextNode(nsIDOMNode *aParentNode,
int32_t aOffset,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing)
{
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
*aResultNode = nullptr;
nsCOMPtr<nsINode> parentNode = do_QueryInterface(aParentNode);
NS_ENSURE_TRUE(parentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetNextNode(parentNode, aOffset,
aEditableNode,
bNoBlockCrossing));
return NS_OK;
}
nsIContent*
nsEditor::GetNextNode(nsINode* aParentNode,
int32_t aOffset,
@ -3006,22 +2968,6 @@ nsEditor::GetNextNode(nsINode* aParentNode,
}
nsresult
nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing)
{
NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
NS_ENSURE_TRUE(currentNode, NS_ERROR_NULL_POINTER);
*aResultNode = do_QueryInterface(GetPriorNode(currentNode, aEditableNode,
bNoBlockCrossing));
return NS_OK;
}
nsIContent*
nsEditor::GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing /* = false */)
@ -3087,22 +3033,6 @@ nsEditor::FindNextLeafNode(nsINode *aCurrentNode,
return nullptr;
}
nsresult
nsEditor::GetNextNode(nsIDOMNode* aCurrentNode,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing)
{
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
if (!currentNode || !aResultNode) {
return NS_ERROR_NULL_POINTER;
}
*aResultNode = do_QueryInterface(GetNextNode(currentNode, aEditableNode,
bNoBlockCrossing));
return NS_OK;
}
nsIContent*
nsEditor::GetNextNode(nsINode* aCurrentNode,
bool aEditableNode,

View File

@ -497,19 +497,10 @@ public:
* If there is no prior node, aResultNode will be nullptr.
* @param bNoBlockCrossing If true, don't move across "block" nodes, whatever that means.
*/
nsresult GetPriorNode(nsIDOMNode *aCurrentNode,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false);
nsIContent* GetPriorNode(nsINode* aCurrentNode, bool aEditableNode,
bool aNoBlockCrossing = false);
// and another version that takes a {parent,offset} pair rather than a node
nsresult GetPriorNode(nsIDOMNode *aParentNode,
int32_t aOffset,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false);
nsIContent* GetPriorNode(nsINode* aParentNode,
int32_t aOffset,
bool aEditableNode,
@ -523,20 +514,11 @@ public:
* skipping non-editable nodes if aEditableNode is true.
* If there is no prior node, aResultNode will be nullptr.
*/
nsresult GetNextNode(nsIDOMNode *aCurrentNode,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false);
nsIContent* GetNextNode(nsINode* aCurrentNode,
bool aEditableNode,
bool bNoBlockCrossing = false);
// and another version that takes a {parent,offset} pair rather than a node
nsresult GetNextNode(nsIDOMNode *aParentNode,
int32_t aOffset,
bool aEditableNode,
nsCOMPtr<nsIDOMNode> *aResultNode,
bool bNoBlockCrossing = false);
nsIContent* GetNextNode(nsINode* aParentNode,
int32_t aOffset,
bool aEditableNode,

View File

@ -796,20 +796,21 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
*aAlign = nsIHTMLEditor::eLeft;
// get selection
nsCOMPtr<nsISelection>selection;
NS_ENSURE_STATE(mHTMLEditor);
nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
NS_ENSURE_SUCCESS(res, res);
nsRefPtr<Selection> selection = mHTMLEditor->GetSelection();
NS_ENSURE_STATE(selection);
// get selection location
NS_ENSURE_STATE(mHTMLEditor);
nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
nsCOMPtr<Element> rootElem = mHTMLEditor->GetRoot();
NS_ENSURE_TRUE(rootElem, NS_ERROR_FAILURE);
int32_t offset, rootOffset;
nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(rootElem, &rootOffset);
nsCOMPtr<nsINode> parent = nsEditor::GetNodeLocation(rootElem, &rootOffset);
NS_ENSURE_STATE(mHTMLEditor);
res = mHTMLEditor->GetStartNodeAndOffset(selection, getter_AddRefs(parent), &offset);
nsresult res = mHTMLEditor->GetStartNodeAndOffset(selection,
getter_AddRefs(parent),
&offset);
NS_ENSURE_SUCCESS(res, res);
// is the selection collapsed?
@ -817,7 +818,7 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
if (selection->Collapsed()) {
// if it is, we want to look at 'parent' and its ancestors
// for divs with alignment on them
nodeToExamine = parent;
nodeToExamine = GetAsDOMNode(parent);
}
else if (!mHTMLEditor) {
return NS_ERROR_UNEXPECTED;
@ -825,12 +826,12 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign)
else if (mHTMLEditor->IsTextNode(parent))
{
// if we are in a text node, then that is the node of interest
nodeToExamine = parent;
} else if (nsEditor::NodeIsType(parent, nsGkAtoms::html) &&
offset == rootOffset) {
nodeToExamine = GetAsDOMNode(parent);
} else if (parent->Tag() == nsGkAtoms::html && offset == rootOffset) {
// if we have selected the body, let's look at the first editable node
NS_ENSURE_STATE(mHTMLEditor);
mHTMLEditor->GetNextNode(parent, offset, true, address_of(nodeToExamine));
nodeToExamine =
GetAsDOMNode(mHTMLEditor->GetNextNode(parent, offset, true));
}
else
{