WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2007 22:04:44 +0000 (22:04 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Nov 2007 22:04:44 +0000 (22:04 +0000)
        Reviewed by Dave Hyatt.

        - fix <rdar://problem/5612459> CrashTracer: [REGRESSION] 61 crashes in Safari at com.apple.WebCore: WebCore::AutoTableLayout::layout + 2046

        Test: fast/table/empty-auto-column-zero-divide.html

        * rendering/AutoTableLayout.cpp:
        (WebCore::AutoTableLayout::recalcColumn):
        (WebCore::AutoTableLayout::fullRecalc):
        (WebCore::AutoTableLayout::calcEffectiveWidth):
        (WebCore::AutoTableLayout::layout): When distributing the remaining
        width among columns, skip those whose effective (rather than
        specified) width is auto and contain only empty cells.

LayoutTests:

        Reviewed by Dave Hyatt.

        - test for <rdar://problem/5612459> CrashTracer: [REGRESSION] 61 crashes in Safari at com.apple.WebCore: WebCore::AutoTableLayout::layout + 2046

        * fast/table/empty-auto-column-zero-divide-expected.txt: Added.
        * fast/table/empty-auto-column-zero-divide.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28118 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/table/empty-auto-column-zero-divide-expected.txt [new file with mode: 0644]
LayoutTests/fast/table/empty-auto-column-zero-divide.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/rendering/AutoTableLayout.cpp

index 6f9f472db1ba7065081ee8017dd3b91735da6379..24bcb4ae91301d0e682085c95b3a477fbf4adb7e 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-28  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        - test for <rdar://problem/5612459> CrashTracer: [REGRESSION] 61 crashes in Safari at com.apple.WebCore: WebCore::AutoTableLayout::layout + 2046
+
+        * fast/table/empty-auto-column-zero-divide-expected.txt: Added.
+        * fast/table/empty-auto-column-zero-divide.html: Added.
+
 2007-11-28  Jon Honeycutt  <jhoneycutt@apple.com>
 
         Reviewed by Dan.
diff --git a/LayoutTests/fast/table/empty-auto-column-zero-divide-expected.txt b/LayoutTests/fast/table/empty-auto-column-zero-divide-expected.txt
new file mode 100644 (file)
index 0000000..b1cfefe
--- /dev/null
@@ -0,0 +1,4 @@
+Test for <rdar://problem/5612459>
+
+              
+
diff --git a/LayoutTests/fast/table/empty-auto-column-zero-divide.html b/LayoutTests/fast/table/empty-auto-column-zero-divide.html
new file mode 100644 (file)
index 0000000..acfdaf4
--- /dev/null
@@ -0,0 +1,22 @@
+<body>
+    <script>
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+    </script>
+    <p>Test for <a href="rdar://problem/5612459">&lt;rdar://problem/5612459&gt;</a></p>
+    <table cellpadding="0" cellspacing="0">
+        <tr>
+            <td style="width: 10000px;">
+                &nbsp;
+            </td>
+            <td style="width: 1px;">
+            </td>
+            <td style="width: 10000px;">
+            </td>
+        </tr>
+        <tr>
+            <td colspan="3" style="width: 100%;">
+            </td>
+        </tr>
+    </table>
+</body>
index 08dbb5008769afdb30ecbd64ba009128f7a725eb..cfc4a2524f216ed42cba5e434beb7b4030770e4a 100644 (file)
@@ -1,3 +1,19 @@
+2007-11-28  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Dave Hyatt.
+
+        - fix <rdar://problem/5612459> CrashTracer: [REGRESSION] 61 crashes in Safari at com.apple.WebCore: WebCore::AutoTableLayout::layout + 2046
+
+        Test: fast/table/empty-auto-column-zero-divide.html
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        (WebCore::AutoTableLayout::fullRecalc):
+        (WebCore::AutoTableLayout::calcEffectiveWidth):
+        (WebCore::AutoTableLayout::layout): When distributing the remaining
+        width among columns, skip those whose effective (rather than
+        specified) width is auto and contain only empty cells.
+
 2007-11-28  Peter Kasting  <zerodpx@gmail.com>
 
         Reviewed by Alp Toker.
index 06adf206fac018a55c74335f1ff3774f526cc00c..7291c7c0eb2e698bb77ccbaaeabca6c86e33af7e 100644 (file)
@@ -149,9 +149,6 @@ void AutoTableLayout::recalcColumn(int effCol)
     }
 
     l.maxWidth = max(l.maxWidth, l.minWidth);
-#ifdef DEBUG_LAYOUT
-    qDebug("col %d, final min=%d, max=%d, width=%d(%d)", effCol, l.minWidth, l.maxWidth, l.width.value,  l.width.type);
-#endif
 
     // ### we need to add col elements as well
 }
@@ -183,9 +180,6 @@ void AutoTableLayout::fullRecalc()
                 if ((w.isFixed() || w.isPercent()) && w.isZero())
                     w = Length();
                 int cEffCol = m_table->colToEffCol(cCol);
