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

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

Issue 2850633003: Rename LayoutTable::CollapseBorders() to ShouldCollapseBorders() (Closed)
Patch Set: Rebase Created 3 years, 7 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, 2007, 2008, 2009 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 void LayoutTableCell::WillBeRemovedFromTree() { 101 void LayoutTableCell::WillBeRemovedFromTree() {
102 LayoutBlockFlow::WillBeRemovedFromTree(); 102 LayoutBlockFlow::WillBeRemovedFromTree();
103 103
104 Section()->SetNeedsCellRecalc(); 104 Section()->SetNeedsCellRecalc();
105 105
106 // When borders collapse, removing a cell can affect the the width of 106 // When borders collapse, removing a cell can affect the the width of
107 // neighboring cells. 107 // neighboring cells.
108 LayoutTable* enclosing_table = Table(); 108 LayoutTable* enclosing_table = Table();
109 DCHECK(enclosing_table); 109 DCHECK(enclosing_table);
110 if (!enclosing_table->CollapseBorders()) 110 if (!enclosing_table->ShouldCollapseBorders())
111 return; 111 return;
112 if (PreviousCell()) { 112 if (PreviousCell()) {
113 // TODO(dgrogan): Should this be setChildNeedsLayout or setNeedsLayout? 113 // TODO(dgrogan): Should this be setChildNeedsLayout or setNeedsLayout?
114 // remove-cell-with-border-box.html only passes with setNeedsLayout but 114 // remove-cell-with-border-box.html only passes with setNeedsLayout but
115 // other places use setChildNeedsLayout. 115 // other places use setChildNeedsLayout.
116 PreviousCell()->SetNeedsLayout(LayoutInvalidationReason::kTableChanged); 116 PreviousCell()->SetNeedsLayout(LayoutInvalidationReason::kTableChanged);
117 PreviousCell()->SetPreferredLogicalWidthsDirty(); 117 PreviousCell()->SetPreferredLogicalWidthsDirty();
118 } 118 }
119 if (NextCell()) { 119 if (NextCell()) {
120 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout. 120 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout.
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 408
409 return offset; 409 return offset;
410 } 410 }
411 411
412 LayoutRect LayoutTableCell::LocalVisualRect() const { 412 LayoutRect LayoutTableCell::LocalVisualRect() const {
413 // If the table grid is dirty, we cannot get reliable information about 413 // If the table grid is dirty, we cannot get reliable information about
414 // adjoining cells, so we ignore outside borders. This should not be a problem 414 // adjoining cells, so we ignore outside borders. This should not be a problem
415 // because it means that the table is going to recalculate the grid, relayout 415 // because it means that the table is going to recalculate the grid, relayout
416 // and issue a paint invalidation of its current rect, which includes any 416 // and issue a paint invalidation of its current rect, which includes any
417 // outside borders of this cell. 417 // outside borders of this cell.
418 if (!Table()->CollapseBorders() || Table()->NeedsSectionRecalc()) 418 if (!Table()->ShouldCollapseBorders() || Table()->NeedsSectionRecalc())
419 return LayoutBlockFlow::LocalVisualRect(); 419 return LayoutBlockFlow::LocalVisualRect();
420 420
421 bool rtl = !StyleForCellFlow().IsLeftToRightDirection(); 421 bool rtl = !StyleForCellFlow().IsLeftToRightDirection();
422 LayoutUnit outline_outset(Style()->OutlineOutsetExtent()); 422 LayoutUnit outline_outset(Style()->OutlineOutsetExtent());
423 LayoutUnit left(std::max(CollapsedBorderHalfLeft(true), outline_outset)); 423 LayoutUnit left(std::max(CollapsedBorderHalfLeft(true), outline_outset));
424 LayoutUnit right(std::max(CollapsedBorderHalfRight(true), outline_outset)); 424 LayoutUnit right(std::max(CollapsedBorderHalfRight(true), outline_outset));
425 LayoutUnit top(std::max(CollapsedBorderHalfTop(true), outline_outset)); 425 LayoutUnit top(std::max(CollapsedBorderHalfTop(true), outline_outset));
426 LayoutUnit bottom(std::max(CollapsedBorderHalfBottom(true), outline_outset)); 426 LayoutUnit bottom(std::max(CollapsedBorderHalfBottom(true), outline_outset));
427 if ((left && !rtl) || (right && rtl)) { 427 if ((left && !rtl) || (right && rtl)) {
428 if (LayoutTableCell* before = Table()->CellBefore(this)) { 428 if (LayoutTableCell* before = Table()->CellBefore(this)) {
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 table->ResolveColor(after_color_property), 1095 table->ResolveColor(after_color_property),
1096 kBorderPrecedenceTable)); 1096 kBorderPrecedenceTable));
1097 if (!result.Exists()) 1097 if (!result.Exists())
1098 return result; 1098 return result;
1099 } 1099 }
1100 1100
1101 return result; 1101 return result;
1102 } 1102 }
1103 1103
1104 LayoutUnit LayoutTableCell::BorderLeft() const { 1104 LayoutUnit LayoutTableCell::BorderLeft() const {
1105 return Table()->CollapseBorders() ? CollapsedBorderHalfLeft(false) 1105 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfLeft(false)
1106 : LayoutBlockFlow::BorderLeft(); 1106 : LayoutBlockFlow::BorderLeft();
1107 } 1107 }
1108 1108
1109 LayoutUnit LayoutTableCell::BorderRight() const { 1109 LayoutUnit LayoutTableCell::BorderRight() const {
1110 return Table()->CollapseBorders() ? CollapsedBorderHalfRight(false) 1110 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfRight(false)
1111 : LayoutBlockFlow::BorderRight(); 1111 : LayoutBlockFlow::BorderRight();
1112 } 1112 }
1113 1113
1114 LayoutUnit LayoutTableCell::BorderTop() const { 1114 LayoutUnit LayoutTableCell::BorderTop() const {
1115 return Table()->CollapseBorders() ? CollapsedBorderHalfTop(false) 1115 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfTop(false)
1116 : LayoutBlockFlow::BorderTop(); 1116 : LayoutBlockFlow::BorderTop();
1117 } 1117 }
1118 1118
1119 LayoutUnit LayoutTableCell::BorderBottom() const { 1119 LayoutUnit LayoutTableCell::BorderBottom() const {
1120 return Table()->CollapseBorders() ? CollapsedBorderHalfBottom(false) 1120 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfBottom(false)
1121 : LayoutBlockFlow::BorderBottom(); 1121 : LayoutBlockFlow::BorderBottom();
1122 } 1122 }
1123 1123
1124 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed 1124 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed
1125 // border drawing work with different block flow values instead of being 1125 // border drawing work with different block flow values instead of being
1126 // hard-coded to top-to-bottom. 1126 // hard-coded to top-to-bottom.
1127 LayoutUnit LayoutTableCell::BorderStart() const { 1127 LayoutUnit LayoutTableCell::BorderStart() const {
1128 return Table()->CollapseBorders() ? CollapsedBorderHalfStart(false) 1128 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfStart(false)
1129 : LayoutBlockFlow::BorderStart(); 1129 : LayoutBlockFlow::BorderStart();
1130 } 1130 }
1131 1131
1132 LayoutUnit LayoutTableCell::BorderEnd() const { 1132 LayoutUnit LayoutTableCell::BorderEnd() const {
1133 return Table()->CollapseBorders() ? CollapsedBorderHalfEnd(false) 1133 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfEnd(false)
1134 : LayoutBlockFlow::BorderEnd(); 1134 : LayoutBlockFlow::BorderEnd();
1135 } 1135 }
1136 1136
1137 LayoutUnit LayoutTableCell::BorderBefore() const { 1137 LayoutUnit LayoutTableCell::BorderBefore() const {
1138 return Table()->CollapseBorders() ? CollapsedBorderHalfBefore(false) 1138 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfBefore(false)
1139 : LayoutBlockFlow::BorderBefore(); 1139 : LayoutBlockFlow::BorderBefore();
1140 } 1140 }
1141 1141
1142 LayoutUnit LayoutTableCell::BorderAfter() const { 1142 LayoutUnit LayoutTableCell::BorderAfter() const {
1143 return Table()->CollapseBorders() ? CollapsedBorderHalfAfter(false) 1143 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfAfter(false)
1144 : LayoutBlockFlow::BorderAfter(); 1144 : LayoutBlockFlow::BorderAfter();
1145 } 1145 }
1146 1146
1147 LayoutUnit LayoutTableCell::CollapsedBorderHalfLeft(bool outer) const { 1147 LayoutUnit LayoutTableCell::CollapsedBorderHalfLeft(bool outer) const {
1148 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); 1148 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow();
1149 if (style_for_cell_flow.IsHorizontalWritingMode()) { 1149 if (style_for_cell_flow.IsHorizontalWritingMode()) {
1150 return style_for_cell_flow.IsLeftToRightDirection() 1150 return style_for_cell_flow.IsLeftToRightDirection()
1151 ? CollapsedBorderHalfStart(outer) 1151 ? CollapsedBorderHalfStart(outer)
1152 : CollapsedBorderHalfEnd(outer); 1152 : CollapsedBorderHalfEnd(outer);
1153 } 1153 }
1154 return style_for_cell_flow.IsFlippedBlocksWritingMode() 1154 return style_for_cell_flow.IsFlippedBlocksWritingMode()
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 TableCellPainter(*this).Paint(paint_info, paint_offset); 1261 TableCellPainter(*this).Paint(paint_info, paint_offset);
1262 } 1262 }
1263 1263
1264 void LayoutTableCell::UpdateCollapsedBorderValues() const { 1264 void LayoutTableCell::UpdateCollapsedBorderValues() const {
1265 Table()->InvalidateCollapsedBordersForAllCellsIfNeeded(); 1265 Table()->InvalidateCollapsedBordersForAllCellsIfNeeded();
1266 if (collapsed_border_values_valid_) 1266 if (collapsed_border_values_valid_)
1267 return; 1267 return;
1268 1268
1269 collapsed_border_values_valid_ = true; 1269 collapsed_border_values_valid_ = true;
1270 1270
1271 if (!Table()->CollapseBorders()) { 1271 if (!Table()->ShouldCollapseBorders()) {
1272 if (collapsed_border_values_) { 1272 if (collapsed_border_values_) {
1273 collapsed_borders_visually_changed_ = true; 1273 collapsed_borders_visually_changed_ = true;
1274 collapsed_border_values_ = nullptr; 1274 collapsed_border_values_ = nullptr;
1275 } 1275 }
1276 return; 1276 return;
1277 } 1277 }
1278 1278
1279 CollapsedBorderValues new_values( 1279 CollapsedBorderValues new_values(
1280 *this, ComputeCollapsedStartBorder(), ComputeCollapsedEndBorder(), 1280 *this, ComputeCollapsedStartBorder(), ComputeCollapsedEndBorder(),
1281 ComputeCollapsedBeforeBorder(), ComputeCollapsedAfterBorder()); 1281 ComputeCollapsedBeforeBorder(), ComputeCollapsedAfterBorder());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 EDisplay::kTableCell); 1419 EDisplay::kTableCell);
1420 new_cell->SetStyle(std::move(new_style)); 1420 new_cell->SetStyle(std::move(new_style));
1421 return new_cell; 1421 return new_cell;
1422 } 1422 }
1423 1423
1424 bool LayoutTableCell::BackgroundIsKnownToBeOpaqueInRect( 1424 bool LayoutTableCell::BackgroundIsKnownToBeOpaqueInRect(
1425 const LayoutRect& local_rect) const { 1425 const LayoutRect& local_rect) const {
1426 // If this object has layer, the area of collapsed borders should be 1426 // If this object has layer, the area of collapsed borders should be
1427 // transparent to expose the collapsed borders painted on the underlying 1427 // transparent to expose the collapsed borders painted on the underlying
1428 // layer. 1428 // layer.
1429 if (HasLayer() && Table()->CollapseBorders()) 1429 if (HasLayer() && Table()->ShouldCollapseBorders())
1430 return false; 1430 return false;
1431 return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect); 1431 return LayoutBlockFlow::BackgroundIsKnownToBeOpaqueInRect(local_rect);
1432 } 1432 }
1433 1433
1434 bool LayoutTableCell::UsesCompositedCellDisplayItemClients() const { 1434 bool LayoutTableCell::UsesCompositedCellDisplayItemClients() const {
1435 // In certain cases such as collapsed borders for composited table cells we 1435 // In certain cases such as collapsed borders for composited table cells we
1436 // paint content for the cell into the table graphics layer backing and so 1436 // paint content for the cell into the table graphics layer backing and so
1437 // must use the table's visual rect. 1437 // must use the table's visual rect.
1438 return (HasLayer() && Layer()->GetCompositingState() != kNotComposited) || 1438 return (HasLayer() && Layer()->GetCompositingState() != kNotComposited) ||
1439 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); 1439 RuntimeEnabledFeatures::slimmingPaintV2Enabled();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 const PaintInvalidatorContext& context) const { 1482 const PaintInvalidatorContext& context) const {
1483 return TableCellPaintInvalidator(*this, context).InvalidatePaint(); 1483 return TableCellPaintInvalidator(*this, context).InvalidatePaint();
1484 } 1484 }
1485 1485
1486 PaintInvalidationReason LayoutTableCell::InvalidatePaint( 1486 PaintInvalidationReason LayoutTableCell::InvalidatePaint(
1487 const PaintInvalidationState& state) { 1487 const PaintInvalidationState& state) {
1488 return LayoutBlockFlow::InvalidatePaint(state); 1488 return LayoutBlockFlow::InvalidatePaint(state);
1489 } 1489 }
1490 1490
1491 } // namespace blink 1491 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698