| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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) |
| 1226 return 0; | 1231 return 0; |
| 1227 | 1232 |
| 1233 if (make_room_for_repeating_footer) { |
| 1234 row_logical_height += |
| 1235 View()->GetLayoutState()->HeightOffsetForTableFooters(); |
| 1236 } |
| 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 |
| 1237 // content completely. No point in leaving a page completely blank. | 1247 // content completely. No point in leaving a page completely blank. |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DCHECK(Table()->Header() == this || Table()->Footer() == this); |
| 1960 if (GetPaginationBreakability() == kAllowAnyBreaks) |
| 1950 return false; | 1961 return false; |
| 1951 | 1962 |
| 1952 if (GetPaginationBreakability() == kAllowAnyBreaks) | |
| 1953 return false; | |
| 1954 // TODO(rhogan): Sections can be self-painting. | 1963 // TODO(rhogan): Sections can be self-painting. |
| 1955 if (HasSelfPaintingLayer()) | 1964 if (HasSelfPaintingLayer()) |
| 1956 return false; | 1965 return false; |
| 1966 |
| 1957 // If we don't know the page height yet, just assume we fit. | 1967 // If we don't know the page height yet, just assume we fit. |
| 1958 if (!IsPageLogicalHeightKnown()) | 1968 if (!IsPageLogicalHeightKnown()) |
| 1959 return true; | 1969 return true; |
| 1960 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit()); | 1970 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit()); |
| 1961 | 1971 |
| 1962 if (LogicalHeight() > page_height) | 1972 if (LogicalHeight() > page_height) |
| 1963 return false; | 1973 return false; |
| 1964 | 1974 |
| 1965 // See https://drafts.csswg.org/css-tables-3/#repeated-headers which says | 1975 // 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. | 1976 // a header/footer can repeat if it takes up less than a quarter of the page. |
| 1967 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4) | 1977 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4) |
| 1968 return false; | 1978 return false; |
| 1969 | 1979 |
| 1970 return true; | 1980 return true; |
| 1971 } | 1981 } |
| 1972 | 1982 |
| 1983 bool LayoutTableSection::HeaderGroupShouldRepeat() const { |
| 1984 if (Table()->Header() != this) |
| 1985 return false; |
| 1986 return GroupShouldRepeat(); |
| 1987 } |
| 1988 |
| 1989 bool LayoutTableSection::FooterGroupShouldRepeat() const { |
| 1990 if (Table()->Footer() != this) |
| 1991 return false; |
| 1992 return GroupShouldRepeat(); |
| 1993 } |
| 1994 |
| 1973 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal( | 1995 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal( |
| 1974 const LayoutBoxModelObject* ancestor, | 1996 const LayoutBoxModelObject* ancestor, |
| 1975 TransformState& transform_state, | 1997 TransformState& transform_state, |
| 1976 VisualRectFlags flags) const { | 1998 VisualRectFlags flags) const { |
| 1977 if (ancestor == this) | 1999 if (ancestor == this) |
| 1978 return true; | 2000 return true; |
| 1979 // Repeating table headers are painted once per fragmentation page/column. | 2001 // Repeating table headers and footers are painted once per |
| 2002 // page/column. So we need to use the rect for the entire table because |
| 2003 // the repeating headers/footers will appear throughout it. |
| 1980 // This does not go through the regular fragmentation machinery, so we need | 2004 // 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 | 2005 // special code to expand the invalidation rect to contain all positions of |
| 1982 // the header in all columns. | 2006 // the header in all columns. |
| 1983 // Note that this is in flow thread coordinates, not visual coordinates. The | 2007 // Note that this is in flow thread coordinates, not visual coordinates. The |
| 1984 // enclosing LayoutFlowThread will convert to visual coordinates. | 2008 // enclosing LayoutFlowThread will convert to visual coordinates. |
| 1985 if (IsRepeatingHeaderGroup()) { | 2009 if (IsRepeatingHeaderGroup() || IsRepeatingFooterGroup()) { |
| 1986 transform_state.Flatten(); | 2010 transform_state.Flatten(); |
| 1987 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox(); | 2011 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox(); |
| 1988 rect.SetHeight(Table()->LogicalHeight()); | 2012 rect.SetHeight(Table()->LogicalHeight()); |
| 1989 transform_state.SetQuad(FloatQuad(rect)); | 2013 transform_state.SetQuad(FloatQuad(rect)); |
| 2014 return Table()->MapToVisualRectInAncestorSpaceInternal( |
| 2015 ancestor, transform_state, flags); |
| 1990 } | 2016 } |
| 1991 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal( | 2017 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal( |
| 1992 ancestor, transform_state, flags); | 2018 ancestor, transform_state, flags); |
| 1993 } | 2019 } |
| 1994 | 2020 |
| 1995 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() | 2021 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() |
| 1996 const { | 2022 const { |
| 1997 // LayoutTableSection paints background from columns. | 2023 // LayoutTableSection paints background from columns. |
| 1998 if (Table()->HasColElements()) | 2024 if (Table()->HasColElements()) |
| 1999 return false; | 2025 return false; |
| 2000 return LayoutTableBoxComponent:: | 2026 return LayoutTableBoxComponent:: |
| 2001 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2027 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
| 2002 } | 2028 } |
| 2003 | 2029 |
| 2004 } // namespace blink | 2030 } // namespace blink |
| OLD | NEW |