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

Side by Side Diff: Source/core/rendering/RenderTableSection.cpp

Issue 23351002: Crash when opening web page http://build.webkit.org/waterfall. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review comments addressed Created 7 years, 3 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 | « LayoutTests/fast/table/table-rowspan-crash-with-huge-rowspan-cells-expected.txt ('k') | no next file » | 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) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 } 364 }
365 m_rowPos[row + 1] += accumulatedPositionIncrease; 365 m_rowPos[row + 1] += accumulatedPositionIncrease;
366 } 366 }
367 367
368 ASSERT(!remainder); 368 ASSERT(!remainder);
369 369
370 extraRowSpanningHeight -= accumulatedPositionIncrease; 370 extraRowSpanningHeight -= accumulatedPositionIncrease;
371 } 371 }
372 372
373 static bool cellIsFullyIncludedInOtherCell(const RenderTableCell* cell1, const R enderTableCell* cell2)
374 {
375 return (cell1->rowIndex() >= cell2->rowIndex() && (cell1->rowIndex() + cell1 ->rowSpan()) <= (cell2->rowIndex() + cell2->rowSpan()));
376 }
377
373 // To avoid unneeded extra height distributions, we apply the following sorting algorithm: 378 // To avoid unneeded extra height distributions, we apply the following sorting algorithm:
374 // 1. We sort by increasing start row but decreasing last row (ie the top-most, shortest cells first). 379 static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell* cell1, const RenderTableCell* cell2)
375 // 2. For cells spanning the same rows, we sort by intrinsic size.
376 static bool compareRowSpanCellsInHeightDistributionOrder(const RenderTableCell* cell2, const RenderTableCell* cell1)
377 { 380 {
378 unsigned cellRowIndex1 = cell1->rowIndex(); 381 // Sorting bigger height cell first if cells are at same index with same spa n because we will skip smaller
379 unsigned cellRowSpan1 = cell1->rowSpan(); 382 // height cell to distribute it's extra height.
380 unsigned cellRowIndex2 = cell2->rowIndex(); 383 if (cell1->rowIndex() == cell2->rowIndex() && cell1->rowSpan() == cell2->row Span())
381 unsigned cellRowSpan2 = cell2->rowSpan(); 384 return (cell1->logicalHeightForRowSizing() > cell2->logicalHeightForRowS izing());
385 // Sorting inner most cell first because if inner spanning cell'e extra heig ht is distributed then outer
386 // spanning cell's extra height will adjust accordingly. In reverse order, t here is more chances that outer
387 // spanning cell's height will exceed than defined by user.
388 if (cellIsFullyIncludedInOtherCell(cell1, cell2))
389 return true;
390 // Sorting lower row index first because first we need to apply the extra he ight of spanning cell which
391 // comes first in the table so lower rows's position would increment in sequ ence.
392 if (cellIsFullyIncludedInOtherCell(cell2, cell1))
393 return (cell1->rowIndex() < cell2->rowIndex());
382 394
383 if (cellRowIndex1 == cellRowIndex2 && cellRowSpan1 == cellRowSpan2) 395 return false;
384 return (cell2->logicalHeightForRowSizing() > cell1->logicalHeightForRowS izing());
385
386 return (cellRowIndex2 >= cellRowIndex1 && (cellRowIndex2 + cellRowSpan2) <= (cellRowIndex1 + cellRowSpan1));
387 } 396 }
388 397
389 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if 398 // Distribute rowSpan cell height in rows those comes in rowSpan cell based on t he ratio of row's height if
390 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll 399 // 1. RowSpan cell height is greater then the total height of rows in rowSpan ce ll
391 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells) 400 void RenderTableSection::distributeRowSpanHeightToRows(SpanningRenderTableCells& rowSpanCells)
392 { 401 {
393 ASSERT(rowSpanCells.size()); 402 ASSERT(rowSpanCells.size());
394 403
395 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order 404 // 'rowSpanCells' list is already sorted based on the cells rowIndex in asce nding order
396 // Arrange row spanning cell in the order in which we need to process first. 405 // Arrange row spanning cell in the order in which we need to process first.
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (!style()->isLeftToRightDirection()) 1692 if (!style()->isLeftToRightDirection())
1684 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing); 1693 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] + horizontalBorderSpacing);
1685 else 1694 else
1686 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1695 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1687 1696
1688 cell->setLogicalLocation(cellLocation); 1697 cell->setLogicalLocation(cellLocation);
1689 view()->addLayoutDelta(oldCellLocation - cell->location()); 1698 view()->addLayoutDelta(oldCellLocation - cell->location());
1690 } 1699 }
1691 1700
1692 } // namespace WebCore 1701 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/table/table-rowspan-crash-with-huge-rowspan-cells-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698