From bded505e94d84670d0064e8b8b6e7f0d22b24dbb Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Tue, 26 Jun 2012 16:24:23 -0700 Subject: [PATCH] Change standards mode height calculations for table cells to use content-box sizing rather than border-box sizing by default (and to honor -moz-box-sizing, which we do not do in quirks mode). Also remove -moz-box-sizing: border-box from default style for caption element (all modes). (Bug 248239) r=dbaron --- layout/reftests/bugs/494667-1.html | 1 + layout/reftests/bugs/494667-2.html | 1 + .../bc_borderoffset1_ref.html | 4 +-- .../bc_borderoffset2.html | 2 +- .../bc_borderoffset2_ref.html | 2 +- layout/style/html.css | 1 - layout/tables/nsTableRowFrame.cpp | 26 +++++++++++++++++-- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/layout/reftests/bugs/494667-1.html b/layout/reftests/bugs/494667-1.html index 1d04b3afc46..076ff652176 100644 --- a/layout/reftests/bugs/494667-1.html +++ b/layout/reftests/bugs/494667-1.html @@ -10,6 +10,7 @@ td, th { background-color: lime; width:100px; height:100px; + -moz-box-sizing:border-box; } td { border-top: 4px solid lime; diff --git a/layout/reftests/bugs/494667-2.html b/layout/reftests/bugs/494667-2.html index 11c728c4d68..061f8f0da30 100644 --- a/layout/reftests/bugs/494667-2.html +++ b/layout/reftests/bugs/494667-2.html @@ -11,6 +11,7 @@ td, th { width:100px; height:100px; border:4px solid lime; + -moz-box-sizing:border-box; } td { border-top:hidden; diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html b/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html index 8c880186961..0759bdf7ebb 100644 --- a/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html +++ b/layout/reftests/table-bordercollapse/bc_borderoffset1_ref.html @@ -9,10 +9,10 @@ div {position:absolute; border:green 4px solid} - +
- +
cell 1
cell 1
diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset2.html b/layout/reftests/table-bordercollapse/bc_borderoffset2.html index a53d958170f..e865326f8ba 100644 --- a/layout/reftests/table-bordercollapse/bc_borderoffset2.html +++ b/layout/reftests/table-bordercollapse/bc_borderoffset2.html @@ -13,7 +13,7 @@ caption {border:solid 4px green} - +
caption
cell 1
diff --git a/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html b/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html index 952018b9a51..bbb0698eb8f 100644 --- a/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html +++ b/layout/reftests/table-bordercollapse/bc_borderoffset2_ref.html @@ -13,7 +13,7 @@ caption {border:solid 4px green} - +
caption
cell 1cell 1
diff --git a/layout/style/html.css b/layout/style/html.css index a7e2ebe10d0..3bbad078541 100644 --- a/layout/style/html.css +++ b/layout/style/html.css @@ -393,7 +393,6 @@ table[rules][rules="groups"] > tbody { caption { display: table-caption; text-align: center; - -moz-box-sizing: border-box; } table[align="center"] > caption { diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 3010caece2c..46160c150cc 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -607,11 +607,33 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame, PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(*aCellFrame); switch (position->mHeight.GetUnit()) { - case eStyleUnit_Coord: - specifiedHeight = position->mHeight.GetCoordValue(); + case eStyleUnit_Coord: { + nscoord outsideBoxSizing = 0; + // In quirks mode, table cell width should be content-box, but height + // should be border-box. + // Because of this historic anomaly, we do not use quirk.css + // (since we can't specify one value of box-sizing for width and another + // for height) + if (PresContext()->CompatibilityMode() != eCompatibility_NavQuirks) { + switch (position->mBoxSizing) { + case NS_STYLE_BOX_SIZING_CONTENT: + outsideBoxSizing = aCellFrame->GetUsedBorderAndPadding().TopBottom(); + break; + case NS_STYLE_BOX_SIZING_PADDING: + outsideBoxSizing = aCellFrame->GetUsedBorder().TopBottom(); + break; + default: + // NS_STYLE_BOX_SIZING_BORDER + break; + } + } + + specifiedHeight = position->mHeight.GetCoordValue() + outsideBoxSizing; + if (1 == rowSpan) SetFixedHeight(specifiedHeight); break; + } case eStyleUnit_Percent: { if (1 == rowSpan) SetPctHeight(position->mHeight.GetPercentValue());