From 70a09127947350eed60b769ea3c090915cf4700e Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Fri, 19 Jan 2018 16:41:41 +0900 Subject: [PATCH] Bug 1425547 - Remove unused methods from nsIHTMLInlineTableEditor. r=masayuki inlineTableEditingEnabled and refreshInlineTableEditingUI are used by bluegriffon, but other methods aren't used by m-c, c-c and bluegriffon. So I would like to remove these methods. Then we can clean up DoInlineTableEditingAction. MozReview-Commit-ID: 3R0bJDU5vqv --HG-- extra : rebase_source : 74c7615613bba65326069929cb53c3ea48f2e9a4 extra : amend_source : a1ac9af3de50daa0cbfd98e2790afa402d9932ef --- editor/libeditor/HTMLEditor.h | 16 ++++ editor/libeditor/HTMLEditorEventListener.cpp | 7 +- editor/libeditor/HTMLInlineTableEditor.cpp | 92 +++++++++----------- editor/nsIHTMLInlineTableEditor.idl | 18 ---- 4 files changed, 60 insertions(+), 73 deletions(-) diff --git a/editor/libeditor/HTMLEditor.h b/editor/libeditor/HTMLEditor.h index 95183de8262e..e075096dc8a9 100644 --- a/editor/libeditor/HTMLEditor.h +++ b/editor/libeditor/HTMLEditor.h @@ -467,6 +467,13 @@ public: */ nsresult OnMouseMove(nsIDOMMouseEvent* aMouseEvent); + /** + * Modifies the table containing the selection according to the + * activation of an inline table editing UI element + * @param aUIAnonymousElement [IN] the inline table editing UI element + */ + nsresult DoInlineTableEditingAction(Element& aUIAnonymousElement); + protected: class BlobReader final : public nsIEditorBlobListener { @@ -1139,8 +1146,17 @@ protected: ManualNACPtr mRemoveRowButton; ManualNACPtr mAddRowAfterButton; + /** + * Shows inline table editing UI around a table cell + * @param aCell [IN] a DOM Element being a table cell, td or th + */ nsresult ShowInlineTableEditingUI(Element* aCell); + /** + * Hide all inline table editing UI + */ + nsresult HideInlineTableEditingUI(); + void AddMouseClickListener(Element* aElement); void RemoveMouseClickListener(Element* aElement); diff --git a/editor/libeditor/HTMLEditorEventListener.cpp b/editor/libeditor/HTMLEditorEventListener.cpp index 95208f9b67e9..ec1a64411d62 100644 --- a/editor/libeditor/HTMLEditorEventListener.cpp +++ b/editor/libeditor/HTMLEditorEventListener.cpp @@ -211,11 +211,14 @@ HTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent) nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target)); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER); - nsCOMPtr element = do_QueryInterface(target); + nsCOMPtr element = do_QueryInterface(target); + if (NS_WARN_IF(!element)) { + return NS_ERROR_FAILURE; + } RefPtr htmlEditor = mEditorBase->AsHTMLEditor(); MOZ_ASSERT(htmlEditor); - htmlEditor->DoInlineTableEditingAction(element); + htmlEditor->DoInlineTableEditingAction(*element); // DoInlineTableEditingAction might cause reframe // Editor is destroyed. if (htmlEditor->Destroyed()) { diff --git a/editor/libeditor/HTMLInlineTableEditor.cpp b/editor/libeditor/HTMLInlineTableEditor.cpp index c7a7bb2e55f6..7160e24c99d3 100644 --- a/editor/libeditor/HTMLInlineTableEditor.cpp +++ b/editor/libeditor/HTMLInlineTableEditor.cpp @@ -42,13 +42,6 @@ HTMLEditor::GetInlineTableEditingEnabled(bool* aIsEnabled) return NS_OK; } -NS_IMETHODIMP -HTMLEditor::ShowInlineTableEditingUI(nsIDOMElement* aCell) -{ - nsCOMPtr cell = do_QueryInterface(aCell); - return ShowInlineTableEditingUI(cell); -} - nsresult HTMLEditor::ShowInlineTableEditingUI(Element* aCell) { @@ -101,7 +94,7 @@ HTMLEditor::ShowInlineTableEditingUI(Element* aCell) return RefreshInlineTableEditingUI(); } -NS_IMETHODIMP +nsresult HTMLEditor::HideInlineTableEditingUI() { mInlineEditedCell = nullptr; @@ -129,62 +122,55 @@ HTMLEditor::HideInlineTableEditingUI() return NS_OK; } -NS_IMETHODIMP -HTMLEditor::DoInlineTableEditingAction(nsIDOMElement* aElement) +nsresult +HTMLEditor::DoInlineTableEditingAction(Element& aElement) { - NS_ENSURE_ARG_POINTER(aElement); - bool anonElement = false; - if (aElement && - NS_SUCCEEDED(aElement->HasAttribute(NS_LITERAL_STRING("_moz_anonclass"), &anonElement)) && - anonElement) { - nsAutoString anonclass; - nsresult rv = - aElement->GetAttribute(NS_LITERAL_STRING("_moz_anonclass"), anonclass); - NS_ENSURE_SUCCESS(rv, rv); + nsAutoString anonclass; + aElement.GetAttr(kNameSpaceID_None, nsGkAtoms::_moz_anonclass, anonclass); - if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) - return NS_OK; + if (!StringBeginsWith(anonclass, NS_LITERAL_STRING("mozTable"))) { + return NS_OK; + } - RefPtr tableElement = GetEnclosingTable(mInlineEditedCell); - int32_t rowCount, colCount; - rv = GetTableSize(tableElement, &rowCount, &colCount); - NS_ENSURE_SUCCESS(rv, rv); + RefPtr tableElement = GetEnclosingTable(mInlineEditedCell); + int32_t rowCount, colCount; + nsresult rv = GetTableSize(tableElement, &rowCount, &colCount); + NS_ENSURE_SUCCESS(rv, rv); - bool hideUI = false; - bool hideResizersWithInlineTableUI = (mResizedObject == tableElement); + bool hideUI = false; + bool hideResizersWithInlineTableUI = (mResizedObject == tableElement); - if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) - InsertTableColumn(1, false); - else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) - InsertTableColumn(1, true); - else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) - InsertTableRow(1, false); - else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) - InsertTableRow(1, true); - else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { - DeleteTableColumn(1); + if (anonclass.EqualsLiteral("mozTableAddColumnBefore")) { + InsertTableColumn(1, false); + } else if (anonclass.EqualsLiteral("mozTableAddColumnAfter")) { + InsertTableColumn(1, true); + } else if (anonclass.EqualsLiteral("mozTableAddRowBefore")) { + InsertTableRow(1, false); + } else if (anonclass.EqualsLiteral("mozTableAddRowAfter")) { + InsertTableRow(1, true); + } else if (anonclass.EqualsLiteral("mozTableRemoveColumn")) { + DeleteTableColumn(1); #ifndef DISABLE_TABLE_DELETION - hideUI = (colCount == 1); + hideUI = (colCount == 1); #endif - } - else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { - DeleteTableRow(1); + } else if (anonclass.EqualsLiteral("mozTableRemoveRow")) { + DeleteTableRow(1); #ifndef DISABLE_TABLE_DELETION - hideUI = (rowCount == 1); + hideUI = (rowCount == 1); #endif - } - else - return NS_OK; + } else { + return NS_OK; + } - // InsertTableRow might causes reframe - if (Destroyed()) { - return NS_OK; - } + // InsertTableRow might causes reframe + if (Destroyed()) { + return NS_OK; + } - if (hideUI) { - HideInlineTableEditingUI(); - if (hideResizersWithInlineTableUI) - HideResizers(); + if (hideUI) { + HideInlineTableEditingUI(); + if (hideResizersWithInlineTableUI) { + HideResizers(); } } diff --git a/editor/nsIHTMLInlineTableEditor.idl b/editor/nsIHTMLInlineTableEditor.idl index bdcd4e36cc8c..b33570155b5f 100644 --- a/editor/nsIHTMLInlineTableEditor.idl +++ b/editor/nsIHTMLInlineTableEditor.idl @@ -18,24 +18,6 @@ interface nsIHTMLInlineTableEditor : nsISupports */ attribute boolean inlineTableEditingEnabled; - /** - * Shows inline table editing UI around a table cell - * @param aCell [IN] a DOM Element being a table cell, td or th - */ - void showInlineTableEditingUI(in nsIDOMElement aCell); - - /** - * Hide all inline table editing UI - */ - void hideInlineTableEditingUI(); - - /** - * Modifies the table containing the selection according to the - * activation of an inline table editing UI element - * @param aUIAnonymousElement [IN] the inline table editing UI element - */ - void doInlineTableEditingAction(in nsIDOMElement aUIAnonymousElement); - /** * Refresh already visible inline table editing UI */