Bug 1157569 part 5 - Convert GetColorAndStyle, GetPaintStyleInfo, and CompareBorders in nsTableFrame to accept writing mode and logical side. r=roc
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 04 May 2015 19:09:25 +1200
changeset 242234 a2165fc522e3b5035a1953658d07cabad2af65ca
parent 242233 433c2ea038e2352a4607dfcfe6741cefffc607fa
child 242235 7738943aa2ed789c986bf49b903065ea465fa1c6
push id28686
push userryanvm@gmail.com
push dateMon, 04 May 2015 20:06:04 +0000
treeherdermozilla-central@102d0e9aa9e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1157569
milestone40.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 1157569 part 5 - Convert GetColorAndStyle, GetPaintStyleInfo, and CompareBorders in nsTableFrame to accept writing mode and logical side. r=roc This changes behavior of border collapse on RTL tables, but it seems that there is no test coverage on those cases, and those cases should have been broken before, due to the mix of m{Start,End}side and physical sides in the methods. Hence this change should be fine, as long as we are going to fix it in later patches.
layout/tables/nsTableFrame.cpp
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -4667,80 +4667,74 @@ static uint8_t styleToPriority[13] = { 0
                                        1,  // NS_STYLE_BORDER_STYLE_INSET
                                        3,  // NS_STYLE_BORDER_STYLE_OUTSET
                                        9 };// NS_STYLE_BORDER_STYLE_HIDDEN
 // priority rules follow CSS 2.1 spec
 // 'hidden', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove',
 // and the lowest: 'inset'. none is even weaker
 #define CELL_CORNER true
 
-/** return the border style, border color and optional the width in
+/** return the border style, border color and optionally the width in
   * pixel for a given frame and side
   * @param aFrame           - query the info for this frame
+  * @param aTableWM         - the writing-mode of the frame
   * @param aSide            - the side of the frame
   * @param aStyle           - the border style
   * @param aColor           - the border color
-  * @param aTableIsLTR      - table direction is LTR
+  * @param aWidth           - the border width in px.
   * @param aWidth           - the border width in px
   */
 static void
-GetColorAndStyle(const nsIFrame*  aFrame,
-                 mozilla::css::Side aSide,
+GetColorAndStyle(const nsIFrame* aFrame,
+                 WritingMode aTableWM,
+                 LogicalSide aSide,
                  uint8_t* aStyle,
                  nscolor* aColor,
-                 bool aTableIsLTR,
                  BCPixelSize* aWidth = nullptr)
 {
   NS_PRECONDITION(aFrame, "null frame");
   NS_PRECONDITION(aStyle && aColor, "null argument");
   // initialize out arg
   *aColor = 0;
   if (aWidth) {
     *aWidth = 0;
   }
 
   const nsStyleBorder* styleData = aFrame->StyleBorder();
-  if(!aTableIsLTR) { // revert the directions
-    if (NS_SIDE_RIGHT == aSide) {
-      aSide = NS_SIDE_LEFT;
-    }
-    else if (NS_SIDE_LEFT == aSide) {
-      aSide = NS_SIDE_RIGHT;
-    }
-  }
-  *aStyle = styleData->GetBorderStyle(aSide);
+  mozilla::Side physicalSide = aTableWM.PhysicalSide(aSide);
+  *aStyle = styleData->GetBorderStyle(physicalSide);
 
   if ((NS_STYLE_BORDER_STYLE_NONE == *aStyle) ||
       (NS_STYLE_BORDER_STYLE_HIDDEN == *aStyle)) {
     return;
   }
   *aColor = aFrame->StyleContext()->GetVisitedDependentColor(
-             nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_color)[aSide]);
+    nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_color)[physicalSide]);
 
   if (aWidth) {
-    nscoord width = styleData->GetComputedBorderWidth(aSide);
+    nscoord width = styleData->GetComputedBorderWidth(physicalSide);
     *aWidth = nsPresContext::AppUnitsToIntCSSPixels(width);
   }
 }
 
 /** coerce the paint style as required by CSS2.1
   * @param aFrame           - query the info for this frame
+  * @param aTableWM         - the writing mode of the frame
   * @param aSide            - the side of the frame
   * @param aStyle           - the border style
   * @param aColor           - the border color
-  * @param aTableIsLTR      - table direction is LTR
   */
 static void
