Bug 1157569 part 11 - Rename methods and fields in nsTableCellFrame from physicals to logicals. r=roc
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 04 May 2015 19:09:25 +1200
changeset 242240 42765978536eff5837d67012ef5fc4716c9043ec
parent 242239 aba4c5eb06de498f63d20d7399b2742891d0aa50
child 242241 8e1f05ac1281b49096c7b5f4d94263d5c9a41ac1
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 11 - Rename methods and fields in nsTableCellFrame from physicals to logicals. r=roc
layout/mathml/nsMathMLmtableFrame.cpp
layout/mathml/nsMathMLmtableFrame.h
layout/tables/nsTableCellFrame.cpp
layout/tables/nsTableCellFrame.h
layout/tables/nsTableFrame.cpp
layout/tables/nsTableRowFrame.cpp
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -1234,23 +1234,22 @@ nsMathMLmtdFrame::ProcessBorders(nsTable
                                  nsDisplayListBuilder* aBuilder,
                                  const nsDisplayListSet& aLists)
 {
   aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
                                             nsDisplaymtdBorder(aBuilder, this));
   return NS_OK;
 }
 
-nsMargin*
-nsMathMLmtdFrame::GetBorderWidth(nsMargin& aBorder) const
+LogicalMargin
+nsMathMLmtdFrame::GetBorderWidth(WritingMode aWM) const
 {
   nsStyleBorder styleBorder = *StyleBorder();
   ApplyBorderToStyle(this, styleBorder);
-  aBorder = styleBorder.GetComputedBorder();
-  return &aBorder;
+  return LogicalMargin(aWM, styleBorder.GetComputedBorder());
 }
 
 nsMargin
 nsMathMLmtdFrame::GetBorderOverflow()
 {
   nsStyleBorder styleBorder = *StyleBorder();
   ApplyBorderToStyle(this, styleBorder);
   nsMargin overflow = ComputeBorderOverflow(this, styleBorder);
--- a/layout/mathml/nsMathMLmtableFrame.h
+++ b/layout/mathml/nsMathMLmtableFrame.h
@@ -259,17 +259,17 @@ public:
 
   virtual int32_t GetRowSpan() override;
   virtual int32_t GetColSpan() override;
   virtual bool IsFrameOfType(uint32_t aFlags) const override
   {
     return nsTableCellFrame::IsFrameOfType(aFlags & ~(nsIFrame::eMathML));
   }
 
-  virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const override;
+  virtual LogicalMargin GetBorderWidth(WritingMode aWM) const override;
 
   virtual nsMargin GetBorderOverflow() override;
 
 protected:
   nsMathMLmtdFrame(nsStyleContext* aContext, nsTableFrame* aTableFrame)
     : nsTableCellFrame(aContext, aTableFrame) {}
   virtual ~nsMathMLmtdFrame();
 }; // class nsMathMLmtdFrame
