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

Side by Side Diff: Source/WebCore/rendering/FixedTableLayout.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
« no previous file with comments | « Source/WebCore/rendering/AutoTableLayout.cpp ('k') | Source/WebCore/rendering/RenderBlock.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc.
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 usedWidth += fixedBorderBoxLogicalWidth * eSpan / span; 175 usedWidth += fixedBorderBoxLogicalWidth * eSpan / span;
176 } 176 }
177 usedSpan += eSpan; 177 usedSpan += eSpan;
178 ++currentColumn; 178 ++currentColumn;
179 } 179 }
180 } 180 }
181 181
182 return usedWidth; 182 return usedWidth;
183 } 183 }
184 184
185 // Use a very large value (in effect infinite). But not too large!
186 // numeric_limits<int>::max() will too easily overflow widths.
187 // Keep this in synch with BLOCK_MAX_WIDTH in RenderBlock.cpp
188 #define TABLE_MAX_WIDTH 15000
189
190 void FixedTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, Layou tUnit& maxWidth) 185 void FixedTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, Layou tUnit& maxWidth)
191 { 186 {
192 // FIXME: This entire calculation is incorrect for both minwidth and maxwidt h. 187 // FIXME: This entire calculation is incorrect for both minwidth and maxwidt h.
193 188
194 // we might want to wait until we have all of the first row before 189 // we might want to wait until we have all of the first row before
195 // layouting for the first time. 190 // layouting for the first time.
196 191
197 // only need to calculate the minimum width as the sum of the 192 // only need to calculate the minimum width as the sum of the
198 // cols/cells with a fixed width. 193 // cols/cells with a fixed width.
199 // 194 //
(...skipping 13 matching lines...) Expand all
213 <table style="background-color:blue"><tr><td> 208 <table style="background-color:blue"><tr><td>
214 <table style="width:100%; background-color:green; table-layout:f ixed"><tr><td> 209 <table style="width:100%; background-color:green; table-layout:f ixed"><tr><td>
215 Content 210 Content
216 </td></tr></table> 211 </td></tr></table>
217 </td></tr></table> 212 </td></tr></table>
218 </td></tr></table> 213 </td></tr></table>
219 */ 214 */
220 // In this example, the two inner tables should be as large as the outer tab le. 215 // In this example, the two inner tables should be as large as the outer tab le.
221 // We can achieve this effect by making the maxwidth of fixed tables with pe rcentage 216 // We can achieve this effect by making the maxwidth of fixed tables with pe rcentage
222 // widths be infinite. 217 // widths be infinite.
223 if (m_table->document()->inQuirksMode() && m_table->style()->logicalWidth(). isPercent() && maxWidth < TABLE_MAX_WIDTH) 218 if (m_table->document()->inQuirksMode() && m_table->style()->logicalWidth(). isPercent() && maxWidth < tableMaxWidth)
224 maxWidth = TABLE_MAX_WIDTH; 219 maxWidth = tableMaxWidth;
225 } 220 }
226 221
227 void FixedTableLayout::layout() 222 void FixedTableLayout::layout()
228 { 223 {
229 int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAnd SpacingInRowDirection(); 224 int tableLogicalWidth = m_table->logicalWidth() - m_table->bordersPaddingAnd SpacingInRowDirection();
230 unsigned nEffCols = m_table->numEffCols(); 225 unsigned nEffCols = m_table->numEffCols();
231 Vector<int> calcWidth(nEffCols, 0); 226 Vector<int> calcWidth(nEffCols, 0);
232 227
233 unsigned numAuto = 0; 228 unsigned numAuto = 0;
234 unsigned autoSpan = 0; 229 unsigned autoSpan = 0;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 for (unsigned i = 0; i < nEffCols; i++) { 318 for (unsigned i = 0; i < nEffCols; i++) {
324 m_table->columnPositions()[i] = pos; 319 m_table->columnPositions()[i] = pos;
325 pos += calcWidth[i] + hspacing; 320 pos += calcWidth[i] + hspacing;
326 } 321 }
327 int colPositionsSize = m_table->columnPositions().size(); 322 int colPositionsSize = m_table->columnPositions().size();
328 if (colPositionsSize > 0) 323 if (colPositionsSize > 0)
329 m_table->columnPositions()[colPositionsSize - 1] = pos; 324 m_table->columnPositions()[colPositionsSize - 1] = pos;
330 } 325 }
331 326
332 } // namespace WebCore 327 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/rendering/AutoTableLayout.cpp ('k') | Source/WebCore/rendering/RenderBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698