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

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

Issue 2422163003: Account for border spacing correctly when repeating header groups (Closed)
Patch Set: Account for border spacing correctly when repeating header groups Created 4 years, 1 month 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. 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 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset); 1239 LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
1240 if (!pageLogicalHeight) 1240 if (!pageLogicalHeight)
1241 return 0; 1241 return 0;
1242 // If the row is too tall for the page don't insert a strut. 1242 // If the row is too tall for the page don't insert a strut.
1243 LayoutUnit rowLogicalHeight = row->logicalHeight(); 1243 LayoutUnit rowLogicalHeight = row->logicalHeight();
1244 if (rowLogicalHeight > pageLogicalHeight) 1244 if (rowLogicalHeight > pageLogicalHeight)
1245 return 0; 1245 return 0;
1246 1246
1247 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset( 1247 LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(
1248 logicalOffset, LayoutBlock::AssociateWithLatterPage); 1248 logicalOffset, LayoutBlock::AssociateWithLatterPage);
1249 LayoutUnit offsetForBorderSpacing =
1250 pageLogicalHeight - (remainingLogicalHeight + table()->vBorderSpacing());
1251 // Border spacing from the previous row has pushed this row just past the top
1252 // of the page, so we must reposition it to the top of the page and avoid any
1253 // repeating header.
1254 if (offsetForBorderSpacing < 0)
1255 return offsetForBorderSpacing.toInt();
1256
1257 if (remainingLogicalHeight >= rowLogicalHeight) 1249 if (remainingLogicalHeight >= rowLogicalHeight)
1258 return 0; // It fits fine where it is. No need to break. 1250 return 0; // It fits fine where it is. No need to break.
1259 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent( 1251 LayoutUnit paginationStrut = calculatePaginationStrutToFitContent(
1260 logicalOffset, remainingLogicalHeight, rowLogicalHeight); 1252 logicalOffset, remainingLogicalHeight, rowLogicalHeight);
1261 if (paginationStrut == remainingLogicalHeight && 1253 if (paginationStrut == remainingLogicalHeight &&
1262 remainingLogicalHeight == pageLogicalHeight) { 1254 remainingLogicalHeight == pageLogicalHeight) {
1263 // Don't break if we were at the top of a page, and we failed to fit the 1255 // Don't break if we were at the top of a page, and we failed to fit the
1264 // content completely. No point in leaving a page completely blank. 1256 // content completely. No point in leaving a page completely blank.
1265 return 0; 1257 return 0;
1266 } 1258 }
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 return logicalHeight; 1983 return logicalHeight;
1992 } 1984 }
1993 1985
1994 void LayoutTableSection::adjustRowForPagination(LayoutTableRow& rowObject, 1986 void LayoutTableSection::adjustRowForPagination(LayoutTableRow& rowObject,
1995 SubtreeLayoutScope& layouter) { 1987 SubtreeLayoutScope& layouter) {
1996 LayoutState& state = *view()->layoutState(); 1988 LayoutState& state = *view()->layoutState();
1997 rowObject.setPaginationStrut(LayoutUnit()); 1989 rowObject.setPaginationStrut(LayoutUnit());
1998 rowObject.setLogicalHeight(LayoutUnit(logicalHeightForRow(rowObject))); 1990 rowObject.setLogicalHeight(LayoutUnit(logicalHeightForRow(rowObject)));
1999 int paginationStrut = 1991 int paginationStrut =
2000 paginationStrutForRow(&rowObject, rowObject.logicalTop()); 1992 paginationStrutForRow(&rowObject, rowObject.logicalTop());
1993 bool rowIsAtTopOfColumn = false;
1994 LayoutUnit offsetFromTopOfPage;
2001 if (!paginationStrut) { 1995 if (!paginationStrut) {
2002 bool rowIsAtTopOfColumn = 1996 if (state.heightOffsetForTableHeaders()) {
2003 state.heightOffsetForTableHeaders() && 1997 offsetFromTopOfPage =
2004 pageLogicalHeightForOffset(rowObject.logicalTop()) == 1998 pageLogicalHeightForOffset(rowObject.logicalTop()) -
2005 pageRemainingLogicalHeightForOffset(rowObject.logicalTop(), 1999 pageRemainingLogicalHeightForOffset(rowObject.logicalTop(),
2006 AssociateWithLatterPage); 2000 AssociateWithLatterPage);
2001 rowIsAtTopOfColumn = !offsetFromTopOfPage ||
2002 offsetFromTopOfPage <= table()->vBorderSpacing();
2003 }
2004
2007 if (!rowIsAtTopOfColumn) 2005 if (!rowIsAtTopOfColumn)
2008 return; 2006 return;
2009 } 2007 }
2010 // We need to push this row to the next fragmentainer. If there are repeated 2008 // We need to push this row to the next fragmentainer. If there are repeated
2011 // table headers, we need to make room for those at the top of the next 2009 // table headers, we need to make room for those at the top of the next
2012 // fragmentainer, above this row. Otherwise, this row will just go at the top 2010 // fragmentainer, above this row. Otherwise, this row will just go at the top
2013 // of the next fragmentainer. 2011 // of the next fragmentainer.
2014 2012
2015 // If there isn't room for at least one content row on a page with a 2013 // If there isn't room for at least one content row on a page with a
2016 // header group, then we won't repeat the header on each page. 2014 // header group, then we won't repeat the header on each page.
2017 LayoutTableSection* header = table()->header(); 2015 LayoutTableSection* header = table()->header();
2018 if (!rowObject.rowIndex() && header && 2016 if (!rowObject.rowIndex() && header &&
2019 table()->sectionAbove(this) == header && 2017 table()->sectionAbove(this) == header &&
2020 header->getPaginationBreakability() != AllowAnyBreaks) { 2018 header->getPaginationBreakability() != AllowAnyBreaks) {
2021 state.setHeightOffsetForTableHeaders(state.heightOffsetForTableHeaders() - 2019 state.setHeightOffsetForTableHeaders(state.heightOffsetForTableHeaders() -
2022 header->logicalHeight()); 2020 header->logicalHeight());
2023 } 2021 }
2022 // Border spacing from the previous row has pushed this row just past the top
2023 // of the page, so we must reposition it to the top of the page and avoid any
2024 // repeating header.
2025 if (rowIsAtTopOfColumn && offsetFromTopOfPage)
2026 paginationStrut -= offsetFromTopOfPage.toInt();
2027
2024 // If we have a header group we will paint it at the top of each page, 2028 // If we have a header group we will paint it at the top of each page,
2025 // move the rows down to accomodate it. 2029 // move the rows down to accomodate it.
2026 paginationStrut += state.heightOffsetForTableHeaders().toInt(); 2030 paginationStrut += state.heightOffsetForTableHeaders().toInt();
2027 rowObject.setPaginationStrut(LayoutUnit(paginationStrut)); 2031 rowObject.setPaginationStrut(LayoutUnit(paginationStrut));
2028 2032
2029 // We have inserted a pagination strut before the row. Adjust the logical top 2033 // We have inserted a pagination strut before the row. Adjust the logical top
2030 // and re-lay out. We no longer want to break inside the row, but rather 2034 // and re-lay out. We no longer want to break inside the row, but rather
2031 // *before* it. From the previous layout pass, there are most likely 2035 // *before* it. From the previous layout pass, there are most likely
2032 // pagination struts inside some cell in this row that we need to get rid of. 2036 // pagination struts inside some cell in this row that we need to get rid of.
2033 rowObject.setLogicalTop(rowObject.logicalTop() + paginationStrut); 2037 rowObject.setLogicalTop(rowObject.logicalTop() + paginationStrut);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 // the header in all columns. 2079 // the header in all columns.
2076 // Note that this is in flow thread coordinates, not visual coordinates. The 2080 // Note that this is in flow thread coordinates, not visual coordinates. The
2077 // enclosing LayoutFlowThread will convert to visual coordinates. 2081 // enclosing LayoutFlowThread will convert to visual coordinates.
2078 if (table()->header() == this && isRepeatingHeaderGroup()) 2082 if (table()->header() == this && isRepeatingHeaderGroup())
2079 rect.setHeight(table()->logicalHeight()); 2083 rect.setHeight(table()->logicalHeight());
2080 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect, 2084 return LayoutTableBoxComponent::mapToVisualRectInAncestorSpace(ancestor, rect,
2081 flags); 2085 flags);
2082 } 2086 }
2083 2087
2084 } // namespace blink 2088 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fragmentation/single-line-cells-repeating-thead-with-border-spacing-at-top-of-row-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698