Bug 1484126 - part 10: Replace all comparisons of CellData::mFirst.mColumn and CellData::mCurrent.mColumn with CellData::IsSpannedFromOtherColumn() or CellData::IsSpannedFromOtherRowOrColumn() r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 15 Oct 2018 08:06:14 +0000
changeset 499835 3e9c08f4f705ff9c789de57b68207d87b6045416
parent 499834 8f7afde0a6f624e98469f07ed14f7f350e503861
child 499836 6ab5dd75fbf4c7d8b02ee5d538ab69bc26fc087d
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1484126
milestone64.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 1484126 - part 10: Replace all comparisons of CellData::mFirst.mColumn and CellData::mCurrent.mColumn with CellData::IsSpannedFromOtherColumn() or CellData::IsSpannedFromOtherRowOrColumn() r=m_kato Differential Revision: https://phabricator.services.mozilla.com/D8347
editor/libeditor/HTMLTableEditor.cpp
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -525,17 +525,17 @@ HTMLEditor::InsertTableColumnsWithTransa
       // Don't fail entire process if we fail to find a cell (may fail just in
       // particular rows with < adequate cells per row).
       // XXX So, here wants to know whether the CellData actually failed above.
       //     Fix this later.
       if (!cellData.mElement) {
         continue;
       }
 
-      if (cellData.mFirst.mColumn < cellData.mCurrent.mColumn) {
+      if (cellData.IsSpannedFromOtherColumn()) {
         // If we have a cell spanning this location, simply increase its
         // colspan to keep table rectangular.
         // Note: we do nothing if colsspan=0, since it should automatically
         // span the new column.
         if (colSpan > 0) {
           SetColSpan(cellData.mElement, colSpan + aNumberOfColumnsToInsert);
         }
         continue;
@@ -1402,25 +1402,25 @@ HTMLEditor::DeleteTableColumnWithTransac
     // int32_t rowSpan =             cellData.mRowSpan;
     int32_t    colSpan =             cellData.mColSpan;
     int32_t    actualRowSpan =       cellData.mEffectiveRowSpan;
     // int32_t actualColSpan =       cellData.mEffectiveColSpan;
     // bool    isSelected =          cellData.mIsSelected;
 
     // Find cells that don't start in column we are deleting.
     MOZ_ASSERT(colSpan >= 0);
-    if (cellData.mFirst.mColumn < cellData.mCurrent.mColumn || colSpan != 1) {
+    if (cellData.IsSpannedFromOtherColumn() || colSpan != 1) {
       // If we have a cell spanning this location, decrease its colspan to
       // keep table rectangular, but if colspan is 0, it'll be adjusted
       // automatically.
       if (colSpan > 0) {
         NS_WARNING_ASSERTION(colSpan > 1, "colspan should be 2 or larger");
         SetColSpan(cellData.mElement, colSpan - 1);
       }
-      if (cellData.mFirst.mColumn == cellData.mCurrent.mColumn) {
+      if (!cellData.IsSpannedFromOtherColumn()) {
         // Cell is in column to be deleted, but must have colspan > 1,
         // 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");
       }
@@ -1900,18 +1900,17 @@ HTMLEditor::SelectBlockOfCells(Element* 
       // int32_t actualRowSpan =       cellData.mEffectiveRowSpan;
                  actualColSpan =       cellData.mEffectiveColSpan;
       bool       isSelected =          cellData.mIsSelected;
 
       // Skip cells that already selected or are spanned from previous locations
       // XXX So, we should distinguish whether CellData returns error or just
       //     not found later.
       if (!isSelected && cellData.mElement &&
-          !cellData.IsSpannedFromOtherRow() &&
-          cellData.mCurrent.mColumn == cellData.mFirst.mColumn) {
+          !cellData.IsSpannedFromOtherRowOrColumn()) {
         rv = AppendNodeToSelectionAsRange(cellData.mElement);
         if (NS_FAILED(rv)) {
           break;
         }
       }
     }
   }
   // NS_OK, otherwise, the last failure of AppendNodeToSelectionAsRange().
@@ -1973,18 +1972,17 @@ HTMLEditor::SelectAllTableCells()
       // int32_t actualRowSpan =       cellData.mEffectiveRowSpan;
                  actualColSpan =       cellData.mEffectiveColSpan;
       // bool    isSelected =          cellData.mIsSelected;
 
       // Skip cells that are spanned from previous rows or columns
       // XXX So, we should distinguish whether CellData returns error or just
       //     not found later.
       if (cellData.mElement &&
-          !cellData.IsSpannedFromOtherRow() &&
-          cellData.mCurrent.mColumn == cellData.mFirst.mColumn) {
+          !cellData.IsSpannedFromOtherRowOrColumn()) {
         rv =  AppendNodeToSelectionAsRange(cellData.mElement);
         if (NS_FAILED(rv)) {
           break;
         }
         cellSelected = true;
       }
     }
   }
@@ -2065,18 +2063,17 @@ HTMLEditor::SelectTableRow()
     // int32_t actualRowSpan =       cellData.mEffectiveRowSpan;
                actualColSpan =       cellData.mEffectiveColSpan;
     // bool    isSelected =          cellData.mIsSelected;
 
     // Skip cells that are spanned from previous rows or columns
     // XXX So, we should distinguish whether CellData returns error or just
     //     not found later.
     if (cellData.mElement &&
-        !cellData.IsSpannedFromOtherRow() &&
-        cellData.mFirst.mColumn == cellData.mCurrent.mColumn) {
+        !cellData.IsSpannedFromOtherRowOrColumn()) {
       rv = AppendNodeToSelectionAsRange(cellData.mElement);
       if (NS_FAILED(rv)) {
         break;
       }
       cellSelected = true;
     }
   }
   // Safety code to select starting cell if nothing else was selected
@@ -2152,18 +2149,17 @@ HTMLEditor::SelectTableColumn()
                actualRowSpan =       cellData.mEffectiveRowSpan;
     // int32_t actualColSpan =       cellData.mEffectiveColSpan;
     // bool    isSelected =          cellData.mIsSelected;
 
     // Skip cells that are spanned from previous rows or columns
     // XXX So, we should distinguish whether CellData returns error or just
     //     not found later.
     if (cellData.mElement &&
-        !cellData.IsSpannedFromOtherRow() &&
-        cellData.mFirst.mColumn == cellData.mCurrent.mColumn) {
+        !cellData.IsSpannedFromOtherRowOrColumn()) {
       rv = AppendNodeToSelectionAsRange(cellData.mElement);
       if (NS_FAILED(rv)) {
         break;
       }
       cellSelected = true;
     }
   }
   // Safety code to select starting cell if nothing else was selected
