Changeset 25171 in webkit
- Timestamp:
- Aug 21, 2007, 10:57:59 AM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r25168 r25171 1 2007-08-21 Mitz Pettel <mitz@webkit.org> 2 3 Reviewed by Darin. 4 5 - test for http://bugs.webkit.org/show_bug.cgi?id=15010 6 <rdar://problem/5423956> REGRESSION (r25000-r25065): Table rendering broken by a recent nightly 7 8 * fast/table/max-width-integer-overflow.html: Added. 9 * platform/mac/fast/table: Added. 10 * platform/mac/fast/table/max-width-integer-overflow-expected.checksum: Added. 11 * platform/mac/fast/table/max-width-integer-overflow-expected.png: Added. 12 * platform/mac/fast/table/max-width-integer-overflow-expected.txt: Added. 13 1 14 2007-08-20 Mitz Pettel <mitz@webkit.org> 2 15 -
trunk/WebCore/ChangeLog
r25170 r25171 1 2007-08-21 Mitz Pettel <mitz@webkit.org> 2 3 Reviewed by Darin. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=15010 6 <rdar://problem/5423956> REGRESSION (r25000-r25065): Table rendering broken by a recent nightly 7 8 Test: fast/table/max-width-integer-overflow.html 9 10 Avoid integer overflows when dealing with maximum widths by 11 1) using floating point arithmetic when summing or multiplying column max widths 12 2) capping max widths at INT_MAX / 2 13 14 * rendering/AutoTableLayout.cpp: 15 (WebCore::AutoTableLayout::calcPrefWidths): 16 (WebCore::AutoTableLayout::calcEffectiveWidth): 17 (WebCore::AutoTableLayout::layout): 18 1 19 2007-08-20 John Sullivan <sullivan@apple.com> 2 20 -
trunk/WebCore/rendering/AutoTableLayout.cpp
r25011 r25171 255 255 minWidth = 0; 256 256 maxWidth = 0; 257 int maxPercent = 0; 258 int maxNonPercent = 0; 257 float maxPercent = 0; 258 float maxNonPercent = 0; 259 bool scaleColumns = shouldScaleColumns(m_table); 259 260 260 261 // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two places below to avoid division by zero. … … 266 267 minWidth += m_layoutStruct[i].effMinWidth; 267 268 maxWidth += m_layoutStruct[i].effMaxWidth; 268 if (m_layoutStruct[i].effWidth.isPercent()) { 269 int percent = min(m_layoutStruct[i].effWidth.rawValue(), remainingPercent); 270 int pw = (m_layoutStruct[i].effMaxWidth * 100 * percentScaleFactor) / max(percent, epsilon); 271 remainingPercent -= percent; 272 maxPercent = max(pw, maxPercent); 273 } else { 274 maxNonPercent += m_layoutStruct[i].effMaxWidth; 275 } 276 } 277 278 if (shouldScaleColumns(m_table)) { 269 if (scaleColumns) { 270 if (m_layoutStruct[i].effWidth.isPercent()) { 271 int percent = min(m_layoutStruct[i].effWidth.rawValue(), remainingPercent); 272 float pw = static_cast<float>(m_layoutStruct[i].effMaxWidth) * 100 * percentScaleFactor / max(percent, epsilon); 273 maxPercent = max(pw, maxPercent); 274 remainingPercent -= percent; 275 } else 276 maxNonPercent += m_layoutStruct[i].effMaxWidth; 277 } 278 } 279 280 if (scaleColumns) { 279 281 maxNonPercent = maxNonPercent * 100 * percentScaleFactor / max(remainingPercent, epsilon); 280 maxWidth = max(max NonPercent, maxWidth);281 maxWidth = max(maxWidth, maxPercent);282 maxWidth = max(maxWidth, static_cast<int>(min(maxNonPercent, INT_MAX / 2.0f))); 283 maxWidth = max(maxWidth, static_cast<int>(min(maxPercent, INT_MAX / 2.0f))); 282 284 } 283 285 … … 301 303 int AutoTableLayout::calcEffectiveWidth() 302 304 { 303 int tMaxWidth = 0;305 float tMaxWidth = 0; 304 306 305 307 unsigned int nEffCols = m_layoutStruct.size(); … … 327 329 unsigned int lastCol = col; 328 330 int cMinWidth = cell->minPrefWidth() + hspacing; 329 int cMaxWidth = cell->maxPrefWidth() + hspacing;331 float cMaxWidth = cell->maxPrefWidth() + hspacing; 330 332 int totalPercent = 0; 331 333 int minWidth = 0; 332 int maxWidth = 0;334 float maxWidth = 0; 333 335 bool allColsArePercent = true; 334 336 bool allColsAreFixed = true; … … 386 388 w = Length(); 387 389 } else { 388 int spanMax = max(maxWidth, cMaxWidth);390 float spanMax = max(maxWidth, cMaxWidth); 389 391 tMaxWidth = max(tMaxWidth, spanMax * 100 * percentScaleFactor / w.rawValue()); 390 392 391 393 // all non percent columns in the span get percent vlaues to sum up correctly. 392 394 int percentMissing = w.rawValue() - totalPercent; 393 int totalWidth = 0;395 float totalWidth = 0; 394 396 for (unsigned int pos = col; pos < lastCol; pos++) { 395 397 if (!(m_layoutStruct[pos].effWidth.isPercent())) … … 399 401 for (unsigned int pos = col; pos < lastCol && totalWidth > 0; pos++) { 400 402 if (!(m_layoutStruct[pos].effWidth.isPercent())) { 401 int percent = percentMissing * m_layoutStruct[pos].effMaxWidth/ totalWidth;403 int percent = percentMissing * static_cast<float>(m_layoutStruct[pos].effMaxWidth) / totalWidth; 402 404 totalWidth -= m_layoutStruct[pos].effMaxWidth; 403 405 percentMissing -= percent; … … 423 425 424 426 } else { 425 int maxw = maxWidth;427 float maxw = maxWidth; 426 428 int minw = minWidth; 427 429 … … 440 442 for (unsigned int pos = col; maxw >= 0 && pos < lastCol && minw < cMinWidth; pos++) { 441 443 if (!(m_layoutStruct[pos].width.isFixed() && haveAuto && fixedWidth <= cMinWidth)) { 442 int w = max(m_layoutStruct[pos].effMinWidth, maxw ? (cMinWidth * m_layoutStruct[pos].effMaxWidth / maxw) : cMinWidth);444 int w = max(m_layoutStruct[pos].effMinWidth, static_cast<int>(maxw ? cMinWidth * static_cast<float>(m_layoutStruct[pos].effMaxWidth) / maxw : cMinWidth)); 443 445 w = min(m_layoutStruct[pos].effMinWidth+(cMinWidth-minw), w); 444 446 … … 454 456 if (cMaxWidth > maxWidth) { 455 457 for (unsigned int pos = col; maxWidth >= 0 && pos < lastCol; pos++) { 456 int w = max(m_layoutStruct[pos].effMaxWidth, maxWidth ? (cMaxWidth * m_layoutStruct[pos].effMaxWidth / maxWidth) : cMaxWidth);458 int w = max(m_layoutStruct[pos].effMaxWidth, static_cast<int>(maxWidth ? cMaxWidth * static_cast<float>(m_layoutStruct[pos].effMaxWidth) / maxWidth : cMaxWidth)); 457 459 maxWidth -= m_layoutStruct[pos].effMaxWidth; 458 460 cMaxWidth -= w; … … 471 473 m_effWidthDirty = false; 472 474 473 return tMaxWidth;475 return static_cast<int>(min(tMaxWidth, INT_MAX / 2.0f)); 474 476 } 475 477 … … 535 537 int numAuto = 0; 536 538 int numFixed = 0; 537 int totalAuto = 0;538 int totalFixed = 0;539 float totalAuto = 0; 540 float totalFixed = 0; 539 541 int totalPercent = 0; 540 542 int allocAuto = 0; … … 639 641 Length &width = m_layoutStruct[i].effWidth; 640 642 if (width.isAuto() && totalAuto != 0 && !m_layoutStruct[i].emptyCellsOnly) { 641 int w = max( int(m_layoutStruct[i].calcWidth), available * m_layoutStruct[i].effMaxWidth / totalAuto);643 int w = max(m_layoutStruct[i].calcWidth, static_cast<int>(available * static_cast<float>(m_layoutStruct[i].effMaxWidth) / totalAuto)); 642 644 available -= w; 643 645 totalAuto -= m_layoutStruct[i].effMaxWidth; … … 656 658 Length &width = m_layoutStruct[i].effWidth; 657 659 if (width.isFixed()) { 658 int w = available * m_layoutStruct[i].effMaxWidth/ totalFixed;660 int w = available * static_cast<float>(m_layoutStruct[i].effMaxWidth) / totalFixed; 659 661 available -= w; 660 662 totalFixed -= m_layoutStruct[i].effMaxWidth;
Note:
See TracChangeset
for help on using the changeset viewer.