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

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

Issue 2584143003: Repeat footers in paginated context (Closed)
Patch Set: bug 656232 Created 3 years, 6 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. 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 LayoutTableSection::LayoutTableSection(Element* element) 89 LayoutTableSection::LayoutTableSection(Element* element)
90 : LayoutTableBoxComponent(element), 90 : LayoutTableBoxComponent(element),
91 c_col_(0), 91 c_col_(0),
92 c_row_(0), 92 c_row_(0),
93 needs_cell_recalc_(false), 93 needs_cell_recalc_(false),
94 force_full_paint_(false), 94 force_full_paint_(false),
95 has_multiple_cell_levels_(false), 95 has_multiple_cell_levels_(false),
96 has_spanning_cells_(false), 96 has_spanning_cells_(false),
97 is_repeating_header_group_(false) { 97 is_repeating_header_group_(false),
98 is_repeating_footer_group_(false) {
98 // init LayoutObject attributes 99 // init LayoutObject attributes
99 SetInline(false); // our object is not Inline 100 SetInline(false); // our object is not Inline
100 } 101 }
101 102
102 LayoutTableSection::~LayoutTableSection() {} 103 LayoutTableSection::~LayoutTableSection() {}
103 104
104 void LayoutTableSection::StyleDidChange(StyleDifference diff, 105 void LayoutTableSection::StyleDidChange(StyleDifference diff,
105 const ComputedStyle* old_style) { 106 const ComputedStyle* old_style) {
106 DCHECK(Style()->Display() == EDisplay::kTableFooterGroup || 107 DCHECK(Style()->Display() == EDisplay::kTableFooterGroup ||
107 Style()->Display() == EDisplay::kTableRowGroup || 108 Style()->Display() == EDisplay::kTableRowGroup ||
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 DCHECK(!NeedsLayout()); 1209 DCHECK(!NeedsLayout());
1209 1210
1210 SetLogicalHeight(LayoutUnit(row_pos_[total_rows])); 1211 SetLogicalHeight(LayoutUnit(row_pos_[total_rows]));
1211 1212
1212 ComputeOverflowFromDescendants(); 1213 ComputeOverflowFromDescendants();
1213 } 1214 }
1214 1215
1215 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row, 1216 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row,
1216 LayoutUnit logical_offset) const { 1217 LayoutUnit logical_offset) const {
1217 DCHECK(row); 1218 DCHECK(row);
1218 if (row->GetPaginationBreakability() == kAllowAnyBreaks) 1219 const LayoutTableSection* footer = Table()->Footer();
1220 bool make_room_for_repeating_footer =
1221 footer && footer->IsRepeatingFooterGroup() && row->RowIndex();
1222 if (!make_room_for_repeating_footer &&
1223 row->GetPaginationBreakability() == kAllowAnyBreaks)
1219 return 0; 1224 return 0;
1220 if (!IsPageLogicalHeightKnown()) 1225 if (!IsPageLogicalHeightKnown())
1221 return 0; 1226 return 0;
1222 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); 1227 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset);
1223 // If the row is too tall for the page don't insert a strut. 1228 // If the row is too tall for the page don't insert a strut.
1224 LayoutUnit row_logical_height = row->LogicalHeight(); 1229 LayoutUnit row_logical_height = row->LogicalHeight();
1225 if (row_logical_height > page_logical_height) 1230 if (row_logical_height > page_logical_height) {
mstensho (USE GERRIT) 2017/06/16 08:43:06 No need for the curls.
rhogan 2017/06/20 18:46:05 OK.
1226 return 0; 1231 return 0;
1232 }
1233
1234 LayoutState* layout_state = View()->GetLayoutState();
mstensho (USE GERRIT) 2017/06/16 08:43:06 Please move it inside the "if (make_room_for_repea
rhogan 2017/06/20 18:46:05 Sure.
1235 if (make_room_for_repeating_footer)
1236 row_logical_height += layout_state->HeightOffsetForTableFooters();
1227 1237
1228 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( 1238 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset(
1229 logical_offset, LayoutBlock::kAssociateWithLatterPage); 1239 logical_offset, LayoutBlock::kAssociateWithLatterPage);
1230 if (remaining_logical_height >= row_logical_height) 1240 if (remaining_logical_height >= row_logical_height)
1231 return 0; // It fits fine where it is. No need to break. 1241 return 0; // It fits fine where it is. No need to break.
1232 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent( 1242 LayoutUnit pagination_strut = CalculatePaginationStrutToFitContent(
1233 logical_offset, remaining_logical_height, row_logical_height); 1243 logical_offset, remaining_logical_height, row_logical_height);
1234 if (pagination_strut == remaining_logical_height && 1244 if (pagination_strut == remaining_logical_height &&
1235 remaining_logical_height == page_logical_height) { 1245 remaining_logical_height == page_logical_height) {
1236 // Don't break if we were at the top of a page, and we failed to fit the 1246 // Don't break if we were at the top of a page, and we failed to fit the
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 // pagination struts inside some cell in this row that we need to get rid of. 1948 // pagination struts inside some cell in this row that we need to get rid of.
1939 row_object.SetLogicalTop(row_object.LogicalTop() + pagination_strut); 1949 row_object.SetLogicalTop(row_object.LogicalTop() + pagination_strut);
1940 layouter.SetChildNeedsLayout(&row_object); 1950 layouter.SetChildNeedsLayout(&row_object);
1941 row_object.LayoutIfNeeded(); 1951 row_object.LayoutIfNeeded();
1942 1952
1943 // It's very likely that re-laying out (and nuking pagination struts inside 1953 // It's very likely that re-laying out (and nuking pagination struts inside
1944 // cells) gave us a new height. 1954 // cells) gave us a new height.
1945 row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object))); 1955 row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object)));
1946 } 1956 }
1947 1957
1948 bool LayoutTableSection::HeaderGroupShouldRepeat() const { 1958 bool LayoutTableSection::GroupShouldRepeat() const {
1949 if (Table()->Header() != this) 1959 if (GetPaginationBreakability() == kAllowAnyBreaks)
mstensho (USE GERRIT) 2017/06/16 08:43:06 I wonder if you should add a DCHECK at the beginni
rhogan 2017/06/20 18:46:06 Done.
1950 return false; 1960 return false;
1951 1961
1952 if (GetPaginationBreakability() == kAllowAnyBreaks)
1953 return false;
1954 // TODO(rhogan): Sections can be self-painting. 1962 // TODO(rhogan): Sections can be self-painting.
1955 if (HasSelfPaintingLayer()) 1963 if (HasSelfPaintingLayer())
1956 return false; 1964 return false;
1965
1957 // If we don't know the page height yet, just assume we fit. 1966 // If we don't know the page height yet, just assume we fit.
1958 if (!IsPageLogicalHeightKnown()) 1967 if (!IsPageLogicalHeightKnown())
1959 return true; 1968 return true;
1960 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit()); 1969 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit());
1961 1970
1962 if (LogicalHeight() > page_height) 1971 if (LogicalHeight() > page_height)
1963 return false; 1972 return false;
1964 1973
1965 // See https://drafts.csswg.org/css-tables-3/#repeated-headers which says 1974 // See https://drafts.csswg.org/css-tables-3/#repeated-headers which says
1966 // a header/footer can repeat if it takes up less than a quarter of the page. 1975 // a header/footer can repeat if it takes up less than a quarter of the page.
1967 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4) 1976 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4)
1968 return false; 1977 return false;
1969 1978
1970 return true; 1979 return true;
1971 } 1980 }
1972 1981
1982 bool LayoutTableSection::HeaderGroupShouldRepeat() const {
1983 if (Table()->Header() != this)
1984 return false;
1985 return GroupShouldRepeat();
1986 }
1987
1988 bool LayoutTableSection::FooterGroupShouldRepeat() const {
1989 if (Table()->Footer() != this)
1990 return false;
1991 return GroupShouldRepeat();
1992 }
1993
1973 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal( 1994 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal(
1974 const LayoutBoxModelObject* ancestor, 1995 const LayoutBoxModelObject* ancestor,
1975 TransformState& transform_state, 1996 TransformState& transform_state,
1976 VisualRectFlags flags) const { 1997 VisualRectFlags flags) const {
1977 if (ancestor == this) 1998 if (ancestor == this)
1978 return true; 1999 return true;
1979 // Repeating table headers are painted once per fragmentation page/column. 2000 // Repeating table headers and footers are painted once per fragmentation
mstensho (USE GERRIT) 2017/06/16 08:43:06 Instead of "fragmentation page/column", I suggest
rhogan 2017/06/20 18:46:05 Indeed.
2001 // page/column. So we need to use the rect for the entire table because
2002 // the repeating headers/footers will appear throughout it.
1980 // This does not go through the regular fragmentation machinery, so we need 2003 // This does not go through the regular fragmentation machinery, so we need
1981 // special code to expand the invalidation rect to contain all positions of 2004 // special code to expand the invalidation rect to contain all positions of
1982 // the header in all columns. 2005 // the header in all columns.
1983 // Note that this is in flow thread coordinates, not visual coordinates. The 2006 // Note that this is in flow thread coordinates, not visual coordinates. The
1984 // enclosing LayoutFlowThread will convert to visual coordinates. 2007 // enclosing LayoutFlowThread will convert to visual coordinates.
1985 if (IsRepeatingHeaderGroup()) { 2008 if (IsRepeatingHeaderGroup() || IsRepeatingFooterGroup()) {
1986 transform_state.Flatten(); 2009 transform_state.Flatten();
1987 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox(); 2010 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox();
1988 rect.SetHeight(Table()->LogicalHeight()); 2011 rect.SetHeight(Table()->LogicalHeight());
1989 transform_state.SetQuad(FloatQuad(rect)); 2012 transform_state.SetQuad(FloatQuad(rect));
2013 return Table()->MapToVisualRectInAncestorSpaceInternal(
2014 ancestor, transform_state, flags);
rhogan 2017/06/20 18:46:06 This is the place which used to trigger the DCHECK
mstensho (USE GERRIT) 2017/06/20 21:39:05 I see no DCHECK removed.
1990 } 2015 }
1991 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal( 2016 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal(
1992 ancestor, transform_state, flags); 2017 ancestor, transform_state, flags);
1993 } 2018 }
1994 2019
1995 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() 2020 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize()
1996 const { 2021 const {
1997 // LayoutTableSection paints background from columns. 2022 // LayoutTableSection paints background from columns.
1998 if (Table()->HasColElements()) 2023 if (Table()->HasColElements())
1999 return false; 2024 return false;
2000 return LayoutTableBoxComponent:: 2025 return LayoutTableBoxComponent::
2001 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2026 PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
2002 } 2027 }
2003 2028
2004 } // namespace blink 2029 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698