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

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

Issue 2199553002: Don't repeat header groups when one row of content doesn't fit on the first page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug 621258 Created 4 years, 4 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 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 if (paginationStrutOnRow) { 1003 if (paginationStrutOnRow) {
1004 // 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 if (r == 0 && table()->sectionAbove(this) == table()->header ())
1007 state.setHeightOffsetForTableHeaders(state.heightOffsetF orTableHeaders() - table()->header()->logicalHeight());
1004 // If we have a header group we will paint it at the top of each page, move the rows 1008 // If we have a header group we will paint it at the top of each page, move the rows
1005 // down to accomodate it. 1009 // down to accomodate it.
1006 paginationStrutOnRow += state.heightOffsetForTableHeaders(). toInt(); 1010 paginationStrutOnRow += state.heightOffsetForTableHeaders(). toInt();
1007 for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex+ +) 1011 for (unsigned rowIndex = r; rowIndex <= totalRows; rowIndex+ +)
1008 m_rowPos[rowIndex] += paginationStrutOnRow; 1012 m_rowPos[rowIndex] += paginationStrutOnRow;
1009 } 1013 }
1010 } 1014 }
1011 } 1015 }
1012 1016
1013 int rowHeightIncreaseForPagination = INT_MIN; 1017 int rowHeightIncreaseForPagination = INT_MIN;
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 bool LayoutTableSection::hasRepeatingHeaderGroup() const 1718 bool LayoutTableSection::hasRepeatingHeaderGroup() const
1715 { 1719 {
1716 if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks) 1720 if (getPaginationBreakability() == LayoutBox::AllowAnyBreaks)
1717 return false; 1721 return false;
1718 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting? 1722 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting?
1719 if (hasSelfPaintingLayer()) 1723 if (hasSelfPaintingLayer())
1720 return false; 1724 return false;
1721 LayoutUnit pageHeight = table()->pageLogicalHeightForOffset(LayoutUnit()); 1725 LayoutUnit pageHeight = table()->pageLogicalHeightForOffset(LayoutUnit());
1722 if (!pageHeight) 1726 if (!pageHeight)
1723 return false; 1727 return false;
1728
1729 if (logicalHeight() > pageHeight)
1730 return false;
1731
1732 // If the first row of the section after the header group doesn't fit on the page, then
1733 // don't repeat the header on each page. See https://drafts.csswg.org/css-ta bles-3/#repeated-headers
1734 LayoutTableSection* sectionBelow = table()->sectionBelow(this);
1735 if (sectionBelow && sectionBelow->paginationStrutForRow(sectionBelow->firstR ow(), sectionBelow->logicalTop()))
1736 return false;
1737
1724 return true; 1738 return true;
1725 } 1739 }
1726 1740
1727 bool LayoutTableSection::mapToVisualRectInAncestorSpace(const LayoutBoxModelObje ct* ancestor, LayoutRect& rect, VisualRectFlags flags) const 1741 bool LayoutTableSection::mapToVisualRectInAncestorSpace(const LayoutBoxModelObje ct* ancestor, LayoutRect& rect, VisualRectFlags flags) const
1728 { 1742 {
1729 if (ancestor == this) 1743 if (ancestor == this)
1730 return true; 1744 return true;
1731 // Repeating table headers are painted once per fragmentation page/column. T his does not go through the regular fragmentation machinery, 1745 // Repeating table headers are painted once per fragmentation page/column. T his does not go through the regular fragmentation machinery,
1732 // so we need special code to expand the invalidation rect to contain all po sitions of the header in all columns. 1746 // so we need special code to expand the invalidation rect to contain all po sitions of the header in all columns.
1733 // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates. 1747 // Note that this is in flow thread coordinates, not visual coordinates. The enclosing LayoutFlowThread will convert to visual coordinates.
1734 if (table()->header() == this && hasRepeatingHeaderGroup()) 1748 if (table()->header() == this && hasRepeatingHeaderGroup())
1735 rect.setHeight(table()->logicalHeight()); 1749 rect.setHeight(table()->logicalHeight());
1736 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec t, flags); 1750 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rec t, flags);
1737 } 1751 }
1738 1752
1739 1753
1740 } // namespace blink 1754 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698