Bug 1425547 - Remove unused methods from nsIHTMLInlineTableEditor. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 19 Jan 2018 16:41:41 +0900
changeset 722938 74c7615613bba65326069929cb53c3ea48f2e9a4
parent 722937 0e3b71fe3a081111865c5a7b982651a4ac597c84
child 746723 e046489977a13b73fb176a6192d042c3124e6b0f
push id96275
push userbmo:m_kato@ga2.so-net.ne.jp
push dateSun, 21 Jan 2018 04:14:29 +0000
reviewersmasayuki
bugs1425547
milestone59.0a1
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
@@ -461,16 +461,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);
@@ -1133,18 +1140,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,21 @@ 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);
 
   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();
 };