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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutTableSection.cpp

Issue 2326303002: Don't repeat headers if at least one row of content doesn't fit (Closed)
Patch Set: bug 624814 Created 4 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
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, 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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 for (unsigned r = 0; r < totalRows; r++) { 994 for (unsigned r = 0; r < totalRows; r++) {
995 // Set the row's x/y position and width/height. 995 // Set the row's x/y position and width/height.
996 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject; 996 LayoutTableRow* rowLayoutObject = m_grid[r].rowLayoutObject;
997 int paginationStrutOnRow = 0; 997 int paginationStrutOnRow = 0;
998 if (rowLayoutObject) { 998 if (rowLayoutObject) {
999 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r])); 999 rowLayoutObject->setLocation(LayoutPoint(0, m_rowPos[r]));
1000 rowLayoutObject->setLogicalWidth(logicalWidth()); 1000 rowLayoutObject->setLogicalWidth(logicalWidth());
1001 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing)); 1001 rowLayoutObject->setLogicalHeight(LayoutUnit(m_rowPos[r + 1] - m_row Pos[r] - vspacing));
1002 rowLayoutObject->updateLayerTransformAfterLayout(); 1002 rowLayoutObject->updateLayerTransformAfterLayout();
1003 if (isPaginated) { 1003 if (isPaginated) {
1004 paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, La youtUnit(m_rowPos[r])); 1004 paginationStrutOnRow = paginationStrutForRow(rowLayoutObject, La youtUnit(m_rowPos[r]));
mstensho (USE GERRIT) 2016/09/15 06:31:55 I think this should be the one and only call to pa
1005 rowLayoutObject->setPaginationStrut(LayoutUnit(paginationStrutOn Row));
1005 if (paginationStrutOnRow) { 1006 if (paginationStrutOnRow) {
1006 // If there isn't room for at least one content row on a pag e with a header group, then 1007 // If there isn't room for at least one content row on a pag e with a header group, then
1007 // we won't repeat the header on each page. 1008 // we won't repeat the header on each page.
1008 if (!r && table()->header() && table()->sectionAbove(this) = = table()->header()) 1009 if (!r && table()->header() && table()->sectionAbove(this) = = table()->header() && table()->header()->getPaginationBreakability() != AllowAn yBreaks)
1009 state.setHeightOffsetForTableHeaders(state.heightOffsetF orTableHeaders() - table()->header()->logicalHeight()); 1010 state.setHeightOffsetForTableHeaders(state.heightOffsetF orTableHeaders() - table()->header()->logicalHeight());
1010 // If we have a header group we will paint it at the top of each page, move the rows 1011 // If we have a header group we will paint it at the top of each page, move the rows
1011 // down to accomodate it. 1012 // down to accomodate it.
1012 paginationStrutOnRow += state.heightOffsetForTableHeaders(). toInt(); 1013 paginationStrutOnRow += state.heightOffsetForTableHeaders(). toInt();
1013 for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex+ +) 1014 for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex+ +)
1014 m_rowPos[rowIndex] += paginationStrutOnRow; 1015 m_rowPos[rowIndex] += paginationStrutOnRow;
1015 } 1016 }
1016 } 1017 }
1017 } 1018 }
1018 1019
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 1712
1712 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691). 1713 // FIXME: The table's direction should determine our row's direction, not th e section's (see bug 96691).
1713 if (!style()->isLeftToRightDirection()) 1714 if (!style()->isLeftToRightDirection())
1714 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing)); 1715 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[table() ->numEffectiveColumns()] - table()->effectiveColumnPositions()[table()->absolute ColumnToEffectiveColumn(cell->absoluteColumnIndex() + cell->colSpan())] + horizo ntalBorderSpacing));
1715 else 1716 else
1716 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing)); 1717 cellLocation.setX(LayoutUnit(table()->effectiveColumnPositions()[effecti veColumn] + horizontalBorderSpacing));
1717 1718
1718 cell->setLogicalLocation(cellLocation); 1719 cell->setLogicalLocation(cellLocation);
1719 } 1720 }
1720 1721
1721 bool LayoutTableSection::hasRepeatingHeaderGroup() const 1722 bool LayoutTableSection::isRepeatingHeaderGroup() const
1722 { 1723 {
1723 if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks) 1724 if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks)
1724 return false; 1725 return false;
1725 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting? 1726 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting?
1726 if (hasSelfPaintingLayer()) 1727 if (hasSelfPaintingLayer())
1727 return false; 1728 return false;
1728 LayoutUnit pageHeight = table()->pageLogicalHeightForOffset(LayoutUnit()); 1729 LayoutUnit pageHeight = table()->pageLogicalHeightForOffset(LayoutUnit());
1729 if (!pageHeight) 1730 if (!pageHeight)
1730 return false; 1731 return false;
1731 1732
1732 if (logicalHeight() > pageHeight) 1733 if (logicalHeight() > pageHeight)
1733 return false; 1734 return false;
1734 1735
1735 // If the first row of the section after the header group doesn't fit on the page, then 1736 // If the first row of the section after the header group doesn't fit on the page, then
1736 // don't repeat the header on each page. See https://drafts.csswg.org/css-ta bles-3/#repeated-headers 1737 // don't repeat the header on each page. See https://drafts.csswg.org/css-ta bles-3/#repeated-headers
1737 LayoutTableSection* sectionBelow = table()->sectionBelow(this); 1738 LayoutTableSection* sectionBelow = table()->sectionBelow(this);
1738 if (sectionBelow && sectionBelow->firstRow() && sectionBelow->paginationStru tForRow(sectionBelow->firstRow(), sectionBelow->logicalTop())) 1739 if (sectionBelow && sectionBelow->firstRow() && sectionBelow->firstRow()->pa ginationStrut())
1739 return false; 1740 return false;
1740 1741
1741 return true; 1742 return true;
1742 } 1743 }
1743 1744
1744 bool LayoutTableSection::mapToVisualRectInAncestorSpace(const LayoutBoxModelObje ct* ancestor, LayoutRect& rect, VisualRectFlags flags) const 1745 bool LayoutTableSection::mapToVisualRectInAncestorSpace(const LayoutBoxModelObje ct* ancestor, LayoutRect& rect, VisualRectFlags flags) const
1745 { 1746 {
1746 if (ancestor == this) 1747 if (ancestor == this)
1747 return true; 1748 return true;
1748 // Repeating table headers are painted once per fragmentation page/column. T his does not go through the regular fragmentation machinery, 1749 // Repeating table headers are painted once per fragmentation page/column. T his does not go through the regular fragmentation machinery,
1749 // so we need special code to expand the invalidation rect to contain all po sitions of the header in all columns. 1750 // so we need special code to expand the invalidation rect to contain all po sitions of the header in all columns.
1750 // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates. 1751 // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates.
1751 if (table()->header() == this && hasRepeatingHeaderGroup()) 1752 if (table()->header() == this && isRepeatingHeaderGroup())
1752 rect.setHeight(table()->logicalHeight()); 1753 rect.setHeight(table()->logicalHeight());
1753 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec t, flags); 1754 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec t, flags);
1754 } 1755 }
1755 1756
1756 1757
1757 } // namespace blink 1758 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698