Bug 1425547 - Remove unused methods from nsIHTMLInlineTableEditor. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 19 Jan 2018 16:41:41 +0900
changeset 400596 c208e865749a5c5840264dff8ff4a9c492cdcc18
parent 400595 06e5dd66fb820b350b9fc4d345acbc34fbc2c88c
child 400597 9725c7458926105b34a7a492582345284fcfd0f1
push id33311
push usernbeleuzu@mozilla.com
push dateWed, 24 Jan 2018 21:56:54 +0000
treeherdermozilla-central@32b850fa28ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1425547
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
editor/libeditor/HTMLEditor.h
editor/libeditor/HTMLEditorEventListener.cpp
editor/libeditor/HTMLInlineTableEditor.cpp
editor/nsIHTMLInlineTableEditor.idl
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -462,16 +462,23 @@ public:
   nsresult OnMouseUp(int32_t aX, int32_t aY, nsIDOMElement* aTarget);
 
   /**
    * event callback when the mouse pointer is moved
    * @param aMouseEvent [IN] the event
    */
   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
   {
   public:
     BlobReader(dom::BlobImpl* aBlob, HTMLEditor* aHTMLEditor,
                bool aIsSafe, nsIDOMDocument* aSourceDoc,
                nsIDOMNode* aDestinationNode, int32_t aDestOffset,
                bool aDoDeleteSelection);
@@ -1134,18 +1141,27 @@ protected:
   ManualNACPtr mAddColumnBeforeButton;
   ManualNACPtr mRemoveColumnButton;
   ManualNACPtr mAddColumnAfterButton;
 
   ManualNACPtr mAddRowBeforeButton;
   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);
 
   nsCOMPtr<nsILinkHandler> mLinkHandler;
 
   ParagraphSeparator mDefaultParagraphSeparator;
 
 public:
--- a/editor/libeditor/HTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -206,21 +206,24 @@ HTMLEditorEventListener::MouseClick(nsID
   if (NS_WARN_IF(DetachedFromEditor())) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIDOMEventTarget> target;
   nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
-  nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
+  nsCOMPtr<Element> element = do_QueryInterface(target);
+  if (NS_WARN_IF(!element)) {
+    return NS_ERROR_FAILURE;
+  }
 
   RefPtr<HTMLEditor> htmlEditor = mEditorBase->AsHTMLEditor();
   MOZ_ASSERT(htmlEditor);
-  htmlEditor->DoInlineTableEditingAction(element);
+  htmlEditor->DoInlineTableEditingAction(*element);
   // DoInlineTableEditingAction might cause reframe
   // Editor is destroyed.
   if (htmlEditor->Destroyed()) {
     return NS_OK;
   }
 
   return EditorEventListener::MouseClick(aMouseEvent);
 }
--- a/editor/libeditor/HTMLInlineTableEditor.cpp
+++ b/editor/libeditor/HTMLInlineTableEditor.cpp
@@ -37,23 +37,16 @@ HTMLEditor::SetInlineTableEditingEnabled
 
 NS_IMETHODIMP
 HTMLEditor::GetInlineTableEditingEnabled(bool* aIsEnabled)
 {
   *aIsEnabled = mIsInlineTableEditingEnabled;
   return NS_OK;
 }
 
-NS_IMETHODIMP
-HTMLEditor::ShowInlineTableEditingUI(nsIDOMElement* aCell)
-{
-  nsCOMPtr<Element> cell = do_QueryInterface(aCell);
-  return ShowInlineTableEditingUI(cell);
-}
-
 nsresult
 HTMLEditor::ShowInlineTableEditingUI(Element* aCell)
 {
   // do nothing if aCell is not a table cell...
   if (!aCell || !HTMLEditUtils::IsTableCell(aCell)) {
     return NS_OK;
   }
 
@@ -96,17 +89,17 @@ HTMLEditor::ShowInlineTableEditingUI(Ele
   AddMouseClickListener(mAddRowBeforeButton);
   AddMouseClickListener(mRemoveRowButton);
   AddMouseClickListener(mAddRowAfterButton);
 
   mInlineEditedCell = aCell;
   return RefreshInlineTableEditingUI();
 }
 
-NS_IMETHODIMP
+nsresult
 HTMLEditor::HideInlineTableEditingUI()
 {
   mInlineEditedCell = nullptr;
 
   RemoveMouseClickListener(mAddColumnBeforeButton);
   RemoveMouseClickListener(mRemoveColumnButton);
   RemoveMouseClickListener(mAddColumnAfterButton);
   RemoveMouseClickListener(mAddRowBeforeButton);
@@ -124,72 +117,65 @@ HTMLEditor::HideInlineTableEditingUI()
   DeleteRefToAnonymousNode(Move(mAddColumnAfterButton), ps);
   DeleteRefToAnonymousNode(Move(mAddRowBeforeButton), ps);
   DeleteRefToAnonymousNode(Move(mRemoveRowButton), ps);
   DeleteRefToAnonymousNode(Move(mAddRowAfterButton), ps);
 
   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<Element> tableElement = GetEnclosingTable(mInlineEditedCell);
+  int32_t rowCount, colCount;
+  nsresult rv = GetTableSize(tableElement, &rowCount, &colCount);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    RefPtr<Element> tableElement = GetEnclosingTable(mInlineEditedCell);
-    int32_t rowCount, colCount;
-    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();
     }
   }
 
   return NS_OK;
 }
 
 void
 HTMLEditor::AddMouseClickListener(Element* aElement)
--- a/editor/nsIHTMLInlineTableEditor.idl
+++ b/editor/nsIHTMLInlineTableEditor.idl
@@ -14,31 +14,13 @@ interface nsIHTMLInlineTableEditor : nsI
    * boolean indicating if inline table editing is enabled in the editor.
    * When inline table editing is enabled, and when the selection is
    * contained in a table cell, special buttons allowing to add/remove
    * a line/column are available on the cell's border.
    */
   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
    */
   void refreshInlineTableEditingUI();
 };