-GetPaintStyleInfo(const nsIFrame*  aFrame,
-                  mozilla::css::Side aSide,
+GetPaintStyleInfo(const nsIFrame* aFrame,
+                  WritingMode aTableWM,
+                  LogicalSide aSide,
                   uint8_t* aStyle,
-                  nscolor* aColor,
-                  bool             aTableIsLTR)
-{
-  GetColorAndStyle(aFrame, aSide, aStyle, aColor, aTableIsLTR);
+                  nscolor* aColor)
+{
+  GetColorAndStyle(aFrame, aTableWM, aSide, aStyle, aColor);
   if (NS_STYLE_BORDER_STYLE_INSET == *aStyle) {
     *aStyle = NS_STYLE_BORDER_STYLE_RIDGE;
   } else if (NS_STYLE_BORDER_STYLE_OUTSET == *aStyle) {
     *aStyle = NS_STYLE_BORDER_STYLE_GROOVE;
   }
 }
 
 class nsDelayedCalcBCBorders : public nsRunnable {
@@ -4843,88 +4837,93 @@ CompareBorders(bool                aIsCo
   * adjacent frames are taken into account the ownership of a single border
   * segment is defined. The return value is the dominating border
   * The cellmap stores only top and left borders for each cellmap position.
   * If the cell border is owned by the cell that is left of the border
   * it will be an adjacent owner aka eAjaCellOwner. See celldata.h for the other
   * scenarios with a adjacent owner.
   * @param xxxFrame         - the frame for style information, might be zero if
   *                           it should not be considered
+  * @param aTableWM         - the writing mode of the frame
   * @param aSide            - side of the frames that should be considered
   * @param aAja             - the border comparison takes place from the point of
   *                           a frame that is adjacent to the cellmap entry, for
   *                           when a cell owns its lower border it will be the
   *                           adjacent owner as in the cellmap only top and left
   *                           borders are stored.
-  * @param aTwipsToPixels   - conversion factor as borders need to be drawn pixel
-  *                           aligned.
   */
 static BCCellBorder
 CompareBorders(const nsIFrame*  aTableFrame,
                const nsIFrame*  aColGroupFrame,
                const nsIFrame*  aColFrame,
                const nsIFrame*  aRowGroupFrame,
                const nsIFrame*  aRowFrame,
                const nsIFrame*  aCellFrame,
-               bool             aTableIsLTR,
-               mozilla::css::Side aSide,
+               WritingMode aTableWM,
+               LogicalSide aSide,
                bool             aAja)
 {
   BCCellBorder border, tempBorder;
-  bool horizontal = (NS_SIDE_TOP == aSide) || (NS_SIDE_BOTTOM == aSide);
+  bool inlineAxis = IsBlock(aSide);
 
   // start with the table as dominant if present
   if (aTableFrame) {
-    GetColorAndStyle(aTableFrame, aSide, &border.style, &border.color, aTableIsLTR, &border.width);
+    GetColorAndStyle(aTableFrame, aTableWM, aSide,
+                     &border.style, &border.color, &border.width);
     border.owner = eTableOwner;
     if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
       return border;
     }
   }
   // see if the colgroup is dominant
   if (aColGroupFrame) {
-    GetColorAndStyle(aColGroupFrame, aSide, &tempBorder.style, &tempBorder.color, aTableIsLTR, &tempBorder.width);
-    tempBorder.owner = (aAja && !horizontal) ? eAjaColGroupOwner : eColGroupOwner;
+    GetColorAndStyle(aColGroupFrame, aTableWM, aSide,
+                     &tempBorder.style, &tempBorder.color, &tempBorder.width);
+    tempBorder.owner = aAja && !inlineAxis ? eAjaColGroupOwner : eColGroupOwner;
     // pass here and below false for aSecondIsHorizontal as it is only used for corner calculations.
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
     if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
       return border;
     }
   }
   // see if the col is dominant
   if (aColFrame) {
-    GetColorAndStyle(aColFrame, aSide, &tempBorder.style, &tempBorder.color, aTableIsLTR, &tempBorder.width);
-    tempBorder.owner = (aAja && !horizontal) ? eAjaColOwner : eColOwner;
+    GetColorAndStyle(aColFrame, aTableWM, aSide,
+                     &tempBorder.style, &tempBorder.color, &tempBorder.width);
+    tempBorder.owner = aAja && !inlineAxis ? eAjaColOwner : eColOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
     if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
       return border;
     }
   }
   // see if the rowgroup is dominant
   if (aRowGroupFrame) {
-    GetColorAndStyle(aRowGroupFrame, aSide, &tempBorder.style, &tempBorder.color, aTableIsLTR, &tempBorder.width);
-    tempBorder.owner = (aAja && horizontal) ? eAjaRowGroupOwner : eRowGroupOwner;
+    GetColorAndStyle(aRowGroupFrame, aTableWM, aSide,
+                     &tempBorder.style, &tempBorder.color, &tempBorder.width);
+    tempBorder.owner = aAja && inlineAxis ? eAjaRowGroupOwner : eRowGroupOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
     if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
       return border;
     }
   }
   // see if the row is dominant
   if (aRowFrame) {
-    GetColorAndStyle(aRowFrame, aSide, &tempBorder.style, &tempBorder.color, aTableIsLTR, &tempBorder.width);
-    tempBorder.owner = (aAja && horizontal) ? eAjaRowOwner : eRowOwner;
+    GetColorAndStyle(aRowFrame, aTableWM, aSide,
+                     &tempBorder.style, &tempBorder.color, &tempBorder.width);
+    tempBorder.owner = aAja && inlineAxis ? eAjaRowOwner : eRowOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
     if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
       return border;
     }
   }
   // see if the cell is dominant
   if (aCellFrame) {
-    GetColorAndStyle(aCellFrame, aSide, &tempBorder.style, &tempBorder.color, aTableIsLTR, &tempBorder.width);
-    tempBorder.owner = (aAja) ? eAjaCellOwner : eCellOwner;
+    GetColorAndStyle(aCellFrame, aTableWM, aSide,
+                     &tempBorder.style, &tempBorder.color, &tempBorder.width);
+    tempBorder.owner = aAja ? eAjaCellOwner : eCellOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
   }
   return border;
 }
 
 static bool
 Perpendicular(mozilla::css::Side aSide1,
               mozilla::css::Side aSide2)
