Bug 1484126 - part 8: Replace |CellData::mCurrent.mRow - CellData::mFirst.mRow| with CellData::NumberOfPrecedingRows() r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 15 Oct 2018 05:06:13 +0000
changeset 489731 b23363aa593d1dffea31f626f53f430953be556b
parent 489730 448d887560d4e6be3e91e831ebe161fc858bb68f
child 489732 8f7afde0a6f624e98469f07ed14f7f350e503861
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersm_kato
bugs1484126
milestone64.0a1
Bug 1484126 - part 8: Replace |CellData::mCurrent.mRow - CellData::mFirst.mRow| with CellData::NumberOfPrecedingRows() r=m_kato Differential Revision: https://phabricator.services.mozilla.com/D8345
editor/libeditor/HTMLTableEditor.cpp
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -1698,28 +1698,27 @@ HTMLEditor::DeleteTableRowWithTransactio
     if (cellData.IsSpannedFromOtherRow()) {
       // 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 (rowSpan > 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.mCurrent.mRow - cellData.mFirst.mRow,
-                   actualRowSpan - 1);
+          std::max(cellData.NumberOfPrecedingRows(), actualRowSpan - 1);
         spanCellArray.AppendElement(
                         SpanCell(cellData.mElement, newRowSpanValue));
       }
     } else {
       if (rowSpan > 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.mCurrent.mRow - cellData.mFirst.mRow + 1;
+          cellData.NumberOfPrecedingRows() + 1;
         int32_t numOfRawSpanRemainingBelow = actualRowSpan - 1;
         nsresult rv =
           SplitCellIntoRows(&aTableElement, cellData.mFirst.mRow, startColIndex,
                             aboveRowToInsertNewCellInto,
                             numOfRawSpanRemainingBelow, nullptr);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
@@ -2853,25 +2852,23 @@ HTMLEditor::JoinTableCells(bool aMergeNo
     }
 
     // sanity check
     NS_ASSERTION(rightCellData.mCurrent.mRow >= rightCellData.mFirst.mRow,
       "JoinCells: rightCellData.mCurrent.mRow < rightCellData.mFirst.mRow");
 
     // Figure out span of merged cell starting from target's starting row
     // to handle case of merged cell starting in a row above
-    int32_t spanAboveMergedCell =
-      rightCellData.mCurrent.mRow - rightCellData.mFirst.mRow;
+    int32_t spanAboveMergedCell = rightCellData.NumberOfPrecedingRows();
     int32_t effectiveRowSpan2 = actualRowSpan2 - spanAboveMergedCell;
-
     if (effectiveRowSpan2 > actualRowSpan) {
       // Cell to the right spans into row below target
       // Split off portion below target cell's bottom-most row
       rv = SplitCellIntoRows(table, rightCellData.mFirst.mRow, startColIndex2,
-                             spanAboveMergedCell+actualRowSpan,
+                             spanAboveMergedCell + actualRowSpan,
                              effectiveRowSpan2-actualRowSpan, nullptr);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     }
 
     // Move contents from cell to the right
     // Delete the cell now only if it starts in the same row