| 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 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 return LayoutBlock::BorderStart().ToInt(); | 1183 return LayoutBlock::BorderStart().ToInt(); |
| 1184 | 1184 |
| 1185 // Determined by the first cell of the first row. See the CSS 2.1 spec, | 1185 // Determined by the first cell of the first row. See the CSS 2.1 spec, |
| 1186 // section 17.6.2. | 1186 // section 17.6.2. |
| 1187 if (!NumEffectiveColumns()) | 1187 if (!NumEffectiveColumns()) |
| 1188 return 0; | 1188 return 0; |
| 1189 | 1189 |
| 1190 int border_width = 0; | 1190 int border_width = 0; |
| 1191 | 1191 |
| 1192 const BorderValue& table_start_border = Style()->BorderStart(); | 1192 const BorderValue& table_start_border = Style()->BorderStart(); |
| 1193 if (table_start_border.Style() == kBorderStyleHidden) | 1193 if (table_start_border.Style() == EBorderStyle::kHidden) |
| 1194 return 0; | 1194 return 0; |
| 1195 if (table_start_border.Style() > kBorderStyleHidden) | 1195 if (table_start_border.Style() > EBorderStyle::kHidden) |
| 1196 border_width = table_start_border.Width(); | 1196 border_width = table_start_border.Width(); |
| 1197 | 1197 |
| 1198 // TODO(dgrogan): This logic doesn't properly account for the first column in | 1198 // TODO(dgrogan): This logic doesn't properly account for the first column in |
| 1199 // the first column-group case. | 1199 // the first column-group case. |
| 1200 if (LayoutTableCol* column = | 1200 if (LayoutTableCol* column = |
| 1201 ColElementAtAbsoluteColumn(0).InnermostColOrColGroup()) { | 1201 ColElementAtAbsoluteColumn(0).InnermostColOrColGroup()) { |
| 1202 // FIXME: We don't account for direction on columns and column groups. | 1202 // FIXME: We don't account for direction on columns and column groups. |
| 1203 const BorderValue& column_adjoining_border = column->Style()->BorderStart(); | 1203 const BorderValue& column_adjoining_border = column->Style()->BorderStart(); |
| 1204 if (column_adjoining_border.Style() == kBorderStyleHidden) | 1204 if (column_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1205 return 0; | 1205 return 0; |
| 1206 if (column_adjoining_border.Style() > kBorderStyleHidden) | 1206 if (column_adjoining_border.Style() > EBorderStyle::kHidden) |
| 1207 border_width = | 1207 border_width = |
| 1208 std::max<int>(border_width, column_adjoining_border.Width()); | 1208 std::max<int>(border_width, column_adjoining_border.Width()); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 if (const LayoutTableSection* top_non_empty_section = | 1211 if (const LayoutTableSection* top_non_empty_section = |
| 1212 this->TopNonEmptySection()) { | 1212 this->TopNonEmptySection()) { |
| 1213 const BorderValue& section_adjoining_border = | 1213 const BorderValue& section_adjoining_border = |
| 1214 top_non_empty_section->BorderAdjoiningTableStart(); | 1214 top_non_empty_section->BorderAdjoiningTableStart(); |
| 1215 if (section_adjoining_border.Style() == kBorderStyleHidden) | 1215 if (section_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1216 return 0; | 1216 return 0; |
| 1217 | 1217 |
| 1218 if (section_adjoining_border.Style() > kBorderStyleHidden) | 1218 if (section_adjoining_border.Style() > EBorderStyle::kHidden) |
| 1219 border_width = | 1219 border_width = |
| 1220 std::max<int>(border_width, section_adjoining_border.Width()); | 1220 std::max<int>(border_width, section_adjoining_border.Width()); |
| 1221 | 1221 |
| 1222 if (const LayoutTableCell* adjoining_start_cell = | 1222 if (const LayoutTableCell* adjoining_start_cell = |
| 1223 top_non_empty_section->FirstRowCellAdjoiningTableStart()) { | 1223 top_non_empty_section->FirstRowCellAdjoiningTableStart()) { |
| 1224 // FIXME: Make this work with perpendicular and flipped cells. | 1224 // FIXME: Make this work with perpendicular and flipped cells. |
| 1225 const BorderValue& start_cell_adjoining_border = | 1225 const BorderValue& start_cell_adjoining_border = |
| 1226 adjoining_start_cell->BorderAdjoiningTableStart(); | 1226 adjoining_start_cell->BorderAdjoiningTableStart(); |
| 1227 if (start_cell_adjoining_border.Style() == kBorderStyleHidden) | 1227 if (start_cell_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1228 return 0; | 1228 return 0; |
| 1229 | 1229 |
| 1230 const BorderValue& first_row_adjoining_border = | 1230 const BorderValue& first_row_adjoining_border = |
| 1231 adjoining_start_cell->Row()->BorderAdjoiningTableStart(); | 1231 adjoining_start_cell->Row()->BorderAdjoiningTableStart(); |
| 1232 if (first_row_adjoining_border.Style() == kBorderStyleHidden) | 1232 if (first_row_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1233 return 0; | 1233 return 0; |
| 1234 | 1234 |
| 1235 if (start_cell_adjoining_border.Style() > kBorderStyleHidden) { | 1235 if (start_cell_adjoining_border.Style() > EBorderStyle::kHidden) { |
| 1236 border_width = | 1236 border_width = |
| 1237 std::max<int>(border_width, start_cell_adjoining_border.Width()); | 1237 std::max<int>(border_width, start_cell_adjoining_border.Width()); |
| 1238 } | 1238 } |
| 1239 if (first_row_adjoining_border.Style() > kBorderStyleHidden) { | 1239 if (first_row_adjoining_border.Style() > EBorderStyle::kHidden) { |
| 1240 border_width = | 1240 border_width = |
| 1241 std::max<int>(border_width, first_row_adjoining_border.Width()); | 1241 std::max<int>(border_width, first_row_adjoining_border.Width()); |
| 1242 } | 1242 } |
| 1243 } | 1243 } |
| 1244 } | 1244 } |
| 1245 return (border_width + (Style()->IsLeftToRightDirection() ? 0 : 1)) / 2; | 1245 return (border_width + (Style()->IsLeftToRightDirection() ? 0 : 1)) / 2; |
| 1246 } | 1246 } |
| 1247 | 1247 |
| 1248 int LayoutTable::CalcBorderEnd() const { | 1248 int LayoutTable::CalcBorderEnd() const { |
| 1249 if (!ShouldCollapseBorders()) | 1249 if (!ShouldCollapseBorders()) |
| 1250 return LayoutBlock::BorderEnd().ToInt(); | 1250 return LayoutBlock::BorderEnd().ToInt(); |
| 1251 | 1251 |
| 1252 // Determined by the last cell of the first row. See the CSS 2.1 spec, section | 1252 // Determined by the last cell of the first row. See the CSS 2.1 spec, section |
| 1253 // 17.6.2. | 1253 // 17.6.2. |
| 1254 if (!NumEffectiveColumns()) | 1254 if (!NumEffectiveColumns()) |
| 1255 return 0; | 1255 return 0; |
| 1256 | 1256 |
| 1257 int border_width = 0; | 1257 int border_width = 0; |
| 1258 | 1258 |
| 1259 const BorderValue& table_end_border = Style()->BorderEnd(); | 1259 const BorderValue& table_end_border = Style()->BorderEnd(); |
| 1260 if (table_end_border.Style() == kBorderStyleHidden) | 1260 if (table_end_border.Style() == EBorderStyle::kHidden) |
| 1261 return 0; | 1261 return 0; |
| 1262 if (table_end_border.Style() > kBorderStyleHidden) | 1262 if (table_end_border.Style() > EBorderStyle::kHidden) |
| 1263 border_width = table_end_border.Width(); | 1263 border_width = table_end_border.Width(); |
| 1264 | 1264 |
| 1265 unsigned end_column = NumEffectiveColumns() - 1; | 1265 unsigned end_column = NumEffectiveColumns() - 1; |
| 1266 | 1266 |
| 1267 // TODO(dgrogan): This logic doesn't properly account for the last column in | 1267 // TODO(dgrogan): This logic doesn't properly account for the last column in |
| 1268 // the last column-group case. | 1268 // the last column-group case. |
| 1269 if (LayoutTableCol* column = | 1269 if (LayoutTableCol* column = |
| 1270 ColElementAtAbsoluteColumn(end_column).InnermostColOrColGroup()) { | 1270 ColElementAtAbsoluteColumn(end_column).InnermostColOrColGroup()) { |
| 1271 // FIXME: We don't account for direction on columns and column groups. | 1271 // FIXME: We don't account for direction on columns and column groups. |
| 1272 const BorderValue& column_adjoining_border = column->Style()->BorderEnd(); | 1272 const BorderValue& column_adjoining_border = column->Style()->BorderEnd(); |
| 1273 if (column_adjoining_border.Style() == kBorderStyleHidden) | 1273 if (column_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1274 return 0; | 1274 return 0; |
| 1275 if (column_adjoining_border.Style() > kBorderStyleHidden) | 1275 if (column_adjoining_border.Style() > EBorderStyle::kHidden) |
| 1276 border_width = | 1276 border_width = |
| 1277 std::max<int>(border_width, column_adjoining_border.Width()); | 1277 std::max<int>(border_width, column_adjoining_border.Width()); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 if (const LayoutTableSection* top_non_empty_section = | 1280 if (const LayoutTableSection* top_non_empty_section = |
| 1281 this->TopNonEmptySection()) { | 1281 this->TopNonEmptySection()) { |
| 1282 const BorderValue& section_adjoining_border = | 1282 const BorderValue& section_adjoining_border = |
| 1283 top_non_empty_section->BorderAdjoiningTableEnd(); | 1283 top_non_empty_section->BorderAdjoiningTableEnd(); |
| 1284 if (section_adjoining_border.Style() == kBorderStyleHidden) | 1284 if (section_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1285 return 0; | 1285 return 0; |
| 1286 | 1286 |
| 1287 if (section_adjoining_border.Style() > kBorderStyleHidden) | 1287 if (section_adjoining_border.Style() > EBorderStyle::kHidden) |
| 1288 border_width = | 1288 border_width = |
| 1289 std::max<int>(border_width, section_adjoining_border.Width()); | 1289 std::max<int>(border_width, section_adjoining_border.Width()); |
| 1290 | 1290 |
| 1291 if (const LayoutTableCell* adjoining_end_cell = | 1291 if (const LayoutTableCell* adjoining_end_cell = |
| 1292 top_non_empty_section->FirstRowCellAdjoiningTableEnd()) { | 1292 top_non_empty_section->FirstRowCellAdjoiningTableEnd()) { |
| 1293 // FIXME: Make this work with perpendicular and flipped cells. | 1293 // FIXME: Make this work with perpendicular and flipped cells. |
| 1294 const BorderValue& end_cell_adjoining_border = | 1294 const BorderValue& end_cell_adjoining_border = |
| 1295 adjoining_end_cell->BorderAdjoiningTableEnd(); | 1295 adjoining_end_cell->BorderAdjoiningTableEnd(); |
| 1296 if (end_cell_adjoining_border.Style() == kBorderStyleHidden) | 1296 if (end_cell_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1297 return 0; | 1297 return 0; |
| 1298 | 1298 |
| 1299 const BorderValue& first_row_adjoining_border = | 1299 const BorderValue& first_row_adjoining_border = |
| 1300 adjoining_end_cell->Row()->BorderAdjoiningTableEnd(); | 1300 adjoining_end_cell->Row()->BorderAdjoiningTableEnd(); |
| 1301 if (first_row_adjoining_border.Style() == kBorderStyleHidden) | 1301 if (first_row_adjoining_border.Style() == EBorderStyle::kHidden) |
| 1302 return 0; | 1302 return 0; |
| 1303 | 1303 |
| 1304 if (end_cell_adjoining_border.Style() > kBorderStyleHidden) { | 1304 if (end_cell_adjoining_border.Style() > EBorderStyle::kHidden) { |
| 1305 border_width = | 1305 border_width = |
| 1306 std::max<int>(border_width, end_cell_adjoining_border.Width()); | 1306 std::max<int>(border_width, end_cell_adjoining_border.Width()); |
| 1307 } | 1307 } |
| 1308 if (first_row_adjoining_border.Style() > kBorderStyleHidden) { | 1308 if (first_row_adjoining_border.Style() > EBorderStyle::kHidden) { |
| 1309 border_width = | 1309 border_width = |
| 1310 std::max<int>(border_width, first_row_adjoining_border.Width()); | 1310 std::max<int>(border_width, first_row_adjoining_border.Width()); |
| 1311 } | 1311 } |
| 1312 } | 1312 } |
| 1313 } | 1313 } |
| 1314 return (border_width + (Style()->IsLeftToRightDirection() ? 1 : 0)) / 2; | 1314 return (border_width + (Style()->IsLeftToRightDirection() ? 1 : 0)) / 2; |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 void LayoutTable::RecalcBordersInRowDirection() { | 1317 void LayoutTable::RecalcBordersInRowDirection() { |
| 1318 // FIXME: We need to compute the collapsed before / after borders in the same | 1318 // FIXME: We need to compute the collapsed before / after borders in the same |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1340 int LayoutTable::OuterBorderBefore() const { | 1340 int LayoutTable::OuterBorderBefore() const { |
| 1341 if (!ShouldCollapseBorders()) | 1341 if (!ShouldCollapseBorders()) |
| 1342 return 0; | 1342 return 0; |
| 1343 int border_width = 0; | 1343 int border_width = 0; |
| 1344 if (LayoutTableSection* top_section = this->TopSection()) { | 1344 if (LayoutTableSection* top_section = this->TopSection()) { |
| 1345 border_width = top_section->OuterBorderBefore(); | 1345 border_width = top_section->OuterBorderBefore(); |
| 1346 if (border_width < 0) | 1346 if (border_width < 0) |
| 1347 return 0; // Overridden by hidden | 1347 return 0; // Overridden by hidden |
| 1348 } | 1348 } |
| 1349 const BorderValue& tb = Style()->BorderBefore(); | 1349 const BorderValue& tb = Style()->BorderBefore(); |
| 1350 if (tb.Style() == kBorderStyleHidden) | 1350 if (tb.Style() == EBorderStyle::kHidden) |
| 1351 return 0; | 1351 return 0; |
| 1352 if (tb.Style() > kBorderStyleHidden) | 1352 if (tb.Style() > EBorderStyle::kHidden) |
| 1353 border_width = std::max<int>(border_width, tb.Width() / 2); | 1353 border_width = std::max<int>(border_width, tb.Width() / 2); |
| 1354 return border_width; | 1354 return border_width; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 int LayoutTable::OuterBorderAfter() const { | 1357 int LayoutTable::OuterBorderAfter() const { |
| 1358 if (!ShouldCollapseBorders()) | 1358 if (!ShouldCollapseBorders()) |
| 1359 return 0; | 1359 return 0; |
| 1360 int border_width = 0; | 1360 int border_width = 0; |
| 1361 | 1361 |
| 1362 if (LayoutTableSection* section = BottomSection()) { | 1362 if (LayoutTableSection* section = BottomSection()) { |
| 1363 border_width = section->OuterBorderAfter(); | 1363 border_width = section->OuterBorderAfter(); |
| 1364 if (border_width < 0) | 1364 if (border_width < 0) |
| 1365 return 0; // Overridden by hidden | 1365 return 0; // Overridden by hidden |
| 1366 } | 1366 } |
| 1367 const BorderValue& tb = Style()->BorderAfter(); | 1367 const BorderValue& tb = Style()->BorderAfter(); |
| 1368 if (tb.Style() == kBorderStyleHidden) | 1368 if (tb.Style() == EBorderStyle::kHidden) |
| 1369 return 0; | 1369 return 0; |
| 1370 if (tb.Style() > kBorderStyleHidden) | 1370 if (tb.Style() > EBorderStyle::kHidden) |
| 1371 border_width = std::max<int>(border_width, (tb.Width() + 1) / 2); | 1371 border_width = std::max<int>(border_width, (tb.Width() + 1) / 2); |
| 1372 return border_width; | 1372 return border_width; |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 int LayoutTable::OuterBorderStart() const { | 1375 int LayoutTable::OuterBorderStart() const { |
| 1376 if (!ShouldCollapseBorders()) | 1376 if (!ShouldCollapseBorders()) |
| 1377 return 0; | 1377 return 0; |
| 1378 | 1378 |
| 1379 int border_width = 0; | 1379 int border_width = 0; |
| 1380 | 1380 |
| 1381 const BorderValue& tb = Style()->BorderStart(); | 1381 const BorderValue& tb = Style()->BorderStart(); |
| 1382 if (tb.Style() == kBorderStyleHidden) | 1382 if (tb.Style() == EBorderStyle::kHidden) |
| 1383 return 0; | 1383 return 0; |
| 1384 if (tb.Style() > kBorderStyleHidden) | 1384 if (tb.Style() > EBorderStyle::kHidden) |
| 1385 border_width = | 1385 border_width = |
| 1386 (tb.Width() + (Style()->IsLeftToRightDirection() ? 0 : 1)) / 2; | 1386 (tb.Width() + (Style()->IsLeftToRightDirection() ? 0 : 1)) / 2; |
| 1387 | 1387 |
| 1388 bool all_hidden = true; | 1388 bool all_hidden = true; |
| 1389 for (LayoutTableSection* section = TopSection(); section; | 1389 for (LayoutTableSection* section = TopSection(); section; |
| 1390 section = SectionBelow(section)) { | 1390 section = SectionBelow(section)) { |
| 1391 int sw = section->OuterBorderStart(); | 1391 int sw = section->OuterBorderStart(); |
| 1392 if (sw < 0) | 1392 if (sw < 0) |
| 1393 continue; | 1393 continue; |
| 1394 all_hidden = false; | 1394 all_hidden = false; |
| 1395 border_width = std::max(border_width, sw); | 1395 border_width = std::max(border_width, sw); |
| 1396 } | 1396 } |
| 1397 if (all_hidden) | 1397 if (all_hidden) |
| 1398 return 0; | 1398 return 0; |
| 1399 | 1399 |
| 1400 return border_width; | 1400 return border_width; |
| 1401 } | 1401 } |
| 1402 | 1402 |
| 1403 int LayoutTable::OuterBorderEnd() const { | 1403 int LayoutTable::OuterBorderEnd() const { |
| 1404 if (!ShouldCollapseBorders()) | 1404 if (!ShouldCollapseBorders()) |
| 1405 return 0; | 1405 return 0; |
| 1406 | 1406 |
| 1407 int border_width = 0; | 1407 int border_width = 0; |
| 1408 | 1408 |
| 1409 const BorderValue& tb = Style()->BorderEnd(); | 1409 const BorderValue& tb = Style()->BorderEnd(); |
| 1410 if (tb.Style() == kBorderStyleHidden) | 1410 if (tb.Style() == EBorderStyle::kHidden) |
| 1411 return 0; | 1411 return 0; |
| 1412 if (tb.Style() > kBorderStyleHidden) | 1412 if (tb.Style() > EBorderStyle::kHidden) |
| 1413 border_width = | 1413 border_width = |
| 1414 (tb.Width() + (Style()->IsLeftToRightDirection() ? 1 : 0)) / 2; | 1414 (tb.Width() + (Style()->IsLeftToRightDirection() ? 1 : 0)) / 2; |
| 1415 | 1415 |
| 1416 bool all_hidden = true; | 1416 bool all_hidden = true; |
| 1417 for (LayoutTableSection* section = TopSection(); section; | 1417 for (LayoutTableSection* section = TopSection(); section; |
| 1418 section = SectionBelow(section)) { | 1418 section = SectionBelow(section)) { |
| 1419 int sw = section->OuterBorderEnd(); | 1419 int sw = section->OuterBorderEnd(); |
| 1420 if (sw < 0) | 1420 if (sw < 0) |
| 1421 continue; | 1421 continue; |
| 1422 all_hidden = false; | 1422 all_hidden = false; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 } | 1760 } |
| 1761 | 1761 |
| 1762 LayoutUnit LayoutTable::PaddingRight() const { | 1762 LayoutUnit LayoutTable::PaddingRight() const { |
| 1763 if (ShouldCollapseBorders()) | 1763 if (ShouldCollapseBorders()) |
| 1764 return LayoutUnit(); | 1764 return LayoutUnit(); |
| 1765 | 1765 |
| 1766 return LayoutBlock::PaddingRight(); | 1766 return LayoutBlock::PaddingRight(); |
| 1767 } | 1767 } |
| 1768 | 1768 |
| 1769 } // namespace blink | 1769 } // namespace blink |
| OLD | NEW |