Bug 1432715 - Don't use NS_IMETHOD when method doesn't override. r?masayuki
Some methods in HTMLEditor uses NS_IMETHOD that doesn't override. So we should
replace with nsresult to avoid virtual method.
MozReview-Commit-ID: 7LillLQNhlg
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1768,17 +1768,17 @@ HTMLEditor::GetCSSBackgroundColorState(b
}
}
nodeToExamine = nodeToExamine->GetParentNode();
} while ( aOutColor.EqualsLiteral("transparent") && nodeToExamine );
}
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::GetHTMLBackgroundColorState(bool* aMixed,
nsAString& aOutColor)
{
//TODO: We don't handle "mixed" correctly!
NS_ENSURE_TRUE(aMixed, NS_ERROR_NULL_POINTER);
*aMixed = false;
aOutColor.Truncate();
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -152,17 +152,17 @@ public:
nsresult CopyLastEditableChildStyles(nsINode* aPreviousBlock,
nsINode* aNewBlock,
Element** aOutBrNode);
nsresult LoadHTML(const nsAString& aInputString);
nsresult GetCSSBackgroundColorState(bool* aMixed, nsAString& aOutColor,
bool aBlockLevel);
- NS_IMETHOD GetHTMLBackgroundColorState(bool* aMixed, nsAString& outColor);
+ nsresult GetHTMLBackgroundColorState(bool* aMixed, nsAString& outColor);
// nsIEditorStyleSheets methods
NS_DECL_NSIEDITORSTYLESHEETS
// nsIEditorMailSupport methods
NS_DECL_NSIEDITORMAILSUPPORT
// nsITableEditor methods
@@ -533,37 +533,37 @@ protected:
// Table Editing (implemented in nsTableEditor.cpp)
/**
* Insert a new cell after or before supplied aCell.
* Optional: If aNewCell supplied, returns the newly-created cell (addref'd,
* of course)
* This doesn't change or use the current selection.
*/
- NS_IMETHOD InsertCell(nsIDOMElement* aCell, int32_t aRowSpan,
- int32_t aColSpan, bool aAfter, bool aIsHeader,
- nsIDOMElement** aNewCell);
+ nsresult InsertCell(nsIDOMElement* aCell, int32_t aRowSpan,
+ int32_t aColSpan, bool aAfter, bool aIsHeader,
+ nsIDOMElement** aNewCell);
/**
* Helpers that don't touch the selection or do batch transactions.
*/
- NS_IMETHOD DeleteRow(nsIDOMElement* aTable, int32_t aRowIndex);
- NS_IMETHOD DeleteColumn(nsIDOMElement* aTable, int32_t aColIndex);
- NS_IMETHOD DeleteCellContents(nsIDOMElement* aCell);
+ nsresult DeleteRow(nsIDOMElement* aTable, int32_t aRowIndex);
+ nsresult DeleteColumn(nsIDOMElement* aTable, int32_t aColIndex);
+ nsresult DeleteCellContents(nsIDOMElement* aCell);
/**
* Move all contents from aCellToMerge into aTargetCell (append at end).
*/
- NS_IMETHOD MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
- nsCOMPtr<nsIDOMElement> aCellToMerge,
- bool aDeleteCellToMerge);
+ nsresult MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
+ nsCOMPtr<nsIDOMElement> aCellToMerge,
+ bool aDeleteCellToMerge);
nsresult DeleteTable2(nsIDOMElement* aTable, Selection* aSelection);
- NS_IMETHOD SetColSpan(nsIDOMElement* aCell, int32_t aColSpan);
- NS_IMETHOD SetRowSpan(nsIDOMElement* aCell, int32_t aRowSpan);
+ nsresult SetColSpan(nsIDOMElement* aCell, int32_t aColSpan);
+ nsresult SetRowSpan(nsIDOMElement* aCell, int32_t aRowSpan);
/**
* Helper used to get nsTableWrapperFrame for a table.
*/
nsTableWrapperFrame* GetTableFrame(nsIDOMElement* aTable);
/**
* Needed to do appropriate deleting when last cell or row is about to be
@@ -591,39 +591,39 @@ protected:
* Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is
* null.
*/
nsresult GetCellContext(Selection** aSelection, nsIDOMElement** aTable,
nsIDOMElement** aCell, nsIDOMNode** aCellParent,
int32_t* aCellOffset, int32_t* aRowIndex,
int32_t* aColIndex);
- NS_IMETHOD GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex,
- int32_t aColIndex, int32_t& aActualRowSpan,
- int32_t& aActualColSpan);
+ nsresult GetCellSpansAt(nsIDOMElement* aTable, int32_t aRowIndex,
+ int32_t aColIndex, int32_t& aActualRowSpan,
+ int32_t& aActualColSpan);
- NS_IMETHOD SplitCellIntoColumns(nsIDOMElement* aTable, int32_t aRowIndex,
- int32_t aColIndex, int32_t aColSpanLeft,
- int32_t aColSpanRight,
- nsIDOMElement** aNewCell);
+ nsresult SplitCellIntoColumns(nsIDOMElement* aTable, int32_t aRowIndex,
+ int32_t aColIndex, int32_t aColSpanLeft,
+ int32_t aColSpanRight,
+ nsIDOMElement** aNewCell);
- NS_IMETHOD SplitCellIntoRows(nsIDOMElement* aTable, int32_t aRowIndex,
- int32_t aColIndex, int32_t aRowSpanAbove,
- int32_t aRowSpanBelow, nsIDOMElement** aNewCell);
+ nsresult SplitCellIntoRows(nsIDOMElement* aTable, int32_t aRowIndex,
+ int32_t aColIndex, int32_t aRowSpanAbove,
+ int32_t aRowSpanBelow, nsIDOMElement** aNewCell);
nsresult CopyCellBackgroundColor(nsIDOMElement* destCell,
nsIDOMElement* sourceCell);
/**
* Reduce rowspan/colspan when cells span into nonexistent rows/columns.
*/
- NS_IMETHOD FixBadRowSpan(nsIDOMElement* aTable, int32_t aRowIndex,
- int32_t& aNewRowCount);
- NS_IMETHOD FixBadColSpan(nsIDOMElement* aTable, int32_t aColIndex,
- int32_t& aNewColCount);
+ nsresult FixBadRowSpan(nsIDOMElement* aTable, int32_t aRowIndex,
+ int32_t& aNewRowCount);
+ nsresult FixBadColSpan(nsIDOMElement* aTable, int32_t aColIndex,
+ int32_t& aNewColCount);
/**
* Fallback method: Call this after using ClearSelection() and you
* failed to set selection to some other content in the document.
*/
nsresult SetSelectionAtDocumentStart(Selection* aSelection);
nsresult GetTableSize(Element* aTable,
@@ -655,30 +655,30 @@ protected:
*/
bool IsTextPropertySetByContent(nsINode* aNode,
nsAtom* aProperty,
nsAtom* aAttribute,
const nsAString* aValue,
nsAString* outValue = nullptr);
// Methods for handling plaintext quotations
- NS_IMETHOD PasteAsPlaintextQuotation(int32_t aSelectionType);
+ nsresult PasteAsPlaintextQuotation(int32_t aSelectionType);
/**
* Insert a string as quoted text, replacing the selected text (if any).
* @param aQuotedText The string to insert.
* @param aAddCites Whether to prepend extra ">" to each line
* (usually true, unless those characters
* have already been added.)
* @return aNodeInserted The node spanning the insertion, if applicable.
* If aAddCites is false, this will be null.
*/
- NS_IMETHOD InsertAsPlaintextQuotation(const nsAString& aQuotedText,
- bool aAddCites,
- nsIDOMNode** aNodeInserted);
+ nsresult InsertAsPlaintextQuotation(const nsAString& aQuotedText,
+ bool aAddCites,
+ nsIDOMNode** aNodeInserted);
nsresult InsertObject(const nsACString& aType, nsISupports* aObject,
bool aIsSafe,
nsIDOMDocument* aSourceDoc,
nsIDOMNode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -1637,17 +1637,17 @@ HTMLEditor::PasteAsCitedQuotation(const
NS_ENSURE_SUCCESS(rv, rv);
return Paste(aSelectionType);
}
/**
* Paste a plaintext quotation.
*/
-NS_IMETHODIMP
+nsresult
HTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType)
{
// Get Clipboard Service
nsresult rv;
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
// Create generic Transferable for getting the data
@@ -1794,17 +1794,17 @@ HTMLEditor::InsertAsQuotation(const nsAS
return InsertAsCitedQuotation(aQuotedText, citation, false,
aNodeInserted);
}
// Insert plaintext as a quotation, with cite marks (e.g. "> ").
// This differs from its corresponding method in TextEditor
// in that here, quoted material is enclosed in a <pre> tag
// in order to preserve the original line wrapping.
-NS_IMETHODIMP
+nsresult
HTMLEditor::InsertAsPlaintextQuotation(const nsAString& aQuotedText,
bool aAddCites,
nsIDOMNode** aNodeInserted)
{
// get selection
RefPtr<Selection> selection = GetSelection();
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -82,17 +82,17 @@ public:
// when one method yields control to another
void CancelSetCaret()
{
mHTMLEditor = nullptr;
mTable = nullptr;
}
};
-NS_IMETHODIMP
+nsresult
HTMLEditor::InsertCell(nsIDOMElement* aDOMCell,
int32_t aRowSpan,
int32_t aColSpan,
bool aAfter,
bool aIsHeader,
nsIDOMElement** aNewDOMCell)
{
if (aNewDOMCell) {
@@ -149,27 +149,27 @@ HTMLEditor::InsertCell(nsIDOMElement* aD
"Failed to advance offset to after the old cell");
}
// Don't let Rules System change the selection.
AutoTransactionsConserveSelection dontChangeSelection(this);
return InsertNode(*newCell, pointToInsert.AsRaw());
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::SetColSpan(nsIDOMElement* aCell,
int32_t aColSpan)
{
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
nsAutoString newSpan;
newSpan.AppendInt(aColSpan, 10);
return SetAttribute(aCell, NS_LITERAL_STRING("colspan"), newSpan);
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::SetRowSpan(nsIDOMElement* aCell,
int32_t aRowSpan)
{
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
nsAutoString newSpan;
newSpan.AppendInt(aRowSpan, 10);
return SetAttribute(aCell, NS_LITERAL_STRING("rowspan"), newSpan);
}
@@ -982,17 +982,17 @@ HTMLEditor::DeleteTableCellContents()
NS_ENSURE_SUCCESS(rv, rv);
} else {
cell = nullptr;
}
}
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::DeleteCellContents(nsIDOMElement* aCell)
{
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
// Prevent rules testing until we're done
AutoRules beginRulesSniffing(this, EditAction::deleteNode, nsIEditor::eNext);
nsCOMPtr<nsIDOMNode> child;
@@ -1084,17 +1084,17 @@ HTMLEditor::DeleteTableColumn(int32_t aN
for (int32_t i = 0; i < aNumber; i++) {
rv = DeleteColumn(table, startColIndex);
NS_ENSURE_SUCCESS(rv, rv);
}
}
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::DeleteColumn(nsIDOMElement* aTable,
int32_t aColIndex)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> cell;
int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
bool isSelected;
@@ -1261,17 +1261,17 @@ HTMLEditor::DeleteTableRow(int32_t aNumb
break;
}
}
}
return NS_OK;
}
// Helper that doesn't batch or change the selection
-NS_IMETHODIMP
+nsresult
HTMLEditor::DeleteRow(nsIDOMElement* aTable,
int32_t aRowIndex)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> cell;
nsCOMPtr<nsIDOMElement> cellInDeleteRow;
int32_t startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
@@ -1790,17 +1790,17 @@ HTMLEditor::CopyCellBackgroundColor(nsID
return rv;
}
if (!isSet) {
return NS_OK;
}
return SetAttribute(destCell, bgcolor, color);
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::SplitCellIntoColumns(nsIDOMElement* aTable,
int32_t aRowIndex,
int32_t aColIndex,
int32_t aColSpanLeft,
int32_t aColSpanRight,
nsIDOMElement** aNewCell)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
@@ -1838,17 +1838,17 @@ HTMLEditor::SplitCellIntoColumns(nsIDOME
return NS_OK;
}
if (aNewCell) {
NS_ADDREF(*aNewCell = newCell.get());
}
return CopyCellBackgroundColor(newCell, cell);
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::SplitCellIntoRows(nsIDOMElement* aTable,
int32_t aRowIndex,
int32_t aColIndex,
int32_t aRowSpanAbove,
int32_t aRowSpanBelow,
nsIDOMElement** aNewCell)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
@@ -2303,17 +2303,17 @@ HTMLEditor::JoinTableCells(bool aMergeNo
// Reset target cell's colspan to encompass cell to the right
rv = SetColSpan(targetCell, actualColSpan+actualColSpan2);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::MergeCells(nsCOMPtr<nsIDOMElement> aTargetCell,
nsCOMPtr<nsIDOMElement> aCellToMerge,
bool aDeleteCellToMerge)
{
nsCOMPtr<dom::Element> targetCell = do_QueryInterface(aTargetCell);
nsCOMPtr<dom::Element> cellToMerge = do_QueryInterface(aCellToMerge);
NS_ENSURE_TRUE(targetCell && cellToMerge, NS_ERROR_NULL_POINTER);
@@ -2355,17 +2355,17 @@ HTMLEditor::MergeCells(nsCOMPtr<nsIDOMEl
if (aDeleteCellToMerge) {
return DeleteNode(aCellToMerge);
}
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::FixBadRowSpan(nsIDOMElement* aTable,
int32_t aRowIndex,
int32_t& aNewRowCount)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
int32_t rowCount, colCount;
nsresult rv = GetTableSize(aTable, &rowCount, &colCount);
@@ -2420,17 +2420,17 @@ HTMLEditor::FixBadRowSpan(nsIDOMElement*
}
}
NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in FixBadRowSpan");
}
}
return GetTableSize(aTable, &aNewRowCount, &colCount);
}
-NS_IMETHODIMP
+nsresult
HTMLEditor::FixBadColSpan(nsIDOMElement* aTable,
int32_t aColIndex,
int32_t& aNewColCount)
{
NS_ENSURE_TRUE(aTable, NS_ERROR_NULL_POINTER);
int32_t rowCount, colCount;
nsresult rv = GetTableSize(aTable, &rowCount, &colCount);
@@ -2780,17 +2780,17 @@ HTMLEditor::GetCellAt(nsIDOMElement* aTa
nsCOMPtr<nsIDOMElement> domCell =
do_QueryInterface(tableFrame->GetCellAt(aRowIndex, aColIndex));
domCell.forget(aCell);
return NS_OK;
}
// When all you want are the rowspan and colspan (not exposed in nsITableEditor)
-NS_IMETHODIMP
+nsresult
HTMLEditor::GetCellSpansAt(nsIDOMElement* aTable,
int32_t aRowIndex,
int32_t aColIndex,
int32_t& aActualRowSpan,
int32_t& aActualColSpan)
{
nsTableWrapperFrame* tableFrame = GetTableFrame(aTable);
if (!tableFrame) {