--- a/layout/tables/nsTableCellFrame.cpp
+++ b/layout/tables/nsTableCellFrame.cpp
@@ -791,19 +791,18 @@ nsTableCellFrame::GetPrefISize(nsRenderi
 nsTableCellFrame::IntrinsicISizeOffsets(nsRenderingContext* aRenderingContext)
 {
   IntrinsicISizeOffsetData result =
     nsContainerFrame::IntrinsicISizeOffsets(aRenderingContext);
 
   result.hMargin = 0;
   result.hPctMargin = 0;
 
-  nsMargin border;
-  GetBorderWidth(border);
-  result.hBorder = border.LeftRight();
+  WritingMode wm = GetWritingMode();
+  result.hBorder = GetBorderWidth(wm).IStartEnd(wm);
 
   return result;
 }
 
 #ifdef DEBUG
 #define PROBABLY_TOO_LARGE 1000000
 static
 void DebugCheckChildSize(nsIFrame*            aChild,
@@ -870,37 +869,36 @@ nsTableCellFrame::Reflow(nsPresContext* 
   }
 
   // see if a special height reflow needs to occur due to having a pct height
   nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState);
 
   aStatus = NS_FRAME_COMPLETE;
   nsSize availSize(aReflowState.AvailableWidth(), aReflowState.AvailableHeight());
 
-  nsMargin borderPadding = aReflowState.ComputedPhysicalPadding();
-  nsMargin border;
-  GetBorderWidth(border);
+  WritingMode wm = aReflowState.GetWritingMode();
+  LogicalMargin borderPadding = aReflowState.ComputedLogicalPadding();
+  LogicalMargin border = GetBorderWidth(wm);
   borderPadding += border;
 
-  nscoord topInset    = borderPadding.top;
-  nscoord rightInset  = borderPadding.right;
-  nscoord bottomInset = borderPadding.bottom;
-  nscoord leftInset   = borderPadding.left;
+  nscoord topInset = borderPadding.Top(wm);
+  nscoord rightInset = borderPadding.Right(wm);
+  nscoord bottomInset = borderPadding.Bottom(wm);
+  nscoord leftInset = borderPadding.Left(wm);
 
   // reduce available space by insets, if we're in a constrained situation
   availSize.width -= leftInset + rightInset;
   if (NS_UNCONSTRAINEDSIZE != availSize.height)
     availSize.height -= topInset + bottomInset;
 
   // Try to reflow the child into the available space. It might not
   // fit or might need continuing.
   if (availSize.height < 0)
     availSize.height = 1;
 
-  WritingMode wm = aReflowState.GetWritingMode();
   nsHTMLReflowMetrics kidSize(wm, aDesiredSize.mFlags);
   kidSize.ClearSize();
   SetPriorAvailWidth(aReflowState.AvailableWidth());
   nsIFrame* firstKid = mFrames.FirstChild();
   NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
   nsTableFrame* tableFrame = GetTableFrame();
 
   if (aReflowState.mFlags.mSpecialHeightReflow) {
@@ -1075,21 +1073,20 @@ NS_NewTableCellFrame(nsIPresShell*   aPr
   if (aTableFrame->IsBorderCollapse())
     return new (aPresShell) nsBCTableCellFrame(aContext, aTableFrame);
   else
     return new (aPresShell) nsTableCellFrame(aContext, aTableFrame);
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsBCTableCellFrame)
 
-nsMargin*
-nsTableCellFrame::GetBorderWidth(nsMargin&  aBorder) const
+LogicalMargin
+nsTableCellFrame::GetBorderWidth(WritingMode aWM) const
 {
-  aBorder = StyleBorder()->GetComputedBorder();
-  return &aBorder;
+  return LogicalMargin(aWM, StyleBorder()->GetComputedBorder());
 }
 
 nsIAtom*
 nsTableCellFrame::GetType() const
 {
   return nsGkAtoms::tableCellFrame;
 }
 
@@ -1102,35 +1099,34 @@ nsTableCellFrame::GetFrameName(nsAString
 #endif
 
 // nsBCTableCellFrame
 
 nsBCTableCellFrame::nsBCTableCellFrame(nsStyleContext* aContext,
                                        nsTableFrame* aTableFrame)
   : nsTableCellFrame(aContext, aTableFrame)
 {
-  mTopBorder = mRightBorder = mBottomBorder = mLeftBorder = 0;
+  mBStartBorder = mIEndBorder = mBEndBorder = mIStartBorder = 0;
 }
 
 nsBCTableCellFrame::~nsBCTableCellFrame()
 {
 }
 
 nsIAtom*
 nsBCTableCellFrame::GetType() const
 {
   return nsGkAtoms::bcTableCellFrame;
 }
 
 /* virtual */ nsMargin
 nsBCTableCellFrame::GetUsedBorder() const
 {
-  nsMargin result;
-  GetBorderWidth(result);
-  return result;
+  WritingMode wm = GetWritingMode();
+  return GetBorderWidth(wm).GetPhysicalMargin(wm);
 }
 
 /* virtual */ bool
 nsBCTableCellFrame::GetBorderRadii(const nsSize& aFrameSize,
                                    const nsSize& aBorderArea,
                                    Sides aSkipSides,
                                    nscoord aRadii[8]) const
 {
@@ -1143,84 +1139,84 @@ nsBCTableCellFrame::GetBorderRadii(const
 #ifdef DEBUG_FRAME_DUMP
 nsresult
 nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
 {
   return MakeFrameName(NS_LITERAL_STRING("BCTableCell"), aResult);
 }
 #endif
 
-nsMargin*
-nsBCTableCellFrame::GetBorderWidth(nsMargin&  aBorder) const
+LogicalMargin
+nsBCTableCellFrame::GetBorderWidth(WritingMode aWM) const
 {
-  int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
-  aBorder.top = BC_BORDER_END_HALF_COORD(aPixelsToTwips, mTopBorder);
-  aBorder.right = BC_BORDER_START_HALF_COORD(aPixelsToTwips, mRightBorder);
-  aBorder.bottom = BC_BORDER_START_HALF_COORD(aPixelsToTwips, mBottomBorder);
-  aBorder.left = BC_BORDER_END_HALF_COORD(aPixelsToTwips, mLeftBorder);
-  return &aBorder;
+  int32_t pixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
+  return LogicalMargin(aWM,
+                       BC_BORDER_END_HALF_COORD(pixelsToTwips, mBStartBorder),
+                       BC_BORDER_START_HALF_COORD(pixelsToTwips, mIEndBorder),
+                       BC_BORDER_START_HALF_COORD(pixelsToTwips, mBEndBorder),
+                       BC_BORDER_END_HALF_COORD(pixelsToTwips, mIStartBorder));
 }
 
 BCPixelSize
-nsBCTableCellFrame::GetBorderWidth(mozilla::css::Side aSide) const
+nsBCTableCellFrame::GetBorderWidth(LogicalSide aSide) const
 {
   switch(aSide) {
-  case NS_SIDE_TOP:
-    return BC_BORDER_END_HALF(mTopBorder);
-  case NS_SIDE_RIGHT:
-    return BC_BORDER_START_HALF(mRightBorder);
-  case NS_SIDE_BOTTOM:
-    return BC_BORDER_START_HALF(mBottomBorder);
+  case eLogicalSideBStart:
+    return BC_BORDER_END_HALF(mBStartBorder);
+  case eLogicalSideIEnd:
+    return BC_BORDER_START_HALF(mIEndBorder);
+  case eLogicalSideBEnd:
+    return BC_BORDER_START_HALF(mBEndBorder);
   default:
-    return BC_BORDER_END_HALF(mLeftBorder);
+    return BC_BORDER_END_HALF(mIStartBorder);
   }
 }
 
 void
-nsBCTableCellFrame::SetBorderWidth(mozilla::css::Side aSide,
-                                   BCPixelSize aValue)
+nsBCTableCellFrame::SetBorderWidth(LogicalSide aSide, BCPixelSize aValue)
 {
   switch(aSide) {
-  case NS_SIDE_TOP:
-    mTopBorder = aValue;
+  case eLogicalSideBStart:
+    mBStartBorder = aValue;
     break;
-  case NS_SIDE_RIGHT:
-    mRightBorder = aValue;
+  case eLogicalSideIEnd:
+    mIEndBorder = aValue;
     break;
-  case NS_SIDE_BOTTOM:
-    mBottomBorder = aValue;
+  case eLogicalSideBEnd:
+    mBEndBorder = aValue;
     break;
   default:
-    mLeftBorder = aValue;
+    mIStartBorder = aValue;
   }
 }
 
 /* virtual */ nsMargin
 nsBCTableCellFrame::GetBorderOverflow()
 {
-  nsMargin halfBorder;
+  WritingMode wm = GetWritingMode();
   int32_t p2t = nsPresContext::AppUnitsPerCSSPixel();
-  halfBorder.top = BC_BORDER_START_HALF_COORD(p2t, mTopBorder);
-  halfBorder.right = BC_BORDER_END_HALF_COORD(p2t, mRightBorder);
-  halfBorder.bottom = BC_BORDER_END_HALF_COORD(p2t, mBottomBorder);
-  halfBorder.left = BC_BORDER_START_HALF_COORD(p2t, mLeftBorder);
-  return halfBorder;
+  LogicalMargin halfBorder(wm,
+                           BC_BORDER_START_HALF_COORD(p2t, mBStartBorder),
+                           BC_BORDER_END_HALF_COORD(p2t, mIEndBorder),
+                           BC_BORDER_END_HALF_COORD(p2t, mBEndBorder),
+                           BC_BORDER_START_HALF_COORD(p2t, mIStartBorder));
+  return halfBorder.GetPhysicalMargin(wm);
 }
 
 
 DrawResult
 nsBCTableCellFrame::PaintBackground(nsRenderingContext& aRenderingContext,
                                     const nsRect&        aDirtyRect,
                                     nsPoint              aPt,
                                     uint32_t             aFlags)
 {
   // make border-width reflect the half of the border-collapse
   // assigned border that's inside the cell
-  nsMargin borderWidth;
-  GetBorderWidth(borderWidth);
+  WritingMode wm = GetWritingMode();
+  nsMargin borderWidth = GetBorderWidth(wm).GetPhysicalMargin(wm);
 
   nsStyleBorder myBorder(*StyleBorder());
 
   NS_FOR_CSS_SIDES(side) {
     myBorder.SetBorderWidth(side, borderWidth.Side(side));
   }
 
   nsRect rect(aPt, GetSize());
--- a/layout/tables/nsTableCellFrame.h
+++ b/layout/tables/nsTableCellFrame.h
@@ -12,16 +12,17 @@
 #include "nscore.h"
 #include "nsContainerFrame.h"
 #include "nsStyleContext.h"
 #include "nsIPercentHeightObserver.h"
 #include "nsGkAtoms.h"
 #include "nsLayoutUtils.h"
 #include "nsTArray.h"
 #include "nsTableRowFrame.h"
+#include "mozilla/WritingModes.h"
 
 /**
  * nsTableCellFrame
  * data structure to maintain information about a single table cell's frame
  *
  * NOTE:  frames are not ref counted.  We expose addref and release here
  * so we can change that decsion in the future.  Users of nsITableCellLayout
  * should refcount correctly as if this object is being ref counted, though
@@ -30,16 +31,21 @@
  * @author  sclark
  */
 class nsTableCellFrame : public nsContainerFrame,
                          public nsITableCellLayout,
                          public nsIPercentHeightObserver
 {
   typedef mozilla::image::DrawResult DrawResult;
 
+protected:
+  typedef mozilla::WritingMode WritingMode;
+  typedef mozilla::LogicalSide LogicalSide;
+  typedef mozilla::LogicalMargin LogicalMargin;
+
 public:
   NS_DECL_QUERYFRAME_TARGET(nsTableCellFrame)
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS
 
   // default constructor supplied by the compiler
 
   nsTableCellFrame(nsStyleContext* aContext, nsTableFrame* aTableFrame);
@@ -210,17 +216,17 @@ public:
   bool GetContentEmpty();
   void SetContentEmpty(bool aContentEmpty);
 
   bool HasPctOverHeight();
   void SetHasPctOverHeight(bool aValue);
 
   nsTableCellFrame* GetNextCell() const;
 
-  virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const;
+  virtual LogicalMargin GetBorderWidth(WritingMode aWM) const;
 
   virtual DrawResult PaintBackground(nsRenderingContext& aRenderingContext,
                                      const nsRect&        aDirtyRect,
                                      nsPoint              aPt,
                                      uint32_t             aFlags);
 
   void DecorateForSelection(nsRenderingContext& aRenderingContext,
                             nsPoint              aPt);
@@ -316,38 +322,38 @@ public:
 
   virtual nsMargin GetUsedBorder() const override;
   virtual bool GetBorderRadii(const nsSize& aFrameSize,
                               const nsSize& aBorderArea,
                               Sides aSkipSides,
                               nscoord aRadii[8]) const override;
 
   // Get the *inner half of the border only*, in twips.
-  virtual nsMargin* GetBorderWidth(nsMargin& aBorder) const override;
+  virtual LogicalMargin GetBorderWidth(WritingMode aWM) const override;
 
   // Get the *inner half of the border only*, in pixels.
-  BCPixelSize GetBorderWidth(mozilla::css::Side aSide) const;
+  BCPixelSize GetBorderWidth(LogicalSide aSide) const;
 
   // Set the full (both halves) width of the border
-  void SetBorderWidth(mozilla::css::Side aSide, BCPixelSize aPixelValue);
+  void SetBorderWidth(LogicalSide aSide, BCPixelSize aPixelValue);
 
   virtual nsMargin GetBorderOverflow() override;
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
 #endif
 
   virtual DrawResult PaintBackground(nsRenderingContext& aRenderingContext,
                                      const nsRect&        aDirtyRect,
                                      nsPoint              aPt,
                                      uint32_t             aFlags) override;
 
 private:
 
   // These are the entire width of the border (the cell edge contains only
   // the inner half, per the macros in nsTablePainter.h).
-  BCPixelSize mTopBorder;
-  BCPixelSize mRightBorder;
-  BCPixelSize mBottomBorder;
-  BCPixelSize mLeftBorder;
+  BCPixelSize mBStartBorder;
+  BCPixelSize mIEndBorder;
+  BCPixelSize mBEndBorder;
+  BCPixelSize mIStartBorder;
 };
 
 #endif
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -5489,59 +5489,59 @@ BCMapCellInfo::SetTableIEndBorderWidth(i
                                            aWidth);
 }
 
 void
 BCMapCellInfo::SetIEndBorderWidths(BCPixelSize aWidth)
 {
    // update the borders of the cells and cols affected
   if (mCell) {
-    mCell->SetBorderWidth(mEndSide, std::max(aWidth,
-                          mCell->GetBorderWidth(mEndSide)));
+    mCell->SetBorderWidth(eLogicalSideIEnd, std::max(aWidth,
+                          mCell->GetBorderWidth(eLogicalSideIEnd)));
   }
   if (mEndCol) {
     BCPixelSize half = BC_BORDER_START_HALF(aWidth);
     mEndCol->SetIEndBorderWidth(
       std::max(nscoord(half), mEndCol->GetIEndBorderWidth()));
   }
 }
 
 void
 BCMapCellInfo::SetBEndBorderWidths(BCPixelSize aWidth)
 {
   // update the borders of the affected cells and rows
   if (mCell) {
-    mCell->SetBorderWidth(NS_SIDE_BOTTOM, std::max(aWidth,
-                          mCell->GetBorderWidth(NS_SIDE_BOTTOM)));
+    mCell->SetBorderWidth(eLogicalSideBEnd, std::max(aWidth,
+                          mCell->GetBorderWidth(eLogicalSideBEnd)));
   }
   if (mEndRow) {
     BCPixelSize half = BC_BORDER_START_HALF(aWidth);
     mEndRow->SetBEndBCBorderWidth(
       std::max(nscoord(half), mEndRow->GetBEndBCBorderWidth()));
   }
 }
 void
 BCMapCellInfo::SetBStartBorderWidths(BCPixelSize aWidth)
 {
  if (mCell) {
-     mCell->SetBorderWidth(NS_SIDE_TOP, std::max(aWidth,
-                           mCell->GetBorderWidth(NS_SIDE_TOP)));
+     mCell->SetBorderWidth(eLogicalSideBStart, std::max(aWidth,
+                           mCell->GetBorderWidth(eLogicalSideBStart)));
   }
   if (mStartRow) {
     BCPixelSize half = BC_BORDER_END_HALF(aWidth);
     mStartRow->SetBStartBCBorderWidth(
       std::max(nscoord(half), mStartRow->GetBStartBCBorderWidth()));
   }
 }
 void
 BCMapCellInfo::SetIStartBorderWidths(BCPixelSize aWidth)
 {
   if (mCell) {
-    mCell->SetBorderWidth(mStartSide, std::max(aWidth,
-                          mCell->GetBorderWidth(mStartSide)));
+    mCell->SetBorderWidth(eLogicalSideIStart, std::max(aWidth,
+                          mCell->GetBorderWidth(eLogicalSideIStart)));
   }
   if (mStartCol) {
     BCPixelSize half = BC_BORDER_END_HALF(aWidth);
     mStartCol->SetIStartBorderWidth(
       std::max(nscoord(half), mStartCol->GetIStartBorderWidth()));
   }
 }
 
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -70,17 +70,19 @@ nsTableRowFrame::InitChildReflowState(ns
                                       nsTableCellReflowState& aReflowState)
 {
   nsMargin collapseBorder;
   nsMargin* pCollapseBorder = nullptr;
   if (aBorderCollapse) {
     // we only reflow cells, so don't need to check frame type
     nsBCTableCellFrame* bcCellFrame = (nsBCTableCellFrame*)aReflowState.frame;
     if (bcCellFrame) {
-      pCollapseBorder = bcCellFrame->GetBorderWidth(collapseBorder);
+      WritingMode wm = GetWritingMode();
+      collapseBorder = bcCellFrame->GetBorderWidth(wm).GetPhysicalMargin(wm);
+      pCollapseBorder = &collapseBorder;
     }
   }
   aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder);
   aReflowState.FixUp(aAvailSize);
 }
 
 void
 nsTableRowFrame::SetFixedHeight(nscoord aValue)