@@ -5283,134 +5282,134 @@ nsTableFrame::ExpandBCDamageArea(TableAr
 void
 BCMapCellInfo::SetTableTopLeftContBCBorder()
 {
   BCCellBorder currentBorder;
   //calculate continuous top first row & rowgroup border: special case
   //because it must include the table in the collapse
   if (mTopRow) {
     currentBorder = CompareBorders(mTableFrame, nullptr, nullptr, mRowGroup,
-                                   mTopRow, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_TOP, !ADJACENT);
+                                   mTopRow, nullptr, mTableWM,
+                                   eLogicalSideBStart, !ADJACENT);
     mTopRow->SetContinuousBCBorderWidth(NS_SIDE_TOP, currentBorder.width);
   }
   if (mCgAtRight && mColGroup) {
     //calculate continuous top colgroup border once per colgroup
     currentBorder = CompareBorders(mTableFrame, mColGroup, nullptr, mRowGroup,
-                                   mTopRow, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_TOP, !ADJACENT);
+                                   mTopRow, nullptr, mTableWM,
+                                   eLogicalSideBStart, !ADJACENT);
     mColGroup->SetContinuousBCBorderWidth(NS_SIDE_TOP, currentBorder.width);
   }
   if (0 == mColIndex) {
     currentBorder = CompareBorders(mTableFrame, mColGroup, mLeftCol, nullptr,
-                                   nullptr, nullptr, mTableWM.IsBidiLTR(), NS_SIDE_LEFT,
-                                   !ADJACENT);
+                                   nullptr, nullptr, mTableWM,
+                                   eLogicalSideIStart, !ADJACENT);
     mTableFrame->SetContinuousLeftBCBorderWidth(currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetRowGroupLeftContBCBorder()
 {
   BCCellBorder currentBorder;
   //get row group continuous borders
   if (mRgAtBottom && mRowGroup) { //once per row group, so check for bottom
      currentBorder = CompareBorders(mTableFrame, mColGroup, mLeftCol, mRowGroup,
-                                    nullptr, nullptr, mTableWM.IsBidiLTR(), NS_SIDE_LEFT,
-                                    !ADJACENT);
+                                    nullptr, nullptr, mTableWM,
+                                    eLogicalSideIStart, !ADJACENT);
      mRowGroup->SetContinuousBCBorderWidth(mStartSide, currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetRowGroupRightContBCBorder()
 {
   BCCellBorder currentBorder;
   //get row group continuous borders
   if (mRgAtBottom && mRowGroup) { //once per mRowGroup, so check for bottom
     currentBorder = CompareBorders(mTableFrame, mColGroup, mRightCol, mRowGroup,
-                                   nullptr, nullptr, mTableWM.IsBidiLTR(), NS_SIDE_RIGHT,
+                                   nullptr, nullptr, mTableWM, eLogicalSideIEnd,
                                    ADJACENT);
     mRowGroup->SetContinuousBCBorderWidth(mEndSide, currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetColumnTopRightContBCBorder()
 {
   BCCellBorder currentBorder;
   //calculate column continuous borders
   //we only need to do this once, so we'll do it only on the first row
   currentBorder = CompareBorders(mTableFrame, mCurrentColGroupFrame,
                                  mCurrentColFrame, mRowGroup, mTopRow, nullptr,
-                                 mTableWM.IsBidiLTR(), NS_SIDE_TOP, !ADJACENT);
+                                 mTableWM, eLogicalSideBStart, !ADJACENT);
   ((nsTableColFrame*) mCurrentColFrame)->SetContinuousBCBorderWidth(NS_SIDE_TOP,
                                                            currentBorder.width);
   if (mNumTableCols == GetCellEndColIndex() + 1) {
     currentBorder = CompareBorders(mTableFrame, mCurrentColGroupFrame,
                                    mCurrentColFrame, nullptr, nullptr, nullptr,
-                                   mTableWM.IsBidiLTR(), NS_SIDE_RIGHT, !ADJACENT);
+                                   mTableWM, eLogicalSideIEnd, !ADJACENT);
   }
   else {
     currentBorder = CompareBorders(nullptr, mCurrentColGroupFrame,
                                    mCurrentColFrame, nullptr,nullptr, nullptr,
-                                   mTableWM.IsBidiLTR(), NS_SIDE_RIGHT, !ADJACENT);
+                                   mTableWM, eLogicalSideIEnd, !ADJACENT);
   }
   mCurrentColFrame->SetContinuousBCBorderWidth(NS_SIDE_RIGHT,
                                                currentBorder.width);
 }
 
 void
 BCMapCellInfo::SetColumnBottomContBCBorder()
 {
   BCCellBorder currentBorder;
   //get col continuous border
   currentBorder = CompareBorders(mTableFrame, mCurrentColGroupFrame,
                                  mCurrentColFrame, mRowGroup, mBottomRow,
-                                 nullptr, mTableWM.IsBidiLTR(), NS_SIDE_BOTTOM, ADJACENT);
+                                 nullptr, mTableWM, eLogicalSideBEnd, ADJACENT);
   mCurrentColFrame->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM,
                                                currentBorder.width);
 }
 
 void
 BCMapCellInfo::SetColGroupBottomContBCBorder()
 {
   BCCellBorder currentBorder;
   if (mColGroup) {
     currentBorder = CompareBorders(mTableFrame, mColGroup, nullptr, mRowGroup,
-                                   mBottomRow, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_BOTTOM, ADJACENT);
+                                   mBottomRow, nullptr, mTableWM,
+                                   eLogicalSideBEnd, ADJACENT);
     mColGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetRowGroupBottomContBCBorder()
 {
   BCCellBorder currentBorder;
   if (mRowGroup) {
     currentBorder = CompareBorders(mTableFrame, nullptr, nullptr, mRowGroup,
-                                   mBottomRow, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_BOTTOM, ADJACENT);
+                                   mBottomRow, nullptr, mTableWM,
+                                   eLogicalSideBEnd, ADJACENT);
     mRowGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetInnerRowGroupBottomContBCBorder(const nsIFrame* aNextRowGroup,
                                                   nsTableRowFrame* aNextRow)
 {
   BCCellBorder currentBorder, adjacentBorder;
 
   const nsIFrame* rowgroup = (mRgAtBottom) ? mRowGroup : nullptr;
   currentBorder = CompareBorders(nullptr, nullptr, nullptr, rowgroup, mBottomRow,
-                                 nullptr, mTableWM.IsBidiLTR(), NS_SIDE_BOTTOM, ADJACENT);
+                                 nullptr, mTableWM, eLogicalSideBEnd, ADJACENT);
 
   adjacentBorder = CompareBorders(nullptr, nullptr, nullptr, aNextRowGroup,
-                                  aNextRow, nullptr, mTableWM.IsBidiLTR(), NS_SIDE_TOP,
+                                  aNextRow, nullptr, mTableWM, eLogicalSideBStart,
                                   !ADJACENT);
   currentBorder = CompareBorders(false, currentBorder, adjacentBorder,
                                  HORIZONTAL);
   if (aNextRow) {
     aNextRow->SetContinuousBCBorderWidth(NS_SIDE_TOP, currentBorder.width);
   }
   if (mRgAtBottom && mRowGroup) {
     mRowGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
@@ -5419,31 +5418,31 @@ BCMapCellInfo::SetInnerRowGroupBottomCon
 
 void
 BCMapCellInfo::SetRowLeftContBCBorder()
 {
   //get row continuous borders
   if (mCurrentRowFrame) {
     BCCellBorder currentBorder;
     currentBorder = CompareBorders(mTableFrame, mColGroup, mLeftCol, mRowGroup,
-                                   mCurrentRowFrame, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_LEFT, !ADJACENT);
+                                   mCurrentRowFrame, nullptr, mTableWM,
+                                   eLogicalSideIStart, !ADJACENT);
     mCurrentRowFrame->SetContinuousBCBorderWidth(mStartSide,
                                                  currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetRowRightContBCBorder()
 {
   if (mCurrentRowFrame) {
     BCCellBorder currentBorder;
     currentBorder = CompareBorders(mTableFrame, mColGroup, mRightCol, mRowGroup,
-                                   mCurrentRowFrame, nullptr, mTableWM.IsBidiLTR(),
-                                   NS_SIDE_RIGHT, ADJACENT);
+                                   mCurrentRowFrame, nullptr, mTableWM,
+                                   eLogicalSideIEnd, ADJACENT);
     mCurrentRowFrame->SetContinuousBCBorderWidth(mEndSide,
                                                  currentBorder.width);
   }
 }
 void
 BCMapCellInfo::SetTableTopBorderWidth(BCPixelSize aWidth)
 {
   mTableBCData->mTopBorderWidth = std::max(mTableBCData->mTopBorderWidth, aWidth);
@@ -5564,71 +5563,71 @@ BCMapCellInfo::IncrementRow(bool aResetT
   mCurrentRowFrame = (aResetToTopRowOfCell) ? mTopRow :
                                                 mCurrentRowFrame->GetNextRow();
 }
 
 BCCellBorder
 BCMapCellInfo::GetTopEdgeBorder()
 {
   return CompareBorders(mTableFrame, mCurrentColGroupFrame, mCurrentColFrame,
-                        mRowGroup, mTopRow, mCell, mTableWM.IsBidiLTR(), NS_SIDE_TOP,
+                        mRowGroup, mTopRow, mCell, mTableWM, eLogicalSideBStart,
                         !ADJACENT);
 }
 
 BCCellBorder
 BCMapCellInfo::GetBottomEdgeBorder()
 {
   return CompareBorders(mTableFrame, mCurrentColGroupFrame, mCurrentColFrame,
-                        mRowGroup, mBottomRow, mCell, mTableWM.IsBidiLTR(),
-                        NS_SIDE_BOTTOM, ADJACENT);
+                        mRowGroup, mBottomRow, mCell, mTableWM,
+                        eLogicalSideBEnd, ADJACENT);
 }
 BCCellBorder
 BCMapCellInfo::GetLeftEdgeBorder()
 {
   return CompareBorders(mTableFrame, mColGroup, mLeftCol, mRowGroup,
-                        mCurrentRowFrame, mCell, mTableWM.IsBidiLTR(), NS_SIDE_LEFT,
+                        mCurrentRowFrame, mCell, mTableWM, eLogicalSideIStart,
                         !ADJACENT);
 }
 BCCellBorder
 BCMapCellInfo::GetRightEdgeBorder()
 {
   return CompareBorders(mTableFrame, mColGroup, mRightCol, mRowGroup,
-                        mCurrentRowFrame, mCell, mTableWM.IsBidiLTR(), NS_SIDE_RIGHT,
+                        mCurrentRowFrame, mCell, mTableWM, eLogicalSideIEnd,
                         ADJACENT);
 }
 BCCellBorder
 BCMapCellInfo::GetRightInternalBorder()
 {
   const nsIFrame* cg = (mCgAtRight) ? mColGroup : nullptr;
   return CompareBorders(nullptr, cg, mRightCol, nullptr, nullptr, mCell,
-                        mTableWM.IsBidiLTR(), NS_SIDE_RIGHT, ADJACENT);
+                        mTableWM, eLogicalSideIEnd, ADJACENT);
 }
 
 BCCellBorder
 BCMapCellInfo::GetLeftInternalBorder()
 {
   const nsIFrame* cg = (mCgAtLeft) ? mColGroup : nullptr;
   return CompareBorders(nullptr, cg, mLeftCol, nullptr, nullptr, mCell,
-                        mTableWM.IsBidiLTR(), NS_SIDE_LEFT, !ADJACENT);
+                        mTableWM, eLogicalSideIStart, !ADJACENT);
 }
 
 BCCellBorder
 BCMapCellInfo::GetBottomInternalBorder()
 {
   const nsIFrame* rg = (mRgAtBottom) ? mRowGroup : nullptr;
   return CompareBorders(nullptr, nullptr, nullptr, rg, mBottomRow, mCell,
-                        mTableWM.IsBidiLTR(), NS_SIDE_BOTTOM, ADJACENT);
+                        mTableWM, eLogicalSideBEnd, ADJACENT);
 }
 
 BCCellBorder
 BCMapCellInfo::GetTopInternalBorder()
 {
   const nsIFrame* rg = (mRgAtTop) ? mRowGroup : nullptr;
   return CompareBorders(nullptr, nullptr, nullptr, rg, mTopRow, mCell,
-                        mTableWM.IsBidiLTR(), NS_SIDE_TOP, !ADJACENT);
+                        mTableWM, eLogicalSideBStart, !ADJACENT);
 }
 
 /* Here is the order for storing border edges in the cell map as a cell is processed. There are
    n=colspan top and bottom border edges per cell and n=rowspan left and right border edges per cell.
 
    1) On the top edge of the table, store the top edge. Never store the top edge otherwise, since
       a bottom edge from a cell above will take care of it.
    2) On the left edge of the table, store the left edge. Never store the left edge othewise, since
@@ -6925,45 +6924,45 @@ BCVerticalSeg::GetBottomCorner(BCPaintBo
  *                        at the start
  */
 void
 BCVerticalSeg::Paint(BCPaintBorderIterator& aIter,
                      nsRenderingContext&   aRenderingContext,
                      BCPixelSize            aHorSegHeight)
 {
   // get the border style, color and paint the segment
-  mozilla::css::Side side = (aIter.IsDamageAreaRightMost()) ? NS_SIDE_RIGHT :
-                                                    NS_SIDE_LEFT;
+  LogicalSide side =
+    aIter.IsDamageAreaRightMost() ? eLogicalSideIEnd : eLogicalSideIStart;
   int32_t relColIndex = aIter.GetRelativeColIndex();
   nsTableColFrame* col           = mCol; if (!col) ABORT0();
   nsTableCellFrame* cell         = mFirstCell; // ???
   nsIFrame* owner = nullptr;
   uint8_t style = NS_STYLE_BORDER_STYLE_SOLID;
   nscolor color = 0xFFFFFFFF;
 
   // All the tables frames have the same presContext, so we just use any one
   // that exists here:
   int32_t appUnitsPerDevPixel = col->PresContext()->AppUnitsPerDevPixel();
 
   switch (mOwner) {
     case eTableOwner:
       owner = aIter.mTable;
       break;
     case eAjaColGroupOwner:
-      side = NS_SIDE_RIGHT;
+      side = eLogicalSideIEnd;
       if (!aIter.IsTableRightMost() && (relColIndex > 0)) {
         col = aIter.mVerInfo[relColIndex - 1].mCol;
       } // and fall through
     case eColGroupOwner:
       if (col) {
         owner = col->GetParent();
       }
       break;
     case eAjaColOwner:
-      side = NS_SIDE_RIGHT;
+      side = eLogicalSideIEnd;
       if (!aIter.IsTableRightMost() && (relColIndex > 0)) {
         col = aIter.mVerInfo[relColIndex - 1].mCol;
       } // and fall through
     case eColOwner:
       owner = col;
       break;
     case eAjaRowGroupOwner:
       NS_ERROR("a neighboring rowgroup can never own a vertical border");
@@ -6976,24 +6975,24 @@ BCVerticalSeg::Paint(BCPaintBorderIterat
     case eAjaRowOwner:
       NS_ASSERTION(false, "program error"); // and fall through
     case eRowOwner:
       NS_ASSERTION(aIter.IsTableLeftMost() || aIter.IsTableRightMost(),
                    "row can own border only at table edge");
       owner = mFirstRow;
       break;
     case eAjaCellOwner:
-      side = NS_SIDE_RIGHT;
+      side = eLogicalSideIEnd;
       cell = mAjaCell; // and fall through
     case eCellOwner:
       owner = cell;
       break;
   }
   if (owner) {
-    ::GetPaintStyleInfo(owner, side, &style, &color, aIter.mTableWM.IsBidiLTR());
+    ::GetPaintStyleInfo(owner, aIter.mTableWM, side, &style, &color);
   }
   BCPixelSize smallHalf, largeHalf;
   DivideBCBorderSize(mWidth, smallHalf, largeHalf);
   nsRect segRect(mOffsetX - nsPresContext::CSSPixelsToAppUnits(largeHalf),
                  mOffsetY,
                  nsPresContext::CSSPixelsToAppUnits(mWidth), mLength);
   nscoord bottomBevelOffset = (mIsBottomBevel) ?
                   nsPresContext::CSSPixelsToAppUnits(mBottomHorSegHeight) : 0;
@@ -7113,18 +7112,18 @@ BCHorizontalSeg::GetRightCorner(BCPaintB
  * @param aIter         - iterator containing the structural information
  * @param aRenderingContext - the rendering context
  */
 void
 BCHorizontalSeg::Paint(BCPaintBorderIterator& aIter,
                        nsRenderingContext&   aRenderingContext)
 {
   // get the border style, color and paint the segment
-  mozilla::css::Side side = (aIter.IsDamageAreaBottomMost()) ? NS_SIDE_BOTTOM :
-                                                     NS_SIDE_TOP;
+  LogicalSide side =
+    aIter.IsDamageAreaBottomMost() ? eLogicalSideBEnd : eLogicalSideBStart;
   nsIFrame* rg   = aIter.mRg;  if (!rg) ABORT0();
   nsIFrame* row  = aIter.mRow; if (!row) ABORT0();
   nsIFrame* cell = mFirstCell;
   nsIFrame* col;
   nsIFrame* owner = nullptr;
 
   // All the tables frames have the same presContext, so we just use any one
   // that exists here:
@@ -7152,41 +7151,41 @@ BCHorizontalSeg::Paint(BCPaintBorderIter
       NS_ERROR("neighboring column can never own a horizontal border");
       // and fall through
     case eColOwner:
       NS_ASSERTION(aIter.IsTableTopMost() || aIter.IsTableBottomMost(),
                    "col can own border only at the table edge");
       owner = aIter.mTableFirstInFlow->GetColFrame(aIter.mColIndex - 1);
       break;
     case eAjaRowGroupOwner:
-      side = NS_SIDE_BOTTOM;
+      side = eLogicalSideBEnd;
       rg = (aIter.IsTableBottomMost()) ? aIter.mRg : aIter.mPrevRg;
       // and fall through
     case eRowGroupOwner:
       owner = rg;
       break;
     case eAjaRowOwner:
-      side = NS_SIDE_BOTTOM;
+      side = eLogicalSideBEnd;
       row = (aIter.IsTableBottomMost()) ? aIter.mRow : aIter.mPrevRow;
       // and fall through
       case eRowOwner:
       owner = row;
       break;
     case eAjaCellOwner:
-      side = NS_SIDE_BOTTOM;
+      side = eLogicalSideBEnd;
       // if this is null due to the damage area origin-y > 0, then the border
       // won't show up anyway
       cell = mAjaCell;
       // and fall through
     case eCellOwner:
       owner = cell;
       break;
   }
   if (owner) {
-    ::GetPaintStyleInfo(owner, side, &style, &color, aIter.mTableWM.IsBidiLTR());
+    ::GetPaintStyleInfo(owner, aIter.mTableWM, side, &style, &color);
   }
   BCPixelSize smallHalf, largeHalf;
   DivideBCBorderSize(mWidth, smallHalf, largeHalf);
   nsRect segRect(mOffsetX,
                  mOffsetY - nsPresContext::CSSPixelsToAppUnits(largeHalf),
                  mLength,
                  nsPresContext::CSSPixelsToAppUnits(mWidth));
   if (aIter.mTableWM.IsBidiLTR()) {