| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 LayoutTableSection::LayoutTableSection(Element* element) | 91 LayoutTableSection::LayoutTableSection(Element* element) |
| 92 : LayoutTableBoxComponent(element), | 92 : LayoutTableBoxComponent(element), |
| 93 c_col_(0), | 93 c_col_(0), |
| 94 c_row_(0), | 94 c_row_(0), |
| 95 needs_cell_recalc_(false), | 95 needs_cell_recalc_(false), |
| 96 force_full_paint_(false), | 96 force_full_paint_(false), |
| 97 has_multiple_cell_levels_(false), | 97 has_multiple_cell_levels_(false), |
| 98 has_spanning_cells_(false), | 98 has_spanning_cells_(false), |
| 99 is_repeating_header_group_(false) { | 99 is_repeating_header_group_(false), |
| 100 is_repeating_footer_group_(false) { |
| 100 // init LayoutObject attributes | 101 // init LayoutObject attributes |
| 101 SetInline(false); // our object is not Inline | 102 SetInline(false); // our object is not Inline |
| 102 } | 103 } |
| 103 | 104 |
| 104 LayoutTableSection::~LayoutTableSection() {} | 105 LayoutTableSection::~LayoutTableSection() {} |
| 105 | 106 |
| 106 void LayoutTableSection::StyleDidChange(StyleDifference diff, | 107 void LayoutTableSection::StyleDidChange(StyleDifference diff, |
| 107 const ComputedStyle* old_style) { | 108 const ComputedStyle* old_style) { |
| 108 DCHECK(Style()->Display() == EDisplay::kTableFooterGroup || | 109 DCHECK(Style()->Display() == EDisplay::kTableFooterGroup || |
| 109 Style()->Display() == EDisplay::kTableRowGroup || | 110 Style()->Display() == EDisplay::kTableRowGroup || |
| (...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 DCHECK(!NeedsLayout()); | 1259 DCHECK(!NeedsLayout()); |
| 1259 | 1260 |
| 1260 SetLogicalHeight(LayoutUnit(row_pos_[total_rows])); | 1261 SetLogicalHeight(LayoutUnit(row_pos_[total_rows])); |
| 1261 | 1262 |
| 1262 ComputeOverflowFromDescendants(); | 1263 ComputeOverflowFromDescendants(); |
| 1263 } | 1264 } |
| 1264 | 1265 |
| 1265 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row, | 1266 int LayoutTableSection::PaginationStrutForRow(LayoutTableRow* row, |
| 1266 LayoutUnit logical_offset) const { | 1267 LayoutUnit logical_offset) const { |
| 1267 DCHECK(row); | 1268 DCHECK(row); |
| 1268 if (row->GetPaginationBreakability() == kAllowAnyBreaks) | 1269 const LayoutTableSection* footer = Table()->Footer(); |
| 1270 bool make_room_for_repeating_footer = |
| 1271 footer && footer->IsRepeatingFooterGroup() && row->RowIndex(); |
| 1272 if (!make_room_for_repeating_footer && |
| 1273 row->GetPaginationBreakability() == kAllowAnyBreaks) |
| 1269 return 0; | 1274 return 0; |
| 1270 if (!IsPageLogicalHeightKnown()) | 1275 if (!IsPageLogicalHeightKnown()) |
| 1271 return 0; | 1276 return 0; |
| 1272 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); | 1277 LayoutUnit page_logical_height = PageLogicalHeightForOffset(logical_offset); |
| 1273 // If the row is too tall for the page don't insert a strut. | 1278 // If the row is too tall for the page don't insert a strut. |
| 1274 LayoutUnit row_logical_height = row->LogicalHeight(); | 1279 LayoutUnit row_logical_height = row->LogicalHeight(); |
| 1275 if (row_logical_height > page_logical_height) | 1280 if (row_logical_height > page_logical_height) |
| 1276 return 0; | 1281 return 0; |
| 1277 | 1282 |
| 1278 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( | 1283 LayoutUnit remaining_logical_height = PageRemainingLogicalHeightForOffset( |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 // pagination struts inside some cell in this row that we need to get rid of. | 1958 // pagination struts inside some cell in this row that we need to get rid of. |
| 1954 row_object.SetLogicalTop(row_object.LogicalTop() + pagination_strut); | 1959 row_object.SetLogicalTop(row_object.LogicalTop() + pagination_strut); |
| 1955 layouter.SetChildNeedsLayout(&row_object); | 1960 layouter.SetChildNeedsLayout(&row_object); |
| 1956 row_object.LayoutIfNeeded(); | 1961 row_object.LayoutIfNeeded(); |
| 1957 | 1962 |
| 1958 // It's very likely that re-laying out (and nuking pagination struts inside | 1963 // It's very likely that re-laying out (and nuking pagination struts inside |
| 1959 // cells) gave us a new height. | 1964 // cells) gave us a new height. |
| 1960 row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object))); | 1965 row_object.SetLogicalHeight(LayoutUnit(LogicalHeightForRow(row_object))); |
| 1961 } | 1966 } |
| 1962 | 1967 |
| 1963 bool LayoutTableSection::HeaderGroupShouldRepeat() const { | 1968 bool LayoutTableSection::GroupShouldRepeat() const { |
| 1964 if (Table()->Header() != this) | 1969 DCHECK(Table()->Header() == this || Table()->Footer() == this); |
| 1970 if (GetPaginationBreakability() == kAllowAnyBreaks) |
| 1965 return false; | 1971 return false; |
| 1966 | 1972 |
| 1967 if (GetPaginationBreakability() == kAllowAnyBreaks) | |
| 1968 return false; | |
| 1969 // TODO(rhogan): Sections can be self-painting. | 1973 // TODO(rhogan): Sections can be self-painting. |
| 1970 if (HasSelfPaintingLayer()) | 1974 if (HasSelfPaintingLayer()) |
| 1971 return false; | 1975 return false; |
| 1976 |
| 1972 // If we don't know the page height yet, just assume we fit. | 1977 // If we don't know the page height yet, just assume we fit. |
| 1973 if (!IsPageLogicalHeightKnown()) | 1978 if (!IsPageLogicalHeightKnown()) |
| 1974 return true; | 1979 return true; |
| 1975 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit()); | 1980 LayoutUnit page_height = PageLogicalHeightForOffset(LayoutUnit()); |
| 1976 | 1981 |
| 1977 if (LogicalHeight() > page_height) | 1982 if (LogicalHeight() > page_height) |
| 1978 return false; | 1983 return false; |
| 1979 | 1984 |
| 1980 // See https://drafts.csswg.org/css-tables-3/#repeated-headers which says | 1985 // See https://drafts.csswg.org/css-tables-3/#repeated-headers which says |
| 1981 // a header/footer can repeat if it takes up less than a quarter of the page. | 1986 // a header/footer can repeat if it takes up less than a quarter of the page. |
| 1982 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4) | 1987 if (LogicalHeight() > 0 && page_height / LogicalHeight() < 4) |
| 1983 return false; | 1988 return false; |
| 1984 | 1989 |
| 1985 return true; | 1990 return true; |
| 1986 } | 1991 } |
| 1987 | 1992 |
| 1988 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal( | 1993 bool LayoutTableSection::MapToVisualRectInAncestorSpaceInternal( |
| 1989 const LayoutBoxModelObject* ancestor, | 1994 const LayoutBoxModelObject* ancestor, |
| 1990 TransformState& transform_state, | 1995 TransformState& transform_state, |
| 1991 VisualRectFlags flags) const { | 1996 VisualRectFlags flags) const { |
| 1992 if (ancestor == this) | 1997 if (ancestor == this) |
| 1993 return true; | 1998 return true; |
| 1994 // Repeating table headers are painted once per fragmentation page/column. | 1999 // Repeating table headers and footers are painted once per |
| 2000 // page/column. So we need to use the rect for the entire table because |
| 2001 // the repeating headers/footers will appear throughout it. |
| 1995 // This does not go through the regular fragmentation machinery, so we need | 2002 // This does not go through the regular fragmentation machinery, so we need |
| 1996 // special code to expand the invalidation rect to contain all positions of | 2003 // special code to expand the invalidation rect to contain all positions of |
| 1997 // the header in all columns. | 2004 // the header in all columns. |
| 1998 // Note that this is in flow thread coordinates, not visual coordinates. The | 2005 // Note that this is in flow thread coordinates, not visual coordinates. The |
| 1999 // enclosing LayoutFlowThread will convert to visual coordinates. | 2006 // enclosing LayoutFlowThread will convert to visual coordinates. |
| 2000 if (IsRepeatingHeaderGroup()) { | 2007 if (IsRepeatingHeaderGroup() || IsRepeatingFooterGroup()) { |
| 2001 transform_state.Flatten(); | 2008 transform_state.Flatten(); |
| 2002 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox(); | 2009 FloatRect rect = transform_state.LastPlanarQuad().BoundingBox(); |
| 2003 rect.SetHeight(Table()->LogicalHeight()); | 2010 rect.SetHeight(Table()->LogicalHeight()); |
| 2004 transform_state.SetQuad(FloatQuad(rect)); | 2011 transform_state.SetQuad(FloatQuad(rect)); |
| 2012 return Table()->MapToVisualRectInAncestorSpaceInternal( |
| 2013 ancestor, transform_state, flags); |
| 2005 } | 2014 } |
| 2006 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal( | 2015 return LayoutTableBoxComponent::MapToVisualRectInAncestorSpaceInternal( |
| 2007 ancestor, transform_state, flags); | 2016 ancestor, transform_state, flags); |
| 2008 } | 2017 } |
| 2009 | 2018 |
| 2010 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() | 2019 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() |
| 2011 const { | 2020 const { |
| 2012 // LayoutTableSection paints background from columns. | 2021 // LayoutTableSection paints background from columns. |
| 2013 if (Table()->HasColElements()) | 2022 if (Table()->HasColElements()) |
| 2014 return false; | 2023 return false; |
| 2015 return LayoutTableBoxComponent:: | 2024 return LayoutTableBoxComponent:: |
| 2016 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 2025 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
| 2017 } | 2026 } |
| 2018 | 2027 |
| 2019 } // namespace blink | 2028 } // namespace blink |
| OLD | NEW |