diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp
index 1155bc215d30..f2dde1cdd542 100644
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -4074,7 +4074,7 @@ nsCOMPtr nsHTMLEditor::FindPreElement()
nsString prestr ("PRE"); // GetFirstNodeOfType requires capitals
nsCOMPtr preNode;
if (NS_FAILED(nsEditor::GetFirstNodeOfType(rootNode, prestr,
- getter_AddRefs(preNode))))
+ getter_AddRefs(preNode))))
return 0;
return do_QueryInterface(preNode);
@@ -4108,10 +4108,11 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
while (!iter->IsDone())
{
- nsCOMPtr text = do_QueryInterface(iter->GetCurrentNode());
- if (text && IsEditable(text))
- {
- textNodes.AppendElement(text);
+ nsINode* node = iter->GetCurrentNode();
+ if (node->NodeType() == nsIDOMNode::TEXT_NODE &&
+ IsEditable(static_cast(node))) {
+ nsCOMPtr domNode = do_QueryInterface(node);
+ textNodes.AppendElement(domNode);
}
iter->Next();
@@ -4150,10 +4151,10 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
NS_IMETHODIMP
nsHTMLEditor::SetSelectionAtDocumentStart(nsISelection *aSelection)
{
- nsCOMPtr rootElement = do_QueryInterface(GetRoot());
+ dom::Element* rootElement = GetRoot();
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
- return aSelection->Collapse(rootElement,0);
+ return aSelection->CollapseNative(rootElement, 0);
}
@@ -4920,26 +4921,24 @@ nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
nsresult
nsHTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked)
{
- nsresult err = NS_ERROR_NOT_INITIALIZED;
- if (mHTMLCSSUtils)
- {
- err = mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
+ if (!mHTMLCSSUtils) {
+ return NS_ERROR_NOT_INITIALIZED;
}
- // Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
- if (NS_SUCCEEDED(err)) {
- PRUint32 flags = mFlags;
- if (aIsCSSPrefChecked) {
- // Turn off NoCSS as we're enabling CSS
- flags &= ~eEditorNoCSSMask;
- } else {
- // Turn on NoCSS, as we're disabling CSS.
- flags |= eEditorNoCSSMask;
- }
- err = SetFlags(flags);
- NS_ENSURE_SUCCESS(err, err);
+ nsresult rv = mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
+ PRUint32 flags = mFlags;
+ if (aIsCSSPrefChecked) {
+ // Turn off NoCSS as we're enabling CSS
+ flags &= ~eEditorNoCSSMask;
+ } else {
+ // Turn on NoCSS, as we're disabling CSS.
+ flags |= eEditorNoCSSMask;
}
- return err;
+
+ return SetFlags(flags);
}
// Set the block background color
@@ -5265,8 +5264,7 @@ nsHTMLEditor::CopyLastEditableChildStyles(nsIDOMNode * aPreviousBlock, nsIDOMNod
res = CreateBR(deepestStyle, 0, address_of(outBRNode));
NS_ENSURE_SUCCESS(res, res);
// Getters must addref
- *aOutBrNode = outBRNode;
- NS_ADDREF(*aOutBrNode);
+ outBRNode.forget(aOutBrNode);
}
return NS_OK;
}
@@ -5410,9 +5408,7 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn)
}
nsCOMPtr focusElement = do_QueryInterface(focusNode);
- *aReturn = focusElement;
- NS_IF_ADDREF(*aReturn);
-
+ focusElement.forget(aReturn);
return NS_OK;
}
@@ -5639,8 +5635,7 @@ nsHTMLEditor::GetFocusedNode()
}
nsCOMPtr doc = do_QueryReferent(mDocWeak);
- nsCOMPtr node = do_QueryInterface(doc);
- return node.forget();
+ return doc.forget();
}
bool