From 4ee30f5479db97f5b8ad39833a6b9369f973f7be Mon Sep 17 00:00:00 2001 From: "mitz@apple.com" Date: Wed, 28 Nov 2007 22:04:44 +0000 Subject: [PATCH] WebCore: Reviewed by Dave Hyatt. - fix 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 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 | 9 ++++ ...empty-auto-column-zero-divide-expected.txt | 4 ++ .../table/empty-auto-column-zero-divide.html | 22 ++++++++ WebCore/ChangeLog | 16 ++++++ WebCore/rendering/AutoTableLayout.cpp | 52 ++----------------- 5 files changed, 54 insertions(+), 49 deletions(-) create mode 100644 LayoutTests/fast/table/empty-auto-column-zero-divide-expected.txt create mode 100644 LayoutTests/fast/table/empty-auto-column-zero-divide.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 6f9f472db1ba..24bcb4ae9130 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,12 @@ +2007-11-28 Dan Bernstein + + Reviewed by Dave Hyatt. + + - test for 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 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 index 000000000000..b1cfefe43b8c --- /dev/null +++ b/LayoutTests/fast/table/empty-auto-column-zero-divide-expected.txt @@ -0,0 +1,4 @@ +Test for + +  + 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 index 000000000000..acfdaf4221bd --- /dev/null +++ b/LayoutTests/fast/table/empty-auto-column-zero-divide.html @@ -0,0 +1,22 @@ + + +

Test for <rdar://problem/5612459>

+ + + + + + + + + +
+   + + +
+
+ diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 08dbb5008769..cfc4a2524f21 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2007-11-28 Dan Bernstein + + Reviewed by Dave Hyatt. + + - fix 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 Reviewed by Alp Toker. diff --git a/WebCore/rendering/AutoTableLayout.cpp b/WebCore/rendering/AutoTableLayout.cpp index 06adf206fac0..7291c7c0eb2e 100644 --- a/WebCore/rendering/AutoTableLayout.cpp +++ b/WebCore/rendering/AutoTableLayout.cpp @@ -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(); } -- 2.36.0