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, 2007, 2008, 2009, 2010, 2013 | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 |
8 * Apple Inc. | 8 * Apple Inc. |
9 * All rights reserved. | 9 * All rights reserved. |
10 * | 10 * |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 if (Section() && Style()->LogicalHeight() != old_style->LogicalHeight()) | 65 if (Section() && Style()->LogicalHeight() != old_style->LogicalHeight()) |
66 Section()->RowLogicalHeightChanged(this); | 66 Section()->RowLogicalHeightChanged(this); |
67 | 67 |
68 if (!Parent()) | 68 if (!Parent()) |
69 return; | 69 return; |
70 LayoutTable* table = this->Table(); | 70 LayoutTable* table = this->Table(); |
71 if (!table) | 71 if (!table) |
72 return; | 72 return; |
73 | 73 |
74 LayoutTableBoxComponent::InvalidateCollapsedBordersOnStyleChange( | 74 if (LayoutTableBoxComponent::NeedsInvalidateCollapsedBordersOnStyleChange( |
75 *this, *table, diff, *old_style); | 75 *this, *table, diff, *old_style)) |
| 76 InvalidateCollapsedBordersOfAffectedCells(); |
76 | 77 |
77 if (LayoutTableBoxComponent::DoCellsHaveDirtyWidth(*this, *table, diff, | 78 if (LayoutTableBoxComponent::DoCellsHaveDirtyWidth(*this, *table, diff, |
78 *old_style)) { | 79 *old_style)) { |
| 80 // TODO(wangxianzhu,dgrogan): The following seems incorrect the row's border |
| 81 // is used by cells not in this row. Could reuse some code in |
| 82 // InvalidateCollapsedBordersOfAffectedCells(). |
79 // If the border width changes on a row, we need to make sure the cells in | 83 // If the border width changes on a row, we need to make sure the cells in |
80 // the row know to lay out again. | 84 // the row know to lay out again. |
81 // This only happens when borders are collapsed, since they end up affecting | 85 // This only happens when borders are collapsed, since they end up affecting |
82 // the border sides of the cell itself. | 86 // the border sides of the cell itself. |
83 for (LayoutBox* child_box = FirstChildBox(); child_box; | 87 for (LayoutBox* child_box = FirstChildBox(); child_box; |
84 child_box = child_box->NextSiblingBox()) { | 88 child_box = child_box->NextSiblingBox()) { |
85 if (!child_box->IsTableCell()) | 89 if (!child_box->IsTableCell()) |
86 continue; | 90 continue; |
87 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is | 91 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is |
88 // needed instead of setNeedsLayout. | 92 // needed instead of setNeedsLayout. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 if (before_child && before_child->Parent() != this) | 163 if (before_child && before_child->Parent() != this) |
160 before_child = SplitAnonymousBoxesAroundChild(before_child); | 164 before_child = SplitAnonymousBoxesAroundChild(before_child); |
161 | 165 |
162 LayoutTableCell* cell = ToLayoutTableCell(child); | 166 LayoutTableCell* cell = ToLayoutTableCell(child); |
163 | 167 |
164 DCHECK(!before_child || before_child->IsTableCell()); | 168 DCHECK(!before_child || before_child->IsTableCell()); |
165 LayoutTableBoxComponent::AddChild(cell, before_child); | 169 LayoutTableBoxComponent::AddChild(cell, before_child); |
166 | 170 |
167 // Generated content can result in us having a null section so make sure to | 171 // Generated content can result in us having a null section so make sure to |
168 // null check our parent. | 172 // null check our parent. |
169 if (Parent()) { | 173 if (!Parent()) |
170 Section()->AddCell(cell, this); | 174 return; |
171 // When borders collapse, adding a cell can affect the the width of | 175 |
172 // neighboring cells. | 176 Section()->AddCell(cell, this); |
173 LayoutTable* enclosing_table = Table(); | |
174 if (enclosing_table && enclosing_table->CollapseBorders()) { | |
175 enclosing_table->InvalidateCollapsedBorders(); | |
176 if (LayoutTableCell* previous_cell = cell->PreviousCell()) | |
177 previous_cell->SetNeedsLayoutAndPrefWidthsRecalc( | |
178 LayoutInvalidationReason::kTableChanged); | |
179 if (LayoutTableCell* next_cell = cell->NextCell()) | |
180 next_cell->SetNeedsLayoutAndPrefWidthsRecalc( | |
181 LayoutInvalidationReason::kTableChanged); | |
182 } | |
183 } | |
184 | 177 |
185 if (before_child || NextRow()) | 178 if (before_child || NextRow()) |
186 Section()->SetNeedsCellRecalc(); | 179 Section()->SetNeedsCellRecalc(); |
| 180 |
| 181 // When borders collapse, adding a cell can affect the the width of |
| 182 // neighboring cells. |
| 183 LayoutTable* enclosing_table = Table(); |
| 184 if (enclosing_table && enclosing_table->CollapseBorders()) { |
| 185 cell->InvalidateCollapsedBordersOfAffectedCells(); |
| 186 // TODO(wangxianzhu,dgrogan): The following seems incorrect if the cell has |
| 187 // adjacent cells other than PreviousCell() and NextCell(). Could reuse some |
| 188 // code in LayoutTableCell::InvalidateCollapsedBordersOfAffectedCells(). |
| 189 if (LayoutTableCell* previous_cell = cell->PreviousCell()) { |
| 190 previous_cell->SetNeedsLayoutAndPrefWidthsRecalc( |
| 191 LayoutInvalidationReason::kTableChanged); |
| 192 } |
| 193 if (LayoutTableCell* next_cell = cell->NextCell()) { |
| 194 next_cell->SetNeedsLayoutAndPrefWidthsRecalc( |
| 195 LayoutInvalidationReason::kTableChanged); |
| 196 } |
| 197 } |
187 } | 198 } |
188 | 199 |
189 void LayoutTableRow::UpdateLayout() { | 200 void LayoutTableRow::UpdateLayout() { |
190 DCHECK(NeedsLayout()); | 201 DCHECK(NeedsLayout()); |
191 LayoutAnalyzer::Scope analyzer(*this); | 202 LayoutAnalyzer::Scope analyzer(*this); |
192 bool paginated = View()->GetLayoutState()->IsPaginated(); | 203 bool paginated = View()->GetLayoutState()->IsPaginated(); |
193 | 204 |
194 for (LayoutTableCell* cell = FirstCell(); cell; cell = cell->NextCell()) { | 205 for (LayoutTableCell* cell = FirstCell(); cell; cell = cell->NextCell()) { |
195 SubtreeLayoutScope layouter(*cell); | 206 SubtreeLayoutScope layouter(*cell); |
196 cell->SetLogicalTop(LogicalTop()); | 207 cell->SetLogicalTop(LogicalTop()); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 // it wants us to drop headers on only the pages that a single row | 337 // it wants us to drop headers on only the pages that a single row |
327 // won't fit but we avoid the complexity of that reading until it | 338 // won't fit but we avoid the complexity of that reading until it |
328 // is clarified. Tracked by crbug.com/675904 | 339 // is clarified. Tracked by crbug.com/675904 |
329 if (RowIndex()) | 340 if (RowIndex()) |
330 return false; | 341 return false; |
331 LayoutTableSection* header = Table()->Header(); | 342 LayoutTableSection* header = Table()->Header(); |
332 return header && Table()->SectionAbove(Section()) == header && | 343 return header && Table()->SectionAbove(Section()) == header && |
333 header->GetPaginationBreakability() != kAllowAnyBreaks; | 344 header->GetPaginationBreakability() != kAllowAnyBreaks; |
334 } | 345 } |
335 | 346 |
| 347 void LayoutTableRow::InvalidateCollapsedBordersOfAffectedCells() { |
| 348 auto* table = Table(); |
| 349 DCHECK(table->CollapseBorders()); |
| 350 if (table->NeedsInvalidateCollapsedBordersForAllCells()) |
| 351 return; |
| 352 |
| 353 table->RecalcSectionsIfNeeded(); |
| 354 table->InvalidateCollapsedBorders(); |
| 355 |
| 356 // Invalidate cells intersecting this row. |
| 357 auto* section = Section(); |
| 358 section->InvalidateCellCollapsedBordersIntersectingRow(RowIndex()); |
| 359 |
| 360 // Invalidate cells above this row. |
| 361 if (RowIndex()) { |
| 362 section->InvalidateCellCollapsedBordersIntersectingRow(RowIndex() - 1); |
| 363 } else if (auto* section_above = |
| 364 table->SectionAbove(section, kSkipEmptySections)) { |
| 365 section_above->InvalidateCellCollapsedBordersIntersectingRow( |
| 366 section_above->NumRows() - 1); |
| 367 } |
| 368 |
| 369 // Invalidate cells below this row. |
| 370 if (RowIndex() + 1 < section->NumRows()) { |
| 371 section->InvalidateCellCollapsedBordersIntersectingRow(RowIndex() + 1); |
| 372 } else if (auto* section_below = |
| 373 table->SectionBelow(section, kSkipEmptySections)) { |
| 374 section_below->InvalidateCellCollapsedBordersIntersectingRow(0); |
| 375 } |
| 376 } |
| 377 |
336 } // namespace blink | 378 } // namespace blink |
OLD | NEW |