mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-04 02:57:38 +00:00
Bug 1086349 part 7 - Remove old nsEditor::GetRight/LeftmostChild overloads; r=ehsan
This commit is contained in:
parent
aa91d2c603
commit
d404d6e149
@ -3075,15 +3075,6 @@ nsEditor::FindNode(nsINode *aCurrentNode,
|
||||
return FindNode(candidate, aGoForward, aEditableNode, bNoBlockCrossing);
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
nsEditor::GetRightmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
|
||||
nsIContent* result = GetRightmostChild(currentNode, bNoBlockCrossing);
|
||||
return result ? result->AsDOMNode() : nullptr;
|
||||
}
|
||||
|
||||
nsIContent*
|
||||
nsEditor::GetRightmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing)
|
||||
@ -3132,15 +3123,6 @@ nsEditor::GetLeftmostChild(nsINode *aCurrentNode,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIDOMNode*
|
||||
nsEditor::GetLeftmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing)
|
||||
{
|
||||
nsCOMPtr<nsINode> currentNode = do_QueryInterface(aCurrentNode);
|
||||
nsIContent* result = GetLeftmostChild(currentNode, bNoBlockCrossing);
|
||||
return result ? result->AsDOMNode() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsEditor::IsBlockNode(nsIDOMNode* aNode)
|
||||
{
|
||||
|
@ -533,8 +533,6 @@ public:
|
||||
* Get the rightmost child of aCurrentNode;
|
||||
* return nullptr if aCurrentNode has no children.
|
||||
*/
|
||||
nsIDOMNode* GetRightmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetRightmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
@ -542,8 +540,6 @@ public:
|
||||
* Get the leftmost child of aCurrentNode;
|
||||
* return nullptr if aCurrentNode has no children.
|
||||
*/
|
||||
nsIDOMNode* GetLeftmostChild(nsIDOMNode* aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
nsIContent* GetLeftmostChild(nsINode *aCurrentNode,
|
||||
bool bNoBlockCrossing = false);
|
||||
|
||||
|
@ -5197,7 +5197,8 @@ nsHTMLEditRules::CheckForInvisibleBR(nsIDOMNode *aBlock,
|
||||
nsCOMPtr<nsIDOMNode> *outBRNode,
|
||||
int32_t aOffset)
|
||||
{
|
||||
NS_ENSURE_TRUE(aBlock && outBRNode, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsINode> block = do_QueryInterface(aBlock);
|
||||
NS_ENSURE_TRUE(block && outBRNode, NS_ERROR_NULL_POINTER);
|
||||
*outBRNode = nullptr;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> testNode;
|
||||
@ -5207,7 +5208,8 @@ nsHTMLEditRules::CheckForInvisibleBR(nsIDOMNode *aBlock,
|
||||
if (aWhere == kBlockEnd)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> rightmostNode =
|
||||
mHTMLEditor->GetRightmostChild(aBlock, true); // no block crossing
|
||||
// no block crossing
|
||||
GetAsDOMNode(mHTMLEditor->GetRightmostChild(block, true));
|
||||
|
||||
if (rightmostNode)
|
||||
{
|
||||
@ -5524,7 +5526,9 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection)
|
||||
// of going "down" into a block and "up" out of a block.
|
||||
if (wsEndObj.mStartReason == WSType::otherBlock) {
|
||||
// endpoint is just after the close of a block.
|
||||
nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetRightmostChild(GetAsDOMNode(wsEndObj.mStartReasonNode), true);
|
||||
nsCOMPtr<nsIDOMNode> child =
|
||||
GetAsDOMNode(mHTMLEditor->GetRightmostChild(wsEndObj.mStartReasonNode,
|
||||
true));
|
||||
if (child)
|
||||
{
|
||||
newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset);
|
||||
@ -5562,7 +5566,9 @@ nsHTMLEditRules::NormalizeSelection(nsISelection *inSelection)
|
||||
// of going "down" into a block and "up" out of a block.
|
||||
if (wsStartObj.mEndReason == WSType::otherBlock) {
|
||||
// startpoint is just before the start of a block.
|
||||
nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetLeftmostChild(GetAsDOMNode(wsStartObj.mEndReasonNode), true);
|
||||
nsCOMPtr<nsIDOMNode> child =
|
||||
GetAsDOMNode(mHTMLEditor->GetLeftmostChild(wsStartObj.mEndReasonNode,
|
||||
true));
|
||||
if (child)
|
||||
{
|
||||
newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset);
|
||||
@ -6883,8 +6889,10 @@ nsHTMLEditRules::SplitParagraph(nsIDOMNode *aPara,
|
||||
|
||||
// selection to beginning of right hand para;
|
||||
// look inside any containers that are up front.
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetLeftmostChild(rightPara, true);
|
||||
nsCOMPtr<nsINode> rightParaNode = do_QueryInterface(rightPara);
|
||||
NS_ENSURE_STATE(mHTMLEditor && rightParaNode);
|
||||
nsCOMPtr<nsIDOMNode> child =
|
||||
GetAsDOMNode(mHTMLEditor->GetLeftmostChild(rightParaNode, true));
|
||||
NS_ENSURE_STATE(mHTMLEditor);
|
||||
if (mHTMLEditor->IsTextNode(child) || !mHTMLEditor ||
|
||||
mHTMLEditor->IsContainer(child))
|
||||
|
@ -4281,15 +4281,15 @@ nsresult
|
||||
nsHTMLEditor::GetFirstEditableLeaf( nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutFirstLeaf)
|
||||
{
|
||||
// check parms
|
||||
NS_ENSURE_TRUE(aOutFirstLeaf && aNode, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node && aOutFirstLeaf, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// init out parms
|
||||
*aOutFirstLeaf = aNode;
|
||||
|
||||
// find leftmost leaf
|
||||
nsCOMPtr<nsIDOMNode> child;
|
||||
nsresult res = NS_OK;
|
||||
child = GetLeftmostChild(aNode);
|
||||
nsCOMPtr<nsIDOMNode> child = GetAsDOMNode(GetLeftmostChild(node));
|
||||
while (child && (!IsEditable(child) || !nsEditorUtils::IsLeafNode(child)))
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> tmp;
|
||||
@ -4315,13 +4315,14 @@ nsresult
|
||||
nsHTMLEditor::GetLastEditableLeaf(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutLastLeaf)
|
||||
{
|
||||
// check parms
|
||||
NS_ENSURE_TRUE(aOutLastLeaf && aNode, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
|
||||
NS_ENSURE_TRUE(node && aOutLastLeaf, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// init out parms
|
||||
*aOutLastLeaf = nullptr;
|
||||
|
||||
// find rightmost leaf
|
||||
nsCOMPtr<nsIDOMNode> child = GetRightmostChild(aNode, false);
|
||||
nsCOMPtr<nsIDOMNode> child = GetAsDOMNode(GetRightmostChild(node, false));
|
||||
nsresult res = NS_OK;
|
||||
while (child && (!IsEditable(child) || !nsEditorUtils::IsLeafNode(child)))
|
||||
{
|
||||
|
@ -686,7 +686,10 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset,
|
||||
}
|
||||
}
|
||||
if (rightNode) {
|
||||
nsCOMPtr<nsIDOMNode> secondSplitParent = GetLeftmostChild(rightNode);
|
||||
nsCOMPtr<nsINode> rightNode_ = do_QueryInterface(rightNode);
|
||||
NS_ENSURE_STATE(rightNode_);
|
||||
nsCOMPtr<nsIDOMNode> secondSplitParent =
|
||||
GetAsDOMNode(GetLeftmostChild(rightNode_));
|
||||
// don't try to split non-containers (br's, images, hr's, etc)
|
||||
if (!secondSplitParent) {
|
||||
secondSplitParent = rightNode;
|
||||
@ -707,9 +710,9 @@ nsHTMLEditor::ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset,
|
||||
address_of(leftNode), address_of(rightNode));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
// should be impossible to not get a new leftnode here
|
||||
NS_ENSURE_TRUE(leftNode, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsINode> newSelParent =
|
||||
do_QueryInterface(GetLeftmostChild(leftNode));
|
||||
nsCOMPtr<nsINode> leftNode_ = do_QueryInterface(leftNode);
|
||||
NS_ENSURE_TRUE(leftNode_, NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsINode> newSelParent = GetLeftmostChild(leftNode_);
|
||||
if (!newSelParent) {
|
||||
newSelParent = do_QueryInterface(leftNode);
|
||||
NS_ENSURE_STATE(newSelParent);
|
||||
|
Loading…
Reference in New Issue
Block a user