Bug 1176523 - Convert Get/SetContinuousBCBorderWidth in nsTableColFrame and nsTableColGroupFrame to logical coordinates. r=dholbert
authorJonathan Kew <jkew@mozilla.com>
Wed, 24 Jun 2015 09:56:54 -0700
changeset 250147 a8fc665d7fab6603fa05cdbcddb32b2f8e00c63a
parent 250146 9e8d2b0dd0ce2a40b31d5344248a97015dbc7e39
child 250148 d2d535a3fdbf0b4ed2d3e3541b30fbb91a03c367
push id28947
push usercbook@mozilla.com
push dateThu, 25 Jun 2015 09:10:19 +0000
treeherdermozilla-central@0b2f5e8b7be5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1176523
milestone41.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 1176523 - Convert Get/SetContinuousBCBorderWidth in nsTableColFrame and nsTableColGroupFrame to logical coordinates. r=dholbert
layout/tables/nsTableColFrame.h
layout/tables/nsTableColGroupFrame.cpp
layout/tables/nsTableColGroupFrame.h
layout/tables/nsTableFrame.cpp
layout/tables/nsTablePainter.cpp
--- a/layout/tables/nsTableColFrame.h
+++ b/layout/tables/nsTableColFrame.h
@@ -90,23 +90,24 @@ public:
 
   nscoord GetIStartBorderWidth() const { return mIStartBorderWidth; }
   nscoord GetIEndBorderWidth() const { return mIEndBorderWidth; }
   void SetIStartBorderWidth(BCPixelSize aWidth) { mIStartBorderWidth = aWidth; }
   void SetIEndBorderWidth(BCPixelSize aWidth) { mIEndBorderWidth = aWidth; }
 
   /**
    * Gets inner border widths before collapsing with cell borders
-   * Caller must get left border from previous column or from table
-   * GetContinuousBCBorderWidth will not overwrite aBorder.left
+   * Caller must get istart border from previous column or from table
+   * GetContinuousBCBorderWidth will not overwrite aBorder.IStart
    * see nsTablePainter about continuous borders
    *
-   * @return outer right border width (left inner for next column)
+   * @return outer iend border width (istart inner for next column)
    */
-  nscoord GetContinuousBCBorderWidth(nsMargin& aBorder);
+  nscoord GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
+                                     mozilla::LogicalMargin& aBorder);
   /**
    * Set full border widths before collapsing with cell borders
    * @param aForSide - side to set; only valid for bstart, iend, and bend
    */
   void SetContinuousBCBorderWidth(mozilla::LogicalSide aForSide,
                                   BCPixelSize aPixelValue);
 #ifdef DEBUG
   void Dump(int32_t aIndent);
@@ -320,25 +321,23 @@ inline int32_t nsTableColFrame::GetColIn
 }
 
 inline void nsTableColFrame::SetColIndex (int32_t aColIndex)
 {
   mColIndex = aColIndex;
 }
 
 inline nscoord
-nsTableColFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
+nsTableColFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
+                                            mozilla::LogicalMargin& aBorder)
 {
   int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
-  mozilla::WritingMode wm = GetWritingMode();
-  mozilla::LogicalMargin border(wm, aBorder);
-  border.BStart(wm) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
-                                               mBStartContBorderWidth);
-  border.IEnd(wm) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
-                                               mIEndContBorderWidth);
-  border.BEnd(wm) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
-                                               mBEndContBorderWidth);
-  aBorder = border.GetPhysicalMargin(wm);
+  aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
+                                                 mBStartContBorderWidth);
+  aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
+                                                 mIEndContBorderWidth);
+  aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
+                                                 mBEndContBorderWidth);
   return BC_BORDER_END_HALF_COORD(aPixelsToTwips, mIEndContBorderWidth);
 }
 
 #endif
 
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -411,41 +411,42 @@ nsTableColFrame * nsTableColGroupFrame::
   return result;
 }
 
 int32_t nsTableColGroupFrame::GetSpan()
 {
   return StyleTable()->mSpan;
 }
 
-void nsTableColGroupFrame::SetContinuousBCBorderWidth(uint8_t     aForSide,
+void nsTableColGroupFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
                                                       BCPixelSize aPixelValue)
 {
   switch (aForSide) {
-    case NS_SIDE_TOP:
-      mTopContBorderWidth = aPixelValue;
+    case eLogicalSideBStart:
+      mBStartContBorderWidth = aPixelValue;
       return;
-    case NS_SIDE_BOTTOM:
-      mBottomContBorderWidth = aPixelValue;
+    case eLogicalSideBEnd:
+      mBEndContBorderWidth = aPixelValue;
       return;
     default:
       NS_ERROR("invalid side arg");
   }
 }
 
