Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1392)

Side by Side Diff: Source/WebCore/rendering/AutoTableLayout.cpp

Issue 10583010: Merge 120257 - Padding and borders can cause integer overflow in block layouts (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2002 Lars Knoll (knoll@kde.org)
3 * (C) 2002 Dirk Mueller (mueller@kde.org) 3 * (C) 2002 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2003, 2006, 2008, 2010 Apple Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License. 9 * version 2 of the License.
10 * 10 *
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 float logicalWidth = static_cast<float>(m_layoutStruct[i].effect iveMaxLogicalWidth) * 100 / max(percent, epsilon); 244 float logicalWidth = static_cast<float>(m_layoutStruct[i].effect iveMaxLogicalWidth) * 100 / max(percent, epsilon);
245 maxPercent = max(logicalWidth, maxPercent); 245 maxPercent = max(logicalWidth, maxPercent);
246 remainingPercent -= percent; 246 remainingPercent -= percent;
247 } else 247 } else
248 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; 248 maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth;
249 } 249 }
250 } 250 }
251 251
252 if (scaleColumns) { 252 if (scaleColumns) {
253 maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon); 253 maxNonPercent = maxNonPercent * 100 / max(remainingPercent, epsilon);
254 maxWidth = max<int>(maxWidth, static_cast<int>(min(maxNonPercent, MAX_LA YOUT_UNIT / 2.0f))); 254 maxWidth = max<int>(maxWidth, static_cast<int>(min(maxNonPercent, static _cast<float>(tableMaxWidth))));
255 maxWidth = max<int>(maxWidth, static_cast<int>(min(maxPercent, MAX_LAYOU T_UNIT / 2.0f))); 255 maxWidth = max<int>(maxWidth, static_cast<int>(min(maxPercent, static_ca st<float>(tableMaxWidth))));
256 } 256 }
257 257
258 maxWidth = max<int>(maxWidth, spanMaxLogicalWidth); 258 maxWidth = max<int>(maxWidth, spanMaxLogicalWidth);
259 259
260 int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirecti on(); 260 int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirecti on();
261 minWidth += bordersPaddingAndSpacing; 261 minWidth += bordersPaddingAndSpacing;
262 maxWidth += bordersPaddingAndSpacing; 262 maxWidth += bordersPaddingAndSpacing;
263 263
264 Length tableLogicalWidth = m_table->style()->logicalWidth(); 264 Length tableLogicalWidth = m_table->style()->logicalWidth();
265 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) { 265 if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) {
266 minWidth = max<int>(minWidth, tableLogicalWidth.value()); 266 minWidth = max<int>(minWidth, tableLogicalWidth.value());
267 maxWidth = minWidth; 267 maxWidth = minWidth;
268 } else if (!remainingPercent && maxNonPercent) { 268 } else if (!remainingPercent && maxNonPercent) {
269 // if there was no remaining percent, maxWidth is invalid 269 // if there was no remaining percent, maxWidth is invalid
270 maxWidth = MAX_LAYOUT_UNIT; 270 maxWidth = tableMaxWidth;
271 } 271 }
272 272
273 Length tableLogicalMinWidth = m_table->style()->logicalMinWidth(); 273 Length tableLogicalMinWidth = m_table->style()->logicalMinWidth();
274 if (tableLogicalMinWidth.isFixed() && tableLogicalMinWidth.isPositive()) { 274 if (tableLogicalMinWidth.isFixed() && tableLogicalMinWidth.isPositive()) {
275 minWidth = max<int>(minWidth, tableLogicalMinWidth.value()); 275 minWidth = max<int>(minWidth, tableLogicalMinWidth.value());
276 maxWidth = max<int>(minWidth, maxWidth); 276 maxWidth = max<int>(minWidth, maxWidth);
277 } 277 }
278 } 278 }
279 279
280 /* 280 /*
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 774
775 int pos = 0; 775 int pos = 0;
776 for (size_t i = 0; i < nEffCols; ++i) { 776 for (size_t i = 0; i < nEffCols; ++i) {
777 m_table->columnPositions()[i] = pos; 777 m_table->columnPositions()[i] = pos;
778 pos += m_layoutStruct[i].computedLogicalWidth + m_table->hBorderSpacing( ); 778 pos += m_layoutStruct[i].computedLogicalWidth + m_table->hBorderSpacing( );
779 } 779 }
780 m_table->columnPositions()[m_table->columnPositions().size() - 1] = pos; 780 m_table->columnPositions()[m_table->columnPositions().size() - 1] = pos;
781 } 781 }
782 782
783 } 783 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/table/table-size-integer-overflow-expected.txt ('k') | Source/WebCore/rendering/FixedTableLayout.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698