Bug 1471596 - Simplify the code in HTMLEditor::GetSelectedOrParentTableElement r?m_kato draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 27 Jun 2018 15:40:43 +0200
changeset 811361 725aa9ff69aa31090b5cd3a5f2eae5d78675836a
parent 810095 5e6723170dbf56ad7fbdf9b2efa1405fbe80f194
push id114274
push userbmo:sledru@mozilla.com
push dateWed, 27 Jun 2018 13:44:14 +0000
reviewersm_kato
bugs1471596
milestone62.0a1
Bug 1471596 - Simplify the code in HTMLEditor::GetSelectedOrParentTableElement r?m_kato the first branch of the if was useless MozReview-Commit-ID: GgKYOcI3sGX
editor/libeditor/HTMLTableEditor.cpp
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -3163,21 +3163,17 @@ HTMLEditor::GetSelectedOrParentTableElem
     nsCOMPtr<nsINode> anchorNode = selection->GetAnchorNode();
     if (NS_WARN_IF(!anchorNode)) {
       return NS_ERROR_FAILURE;
     }
 
     // Get child of anchor node, if exists
     if (anchorNode->HasChildNodes()) {
       nsINode* selectedNode = selection->GetChildAtAnchorOffset();
-      if (!selectedNode) {
-        selectedNode = anchorNode;
-        // If anchor doesn't have a child, we can't be selecting a table element,
-        //  so don't do the following:
-      } else {
+      if (selectedNode) {
         if (selectedNode->IsHTMLElement(nsGkAtoms::td)) {
           tableOrCellElement = selectedNode->AsElement();
           aTagName = tdName;
           // Each cell is in its own selection range,
           //  so count signals multiple-cell selection
           *aSelectedCount = selection->RangeCount();
         } else if (selectedNode->IsHTMLElement(nsGkAtoms::table)) {
           tableOrCellElement = selectedNode->AsElement();