Bug 1484126 - part 14: Replace |CellData::mEffectiveRowSpan - 1| with CellData::NumberOfFollowingRows() r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 15 Oct 2018 11:15:15 +0000
changeset 489737 ed17432df28cf6e49cd8909835ae1b684d66f14c
parent 489736 3e1b1e01e6a43921ba453465c7d18ce5623b787d
child 489738 e5c8e5cbaf3dbbc60d6d2dce5db844820c6009b9
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersm_kato
bugs1484126
milestone64.0a1
Bug 1484126 - part 14: Replace |CellData::mEffectiveRowSpan - 1| with CellData::NumberOfFollowingRows() r=m_kato Differential Revision: https://phabricator.services.mozilla.com/D8351
editor/libeditor/HTMLTableEditor.cpp
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -1404,34 +1404,34 @@ HTMLEditor::DeleteTableColumnWithTransac
         // so delete contents of cell instead of cell itself (We must have
         // reset colspan above).
         DebugOnly<nsresult> rv =
           DeleteAllChildrenWithTransaction(*cellData.mElement);
         NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
           "Failed to remove all children of the cell element");
       }
       // Skip rows which the removed cell spanned.
-      rowIndex += cellData.mEffectiveRowSpan - 1;
+      rowIndex += cellData.NumberOfFollowingRows();
       continue;
     }
 
     // Delete the cell
     int32_t numberOfCellsInRow =
       GetNumberOfCellsInRow(aTableElement, cellData.mCurrent.mRow);
     NS_WARNING_ASSERTION(numberOfCellsInRow > 0,
       "Failed to count existing cells in the row");
     if (numberOfCellsInRow != 1) {
       // If removing cell is not the last cell of the row, we can just remove
       // it.
       nsresult rv = DeleteNodeWithTransaction(*cellData.mElement);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       // Skip rows which the removed cell spanned.
-      rowIndex += cellData.mEffectiveRowSpan - 1;
+      rowIndex += cellData.NumberOfFollowingRows();
       continue;
     }
 
     // When the cell is the last cell in the row, remove the row instead.
     Element* parentRow =
       GetElementOrParentByTagNameInternal(*nsGkAtoms::tr, *cellData.mElement);
     if (NS_WARN_IF(!parentRow)) {
       return NS_ERROR_FAILURE;
@@ -1672,33 +1672,32 @@ HTMLEditor::DeleteTableRowWithTransactio
       // If a cell starts in row above us, decrease its rowspan to keep table
       // rectangular but we don't need to do this if rowspan=0, since it will
       // be automatically adjusted.
       if (cellData.mRowSpan > 0) {
         // Build list of cells to change rowspan.  We can't do it now since
         // it upsets cell map, so we will do it after deleting the row.
         int32_t newRowSpanValue =
           std::max(cellData.NumberOfPrecedingRows(),
-                   cellData.mEffectiveRowSpan - 1);
+                   cellData.NumberOfFollowingRows());
         spanCellArray.AppendElement(
                         SpanCell(cellData.mElement, newRowSpanValue));
       }
     } else {
       if (cellData.mRowSpan > 1) {
         // Cell spans below row to delete, so we must insert new cells to
         // keep rows below.  Note that we test "rowSpan" so we don't do this
         // if rowSpan = 0 (automatic readjustment).
         int32_t aboveRowToInsertNewCellInto =
           cellData.NumberOfPrecedingRows() + 1;
-        int32_t numOfRawSpanRemainingBelow = cellData.mEffectiveRowSpan - 1;
         nsresult rv =
           SplitCellIntoRows(&aTableElement,
                             cellData.mFirst.mRow, cellData.mFirst.mColumn,
                             aboveRowToInsertNewCellInto,
-                            numOfRawSpanRemainingBelow, nullptr);
+                            cellData.NumberOfFollowingRows(), nullptr);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
       if (!cellInDeleteRow) {
         // Reference cell to find row to delete.
         cellInDeleteRow = std::move(cellData.mElement);
       }