include the border width for border collapsed tables as required by CSS 2.1. We implemented before what CSS 2.0 required and it was ugly, so the spec changed. r=fantasai sr=roc, bug 155955
authorBernd <bmlk@gmx.de>
Sun, 08 Feb 2009 17:46:42 +0100
changeset 24768 fc7431820ea33d0e2ebfa92eccef4ff35c90ea1d
parent 24767 1c9f9b078e2287427888e318e6de1db4c169a4c5
child 24769 57eeb5a25f65829044a239b0cada60a0861799e0
push id5229
push userbmlk@gmx.de
push dateSun, 08 Feb 2009 16:47:17 +0000
treeherdermozilla-central@fc7431820ea3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfantasai, roc, bug
bugs155955
milestone1.9.2a1pre
include the border width for border collapsed tables as required by CSS 2.1. We implemented before what CSS 2.0 required and it was ugly, so the spec changed. r=fantasai sr=roc, bug 155955
layout/reftests/bugs/356774-1.html
layout/reftests/table-background/border-collapse-opacity-table-cell-ref.html
layout/reftests/table-background/border-collapse-opacity-table-column-group-ref.html
layout/reftests/table-background/border-collapse-opacity-table-column-ref.html
layout/reftests/table-background/border-collapse-opacity-table-ref.html
layout/reftests/table-background/border-collapse-opacity-table-row-group-ref.html
layout/reftests/table-background/border-collapse-opacity-table-row-ref.html
layout/reftests/table-background/border-collapse-table-cell-ref.html
layout/reftests/table-background/border-collapse-table-column-group-ref.html
layout/reftests/table-background/border-collapse-table-column-ref.html
layout/reftests/table-background/border-collapse-table-ref.html
layout/reftests/table-background/border-collapse-table-row-group-ref.html
layout/reftests/table-background/border-collapse-table-row-ref.html
layout/reftests/table-bordercollapse/bc_borderoffset1.html
layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html
layout/reftests/table-bordercollapse/bc_borderoffset2.html
layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html
layout/reftests/table-bordercollapse/reftest.list
layout/tables/nsTableFrame.cpp
layout/tables/nsTableFrame.h
--- a/layout/reftests/bugs/356774-1.html
+++ b/layout/reftests/bugs/356774-1.html
@@ -1,13 +1,12 @@
 <!DOCTYPE html>
 <html>
 <style>
 table {
- margin: 1px;
  border: .1mm solid black;
  border-collapse: collapse;
 }
 </style>
 <body>
 <table>
  <tr>
   <td>border: .1mm, collapsed</td>
--- a/layout/reftests/table-background/border-collapse-opacity-table-cell-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-cell-ref.html
@@ -36,17 +36,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 57px; height: 19px; margin: 38px 117px 80px 120px; }
+	div { width: 57px; height: 19px; margin: 40px 118px 86px 123px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 1px 2px; }
 	div.imagebr { background-position: 56px 17px; }
--- a/layout/reftests/table-background/border-collapse-opacity-table-column-group-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-column-group-ref.html
@@ -36,17 +36,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 171px; height: 97px; margin: 0px 60px 2px 63px; }
+	div { width: 171px; height: 97px; margin: 2px 61px 8px 66px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 171px 97px; }
--- a/layout/reftests/table-background/border-collapse-opacity-table-column-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-column-ref.html
@@ -36,17 +36,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 57px; height: 97px; margin: 0px 117px 2px 120px; }
+	div { width: 57px; height: 97px; margin: 2px 121px 8px 123px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 57px 97px; }
--- a/layout/reftests/table-background/border-collapse-opacity-table-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-ref.html
@@ -36,25 +36,25 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 97px; margin: 0px 3px 2px 4px; }
+	div { width: 291px; height: 103px; margin: 0px 3px 2px 4px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
-	div.imagetl { background-position: 0 0; }
-	div.imagebr { background-position: 287px 97px; }
+	div.imagetl { background-position: 3px 2px; }
+	div.imagebr { background-position: 290px 99px; }
 
 	</style>
 </head>
 <body>
 
 <div class="color o"></div>
 <div class="imagetl o"></div>
 <div class="imagebr"></div>
--- a/layout/reftests/table-background/border-collapse-opacity-table-row-group-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-row-group-ref.html
@@ -36,17 +36,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 57px; margin: 19px 3px 42px 4px; }
+	div { width: 287px; height: 57px; margin: 21px 4px 48px 7px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 287px 57px; }
--- a/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html
+++ b/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html
@@ -36,17 +36,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 19px; margin: 38px 3px 80px 4px; }
+	div { width: 287px; height: 19px; margin: 40px 4px 86px 7px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 287px 19px; }
--- a/layout/reftests/table-background/border-collapse-table-cell-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-cell-ref.html
@@ -34,17 +34,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 57px; height: 19px; margin: 38px 117px 80px 120px; }
+	div { width: 57px; height: 19px; margin: 40px 118px 86px 123px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 1px 2px; }
 	div.imagebr { background-position: 56px 17px; }
