Convert border spacing storage from nsStyleCoord to nscoord. (Bug 443057) r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Fri, 12 Sep 2008 20:45:37 -0700
changeset 19206 ade776b76598fde98928fce35e59e01d360e8754
parent 19205 47e7de9ac585147de70d55357235338595cbfaa7
child 19207 e26688231f7b61a0e61a18a585d8ed07e1bac72e
push id2020
push userdbaron@mozilla.com
push dateSat, 13 Sep 2008 03:46:28 +0000
treeherderautoland@95f310fa27bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs443057
milestone1.9.1b1pre
Convert border spacing storage from nsStyleCoord to nscoord. (Bug 443057) r+sr=bzbarsky
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleContext.cpp
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/tables/nsTableFrame.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -1246,18 +1246,18 @@ nsComputedDOMStyle::GetBorderSpacing(nsI
   }
   if (!valueList->AppendCSSValue(ySpacing)) {
     delete valueList;
     delete ySpacing;
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   const nsStyleTableBorder *border = GetStyleTableBorder();
-  SetValueToCoord(xSpacing, border->mBorderSpacingX);
-  SetValueToCoord(ySpacing, border->mBorderSpacingY);
+  xSpacing->SetAppUnits(border->mBorderSpacingX);
+  ySpacing->SetAppUnits(border->mBorderSpacingY);
 
   return CallQueryInterface(valueList, aValue);
 }
 
 nsresult
 nsComputedDOMStyle::GetCaptionSide(nsIDOMCSSValue** aValue)
 {
   nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -4157,23 +4157,37 @@ nsRuleNode::ComputeTableBorderData(void*
                           Table, tableData)
 
   // border-collapse: enum, inherit, initial
   SetDiscrete(tableData.mBorderCollapse, table->mBorderCollapse, inherited,
               SETDSC_ENUMERATED, parentTable->mBorderCollapse,
               NS_STYLE_BORDER_SEPARATE, 0, 0, 0, 0);
 
   // border-spacing-x: length, inherit
-  SetCoord(tableData.mBorderSpacing.mXValue, table->mBorderSpacingX,
-           parentTable->mBorderSpacingX, SETCOORD_LH | SETCOORD_INITIAL_ZERO,
-           aContext, mPresContext, inherited);
+  nsStyleCoord tempCoord;
+  if (SetCoord(tableData.mBorderSpacing.mXValue, tempCoord,
+               parentTable->mBorderSpacingX,
+               SETCOORD_LH | SETCOORD_INITIAL_ZERO,
+               aContext, mPresContext, inherited)) {
+    table->mBorderSpacingX = tempCoord.GetCoordValue();
+  } else {
+    NS_ASSERTION(tableData.mBorderSpacing.mXValue.GetUnit() == eCSSUnit_Null,
+                 "unexpected unit");
+  }
+
   // border-spacing-y: length, inherit
-  SetCoord(tableData.mBorderSpacing.mYValue, table->mBorderSpacingY,
-           parentTable->mBorderSpacingY, SETCOORD_LH | SETCOORD_INITIAL_ZERO,
-           aContext, mPresContext, inherited);
+  if (SetCoord(tableData.mBorderSpacing.mYValue, tempCoord,
+               parentTable->mBorderSpacingY,
+               SETCOORD_LH | SETCOORD_INITIAL_ZERO,
+               aContext, mPresContext, inherited)) {
+    table->mBorderSpacingY = tempCoord.GetCoordValue();
+  } else {
+    NS_ASSERTION(tableData.mBorderSpacing.mYValue.GetUnit() == eCSSUnit_Null,
+                 "unexpected unit");
+  }
 
   // caption-side: enum, inherit, initial
   SetDiscrete(tableData.mCaptionSide, table->mCaptionSide, inherited,
               SETDSC_ENUMERATED, parentTable->mCaptionSide,
               NS_STYLE_CAPTION_SIDE_TOP, 0, 0, 0, 0);
 
   // empty-cells: enum, inherit, initial
   SetDiscrete(tableData.mEmptyCells, table->mEmptyCells, inherited,
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -762,23 +762,20 @@ void nsStyleContext::DumpRegressionData(
   fprintf(out, "%ld %ld ",
     (long)table->mCols,
     (long)table->mSpan);
   fprintf(out, "\" />\n");
 
   // TABLEBORDER
   IndentBy(out,aIndent);
   const nsStyleTableBorder* tableBorder = GetStyleTableBorder();
-  fprintf(out, "<tableborder data=\"%d ",
-    (int)tableBorder->mBorderCollapse);
-  tableBorder->mBorderSpacingX.ToString(str);
-  fprintf(out, "%s ", NS_ConvertUTF16toUTF8(str).get());
-  tableBorder->mBorderSpacingY.ToString(str);
-  fprintf(out, "%s ", NS_ConvertUTF16toUTF8(str).get());
-  fprintf(out, "%d %d ",
+  fprintf(out, "<tableborder data=\"%d %d %d %d %d ",
+    (int)tableBorder->mBorderCollapse,
+    (int)tableBorder->mBorderSpacingX,
+    (int)tableBorder->mBorderSpacingY,
     (int)tableBorder->mCaptionSide,
     (int)tableBorder->mEmptyCells);
   fprintf(out, "\" />\n");
 
   // CONTENT
   IndentBy(out,aIndent);
   const nsStyleContent* content = GetStyleContent();
   fprintf(out, "<content data=\"%ld %ld %ld ",
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1072,18 +1072,18 @@ nsStyleTableBorder::nsStyleTableBorder(n
 
   nsCompatibility compatMode = eCompatibility_FullStandards;
   if (aPresContext)
     compatMode = aPresContext->CompatibilityMode();
   mEmptyCells = (compatMode == eCompatibility_NavQuirks)
                   ? NS_STYLE_TABLE_EMPTY_CELLS_SHOW_BACKGROUND     
                   : NS_STYLE_TABLE_EMPTY_CELLS_SHOW;
   mCaptionSide = NS_STYLE_CAPTION_SIDE_TOP;
-  mBorderSpacingX.SetCoordValue(0);
-  mBorderSpacingY.SetCoordValue(0);
+  mBorderSpacingX = 0;
+  mBorderSpacingY = 0;
 }
 
 nsStyleTableBorder::~nsStyleTableBorder(void) 
 { 
 }
 
 nsStyleTableBorder::nsStyleTableBorder(const nsStyleTableBorder& aSource)
 {
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -973,18 +973,18 @@ struct nsStyleTableBorder {
     aContext->FreeToShell(sizeof(nsStyleTableBorder), this);
   }
 
   nsChangeHint CalcDifference(const nsStyleTableBorder& aOther) const;
 #ifdef DEBUG
   static nsChangeHint MaxDifference();
 #endif
   
-  nsStyleCoord  mBorderSpacingX;// [inherited] coord
-  nsStyleCoord  mBorderSpacingY;// [inherited] coord
+  nscoord       mBorderSpacingX;// [inherited]
+  nscoord       mBorderSpacingY;// [inherited]
   PRUint8       mBorderCollapse;// [inherited]
   PRUint8       mCaptionSide;   // [inherited]
   PRUint8       mEmptyCells;    // [inherited]
 };
 
 enum nsStyleContentType {
   eStyleContentType_String        = 1,
   eStyleContentType_Image         = 10,
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -3556,30 +3556,26 @@ void nsTableFrame::SetColumnWidth(PRInt3
 }
 
 // XXX: could cache this.  But be sure to check style changes if you do!
 nscoord nsTableFrame::GetCellSpacingX()
 {
   if (IsBorderCollapse())
     return 0;
 
-  NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingX.GetUnit() == eStyleUnit_Coord,
-               "Not a coord value!");
-  return GetStyleTableBorder()->mBorderSpacingX.GetCoordValue();
+  return GetStyleTableBorder()->mBorderSpacingX;
 }
 
 // XXX: could cache this. But be sure to check style changes if you do!
 nscoord nsTableFrame::GetCellSpacingY()
 {
   if (IsBorderCollapse())
     return 0;
 
-  NS_ASSERTION(GetStyleTableBorder()->mBorderSpacingY.GetUnit() == eStyleUnit_Coord,
-               "Not a coord value!");
-  return GetStyleTableBorder()->mBorderSpacingY.GetCoordValue();
+  return GetStyleTableBorder()->mBorderSpacingY;
 }
 
 
 /* virtual */ nscoord
 nsTableFrame::GetBaseline() const
 {
   nscoord ascent = 0;
   RowGroupArray orderedRowGroups;