-#ifdef DEBUG_LAYOUT
-                qDebug("    col element %d (eff=%d): Length=%d(%d), span=%d, effColSpan=%d",  cCol, cEffCol, w.value, w.type, span, m_table->spanOfEffCol(cEffCol));
-#endif
                 if (!w.isAuto() && span == 1 && cEffCol < nEffCols) {
                     if (m_table->spanOfEffCol(cEffCol) == 1) {
                         m_layoutStruct[cEffCol].width = w;
@@ -306,9 +300,7 @@ int AutoTableLayout::calcEffectiveWidth()
 
     unsigned int nEffCols = m_layoutStruct.size();
     int hspacing = m_table->hBorderSpacing();
-#ifdef DEBUG_LAYOUT
-    qDebug("AutoTableLayout::calcEffectiveWidth for %d cols", nEffCols);
-#endif
+
     for (unsigned int i = 0; i < nEffCols; i++) {
         m_layoutStruct[i].effWidth = m_layoutStruct[i].width;
         m_layoutStruct[i].effMinWidth = m_layoutStruct[i].minWidth;
@@ -512,25 +504,10 @@ void AutoTableLayout::layout()
         fullRecalc();
         nEffCols = m_table->numEffCols();
     }
-#ifdef DEBUG_LAYOUT
-    qDebug("AutoTableLayout::layout()");
-#endif
 
     if (m_effWidthDirty)
         calcEffectiveWidth();
 
-#ifdef DEBUG_LAYOUT
-    qDebug("    tableWidth=%d,  nEffCols=%d", tableWidth,  nEffCols);
-    for (int i = 0; i < nEffCols; i++) {
-        qDebug("    effcol %d is of type %d value %d, minWidth=%d, maxWidth=%d",
-               i, m_layoutStruct[i].width.type, m_layoutStruct[i].width.value,
-               m_layoutStruct[i].minWidth, m_layoutStruct[i].maxWidth);
-        qDebug("        effective: type %d value %d, minWidth=%d, maxWidth=%d",
-               m_layoutStruct[i].effWidth.type, m_layoutStruct[i].effWidth.value,
-               m_layoutStruct[i].effMinWidth, m_layoutStruct[i].effMaxWidth);
-    }
-#endif
-
     bool havePercent = false;
     bool haveRelative = false;
     int totalRelative = 0;
@@ -603,9 +580,6 @@ void AutoTableLayout::layout()
             }
         }
     }
-#ifdef DEBUG_LAYOUT
-    qDebug("percent satisfied: available is %d", available);
-#endif
     
     // then allocate width to fixed cols
     if (available > 0) {
@@ -617,9 +591,6 @@ void AutoTableLayout::layout()
             }
         }
     }
-#ifdef DEBUG_LAYOUT
-    qDebug("fixed satisfied: available is %d", available);
-#endif
 
     // now satisfy relative
     if (available > 0) {
@@ -647,9 +618,6 @@ void AutoTableLayout::layout()
             }
         }
     }
-#ifdef DEBUG_LAYOUT
-    qDebug("variable satisfied: available is %d",  available);
-#endif
 
     // spread over fixed columns
     if (available > 0 && numFixed) {
@@ -664,11 +632,7 @@ void AutoTableLayout::layout()
             }
         }
     }
-    
-#ifdef DEBUG_LAYOUT
-    qDebug("after fixed distribution: available=%d",  available);
-#endif
-    
+
     // spread over percent colums
     if (available > 0 && m_hasPercent && totalPercent < 100 * percentScaleFactor) {
         // still have some width to spread, distribute weighted to percent columns
@@ -684,10 +648,6 @@ void AutoTableLayout::layout()
         }
     }
 
-#ifdef DEBUG_LAYOUT
-    qDebug("after percent distribution: available=%d",  available);
-#endif
-
     // spread over the rest
     if (available > 0 && nEffCols > numAutoEmptyCellsOnly) {
         int total = nEffCols - numAutoEmptyCellsOnly;
@@ -695,7 +655,7 @@ void AutoTableLayout::layout()
         int i = nEffCols;
         while (i--) {
             // variable columns with empty cells only don't get any width
-            if (m_layoutStruct[i].width.isAuto() && m_layoutStruct[i].emptyCellsOnly)
+            if (m_layoutStruct[i].effWidth.isAuto() && m_layoutStruct[i].emptyCellsOnly)
                 continue;
             int w = available / total;
             available -= w;
@@ -704,9 +664,6 @@ void AutoTableLayout::layout()
         }
     }
 
-#ifdef DEBUG_LAYOUT
-    qDebug("after equal distribution: available=%d",  available);
-#endif
     // if we have overallocated, reduce every cell according to the difference between desired width and minwidth
     // this seems to produce to the pixel exaxt results with IE. Wonder is some of this also holds for width distributing.
     if (available < 0) {
@@ -807,9 +764,6 @@ void AutoTableLayout::layout()
 
     int pos = 0;
     for (int i = 0; i < nEffCols; i++) {
-#ifdef DEBUG_LAYOUT
-        qDebug("col %d: %d (width %d)", i, pos, m_layoutStruct[i].calcWidth);
-#endif
         m_table->columnPositions()[i] = pos;
         pos += m_layoutStruct[i].calcWidth + m_table->hBorderSpacing();
     }