--- a/layout/reftests/table-background/border-collapse-table-column-group-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-column-group-ref.html
@@ -34,17 +34,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 171px; height: 97px; margin: 0px 60px 2px 63px; }
+	div { width: 171px; height: 97px; margin: 2px 61px 8px 66px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 171px 97px; }
--- a/layout/reftests/table-background/border-collapse-table-column-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-column-ref.html
@@ -34,17 +34,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 57px; height: 97px; margin: 0px 117px 2px 120px; }
+	div { width: 57px; height: 97px; margin: 2px 121px 8px 123px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 57px 97px; }
--- a/layout/reftests/table-background/border-collapse-table-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-ref.html
@@ -34,25 +34,25 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 97px; margin: 0px 3px 2px 4px; }
+	div { width: 291px; height: 103px; margin: 0px 3px 2px 4px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
-	div.imagetl { background-position: 0 0; }
-	div.imagebr { background-position: 287px 97px; }
+	div.imagetl { background-position: 3px 2px;}
+	div.imagebr { background-position: 290px 99px;}
 
 	</style>
 </head>
 <body>
 
 <div class="color"></div>
 <div class="imagetl"></div>
 <div class="imagebr"></div>
--- a/layout/reftests/table-background/border-collapse-table-row-group-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-row-group-ref.html
@@ -34,17 +34,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 57px; margin: 19px 3px 42px 4px; }
+	div { width: 287px; height: 57px; margin: 21px 4px 48px 7px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 287px 57px; }
--- a/layout/reftests/table-background/border-collapse-table-row-ref.html
+++ b/layout/reftests/table-background/border-collapse-table-row-ref.html
@@ -34,17 +34,17 @@
 		    border-left: 1px;
 		    padding-left: 3px;
 		    width: 50px;
 		    padding-right: 2px;
 		    border-right: 1px;
 		  (1px of border outside width)
     */
 
-	div { width: 287px; height: 19px; margin: 38px 3px 80px 4px; }
+	div { width: 287px; height: 19px; margin: 40px 4px 86px 7px; }
 	div.color { background-color: aqua; }
 
 	div.imagetl, div.imagebr {
 		background-image: url(repeatable-diagonal-gradient-with-ticks.png);
 	}
 
 	div.imagetl { background-position: 0 0; }
 	div.imagebr { background-position: 287px 19px; }
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-bordercollapse/bc_borderoffset1.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+td {width: 100px; text-align:center}
+div {position:absolute; border:green 4px solid}
+
+</style>
+</head>
+
+<body>
+<div>
+<table style="border-collapse:collapse;">
+  <tr><td style="border:solid 4px orange; height:30px">cell 1</td></tr>
+</table>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+td {width: 100px; text-align:center}
+div {position:absolute; border:green 4px solid}
+
+</style>
+</head>
+
+<body>
+<!-- the height for table cells includes the border -->
+<div>
+<table  cellspacing="0">
+  <tr><td style="border:solid 4px orange; height:34px">cell 1</td></tr>
+</table>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-bordercollapse/bc_borderoffset2.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+td {width: 100px; text-align:center}
+caption {border:solid 4px green}
+
+</style>
+</head>
+
+<body>
+
+<table style="border-collapse:collapse;"><caption>caption</caption>
+  <tr><td style="border:solid 4px orange; height:30px">cell 1</td></tr>
+</table>
+
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+td {width: 100px; text-align:center}
+caption {border:solid 4px green}
+
+</style>
+</head>
+
+<body>
+
+
+<table cellspacing="0" cellpadding="0"><caption>caption</caption>
+  <tr>
+    <td style="border:solid 4px orange; width:102px; height:34px">cell 1</td>
+  </tr>
+</table>
+</body>
+</html>
--- a/layout/reftests/table-bordercollapse/reftest.list
+++ b/layout/reftests/table-bordercollapse/reftest.list
@@ -13,8 +13,10 @@
 == bc_dyn_col2.html bc_dyn_cg2_ref.html
 == bc_dyn_col3.html bc_dyn_cg3_ref.html
 == bc_dyn_cg1.html bc_dyn_cg1_ref.html
 == bc_dyn_cg2.html bc_dyn_cg2_ref.html
 == bc_dyn_cg3.html bc_dyn_cg3_ref.html
 == bc_dyn_table1.html bc_dyn_table1_ref.html
 == bc_dyn_table2.html bc_dyn_table2_ref.html
 == bc_dyn_table3.html bc_dyn_table3_ref.html
