mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 812891 - Remove duplicated code from nsEditor::Get{Left,Right}mostChild; r=ehsan
This commit is contained in:
parent
590f343557
commit
cf85be986f
@ -3385,28 +3385,13 @@ nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing);
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
nsEditor::GetRightmostChild(nsIDOMNode *aCurrentNode,
|
||||
nsIDOMNode*
|
||||
nsEditor::GetRightmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
NS_ENSURE_TRUE(aCurrentNode, nullptr);
|
||||
nsCOMPtr<nsIDOMNode> resultNode, temp = aCurrentNode;
|
||||
bool hasChildren;
|
||||
aCurrentNode->HasChildNodes(&hasChildren);
|
||||
while (hasChildren) {
|
||||
temp->GetLastChild(getter_AddRefs(resultNode));
|
||||
if (resultNode) {
|
||||
if (bNoBlockCrossing && IsBlockNode(resultNode)) {
|
||||
return resultNode.forget();
|
||||
}
|
||||
resultNode->HasChildNodes(&hasChildren);
|
||||
temp = resultNode;
|
||||
} else {
|
||||
hasChildren = false;
|
||||
}
|
||||
}
|
||||
|
||||
return resultNode.forget();
|
||||
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
|
||||
nsIContent* result = GetRightmostChild(currentNode, bNoBlockCrossing);
|
||||
return result ? result->AsDOMNode() : nullptr;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
@ -3457,28 +3442,13 @@ nsEditor::GetLeftmostChild(nsINode *aCurrentNode,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMNode>
|
||||
nsEditor::GetLeftmostChild(nsIDOMNode *aCurrentNode,
|
||||
nsIDOMNode*
|
||||
nsEditor::GetLeftmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
NS_ENSURE_TRUE(aCurrentNode, nullptr);
|
||||
nsCOMPtr<nsIDOMNode> resultNode, temp = aCurrentNode;
|
||||
bool hasChildren;
|
||||
aCurrentNode->HasChildNodes(&hasChildren);
|
||||
while (hasChildren) {
|
||||
temp->GetFirstChild(getter_AddRefs(resultNode));
|
||||
if (resultNode) {
|
||||
if (bNoBlockCrossing && IsBlockNode(resultNode)) {
|
||||
return resultNode.forget();
|
||||
}
|
||||
resultNode->HasChildNodes(&hasChildren);
|
||||
temp = resultNode;
|
||||
} else {
|
||||
hasChildren = false;
|
||||
}
|
||||
}
|
||||
|
||||
return resultNode.forget();
|
||||
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
|
||||
nsIContent* result = GetLeftmostChild(currentNode, bNoBlockCrossing);
|
||||
return result ? result->AsDOMNode() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -539,8 +539,8 @@ public:
|
||||
* Get the rightmost child of aCurrentNode;
|
||||
* return nullptr if aCurrentNode has no children.
|
||||
*/
|
||||
already_AddRefed<nsIDOMNode> GetRightmostChild(nsIDOMNode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIDOMNode* GetRightmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetRightmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
@ -548,8 +548,8 @@ public:
|
||||
* Get the leftmost child of aCurrentNode;
|
||||
* return nullptr if aCurrentNode has no children.
|
||||
*/
|
||||
already_AddRefed<nsIDOMNode> GetLeftmostChild(nsIDOMNode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIDOMNode* GetLeftmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetLeftmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user