diff --git a/layout/reftests/bugs/356774-1.html b/layout/reftests/bugs/356774-1.html index 5209f1505692..4299f31893b6 100644 --- a/layout/reftests/bugs/356774-1.html +++ b/layout/reftests/bugs/356774-1.html @@ -2,7 +2,6 @@ diff --git 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 index 7597d0457739..053c9d620c6a 100644 --- 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 @@ -41,7 +41,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html b/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html index 065f3fefe6f7..80e548ab25cf 100644 --- a/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html +++ b/layout/reftests/table-background/border-collapse-opacity-table-row-ref.html @@ -41,7 +41,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-table-cell-ref.html b/layout/reftests/table-background/border-collapse-table-cell-ref.html index 0f913efb4bbb..2eabe4dba716 100644 --- a/layout/reftests/table-background/border-collapse-table-cell-ref.html +++ b/layout/reftests/table-background/border-collapse-table-cell-ref.html @@ -39,7 +39,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-table-column-group-ref.html b/layout/reftests/table-background/border-collapse-table-column-group-ref.html index 740ef8c6ecc7..9ec969236a41 100644 --- a/layout/reftests/table-background/border-collapse-table-column-group-ref.html +++ b/layout/reftests/table-background/border-collapse-table-column-group-ref.html @@ -39,7 +39,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-table-column-ref.html b/layout/reftests/table-background/border-collapse-table-column-ref.html index d7f171a2190a..82795ef8bebf 100644 --- a/layout/reftests/table-background/border-collapse-table-column-ref.html +++ b/layout/reftests/table-background/border-collapse-table-column-ref.html @@ -39,7 +39,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-table-ref.html b/layout/reftests/table-background/border-collapse-table-ref.html index b1da97dc40a3..f0bed1aa220c 100644 --- a/layout/reftests/table-background/border-collapse-table-ref.html +++ b/layout/reftests/table-background/border-collapse-table-ref.html @@ -39,15 +39,15 @@ (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;} diff --git a/layout/reftests/table-background/border-collapse-table-row-group-ref.html b/layout/reftests/table-background/border-collapse-table-row-group-ref.html index 949ec4bba95b..90ce2e71b8c9 100644 --- a/layout/reftests/table-background/border-collapse-table-row-group-ref.html +++ b/layout/reftests/table-background/border-collapse-table-row-group-ref.html @@ -39,7 +39,7 @@ (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 { diff --git a/layout/reftests/table-background/border-collapse-table-row-ref.html b/layout/reftests/table-background/border-collapse-table-row-ref.html index f47c7d580361..cba5aac79c14 100644 --- a/layout/reftests/table-background/border-collapse-table-row-ref.html +++ b/layout/reftests/table-background/border-collapse-table-row-ref.html @@ -39,7 +39,7 @@ (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 { diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset1.html b/layout/reftests/table-bordercollapse/bc_borderoffset1.html new file mode 100644 index 000000000000..09225541bf4e --- /dev/null +++ b/layout/reftests/table-bordercollapse/bc_borderoffset1.html @@ -0,0 +1,18 @@ + + + + + + + +
+ + +
cell 1
+
+ + diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html b/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html new file mode 100644 index 000000000000..4baeeffd7a4a --- /dev/null +++ b/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html @@ -0,0 +1,19 @@ + + + + + + + + +
+ + +
cell 1
+
+ + diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset2.html b/layout/reftests/table-bordercollapse/bc_borderoffset2.html new file mode 100644 index 000000000000..f4ccb376f3cd --- /dev/null +++ b/layout/reftests/table-bordercollapse/bc_borderoffset2.html @@ -0,0 +1,18 @@ + + + + + + + + + + +
caption
cell 1
+ + + diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html b/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html new file mode 100644 index 000000000000..8388aa5fa418 --- /dev/null +++ b/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + + +
caption
cell 1
+ + diff --git a/layout/reftests/table-bordercollapse/reftest.list b/layout/reftests/table-bordercollapse/reftest.list index 93c43472bb68..2bd2f814a669 100644 --- a/layout/reftests/table-bordercollapse/reftest.list +++ b/layout/reftests/table-bordercollapse/reftest.list @@ -18,3 +18,5 @@ == 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 diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 97fabd46919c..8d7718faecf8 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -145,13 +145,17 @@ struct nsTableReflowState { 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 @@ -2550,10 +2554,10 @@ nsTableFrame::GetOuterBCBorder() const 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; } @@ -2561,21 +2565,28 @@ nsTableFrame::GetOuterBCBorder() const nsMargin nsTableFrame::GetIncludedOuterBCBorder() const { - if (eCompatibility_NavQuirks == PresContext()->CompatibilityMode()) { - return GetOuterBCBorder(); - } + if (NeedToCalcBCBorders()) + const_cast(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, @@ -2597,34 +2608,7 @@ 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); @@ -3702,7 +3686,7 @@ 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); @@ -5498,6 +5482,15 @@ nsTableFrame::CalcBCBorders() 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 @@ -5554,6 +5547,15 @@ nsTableFrame::CalcBCBorders() // 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))); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index c20f0278658c..9b792a004b7c 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -213,9 +213,6 @@ public: // 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); @@ -284,26 +281,26 @@ public: 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;