+== bc_borderoffset1.html bc_borderoffset1_ref.html
+== bc_borderoffset2.html bc_borderoffset2_ref.html
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -140,23 +140,27 @@ struct nsTableReflowState {
 };
 
 /********************************************************************************
  ** nsTableFrame                                                               **
  ********************************************************************************/
 
 struct BCPropertyData
 {
-  BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width = mDamageArea.height =
-                     mTopBorderWidth = mRightBorderWidth = mBottomBorderWidth = mLeftBorderWidth = 0; }
+  BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width =
+                     mDamageArea.height = mTopBorderWidth = mRightBorderWidth =
+                     mBottomBorderWidth = mLeftBorderWidth =
+                     mLeftCellBorderWidth = mRightCellBorderWidth = 0; }
   nsRect  mDamageArea;
   BCPixelSize mTopBorderWidth;
   BCPixelSize mRightBorderWidth;
   BCPixelSize mBottomBorderWidth;
   BCPixelSize mLeftBorderWidth;
+  BCPixelSize mLeftCellBorderWidth;
+  BCPixelSize mRightCellBorderWidth;
 };
 
 NS_IMETHODIMP 
 nsTableFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
                                          nsIFrame**      aProviderFrame,
                                          PRBool*         aIsChild)
 {
   // Since our parent, the table outer frame, returned this frame, we
@@ -2545,42 +2549,49 @@ nsTableFrame::GetOuterBCBorder() const
   if (NeedToCalcBCBorders())
     const_cast<nsTableFrame*>(this)->CalcBCBorders();
 
   nsMargin border(0, 0, 0, 0);
   PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel();
   BCPropertyData* propData = 
     (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this, nsGkAtoms::tableBCProperty, PR_FALSE);
   if (propData) {
-    border.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
-    border.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth);
-    border.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
-    border.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
+    border.top    = BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
+    border.right  = BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth);
+    border.bottom = BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
+    border.left   = BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
   }
   return border;
 }
 
 nsMargin
 nsTableFrame::GetIncludedOuterBCBorder() const
 {
-  if (eCompatibility_NavQuirks == PresContext()->CompatibilityMode()) {
-    return GetOuterBCBorder();
-  }
+  if (NeedToCalcBCBorders())
+    const_cast<nsTableFrame*>(this)->CalcBCBorders();
+
   nsMargin border(0, 0, 0, 0);
+  PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel();
+  BCPropertyData* propData =
+    (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this,
+                                                nsGkAtoms::tableBCProperty,
+                                                PR_FALSE);
+  if (propData) {
+    border.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
+    border.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightCellBorderWidth);
+    border.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
+    border.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftCellBorderWidth);
+  }
   return border;
 }
 
 nsMargin
 nsTableFrame::GetExcludedOuterBCBorder() const
 {
-  if (eCompatibility_NavQuirks != PresContext()->CompatibilityMode()) {
-    return GetOuterBCBorder();
-  }
-  nsMargin border(0, 0, 0, 0);
-  return border;
+  return GetOuterBCBorder() - GetIncludedOuterBCBorder();
 }
 static
 void GetSeparateModelBorderPadding(const nsHTMLReflowState* aReflowState,
                                    nsStyleContext&          aStyleContext,
                                    nsMargin&                aBorderPadding)
 {
   // XXXbz Either we _do_ have a reflow state and then we can use its
   // mComputedBorderPadding or we don't and then we get the padding
@@ -2592,44 +2603,17 @@ void GetSeparateModelBorderPadding(const
   }
 }
 
 nsMargin 
 nsTableFrame::GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const
 {
   nsMargin offset(0,0,0,0);
   if (IsBorderCollapse()) {
-    nsPresContext* presContext = PresContext();
-    if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) {
-      nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset);
-      PRInt32 p2t = nsPresContext::AppUnitsPerCSSPixel();
-      BCPropertyData* propData = 
-        (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)firstInFlow, nsGkAtoms::tableBCProperty, PR_FALSE);
-      if (!propData) ABORT1(offset);
-
-      offset.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
-      offset.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth);
-      offset.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
-      offset.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
-    }
-  }
-  else {
-    GetSeparateModelBorderPadding(aReflowState, *mStyleContext, offset);
-  }
-  return offset;
-}
-
-nsMargin 
-nsTableFrame::GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const
-{
-  nsMargin offset(0,0,0,0);
-  if (IsBorderCollapse()) {
-    // LDB: This used to unconditionally include the inner half as well,
-    // but that's pretty clearly wrong per the CSS2.1 spec.
-    offset = GetOuterBCBorder();
+    offset = GetIncludedOuterBCBorder();
   }
   else {
     GetSeparateModelBorderPadding(aReflowState, *mStyleContext, offset);
   }
   return offset;
 }
 
 void