@@ -3029,18 +3025,17 @@ HTMLEditor::FixBadRowSpan(Element* aTabl
       // int32_t actualRowSpan =       cellData.mEffectiveRowSpan;
                  actualColSpan =       cellData.mEffectiveColSpan;
       // bool    isSelected =          cellData.mIsSelected;
 
       // Fixup rowspans only for cells starting in current row
       // XXX So, this does not assume that CellData returns error when just
       //     not found a cell.  Fix this later.
       if (cellData.mElement && rowSpan > 0 &&
-          !cellData.IsSpannedFromOtherRow() &&
-          cellData.mFirst.mColumn == cellData.mCurrent.mColumn) {
+          !cellData.IsSpannedFromOtherRowOrColumn()) {
         nsresult rv = SetRowSpan(cellData.mElement, rowSpan-rowsReduced);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
       NS_ASSERTION((actualColSpan > 0),"ActualColSpan = 0 in FixBadRowSpan");
     }
   }
@@ -3089,17 +3084,17 @@ HTMLEditor::FixBadColSpan(Element* aTabl
     // bool    isSelected =          cellData.mIsSelected;
 
     // XXX So, this does not assume that CellData returns error when just
     //     not found a cell.  Fix this later.
     if (!cellData.mElement) {
       break;
     }
     if (colSpan > 0 &&
-        cellData.mFirst.mColumn == cellData.mCurrent.mColumn &&
+        !cellData.IsSpannedFromOtherColumn() &&
         (colSpan < minColSpan || minColSpan == -1)) {
       minColSpan = colSpan;
     }
     NS_ASSERTION((actualRowSpan > 0),"ActualRowSpan = 0 in FixBadColSpan");
   }
   if (minColSpan > 1) {
     // The amount to reduce everyone's colspan
     // so at least one cell has colspan = 1
@@ -3117,18 +3112,17 @@ HTMLEditor::FixBadColSpan(Element* aTabl
                  actualRowSpan =       cellData.mEffectiveRowSpan;
       // int32_t actualColSpan =       cellData.mEffectiveColSpan;
       // bool    isSelected =          cellData.mIsSelected;
 
       // Fixup colspans only for cells starting in current column
       // XXX So, this does not assume that CellData returns error when just
       //     not found a cell.  Fix this later.
       if (cellData.mElement && colSpan > 0 &&
-          cellData.mFirst.mColumn == cellData.mCurrent.mColumn &&
-          !cellData.IsSpannedFromOtherRow()) {
+          !cellData.IsSpannedFromOtherRowOrColumn()) {
         nsresult rv = SetColSpan(cellData.mElement, colSpan-colsReduced);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           return rv;
         }
       }
       NS_ASSERTION((actualRowSpan > 0),"ActualRowSpan = 0 in FixBadColSpan");
     }
   }