-void nsTableColGroupFrame::GetContinuousBCBorderWidth(nsMargin& aBorder)
+void nsTableColGroupFrame::GetContinuousBCBorderWidth(WritingMode aWM,
+                                                      LogicalMargin& aBorder)
 {
   int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
   nsTableColFrame* col = GetTableFrame()->
     GetColFrame(mStartColIndex + mColCount - 1);
-  col->GetContinuousBCBorderWidth(aBorder);
-  aBorder.top = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
-                                         mTopContBorderWidth);
-  aBorder.bottom = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
-                                              mBottomContBorderWidth);
+  col->GetContinuousBCBorderWidth(aWM, aBorder);
+  aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
+                                                 mBStartContBorderWidth);
+  aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
+                                                 mBEndContBorderWidth);
 }
 
 /* ----- global methods ----- */
 
 nsTableColGroupFrame*
 NS_NewTableColGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsTableColGroupFrame(aContext);
--- a/layout/tables/nsTableColGroupFrame.h
+++ b/layout/tables/nsTableColGroupFrame.h
@@ -181,26 +181,27 @@ public:
     *                         starts with the first column
     */
   static void ResetColIndices(nsIFrame*       aFirstColGroup,
                               int32_t         aFirstColIndex,
                               nsIFrame*       aStartColFrame = nullptr);
 
   /**
    * Gets inner border widths before collapsing with cell borders
-   * Caller must get left border from previous column
-   * GetContinuousBCBorderWidth will not overwrite aBorder.left
+   * Caller must get istart border from previous column
+   * GetContinuousBCBorderWidth will not overwrite aBorder.IStart
    * see nsTablePainter about continuous borders
    */
-  void GetContinuousBCBorderWidth(nsMargin& aBorder);
+  void GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
+                                  mozilla::LogicalMargin& aBorder);
   /**
    * Set full border widths before collapsing with cell borders
-   * @param aForSide - side to set; only accepts top and bottom
+   * @param aForSide - side to set; only accepts bstart and bend
    */