@@ -3697,17 +3681,17 @@ nsTableFrame::IsAutoHeight()
   return isAuto; 
 }
 
 nscoord 
 nsTableFrame::CalcBorderBoxHeight(const nsHTMLReflowState& aState)
 {
   nscoord height = aState.ComputedHeight();
   if (NS_AUTOHEIGHT != height) {
-    nsMargin borderPadding = GetContentAreaOffset(&aState);
+    nsMargin borderPadding = GetChildAreaOffset(&aState);
     height += borderPadding.top + borderPadding.bottom;
   }
   height = PR_MAX(0, height);
 
   return height;
 }
 
 PRBool 
@@ -5493,16 +5477,25 @@ nsTableFrame::CalcBCBorders()
         rowFrame = (rowX == info.rowIndex) ? info.topRow : rowFrame->GetNextRow();
         currentBorder = CompareBorders(this, info.cg, info.leftCol, info.rg, rowFrame, info.cell, 
                                        tableIsLTR, TABLE_EDGE, NS_SIDE_LEFT, !ADJACENT);
         BCCornerInfo& tlCorner = (0 == rowX) ? topCorners[0] : bottomCorners[0]; // top left
         tlCorner.Update(NS_SIDE_BOTTOM, currentBorder);
         tableCellMap->SetBCBorderCorner(eTopLeft, *info.cellMap, iter.mRowGroupStart, rowX, 
                                         0, tlCorner.ownerSide, tlCorner.subWidth, tlCorner.bevel);
         bottomCorners[0].Set(NS_SIDE_TOP, currentBorder); // bottom left             
+        // update the left/right first cell border
+        if (0 == rowX) {
+          if (tableIsLTR) {
+            propData->mLeftCellBorderWidth = currentBorder.width;
+          }
+          else {
+            propData->mRightCellBorderWidth = currentBorder.width;
+          }
+        }
         // update lastVerBordersBorder and see if a new segment starts
         startSeg = SetBorder(currentBorder, lastVerBorders[0]);
         // store the border segment in the cell map 
         tableCellMap->SetBCBorderEdge(NS_SIDE_LEFT, *info.cellMap, iter.mRowGroupStart, rowX, 
                                       info.colIndex, 1, currentBorder.owner, currentBorder.width, startSeg);
         // update the left border of the cell, col and table
         if (info.cell) {
           info.cell->SetBorderWidth(firstSide, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(firstSide)));
