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 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 LayoutBlockFlow::ComputeOverflow(old_client_after_edge, recompute_floats); | 411 LayoutBlockFlow::ComputeOverflow(old_client_after_edge, recompute_floats); |
412 | 412 |
413 UpdateCollapsedBorderValues(); | 413 UpdateCollapsedBorderValues(); |
414 if (!collapsed_border_values_) | 414 if (!collapsed_border_values_) |
415 return; | 415 return; |
416 | 416 |
417 // Calculate local visual rect of collapsed borders. | 417 // Calculate local visual rect of collapsed borders. |
418 // Our border rect already includes the inner halves of the collapsed borders, | 418 // Our border rect already includes the inner halves of the collapsed borders, |
419 // so here we get the outer halves. | 419 // so here we get the outer halves. |
420 bool rtl = !StyleForCellFlow().IsLeftToRightDirection(); | 420 bool rtl = !StyleForCellFlow().IsLeftToRightDirection(); |
421 LayoutUnit left = CollapsedBorderHalfLeft(true); | 421 unsigned left = CollapsedBorderHalfLeft(true); |
422 LayoutUnit right = CollapsedBorderHalfRight(true); | 422 unsigned right = CollapsedBorderHalfRight(true); |
423 LayoutUnit top = CollapsedBorderHalfTop(true); | 423 unsigned top = CollapsedBorderHalfTop(true); |
424 LayoutUnit bottom = CollapsedBorderHalfBottom(true); | 424 unsigned bottom = CollapsedBorderHalfBottom(true); |
425 | 425 |
426 // This cell's borders may be lengthened to match the widths of orthogonal | 426 // This cell's borders may be lengthened to match the widths of orthogonal |
427 // borders of adjacent cells. Expand visual overflow to cover the lengthened | 427 // borders of adjacent cells. Expand visual overflow to cover the lengthened |
428 // parts. | 428 // parts. |
429 if ((left && !rtl) || (right && rtl)) { | 429 if ((left && !rtl) || (right && rtl)) { |
430 if (LayoutTableCell* before = Table()->CellBefore(this)) { | 430 if (LayoutTableCell* before = Table()->CellBefore(this)) { |
431 top = std::max(top, before->CollapsedBorderHalfTop(true)); | 431 top = std::max(top, before->CollapsedBorderHalfTop(true)); |
432 bottom = std::max(bottom, before->CollapsedBorderHalfBottom(true)); | 432 bottom = std::max(bottom, before->CollapsedBorderHalfBottom(true)); |
433 } | 433 } |
434 } | 434 } |
(...skipping 10 matching lines...) Expand all Loading... |
445 } | 445 } |
446 } | 446 } |
447 if (bottom) { | 447 if (bottom) { |
448 if (LayoutTableCell* below = Table()->CellBelow(this)) { | 448 if (LayoutTableCell* below = Table()->CellBelow(this)) { |
449 left = std::max(left, below->CollapsedBorderHalfLeft(true)); | 449 left = std::max(left, below->CollapsedBorderHalfLeft(true)); |
450 right = std::max(right, below->CollapsedBorderHalfRight(true)); | 450 right = std::max(right, below->CollapsedBorderHalfRight(true)); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 LayoutRect rect = BorderBoxRect(); | 454 LayoutRect rect = BorderBoxRect(); |
455 rect.ExpandEdges(top, right, bottom, left); | 455 rect.ExpandEdges(LayoutUnit(top), LayoutUnit(right), LayoutUnit(bottom), |
| 456 LayoutUnit(left)); |
456 collapsed_border_values_->SetLocalVisualRect(rect); | 457 collapsed_border_values_->SetLocalVisualRect(rect); |
457 } | 458 } |
458 | 459 |
459 LayoutRect LayoutTableCell::LocalVisualRect() const { | 460 LayoutRect LayoutTableCell::LocalVisualRect() const { |
460 LayoutRect rect = SelfVisualOverflowRect(); | 461 LayoutRect rect = SelfVisualOverflowRect(); |
461 if (collapsed_border_values_) | 462 if (collapsed_border_values_) |
462 rect.Unite(collapsed_border_values_->LocalVisualRect()); | 463 rect.Unite(collapsed_border_values_->LocalVisualRect()); |
463 return rect; | 464 return rect; |
464 } | 465 } |
465 | 466 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 table->ResolveColor(after_color_property), | 1084 table->ResolveColor(after_color_property), |
1084 kBorderPrecedenceTable)); | 1085 kBorderPrecedenceTable)); |
1085 if (!result.Exists()) | 1086 if (!result.Exists()) |
1086 return result; | 1087 return result; |
1087 } | 1088 } |
1088 | 1089 |
1089 return result; | 1090 return result; |
1090 } | 1091 } |
1091 | 1092 |
1092 LayoutUnit LayoutTableCell::BorderLeft() const { | 1093 LayoutUnit LayoutTableCell::BorderLeft() const { |
1093 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfLeft(false) | 1094 return Table()->ShouldCollapseBorders() |
1094 : LayoutBlockFlow::BorderLeft(); | 1095 ? LayoutUnit(CollapsedBorderHalfLeft(false)) |
| 1096 : LayoutBlockFlow::BorderLeft(); |
1095 } | 1097 } |
1096 | 1098 |
1097 LayoutUnit LayoutTableCell::BorderRight() const { | 1099 LayoutUnit LayoutTableCell::BorderRight() const { |
1098 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfRight(false) | 1100 return Table()->ShouldCollapseBorders() |
1099 : LayoutBlockFlow::BorderRight(); | 1101 ? LayoutUnit(CollapsedBorderHalfRight(false)) |
| 1102 : LayoutBlockFlow::BorderRight(); |
1100 } | 1103 } |
1101 | 1104 |
1102 LayoutUnit LayoutTableCell::BorderTop() const { | 1105 LayoutUnit LayoutTableCell::BorderTop() const { |
1103 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfTop(false) | 1106 return Table()->ShouldCollapseBorders() |
1104 : LayoutBlockFlow::BorderTop(); | 1107 ? LayoutUnit(CollapsedBorderHalfTop(false)) |
| 1108 : LayoutBlockFlow::BorderTop(); |
1105 } | 1109 } |
1106 | 1110 |
1107 LayoutUnit LayoutTableCell::BorderBottom() const { | 1111 LayoutUnit LayoutTableCell::BorderBottom() const { |
1108 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfBottom(false) | 1112 return Table()->ShouldCollapseBorders() |
1109 : LayoutBlockFlow::BorderBottom(); | 1113 ? LayoutUnit(CollapsedBorderHalfBottom(false)) |
| 1114 : LayoutBlockFlow::BorderBottom(); |
1110 } | 1115 } |
1111 | 1116 |
1112 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed | 1117 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=46191, make the collapsed |
1113 // border drawing work with different block flow values instead of being | 1118 // border drawing work with different block flow values instead of being |
1114 // hard-coded to top-to-bottom. | 1119 // hard-coded to top-to-bottom. |
1115 LayoutUnit LayoutTableCell::BorderStart() const { | 1120 LayoutUnit LayoutTableCell::BorderStart() const { |
1116 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfStart(false) | 1121 return Table()->ShouldCollapseBorders() |
1117 : LayoutBlockFlow::BorderStart(); | 1122 ? LayoutUnit(CollapsedBorderHalfStart(false)) |
| 1123 : LayoutBlockFlow::BorderStart(); |
1118 } | 1124 } |
1119 | 1125 |
1120 LayoutUnit LayoutTableCell::BorderEnd() const { | 1126 LayoutUnit LayoutTableCell::BorderEnd() const { |
1121 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfEnd(false) | 1127 return Table()->ShouldCollapseBorders() |
1122 : LayoutBlockFlow::BorderEnd(); | 1128 ? LayoutUnit(CollapsedBorderHalfEnd(false)) |
| 1129 : LayoutBlockFlow::BorderEnd(); |
1123 } | 1130 } |
1124 | 1131 |
1125 LayoutUnit LayoutTableCell::BorderBefore() const { | 1132 LayoutUnit LayoutTableCell::BorderBefore() const { |
1126 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfBefore(false) | 1133 return Table()->ShouldCollapseBorders() |
1127 : LayoutBlockFlow::BorderBefore(); | 1134 ? LayoutUnit(CollapsedBorderHalfBefore(false)) |
| 1135 : LayoutBlockFlow::BorderBefore(); |
1128 } | 1136 } |
1129 | 1137 |
1130 LayoutUnit LayoutTableCell::BorderAfter() const { | 1138 LayoutUnit LayoutTableCell::BorderAfter() const { |
1131 return Table()->ShouldCollapseBorders() ? CollapsedBorderHalfAfter(false) | 1139 return Table()->ShouldCollapseBorders() |
1132 : LayoutBlockFlow::BorderAfter(); | 1140 ? LayoutUnit(CollapsedBorderHalfAfter(false)) |
| 1141 : LayoutBlockFlow::BorderAfter(); |
1133 } | 1142 } |
1134 | 1143 |
1135 LayoutUnit LayoutTableCell::CollapsedBorderHalfLeft(bool outer) const { | 1144 unsigned LayoutTableCell::CollapsedBorderHalfLeft(bool outer) const { |
1136 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); | 1145 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); |
1137 if (style_for_cell_flow.IsHorizontalWritingMode()) { | 1146 if (style_for_cell_flow.IsHorizontalWritingMode()) { |
1138 return style_for_cell_flow.IsLeftToRightDirection() | 1147 return style_for_cell_flow.IsLeftToRightDirection() |
1139 ? CollapsedBorderHalfStart(outer) | 1148 ? CollapsedBorderHalfStart(outer) |
1140 : CollapsedBorderHalfEnd(outer); | 1149 : CollapsedBorderHalfEnd(outer); |
1141 } | 1150 } |
1142 return style_for_cell_flow.IsFlippedBlocksWritingMode() | 1151 return style_for_cell_flow.IsFlippedBlocksWritingMode() |
1143 ? CollapsedBorderHalfAfter(outer) | 1152 ? CollapsedBorderHalfAfter(outer) |
1144 : CollapsedBorderHalfBefore(outer); | 1153 : CollapsedBorderHalfBefore(outer); |
1145 } | 1154 } |
1146 | 1155 |
1147 LayoutUnit LayoutTableCell::CollapsedBorderHalfRight(bool outer) const { | 1156 unsigned LayoutTableCell::CollapsedBorderHalfRight(bool outer) const { |
1148 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); | 1157 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); |
1149 if (style_for_cell_flow.IsHorizontalWritingMode()) { | 1158 if (style_for_cell_flow.IsHorizontalWritingMode()) { |
1150 return style_for_cell_flow.IsLeftToRightDirection() | 1159 return style_for_cell_flow.IsLeftToRightDirection() |
1151 ? CollapsedBorderHalfEnd(outer) | 1160 ? CollapsedBorderHalfEnd(outer) |
1152 : CollapsedBorderHalfStart(outer); | 1161 : CollapsedBorderHalfStart(outer); |
1153 } | 1162 } |
1154 return style_for_cell_flow.IsFlippedBlocksWritingMode() | 1163 return style_for_cell_flow.IsFlippedBlocksWritingMode() |
1155 ? CollapsedBorderHalfBefore(outer) | 1164 ? CollapsedBorderHalfBefore(outer) |
1156 : CollapsedBorderHalfAfter(outer); | 1165 : CollapsedBorderHalfAfter(outer); |
1157 } | 1166 } |
1158 | 1167 |
1159 LayoutUnit LayoutTableCell::CollapsedBorderHalfTop(bool outer) const { | 1168 unsigned LayoutTableCell::CollapsedBorderHalfTop(bool outer) const { |
1160 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); | 1169 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); |
1161 if (style_for_cell_flow.IsHorizontalWritingMode()) { | 1170 if (style_for_cell_flow.IsHorizontalWritingMode()) { |
1162 return style_for_cell_flow.IsFlippedBlocksWritingMode() | 1171 return style_for_cell_flow.IsFlippedBlocksWritingMode() |
1163 ? CollapsedBorderHalfAfter(outer) | 1172 ? CollapsedBorderHalfAfter(outer) |
1164 : CollapsedBorderHalfBefore(outer); | 1173 : CollapsedBorderHalfBefore(outer); |
1165 } | 1174 } |
1166 return style_for_cell_flow.IsLeftToRightDirection() | 1175 return style_for_cell_flow.IsLeftToRightDirection() |
1167 ? CollapsedBorderHalfStart(outer) | 1176 ? CollapsedBorderHalfStart(outer) |
1168 : CollapsedBorderHalfEnd(outer); | 1177 : CollapsedBorderHalfEnd(outer); |
1169 } | 1178 } |
1170 | 1179 |
1171 LayoutUnit LayoutTableCell::CollapsedBorderHalfBottom(bool outer) const { | 1180 unsigned LayoutTableCell::CollapsedBorderHalfBottom(bool outer) const { |
1172 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); | 1181 const ComputedStyle& style_for_cell_flow = this->StyleForCellFlow(); |
1173 if (style_for_cell_flow.IsHorizontalWritingMode()) { | 1182 if (style_for_cell_flow.IsHorizontalWritingMode()) { |
1174 return style_for_cell_flow.IsFlippedBlocksWritingMode() | 1183 return style_for_cell_flow.IsFlippedBlocksWritingMode() |
1175 ? CollapsedBorderHalfBefore(outer) | 1184 ? CollapsedBorderHalfBefore(outer) |
1176 : CollapsedBorderHalfAfter(outer); | 1185 : CollapsedBorderHalfAfter(outer); |
1177 } | 1186 } |
1178 return style_for_cell_flow.IsLeftToRightDirection() | 1187 return style_for_cell_flow.IsLeftToRightDirection() |
1179 ? CollapsedBorderHalfEnd(outer) | 1188 ? CollapsedBorderHalfEnd(outer) |
1180 : CollapsedBorderHalfStart(outer); | 1189 : CollapsedBorderHalfStart(outer); |
1181 } | 1190 } |
1182 | 1191 |
1183 LayoutUnit LayoutTableCell::CollapsedBorderHalfStart(bool outer) const { | 1192 unsigned LayoutTableCell::CollapsedBorderHalfStart(bool outer) const { |
1184 UpdateCollapsedBorderValues(); | 1193 UpdateCollapsedBorderValues(); |
1185 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); | 1194 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); |
1186 if (!collapsed_border_values) | 1195 if (!collapsed_border_values) |
1187 return LayoutUnit(); | 1196 return 0; |
1188 | 1197 |
1189 const auto& border = collapsed_border_values->StartBorder(); | 1198 const auto& border = collapsed_border_values->StartBorder(); |
1190 if (border.Exists()) { | 1199 if (border.Exists()) { |
1191 return LayoutUnit( | 1200 return (border.Width() + |
1192 (border.Width() + | 1201 ((StyleForCellFlow().IsLeftToRightDirection() ^ outer) ? 1 : 0)) / |
1193 ((StyleForCellFlow().IsLeftToRightDirection() ^ outer) ? 1 : 0)) / | 1202 2; // Give the extra pixel to top and left. |
1194 2); // Give the extra pixel to top and left. | |
1195 } | 1203 } |
1196 return LayoutUnit(); | 1204 return 0; |
1197 } | 1205 } |
1198 | 1206 |
1199 LayoutUnit LayoutTableCell::CollapsedBorderHalfEnd(bool outer) const { | 1207 unsigned LayoutTableCell::CollapsedBorderHalfEnd(bool outer) const { |
1200 UpdateCollapsedBorderValues(); | 1208 UpdateCollapsedBorderValues(); |
1201 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); | 1209 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); |
1202 if (!collapsed_border_values) | 1210 if (!collapsed_border_values) |
1203 return LayoutUnit(); | 1211 return 0; |
1204 | 1212 |
1205 const auto& border = collapsed_border_values->EndBorder(); | 1213 const auto& border = collapsed_border_values->EndBorder(); |
1206 if (border.Exists()) { | 1214 if (border.Exists()) { |
1207 return LayoutUnit( | 1215 return (border.Width() + |
1208 (border.Width() + | 1216 ((StyleForCellFlow().IsLeftToRightDirection() ^ outer) ? 0 : 1)) / |
1209 ((StyleForCellFlow().IsLeftToRightDirection() ^ outer) ? 0 : 1)) / | 1217 2; |
1210 2); | |
1211 } | 1218 } |
1212 return LayoutUnit(); | 1219 return 0; |
1213 } | 1220 } |
1214 | 1221 |
1215 LayoutUnit LayoutTableCell::CollapsedBorderHalfBefore(bool outer) const { | 1222 unsigned LayoutTableCell::CollapsedBorderHalfBefore(bool outer) const { |
1216 UpdateCollapsedBorderValues(); | 1223 UpdateCollapsedBorderValues(); |
1217 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); | 1224 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); |
1218 if (!collapsed_border_values) | 1225 if (!collapsed_border_values) |
1219 return LayoutUnit(); | 1226 return 0; |
1220 | 1227 |
1221 const auto& border = collapsed_border_values->BeforeBorder(); | 1228 const auto& border = collapsed_border_values->BeforeBorder(); |
1222 if (border.Exists()) { | 1229 if (border.Exists()) { |
1223 return LayoutUnit( | 1230 return (border.Width() + |
1224 (border.Width() + | 1231 ((StyleForCellFlow().IsFlippedBlocksWritingMode() ^ outer) ? 0 |
1225 ((StyleForCellFlow().IsFlippedBlocksWritingMode() ^ outer) ? 0 : 1)) / | 1232 : 1)) / |
1226 2); // Give the extra pixel to top and left. | 1233 2; // Give the extra pixel to top and left. |
1227 } | 1234 } |
1228 return LayoutUnit(); | 1235 return 0; |
1229 } | 1236 } |
1230 | 1237 |
1231 LayoutUnit LayoutTableCell::CollapsedBorderHalfAfter(bool outer) const { | 1238 unsigned LayoutTableCell::CollapsedBorderHalfAfter(bool outer) const { |
1232 UpdateCollapsedBorderValues(); | 1239 UpdateCollapsedBorderValues(); |
1233 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); | 1240 const auto* collapsed_border_values = this->GetCollapsedBorderValues(); |
1234 if (!collapsed_border_values) | 1241 if (!collapsed_border_values) |
1235 return LayoutUnit(); | 1242 return 0; |
1236 | 1243 |
1237 const auto& border = collapsed_border_values->AfterBorder(); | 1244 const auto& border = collapsed_border_values->AfterBorder(); |
1238 if (border.Exists()) { | 1245 if (border.Exists()) { |
1239 return LayoutUnit( | 1246 return (border.Width() + |
1240 (border.Width() + | 1247 ((StyleForCellFlow().IsFlippedBlocksWritingMode() ^ outer) ? 1 |
1241 ((StyleForCellFlow().IsFlippedBlocksWritingMode() ^ outer) ? 1 : 0)) / | 1248 : 0)) / |
1242 2); | 1249 2; |
1243 } | 1250 } |
1244 return LayoutUnit(); | 1251 return 0; |
1245 } | 1252 } |
1246 | 1253 |
1247 void LayoutTableCell::Paint(const PaintInfo& paint_info, | 1254 void LayoutTableCell::Paint(const PaintInfo& paint_info, |
1248 const LayoutPoint& paint_offset) const { | 1255 const LayoutPoint& paint_offset) const { |
1249 TableCellPainter(*this).Paint(paint_info, paint_offset); | 1256 TableCellPainter(*this).Paint(paint_info, paint_offset); |
1250 } | 1257 } |
1251 | 1258 |
1252 void LayoutTableCell::UpdateCollapsedBorderValues() const { | 1259 void LayoutTableCell::UpdateCollapsedBorderValues() const { |
1253 if (!Table()->ShouldCollapseBorders()) { | 1260 if (!Table()->ShouldCollapseBorders()) { |
1254 if (collapsed_border_values_) { | 1261 if (collapsed_border_values_) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 | 1472 |
1466 return LayoutBlock::HasLineIfEmpty(); | 1473 return LayoutBlock::HasLineIfEmpty(); |
1467 } | 1474 } |
1468 | 1475 |
1469 PaintInvalidationReason LayoutTableCell::InvalidatePaint( | 1476 PaintInvalidationReason LayoutTableCell::InvalidatePaint( |
1470 const PaintInvalidatorContext& context) const { | 1477 const PaintInvalidatorContext& context) const { |
1471 return TableCellPaintInvalidator(*this, context).InvalidatePaint(); | 1478 return TableCellPaintInvalidator(*this, context).InvalidatePaint(); |
1472 } | 1479 } |
1473 | 1480 |
1474 } // namespace blink | 1481 } // namespace blink |
OLD | NEW |