-  void SetContinuousBCBorderWidth(uint8_t     aForSide,
+  void SetContinuousBCBorderWidth(mozilla::LogicalSide aForSide,
                                   BCPixelSize aPixelValue);
 
   virtual bool IsFrameOfType(uint32_t aFlags) const override
   {
     return nsContainerFrame::IsFrameOfType(aFlags & ~(nsIFrame::eTablePart));
   }
   
   virtual void InvalidateFrame(uint32_t aDisplayItemKey = 0) override;
@@ -216,18 +217,18 @@ protected:
   virtual LogicalSides GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const override;
 
   // data members
   int32_t mColCount;
   // the starting column index this col group represents. Must be >= 0. 
   int32_t mStartColIndex;
 
   // border width in pixels
-  BCPixelSize mTopContBorderWidth;
-  BCPixelSize mBottomContBorderWidth;
+  BCPixelSize mBStartContBorderWidth;
+  BCPixelSize mBEndContBorderWidth;
 };
 
 inline nsTableColGroupFrame::nsTableColGroupFrame(nsStyleContext *aContext)
 : nsContainerFrame(aContext), mColCount(0), mStartColIndex(0)
 { 
   SetColType(eColGroupContent);
 }
   
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -5378,17 +5378,17 @@ BCMapCellInfo::SetColumnBEndContBCBorder
 void
 BCMapCellInfo::SetColGroupBEndContBCBorder()
 {
   BCCellBorder currentBorder;
   if (mColGroup) {
     currentBorder = CompareBorders(mTableFrame, mColGroup, nullptr, mRowGroup,
                                    mEndRow, nullptr, mTableWM,
                                    eLogicalSideBEnd, ADJACENT);
-    mColGroup->SetContinuousBCBorderWidth(NS_SIDE_BOTTOM, currentBorder.width);
+    mColGroup->SetContinuousBCBorderWidth(eLogicalSideBEnd, currentBorder.width);
   }
 }
 
 void
 BCMapCellInfo::SetRowGroupBEndContBCBorder()
 {
   BCCellBorder currentBorder;
   if (mRowGroup) {
--- a/layout/tables/nsTablePainter.cpp
+++ b/layout/tables/nsTablePainter.cpp
@@ -208,36 +208,36 @@ TableBackgroundPainter::PaintTableFrame(
   TableBackgroundData tableData(aTableFrame);
   tableData.mRect.MoveTo(0,0); //using table's coords
   tableData.mRect.Deflate(aDeflate);
   WritingMode wm = aTableFrame->GetWritingMode();
   if (mIsBorderCollapse && tableData.ShouldSetBCBorder()) {
     if (aFirstRowGroup && aLastRowGroup && mNumCols > 0) {
       //only handle non-degenerate tables; we need a more robust BC model
       //to make degenerate tables' borders reasonable to deal with
-      nsMargin border, tempBorder;
+      LogicalMargin border(wm);
+      LogicalMargin tempBorder(wm);
       nsTableColFrame* colFrame = aTableFrame->GetColFrame(mNumCols - 1);
       if (colFrame) {
-        colFrame->GetContinuousBCBorderWidth(tempBorder);
+        colFrame->GetContinuousBCBorderWidth(wm, tempBorder);
       }
-      border.right = tempBorder.right;
+      border.IEnd(wm) = tempBorder.IEnd(wm);
 
-      LogicalMargin logBorder(wm);
-      aLastRowGroup->GetContinuousBCBorderWidth(wm, logBorder);
-      border.bottom = logBorder.Bottom(wm);
+      aLastRowGroup->GetContinuousBCBorderWidth(wm, tempBorder);
+      border.BEnd(wm) = tempBorder.BEnd(wm);
 
       nsTableRowFrame* rowFrame = aFirstRowGroup->GetFirstRow();
       if (rowFrame) {
-        rowFrame->GetContinuousBCBorderWidth(wm, logBorder);
-        border.top = logBorder.Top(wm);
+        rowFrame->GetContinuousBCBorderWidth(wm, tempBorder);
+        border.BStart(wm) = tempBorder.BStart(wm);
       }
 
-      border.left = aTableFrame->GetContinuousLeftBCBorderWidth();
+      border.IStart(wm) = aTableFrame->GetContinuousLeftBCBorderWidth();
 
-      tableData.SetBCBorder(border);
+      tableData.SetBCBorder(border.GetPhysicalMargin(wm));
     }
   }
 
   DrawResult result = DrawResult::SUCCESS;
 
   if (tableData.IsVisible()) {
     result =
       nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
@@ -274,16 +274,17 @@ DrawResult
 TableBackgroundPainter::PaintTable(nsTableFrame*   aTableFrame,
                                    const nsMargin& aDeflate,
                                    bool            aPaintTableBackground)
 {
   NS_PRECONDITION(aTableFrame, "null table frame");
 
   nsTableFrame::RowGroupArray rowGroups;
   aTableFrame->OrderRowGroups(rowGroups);
+  WritingMode wm = aTableFrame->GetWritingMode();
 
   DrawResult result = DrawResult::SUCCESS;
 
   if (rowGroups.Length() < 1) { //degenerate case
     if (aPaintTableBackground) {
       PaintTableFrame(aTableFrame, nullptr, nullptr, nsMargin(0,0,0,0));
     }
     /* No cells; nothing else to paint */
@@ -312,44 +313,44 @@ TableBackgroundPainter::PaintTable(nsTab
       colGroupFrames.AppendElement(cgFrame);
     }
 
     // Ensure that mColGroups won't reallocate during the loop below, because
     // we grab references to its contents and need those to stay valid until
     // mColGroups is destroyed as part of TablePainter destruction.
     mColGroups.SetCapacity(colGroupFrames.Length());
 
-    nsMargin border;
+    LogicalMargin border(wm);
     /* BC left borders aren't stored on cols, but the previous column's
        right border is the next one's left border.*/
     //Start with table's left border.
     nscoord lastLeftBorder = aTableFrame->GetContinuousLeftBCBorderWidth();
 
     for (nsTableColGroupFrame* cgFrame : colGroupFrames) {
       /*Create data struct for column group*/
       TableBackgroundData& cgData = *mColGroups.AppendElement(TableBackgroundData(cgFrame));
       if (mIsBorderCollapse && cgData.ShouldSetBCBorder()) {
-        border.left = lastLeftBorder;
-        cgFrame->GetContinuousBCBorderWidth(border);
-        cgData.SetBCBorder(border);
+        border.IStart(wm) = lastLeftBorder;
+        cgFrame->GetContinuousBCBorderWidth(wm, border);
+        cgData.SetBCBorder(border.GetPhysicalMargin(wm));
       }
 
       /*Loop over columns in this colgroup*/
       for (nsTableColFrame* col = cgFrame->GetFirstColumn(); col;
            col = static_cast<nsTableColFrame*>(col->GetNextSibling())) {
         MOZ_ASSERT(size_t(col->GetColIndex()) == mCols.Length());
         // Store a reference to the colGroup in the ColData element.
         ColData& colData = *mCols.AppendElement(ColData(col, cgData));
         //Bring column mRect into table's coord system
         colData.mCol.mRect.MoveBy(cgData.mRect.x, cgData.mRect.y);
         if (mIsBorderCollapse) {
-          border.left = lastLeftBorder;
-          lastLeftBorder = col->GetContinuousBCBorderWidth(border);
+          border.IStart(wm) = lastLeftBorder;
+          lastLeftBorder = col->GetContinuousBCBorderWidth(wm, border);
           if (colData.mCol.ShouldSetBCBorder()) {
-            colData.mCol.SetBCBorder(border);
+            colData.mCol.SetBCBorder(border.GetPhysicalMargin(wm));
           }
         }
       }
     }
   }
 
   for (uint32_t i = 0; i < rowGroups.Length(); i++) {
     nsTableRowGroupFrame* rg = rowGroups[i];