diff --git a/editor/libeditor/nsEditor.cpp b/editor/libeditor/nsEditor.cpp index 05f65582d76e..f1edc2cc95dc 100644 --- a/editor/libeditor/nsEditor.cpp +++ b/editor/libeditor/nsEditor.cpp @@ -2882,25 +2882,6 @@ nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, uint32_t &aCount) } -nsresult -nsEditor::GetPriorNode(nsIDOMNode *aParentNode, - int32_t aOffset, - bool aEditableNode, - nsCOMPtr *aResultNode, - bool bNoBlockCrossing) -{ - NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); - *aResultNode = nullptr; - - nsCOMPtr 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 *aResultNode, - bool bNoBlockCrossing) -{ - NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); - *aResultNode = nullptr; - - nsCOMPtr 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 *aResultNode, - bool bNoBlockCrossing) -{ - NS_ENSURE_TRUE(aResultNode, NS_ERROR_NULL_POINTER); - - nsCOMPtr 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 *aResultNode, - bool bNoBlockCrossing) -{ - nsCOMPtr 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, diff --git a/editor/libeditor/nsEditor.h b/editor/libeditor/nsEditor.h index eed7d819d84c..c944791ced84 100644 --- a/editor/libeditor/nsEditor.h +++ b/editor/libeditor/nsEditor.h @@ -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 *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 *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 *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 *aResultNode, - bool bNoBlockCrossing = false); nsIContent* GetNextNode(nsINode* aParentNode, int32_t aOffset, bool aEditableNode, diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp index d21fc97f8cd3..c0d3fed67707 100644 --- a/editor/libeditor/nsHTMLEditRules.cpp +++ b/editor/libeditor/nsHTMLEditRules.cpp @@ -796,20 +796,21 @@ nsHTMLEditRules::GetAlignment(bool *aMixed, nsIHTMLEditor::EAlignment *aAlign) *aAlign = nsIHTMLEditor::eLeft; // get selection - nsCOMPtrselection; NS_ENSURE_STATE(mHTMLEditor); - nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection)); - NS_ENSURE_SUCCESS(res, res); + nsRefPtr selection = mHTMLEditor->GetSelection(); + NS_ENSURE_STATE(selection); // get selection location NS_ENSURE_STATE(mHTMLEditor); - nsCOMPtr rootElem = do_QueryInterface(mHTMLEditor->GetRoot()); + nsCOMPtr rootElem = mHTMLEditor->GetRoot(); NS_ENSURE_TRUE(rootElem, NS_ERROR_FAILURE); int32_t offset, rootOffset; - nsCOMPtr parent = nsEditor::GetNodeLocation(rootElem, &rootOffset); + nsCOMPtr 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 {