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

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

Powered by Google App Engine
This is Rietveld 408576698