| 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. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. |
| 8 * All rights reserved. | 8 * All rights reserved. |
| 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 9 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 10 * | 10 * |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 | 846 |
| 847 // We ignore the border-spacing on any non-top section as it is already | 847 // We ignore the border-spacing on any non-top section as it is already |
| 848 // included in the previous section's last row position. | 848 // included in the previous section's last row position. |
| 849 if (this == table()->topSection()) | 849 if (this == table()->topSection()) |
| 850 m_rowPos[0] = table()->vBorderSpacing(); | 850 m_rowPos[0] = table()->vBorderSpacing(); |
| 851 else | 851 else |
| 852 m_rowPos[0] = 0; | 852 m_rowPos[0] = 0; |
| 853 | 853 |
| 854 SpanningLayoutTableCells rowSpanCells; | 854 SpanningLayoutTableCells rowSpanCells; |
| 855 | 855 |
| 856 // At fragmentainer breaks we need to prevent rowspanned cells (and whatever |
| 857 // else) from distributing their extra height requirements over the rows that |
| 858 // it spans. Otherwise we'd need to refragment afterwards. |
| 859 unsigned indexOfFirstStretchableRow = 0; |
| 860 |
| 856 for (unsigned r = 0; r < m_grid.size(); r++) { | 861 for (unsigned r = 0; r < m_grid.size(); r++) { |
| 857 m_grid[r].baseline = -1; | 862 m_grid[r].baseline = -1; |
| 858 int baselineDescent = 0; | 863 int baselineDescent = 0; |
| 859 | 864 |
| 860 if (state.isPaginated() && m_grid[r].rowLayoutObject) | 865 if (state.isPaginated() && m_grid[r].rowLayoutObject) |
| 861 m_rowPos[r] += m_grid[r].rowLayoutObject->paginationStrut().ceil(); | 866 m_rowPos[r] += m_grid[r].rowLayoutObject->paginationStrut().ceil(); |
| 862 | 867 |
| 863 if (m_grid[r].logicalHeight.isSpecified()) { | 868 if (m_grid[r].logicalHeight.isSpecified()) { |
| 864 // Our base size is the biggest logical height from our cells' styles | 869 // Our base size is the biggest logical height from our cells' styles |
| 865 // (excluding row spanning cells). | 870 // (excluding row spanning cells). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 882 if (current.inColSpan) | 887 if (current.inColSpan) |
| 883 continue; | 888 continue; |
| 884 for (unsigned i = 0; i < current.cells.size(); i++) { | 889 for (unsigned i = 0; i < current.cells.size(); i++) { |
| 885 cell = current.cells[i]; | 890 cell = current.cells[i]; |
| 886 | 891 |
| 887 // For row spanning cells, we only handle them for the first row they | 892 // For row spanning cells, we only handle them for the first row they |
| 888 // span. This ensures we take their baseline into account. | 893 // span. This ensures we take their baseline into account. |
| 889 if (cell->rowIndex() != r) | 894 if (cell->rowIndex() != r) |
| 890 continue; | 895 continue; |
| 891 | 896 |
| 892 if (cell->rowSpan() > 1) { | 897 if (r < indexOfFirstStretchableRow || |
| 898 (state.isPaginated() && |
| 899 crossesPageBoundary( |
| 900 LayoutUnit(m_rowPos[r]), |
| 901 LayoutUnit(cell->logicalHeightForRowSizing())))) { |
| 902 // Entering or extending a range of unstretchable rows. We enter this |
| 903 // mode when a cell in a row crosses a fragmentainer boundary, and |
| 904 // we'll stay in this mode until we get to a row where we're past all |
| 905 // rowspanned cells that we encountered while in this mode. |
| 906 DCHECK(state.isPaginated()); |
| 907 unsigned rowIndexBelowCell = r + cell->rowSpan(); |
| 908 indexOfFirstStretchableRow = |
| 909 std::max(indexOfFirstStretchableRow, rowIndexBelowCell); |
| 910 } else if (cell->rowSpan() > 1) { |
| 893 DCHECK(!rowSpanCells.contains(cell)); | 911 DCHECK(!rowSpanCells.contains(cell)); |
| 894 rowSpanCells.append(cell); | 912 rowSpanCells.append(cell); |
| 895 } | 913 } |
| 896 | 914 |
| 897 if (cell->hasOverrideLogicalContentHeight()) { | 915 if (cell->hasOverrideLogicalContentHeight()) { |
| 898 cell->clearIntrinsicPadding(); | 916 cell->clearIntrinsicPadding(); |
| 899 cell->clearOverrideSize(); | 917 cell->clearOverrideSize(); |
| 900 cell->forceChildLayout(); | 918 cell->forceChildLayout(); |
| 901 } | 919 } |
| 902 | 920 |
| 903 if (cell->rowSpan() == 1) | 921 if (cell->rowSpan() == 1) |
| 904 m_rowPos[r + 1] = std::max( | 922 m_rowPos[r + 1] = std::max( |
| 905 m_rowPos[r + 1], m_rowPos[r] + cell->logicalHeightForRowSizing()); | 923 m_rowPos[r + 1], m_rowPos[r] + cell->logicalHeightForRowSizing()); |
| 906 | 924 |
| 907 // Find out the baseline. The baseline is set on the first row in a | 925 // Find out the baseline. The baseline is set on the first row in a |
| 908 // rowSpan. | 926 // rowSpan. |
| 909 updateBaselineForCell(cell, r, baselineDescent); | 927 updateBaselineForCell(cell, r, baselineDescent); |
| 910 } | 928 } |
| 911 } | 929 } |
| 912 | 930 |
| 931 if (r < indexOfFirstStretchableRow && m_grid[r].rowLayoutObject) { |
| 932 // We're not allowed to resize this row. Just scratch what we've |
| 933 // calculated so far, and use the height that we got during initial |
| 934 // layout instead. |
| 935 m_rowPos[r + 1] = |
| 936 m_rowPos[r] + m_grid[r].rowLayoutObject->logicalHeight().toInt(); |
| 937 } |
| 938 |
| 913 // Add the border-spacing to our final position. | 939 // Add the border-spacing to our final position. |
| 914 m_rowPos[r + 1] += borderSpacingForRow(r); | 940 m_rowPos[r + 1] += borderSpacingForRow(r); |
| 915 m_rowPos[r + 1] = std::max(m_rowPos[r + 1], m_rowPos[r]); | 941 m_rowPos[r + 1] = std::max(m_rowPos[r + 1], m_rowPos[r]); |
| 916 } | 942 } |
| 917 | 943 |
| 918 if (!rowSpanCells.isEmpty()) | 944 if (!rowSpanCells.isEmpty()) |
| 919 distributeRowSpanHeightToRows(rowSpanCells); | 945 distributeRowSpanHeightToRows(rowSpanCells); |
| 920 | 946 |
| 921 ASSERT(!needsLayout()); | 947 ASSERT(!needsLayout()); |
| 922 | 948 |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1927 unsigned rowIndex = rowObject.rowIndex(); | 1953 unsigned rowIndex = rowObject.rowIndex(); |
| 1928 DCHECK(rowIndex < m_grid.size()); | 1954 DCHECK(rowIndex < m_grid.size()); |
| 1929 int logicalHeight = 0; | 1955 int logicalHeight = 0; |
| 1930 const Row& row = m_grid[rowIndex].row; | 1956 const Row& row = m_grid[rowIndex].row; |
| 1931 unsigned cols = row.size(); | 1957 unsigned cols = row.size(); |
| 1932 for (unsigned colIndex = 0; colIndex < cols; colIndex++) { | 1958 for (unsigned colIndex = 0; colIndex < cols; colIndex++) { |
| 1933 const CellStruct& cellStruct = cellAt(rowIndex, colIndex); | 1959 const CellStruct& cellStruct = cellAt(rowIndex, colIndex); |
| 1934 const LayoutTableCell* cell = cellStruct.primaryCell(); | 1960 const LayoutTableCell* cell = cellStruct.primaryCell(); |
| 1935 if (!cell || cellStruct.inColSpan) | 1961 if (!cell || cellStruct.inColSpan) |
| 1936 continue; | 1962 continue; |
| 1937 // TODO(mstensho): Rowspanned cells also need to contribute to row heights | 1963 unsigned rowSpan = cell->rowSpan(); |
| 1938 // during the first layout pass, in order to get fragmentation right. | 1964 if (rowSpan == 1) { |
| 1939 if (cell->rowSpan() == 1) { | |
| 1940 logicalHeight = | 1965 logicalHeight = |
| 1941 std::max(logicalHeight, cell->logicalHeightForRowSizing()); | 1966 std::max(logicalHeight, cell->logicalHeightForRowSizing()); |
| 1967 continue; |
| 1968 } |
| 1969 unsigned rowIndexForCell = cell->rowIndex(); |
| 1970 if (rowIndex == m_grid.size() - 1 || |
| 1971 (rowSpan > 1 && rowIndex - rowIndexForCell == rowSpan - 1)) { |
| 1972 // This is the last row of the rowspanned cell. Add extra height if |
| 1973 // needed. |
| 1974 if (LayoutTableRow* firstRowForCell = |
| 1975 m_grid[rowIndexForCell].rowLayoutObject) { |
| 1976 int minLogicalHeight = cell->logicalHeightForRowSizing(); |
| 1977 // Subtract space provided by previous rows. |
| 1978 minLogicalHeight -= rowObject.logicalTop().toInt() - |
| 1979 firstRowForCell->logicalTop().toInt(); |
| 1980 |
| 1981 logicalHeight = std::max(logicalHeight, minLogicalHeight); |
| 1982 } |
| 1942 } | 1983 } |
| 1943 } | 1984 } |
| 1944 | 1985 |
| 1945 if (m_grid[rowIndex].logicalHeight.isSpecified()) { | 1986 if (m_grid[rowIndex].logicalHeight.isSpecified()) { |
| 1946 LayoutUnit specifiedLogicalHeight = | 1987 LayoutUnit specifiedLogicalHeight = |
| 1947 minimumValueForLength(m_grid[rowIndex].logicalHeight, LayoutUnit()); | 1988 minimumValueForLength(m_grid[rowIndex].logicalHeight, LayoutUnit()); |
| 1948 logicalHeight = std::max(logicalHeight, specifiedLogicalHeight.toInt()); | 1989 logicalHeight = std::max(logicalHeight, specifiedLogicalHeight.toInt()); |
| 1949 } | 1990 } |
| 1950 return logicalHeight; | 1991 return logicalHeight; |
| 1951 } | 1992 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 // the header in all columns. | 2075 // the header in all columns. |
| 2035 // Note that this is in flow thread coordinates, not visual coordinates. The | 2076 // Note that this is in flow thread coordinates, not visual coordinates. The |
| 2036 // enclosing LayoutFlowThread will convert to visual coordinates. | 2077 // enclosing LayoutFlowThread will convert to visual coordinates. |
| 2037 if (table()->header() == this && isRepeatingHeaderGroup()) | 2078 if (table()->header() == this && isRepeatingHeaderGroup()) |
| 2038 rect.setHeight(table()->logicalHeight()); | 2079 rect.setHeight(table()->logicalHeight()); |
| 2039 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, | 2080 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, |
| 2040 flags); | 2081 flags); |
| 2041 } | 2082 } |
| 2042 | 2083 |
| 2043 } // namespace blink | 2084 } // namespace blink |
| OLD | NEW |