| OLD | NEW |
| 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, 2013 Apple Inc. All r
ights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r
ights 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // We ignore height settings on rowspan cells. | 56 // We ignore height settings on rowspan cells. |
| 57 if (cell->rowSpan() != 1) | 57 if (cell->rowSpan() != 1) |
| 58 return; | 58 return; |
| 59 | 59 |
| 60 Length logicalHeight = cell->style()->logicalHeight(); | 60 Length logicalHeight = cell->style()->logicalHeight(); |
| 61 if (logicalHeight.isPositive()) { | 61 if (logicalHeight.isPositive()) { |
| 62 Length cRowLogicalHeight = row.logicalHeight; | 62 Length cRowLogicalHeight = row.logicalHeight; |
| 63 switch (logicalHeight.type()) { | 63 switch (logicalHeight.type()) { |
| 64 case Percent: | 64 case Percent: |
| 65 // TODO(alancutter): Make this work correctly for calc lengths. | 65 // TODO(alancutter): Make this work correctly for calc lengths. |
| 66 if (!(cRowLogicalHeight.hasPercent()) | 66 if (!(cRowLogicalHeight.isPercentOrCalc()) |
| 67 || (cRowLogicalHeight.hasPercent() && cRowLogicalHeight.percent(
) < logicalHeight.percent())) | 67 || (cRowLogicalHeight.isPercent() && cRowLogicalHeight.percent()
< logicalHeight.percent())) |
| 68 row.logicalHeight = logicalHeight; | 68 row.logicalHeight = logicalHeight; |
| 69 break; | 69 break; |
| 70 case Fixed: | 70 case Fixed: |
| 71 if (cRowLogicalHeight.type() < Percent | 71 if (cRowLogicalHeight.type() < Percent |
| 72 || (cRowLogicalHeight.isFixed() && cRowLogicalHeight.value() < l
ogicalHeight.value())) | 72 || (cRowLogicalHeight.isFixed() && cRowLogicalHeight.value() < l
ogicalHeight.value())) |
| 73 row.logicalHeight = logicalHeight; | 73 row.logicalHeight = logicalHeight; |
| 74 break; | 74 break; |
| 75 default: | 75 default: |
| 76 break; | 76 break; |
| 77 } | 77 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 const unsigned rowIndex = cell->rowIndex(); | 359 const unsigned rowIndex = cell->rowIndex(); |
| 360 float percent = std::min(totalPercent, 100.0f); | 360 float percent = std::min(totalPercent, 100.0f); |
| 361 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight; | 361 const int tableHeight = m_rowPos[m_grid.size()] + extraRowSpanningHeight; |
| 362 | 362 |
| 363 // Our algorithm matches Firefox. Extra spanning height would be distributed
Only in first percent height rows | 363 // Our algorithm matches Firefox. Extra spanning height would be distributed
Only in first percent height rows |
| 364 // those total percent is 100. Other percent rows would be uneffected even e
xtra spanning height is remain. | 364 // those total percent is 100. Other percent rows would be uneffected even e
xtra spanning height is remain. |
| 365 int accumulatedPositionIncrease = 0; | 365 int accumulatedPositionIncrease = 0; |
| 366 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 366 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 367 if (percent > 0 && extraRowSpanningHeight > 0) { | 367 if (percent > 0 && extraRowSpanningHeight > 0) { |
| 368 // TODO(alancutter): Make this work correctly for calc lengths. | 368 // TODO(alancutter): Make this work correctly for calc lengths. |
| 369 if (m_grid[row].logicalHeight.hasPercent()) { | 369 if (m_grid[row].logicalHeight.isPercent()) { |
| 370 int toAdd = (tableHeight * std::min(m_grid[row].logicalHeight.pe
rcent(), percent) / 100) - rowsHeight[row - rowIndex]; | 370 int toAdd = (tableHeight * std::min(m_grid[row].logicalHeight.pe
rcent(), percent) / 100) - rowsHeight[row - rowIndex]; |
| 371 | 371 |
| 372 toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0); | 372 toAdd = std::max(std::min(toAdd, extraRowSpanningHeight), 0); |
| 373 accumulatedPositionIncrease += toAdd; | 373 accumulatedPositionIncrease += toAdd; |
| 374 extraRowSpanningHeight -= toAdd; | 374 extraRowSpanningHeight -= toAdd; |
| 375 percent -= m_grid[row].logicalHeight.percent(); | 375 percent -= m_grid[row].logicalHeight.percent(); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 m_rowPos[row + 1] += accumulatedPositionIncrease; | 378 m_rowPos[row + 1] += accumulatedPositionIncrease; |
| 379 } | 379 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 402 if (!extraRowSpanningHeight || !totalPercent) | 402 if (!extraRowSpanningHeight || !totalPercent) |
| 403 return; | 403 return; |
| 404 | 404 |
| 405 const unsigned rowSpan = cell->rowSpan(); | 405 const unsigned rowSpan = cell->rowSpan(); |
| 406 const unsigned rowIndex = cell->rowIndex(); | 406 const unsigned rowIndex = cell->rowIndex(); |
| 407 double remainder = 0; | 407 double remainder = 0; |
| 408 | 408 |
| 409 int accumulatedPositionIncrease = 0; | 409 int accumulatedPositionIncrease = 0; |
| 410 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 410 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 411 // TODO(alancutter): Make this work correctly for calc lengths. | 411 // TODO(alancutter): Make this work correctly for calc lengths. |
| 412 if (m_grid[row].logicalHeight.hasPercent()) { | 412 if (m_grid[row].logicalHeight.isPercent()) { |
| 413 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, m_grid[
row].logicalHeight.percent(), totalPercent, accumulatedPositionIncrease, remaind
er); | 413 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, m_grid[
row].logicalHeight.percent(), totalPercent, accumulatedPositionIncrease, remaind
er); |
| 414 } | 414 } |
| 415 m_rowPos[row + 1] += accumulatedPositionIncrease; | 415 m_rowPos[row + 1] += accumulatedPositionIncrease; |
| 416 } | 416 } |
| 417 | 417 |
| 418 DCHECK(!round(remainder)) << "remainder was " << remainder; | 418 DCHECK(!round(remainder)) << "remainder was " << remainder; |
| 419 | 419 |
| 420 extraRowSpanningHeight -= accumulatedPositionIncrease; | 420 extraRowSpanningHeight -= accumulatedPositionIncrease; |
| 421 } | 421 } |
| 422 | 422 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 450 return; | 450 return; |
| 451 | 451 |
| 452 const unsigned rowSpan = cell->rowSpan(); | 452 const unsigned rowSpan = cell->rowSpan(); |
| 453 const unsigned rowIndex = cell->rowIndex(); | 453 const unsigned rowIndex = cell->rowIndex(); |
| 454 int accumulatedPositionIncrease = 0; | 454 int accumulatedPositionIncrease = 0; |
| 455 double remainder = 0; | 455 double remainder = 0; |
| 456 | 456 |
| 457 // Aspect ratios of the rows should not change otherwise table may look diff
erent than user expected. | 457 // Aspect ratios of the rows should not change otherwise table may look diff
erent than user expected. |
| 458 // So extra height distribution in remaining spanning rows based on their we
ight in spanning cell. | 458 // So extra height distribution in remaining spanning rows based on their we
ight in spanning cell. |
| 459 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { | 459 for (unsigned row = rowIndex; row < (rowIndex + rowSpan); row++) { |
| 460 if (!m_grid[row].logicalHeight.hasPercent()) { | 460 if (!m_grid[row].logicalHeight.isPercentOrCalc()) { |
| 461 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei
ght[row - rowIndex], totalRemainingRowsHeight, accumulatedPositionIncrease, rema
inder); | 461 updatePositionIncreasedWithRowHeight(extraRowSpanningHeight, rowsHei
ght[row - rowIndex], totalRemainingRowsHeight, accumulatedPositionIncrease, rema
inder); |
| 462 } | 462 } |
| 463 m_rowPos[row + 1] += accumulatedPositionIncrease; | 463 m_rowPos[row + 1] += accumulatedPositionIncrease; |
| 464 } | 464 } |
| 465 | 465 |
| 466 DCHECK(!round(remainder)) << "remainder was " << remainder; | 466 DCHECK(!round(remainder)) << "remainder was " << remainder; |
| 467 | 467 |
| 468 extraRowSpanningHeight -= accumulatedPositionIncrease; | 468 extraRowSpanningHeight -= accumulatedPositionIncrease; |
| 469 } | 469 } |
| 470 | 470 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 float totalPercent = 0; | 654 float totalPercent = 0; |
| 655 int totalAutoRowsHeight = 0; | 655 int totalAutoRowsHeight = 0; |
| 656 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; | 656 int totalRemainingRowsHeight = spanningRowsHeight.totalRowsHeight; |
| 657 | 657 |
| 658 // FIXME: Inner spanning cell height should not change if it have fixed
height when it's parent spanning cell | 658 // FIXME: Inner spanning cell height should not change if it have fixed
height when it's parent spanning cell |
| 659 // is distributing it's extra height in rows. | 659 // is distributing it's extra height in rows. |
| 660 | 660 |
| 661 // Calculate total percentage, total auto rows height and total rows hei
ght except percent rows. | 661 // Calculate total percentage, total auto rows height and total rows hei
ght except percent rows. |
| 662 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { | 662 for (unsigned row = rowIndex; row < spanningCellEndIndex; row++) { |
| 663 // TODO(alancutter): Make this work correctly for calc lengths. | 663 // TODO(alancutter): Make this work correctly for calc lengths. |
| 664 if (m_grid[row].logicalHeight.hasPercent()) { | 664 if (m_grid[row].logicalHeight.isPercent()) { |
| 665 totalPercent += m_grid[row].logicalHeight.percent(); | 665 totalPercent += m_grid[row].logicalHeight.percent(); |
| 666 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r
owIndex]; | 666 totalRemainingRowsHeight -= spanningRowsHeight.rowHeight[row - r
owIndex]; |
| 667 } else if (m_grid[row].logicalHeight.isAuto()) { | 667 } else if (m_grid[row].logicalHeight.isAuto()) { |
| 668 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd
ex]; | 668 totalAutoRowsHeight += spanningRowsHeight.rowHeight[row - rowInd
ex]; |
| 669 } | 669 } |
| 670 } | 670 } |
| 671 | 671 |
| 672 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori
ngBorderSpacing - spanningRowsHeight.totalRowsHeight; | 672 int extraRowSpanningHeight = spanningRowsHeight.spanningCellHeightIgnori
ngBorderSpacing - spanningRowsHeight.totalRowsHeight; |
| 673 | 673 |
| 674 if (totalPercent < 100 && !totalAutoRowsHeight && !totalRemainingRowsHei
ght) { | 674 if (totalPercent < 100 && !totalAutoRowsHeight && !totalRemainingRowsHei
ght) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 if (!totalPercent) | 862 if (!totalPercent) |
| 863 return; | 863 return; |
| 864 | 864 |
| 865 unsigned totalRows = m_grid.size(); | 865 unsigned totalRows = m_grid.size(); |
| 866 int totalHeight = m_rowPos[totalRows] + extraLogicalHeight; | 866 int totalHeight = m_rowPos[totalRows] + extraLogicalHeight; |
| 867 int totalLogicalHeightAdded = 0; | 867 int totalLogicalHeightAdded = 0; |
| 868 totalPercent = std::min(totalPercent, 100); | 868 totalPercent = std::min(totalPercent, 100); |
| 869 int rowHeight = m_rowPos[1] - m_rowPos[0]; | 869 int rowHeight = m_rowPos[1] - m_rowPos[0]; |
| 870 for (unsigned r = 0; r < totalRows; ++r) { | 870 for (unsigned r = 0; r < totalRows; ++r) { |
| 871 // TODO(alancutter): Make this work correctly for calc lengths. | 871 // TODO(alancutter): Make this work correctly for calc lengths. |
| 872 if (totalPercent > 0 && m_grid[r].logicalHeight.hasPercent()) { | 872 if (totalPercent > 0 && m_grid[r].logicalHeight.isPercent()) { |
| 873 int toAdd = std::min<int>(extraLogicalHeight, (totalHeight * m_grid[
r].logicalHeight.percent() / 100) - rowHeight); | 873 int toAdd = std::min<int>(extraLogicalHeight, (totalHeight * m_grid[
r].logicalHeight.percent() / 100) - rowHeight); |
| 874 // If toAdd is negative, then we don't want to shrink the row (this
bug | 874 // If toAdd is negative, then we don't want to shrink the row (this
bug |
| 875 // affected Outlook Web Access). | 875 // affected Outlook Web Access). |
| 876 toAdd = std::max(0, toAdd); | 876 toAdd = std::max(0, toAdd); |
| 877 totalLogicalHeightAdded += toAdd; | 877 totalLogicalHeightAdded += toAdd; |
| 878 extraLogicalHeight -= toAdd; | 878 extraLogicalHeight -= toAdd; |
| 879 totalPercent -= m_grid[r].logicalHeight.percent(); | 879 totalPercent -= m_grid[r].logicalHeight.percent(); |
| 880 } | 880 } |
| 881 ASSERT(totalRows >= 1); | 881 ASSERT(totalRows >= 1); |
| 882 if (r < totalRows - 1) | 882 if (r < totalRows - 1) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 return extraLogicalHeight; | 934 return extraLogicalHeight; |
| 935 | 935 |
| 936 if (!m_rowPos[totalRows] && nextSibling()) | 936 if (!m_rowPos[totalRows] && nextSibling()) |
| 937 return extraLogicalHeight; | 937 return extraLogicalHeight; |
| 938 | 938 |
| 939 unsigned autoRowsCount = 0; | 939 unsigned autoRowsCount = 0; |
| 940 int totalPercent = 0; | 940 int totalPercent = 0; |
| 941 for (unsigned r = 0; r < totalRows; r++) { | 941 for (unsigned r = 0; r < totalRows; r++) { |
| 942 if (m_grid[r].logicalHeight.isAuto()) | 942 if (m_grid[r].logicalHeight.isAuto()) |
| 943 ++autoRowsCount; | 943 ++autoRowsCount; |
| 944 else if (m_grid[r].logicalHeight.hasPercent()) | 944 else if (m_grid[r].logicalHeight.isPercent()) |
| 945 totalPercent += m_grid[r].logicalHeight.percent(); | 945 totalPercent += m_grid[r].logicalHeight.percent(); |
| 946 } | 946 } |
| 947 | 947 |
| 948 int remainingExtraLogicalHeight = extraLogicalHeight; | 948 int remainingExtraLogicalHeight = extraLogicalHeight; |
| 949 distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, total
Percent); | 949 distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, total
Percent); |
| 950 distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRows
Count); | 950 distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRows
Count); |
| 951 distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight); | 951 distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight); |
| 952 return extraLogicalHeight - remainingExtraLogicalHeight; | 952 return extraLogicalHeight - remainingExtraLogicalHeight; |
| 953 } | 953 } |
| 954 | 954 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 // | 1037 // |
| 1038 // Note also the oddity where replaced elements always flex, and yet
blocks/tables do | 1038 // Note also the oddity where replaced elements always flex, and yet
blocks/tables do |
| 1039 // not necessarily flex. WinIE is crazy and inconsistent, and we ca
n't hope to | 1039 // not necessarily flex. WinIE is crazy and inconsistent, and we ca
n't hope to |
| 1040 // match the behavior perfectly, but we'll continue to refine it as
we discover new | 1040 // match the behavior perfectly, but we'll continue to refine it as
we discover new |
| 1041 // bugs. :) | 1041 // bugs. :) |
| 1042 bool cellChildrenFlex = false; | 1042 bool cellChildrenFlex = false; |
| 1043 bool flexAllChildren = cell->style()->logicalHeight().isFixed() | 1043 bool flexAllChildren = cell->style()->logicalHeight().isFixed() |
| 1044 || (!table()->style()->logicalHeight().isAuto() && rHeight != ce
ll->logicalHeight()); | 1044 || (!table()->style()->logicalHeight().isAuto() && rHeight != ce
ll->logicalHeight()); |
| 1045 | 1045 |
| 1046 for (LayoutObject* child = cell->firstChild(); child; child = child-
>nextSibling()) { | 1046 for (LayoutObject* child = cell->firstChild(); child; child = child-
>nextSibling()) { |
| 1047 if (!child->isText() && child->style()->logicalHeight().hasPerce
nt() | 1047 if (!child->isText() && child->style()->logicalHeight().isPercen
tOrCalc() |
| 1048 && (flexAllChildren || shouldFlexCellChild(child)) | 1048 && (flexAllChildren || shouldFlexCellChild(child)) |
| 1049 && (!child->isTable() || toLayoutTable(child)->hasSections()
)) { | 1049 && (!child->isTable() || toLayoutTable(child)->hasSections()
)) { |
| 1050 cellChildrenFlex = true; | 1050 cellChildrenFlex = true; |
| 1051 break; | 1051 break; |
| 1052 } | 1052 } |
| 1053 } | 1053 } |
| 1054 | 1054 |
| 1055 if (!cellChildrenFlex) { | 1055 if (!cellChildrenFlex) { |
| 1056 if (TrackedLayoutBoxListHashSet* percentHeightDescendants = cell
->percentHeightDescendants()) { | 1056 if (TrackedLayoutBoxListHashSet* percentHeightDescendants = cell
->percentHeightDescendants()) { |
| 1057 for (auto* descendant : *percentHeightDescendants) { | 1057 for (auto* descendant : *percentHeightDescendants) { |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 // Repeating table headers are painted once per fragmentation page/column. T
his does not go through the regular fragmentation machinery, | 1746 // Repeating table headers are painted once per fragmentation page/column. T
his does not go through the regular fragmentation machinery, |
| 1747 // so we need special code to expand the invalidation rect to contain all po
sitions of the header in all columns. | 1747 // so we need special code to expand the invalidation rect to contain all po
sitions of the header in all columns. |
| 1748 // Note that this is in flow thread coordinates, not visual coordinates. The
enclosing LayoutFlowThread will convert to visual coordinates. | 1748 // Note that this is in flow thread coordinates, not visual coordinates. The
enclosing LayoutFlowThread will convert to visual coordinates. |
| 1749 if (table()->header() == this && hasRepeatingHeaderGroup()) | 1749 if (table()->header() == this && hasRepeatingHeaderGroup()) |
| 1750 rect.setHeight(table()->logicalHeight()); | 1750 rect.setHeight(table()->logicalHeight()); |
| 1751 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec
t, flags); | 1751 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec
t, flags); |
| 1752 } | 1752 } |
| 1753 | 1753 |
| 1754 | 1754 |
| 1755 } // namespace blink | 1755 } // namespace blink |
| OLD | NEW |