Bug 338554 - Honor -moz-box-sizing on table cells in standards mode (we ignore it in quirks mode). r=dbaron
authorTal Aloni <tal.aloni.il@gmail.com>
Thu, 12 Jul 2012 19:28:52 -0400
changeset 99128 f0f359a747728214f26417c0decb355bda7d7b56
parent 99127 54cfa52ffb78b0ddbb707bb374243839ee24ebb9
child 99129 de697e323b394b9e9d346003db7288b97a6d89b4
push id23105
push useremorley@mozilla.com
push dateFri, 13 Jul 2012 12:23:43 +0000
treeherdermozilla-central@a2d40b91eea9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs338554
milestone16.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 338554 - Honor -moz-box-sizing on table cells in standards mode (we ignore it in quirks mode). r=dbaron
layout/reftests/bugs/494667-2-ref.html
layout/tables/BasicTableLayoutStrategy.cpp
--- a/layout/reftests/bugs/494667-2-ref.html
+++ b/layout/reftests/bugs/494667-2-ref.html
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML>
 <html>
 <body>
-<div style="width:212px; height:204px; background:lime;"></div>
+<div style="width:204px; height:204px; background:lime;"></div>
 </body>
 </html>
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -89,18 +89,16 @@ GetWidthInfo(nsRenderingContext *aRender
         prefCoord = aFrame->GetPrefWidth(aRenderingContext);
     } else {
         minCoord = 0;
         prefCoord = 0;
     }
     float prefPercent = 0.0f;
     bool hasSpecifiedWidth = false;
 
-    // XXXldb Should we consider -moz-box-sizing?
-
     const nsStylePosition *stylePos = aFrame->GetStylePosition();
     const nsStyleCoord &width = stylePos->mWidth;
     nsStyleUnit unit = width.GetUnit();
     // NOTE: We're ignoring calc() units here, for lack of a sensible
     // idea for what to do with them.  This means calc() is basically
     // handled like 'auto' for table cells and columns.
     if (unit == eStyleUnit_Coord) {
         hasSpecifiedWidth = true;
@@ -193,17 +191,42 @@ GetWidthInfo(nsRenderingContext *aRender
     }
     // treat calc() on min-width just like '0'.
 
     // XXX Should col frame have border/padding considered?
     if (aIsCell) {
         nsIFrame::IntrinsicWidthOffsetData offsets =
             aFrame->IntrinsicWidthOffsets(aRenderingContext);
         // XXX Should we ignore percentage padding?
-        nscoord add = offsets.hPadding + offsets.hBorder;
+
+        // 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.
+        // (We can't specify one value of box-sizing for width and another
+        // for height).
+        // For this reason, we also do not use box-sizing for just one of
+        // them, as this may be confusing.
+        nscoord add = 0;
+        if (aFrame->PresContext()->CompatibilityMode() == eCompatibility_NavQuirks) {
+          add = offsets.hPadding + offsets.hBorder;
+        }
+        else
+        {
+          switch (stylePos->mBoxSizing) {
+            case NS_STYLE_BOX_SIZING_CONTENT:
+              add = offsets.hPadding + offsets.hBorder;
+              break;
+            case NS_STYLE_BOX_SIZING_PADDING:
+              add = offsets.hBorder;
+              break;
+            default:
+              // NS_STYLE_BOX_SIZING_BORDER
+              break;
+          }
+        }
         minCoord += add;
         prefCoord = NSCoordSaturatingAdd(prefCoord, add);
     }
 
     return CellWidthInfo(minCoord, prefCoord, prefPercent, hasSpecifiedWidth);
 }
 
 static inline CellWidthInfo