@@ -5549,16 +5542,25 @@ nsTableFrame::CalcBCBorders()
         brCorner.Set(NS_SIDE_TOP, currentBorder); // bottom right
         tableCellMap->SetBCBorderCorner(eBottomRight, *info.cellMap, iter.mRowGroupStart, rowX,
                                         cellEndColIndex, brCorner.ownerSide, brCorner.subWidth, brCorner.bevel);
         // update lastVerBorders and see if a new segment starts
         startSeg = SetBorder(currentBorder, lastVerBorders[cellEndColIndex + 1]);
         // store the border segment in the cell map and update cellBorders
         tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX,
                                       cellEndColIndex, 1, currentBorder.owner, currentBorder.width, startSeg);
+        // update the left/right first cell border
+        if (0 == rowX) {
+          if (tableIsLTR) {
+            propData->mRightCellBorderWidth = currentBorder.width;
+          }
+          else {
+            propData->mLeftCellBorderWidth = currentBorder.width;
+          }
+        }
         // update the affected borders of the cell, col, and table
         if (info.cell) {
           info.cell->SetBorderWidth(secondSide, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(secondSide)));
         }
         if (info.rightCol) {
           BCPixelSize half = BC_BORDER_LEFT_HALF(currentBorder.width);
           info.rightCol->SetRightBorderWidth(PR_MAX(half, info.rightCol->GetRightBorderWidth()));
         }
--- a/layout/tables/nsTableFrame.h
+++ b/layout/tables/nsTableFrame.h
@@ -208,19 +208,16 @@ public:
                          nsIFrame*       aOldFrame);
 
   virtual nsMargin GetUsedBorder() const;
   virtual nsMargin GetUsedPadding() const;
 
   // Get the offset from the border box to the area where the row groups fit
   nsMargin GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const;
 
-  // Get the offset from the border box to the area where the content fits
-  nsMargin GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const;
-
   /** helper method to find the table parent of any table frame object */
   static nsTableFrame* GetTableFrame(nsIFrame* aSourceFrame);
                                  
   typedef nsresult (* DisplayGenericTablePartTraversal)
       (nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
        const nsRect& aDirtyRect, const nsDisplayListSet& aLists);
   static nsresult GenericTraversal(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
                                    const nsRect& aDirtyRect, const nsDisplayListSet& aLists);
@@ -279,36 +276,36 @@ public:
    * Paint the background of the table and its parts (column groups,
    * columns, row groups, rows, and cells), and the table border, and all
    * internal borders if border-collapse is on.
    */
   void PaintTableBorderBackground(nsIRenderingContext& aRenderingContext,
                                   const nsRect& aDirtyRect,
                                   nsPoint aPt);
 
-  // Get the outer half (i.e., the part outside the height and width of
-  // the table) of the largest segment (?) of border-collapsed border on
-  // the table on each side, or 0 for non border-collapsed tables.
+  /** Get the outer half (i.e., the part outside the height and width of
+   *  the table) of the largest segment (?) of border-collapsed border on
+   *  the table on each side, or 0 for non border-collapsed tables.
+   */
   nsMargin GetOuterBCBorder() const;
 
-  // Same as above, but only if it's included from the border-box width
-  // of the table (nonzero only in quirks mode).
+  /** Same as above, but only if it's included from the border-box width
+   *  of the table.
+   */
   nsMargin GetIncludedOuterBCBorder() const;
 
-  // Same as above, but only if it's excluded from the border-box width
-  // of the table (nonzero only in standards mode).  This is the area
-  // that leaks out into the margin (or potentially past it, if there is
-  // no margin).
+  /** Same as above, but only if it's excluded from the border-box width
+   *  of the table.  This is the area that leaks out into the margin
+   *  (or potentially past it, if there is no margin).
+   */
   nsMargin GetExcludedOuterBCBorder() const;
 
   /** Get width of table + colgroup + col collapse: elements that
    *  continue along the length of the whole left side.
    *  see nsTablePainter about continuous borders
-   *  @param aPixelsToTwips - conversion factor
-   *  @param aGetInner - get only inner half of border width
    */
   nscoord GetContinuousLeftBCBorderWidth() const;
   friend class nsDelayedCalcBCBorders;
   
   void SetBCDamageArea(const nsRect& aValue);
   PRBool BCRecalcNeeded(nsStyleContext* aOldStyleContext,
                         nsStyleContext* aNewStyleContext);
   void PaintBCBorders(nsIRenderingContext& aRenderingContext,