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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 "Asserts below assume end_ is unsigned"); | 83 "Asserts below assume end_ is unsigned"); |
84 CHECK_LE(start_, maximum_span_size); | 84 CHECK_LE(start_, maximum_span_size); |
85 CHECK_LE(end_, maximum_span_size); | 85 CHECK_LE(end_, maximum_span_size); |
86 CHECK_LE(start_, end_); | 86 CHECK_LE(start_, end_); |
87 } | 87 } |
88 | 88 |
89 LayoutTableSection::LayoutTableSection(Element* element) | 89 LayoutTableSection::LayoutTableSection(Element* element) |
90 : LayoutTableBoxComponent(element), | 90 : LayoutTableBoxComponent(element), |
91 c_col_(0), | 91 c_col_(0), |
92 c_row_(0), | 92 c_row_(0), |
93 outer_border_start_(0), | |
94 outer_border_end_(0), | |
95 outer_border_before_(0), | |
96 outer_border_after_(0), | |
97 needs_cell_recalc_(false), | 93 needs_cell_recalc_(false), |
98 force_full_paint_(false), | 94 force_full_paint_(false), |
99 has_multiple_cell_levels_(false), | 95 has_multiple_cell_levels_(false), |
100 has_spanning_cells_(false) { | 96 has_spanning_cells_(false) { |
101 // init LayoutObject attributes | 97 // init LayoutObject attributes |
102 SetInline(false); // our object is not Inline | 98 SetInline(false); // our object is not Inline |
103 } | 99 } |
104 | 100 |
105 LayoutTableSection::~LayoutTableSection() {} | 101 LayoutTableSection::~LayoutTableSection() {} |
106 | 102 |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) { | 1332 for (LayoutTableRow* row = FirstRow(); row; row = row->NextRow()) { |
1337 for (LayoutTableCell* cell = row->FirstCell(); cell; | 1333 for (LayoutTableCell* cell = row->FirstCell(); cell; |
1338 cell = cell->NextCell()) { | 1334 cell = cell->NextCell()) { |
1339 cell->SetPreferredLogicalWidthsDirty(); | 1335 cell->SetPreferredLogicalWidthsDirty(); |
1340 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout) | 1336 if (what_to_mark == LayoutTable::kMarkDirtyAndNeedsLayout) |
1341 cell->SetChildNeedsLayout(); | 1337 cell->SetChildNeedsLayout(); |
1342 } | 1338 } |
1343 } | 1339 } |
1344 } | 1340 } |
1345 | 1341 |
1346 int LayoutTableSection::CalcBlockDirectionOuterBorder( | |
1347 BlockBorderSide side) const { | |
1348 // TODO(wangxianzhu): There are several issues in this function: | |
1349 // 1. Row borders are not respected; | |
1350 // 2. Column borders should be ignored if this section is not at the top or | |
1351 // the bottom. | |
1352 // 3. It's unnecessarily complex. | |
1353 // I think we should just use cell's calculated collapsed border values to | |
1354 // avoid all of the problems. | |
1355 if (!grid_.size() || !Table()->NumEffectiveColumns()) | |
1356 return 0; | |
1357 | |
1358 int border_width = 0; | |
1359 | |
1360 const BorderValue& sb = | |
1361 side == kBorderBefore ? Style()->BorderBefore() : Style()->BorderAfter(); | |
1362 if (sb.Style() == kBorderStyleHidden) | |
1363 return -1; | |
1364 if (sb.Style() > kBorderStyleHidden) | |
1365 border_width = sb.Width(); | |
1366 | |
1367 const BorderValue& rb = side == kBorderBefore | |
1368 ? FirstRow()->Style()->BorderBefore() | |
1369 : LastRow()->Style()->BorderAfter(); | |
1370 if (rb.Style() == kBorderStyleHidden) | |
1371 return -1; | |
1372 if (rb.Style() > kBorderStyleHidden && rb.Width() > border_width) | |
1373 border_width = rb.Width(); | |
1374 | |
1375 bool all_hidden = true; | |
1376 unsigned r = side == kBorderBefore ? 0 : grid_.size() - 1; | |
1377 unsigned n_cols = NumEffectiveColumns(r); | |
1378 for (unsigned c = 0; c < n_cols; c++) { | |
1379 const auto& grid_cell = GridCellAt(r, c); | |
1380 if (grid_cell.InColSpan() || !grid_cell.HasCells()) | |
1381 continue; | |
1382 const ComputedStyle& primary_cell_style = | |
1383 grid_cell.PrimaryCell()->StyleRef(); | |
1384 // FIXME: Make this work with perpendicular and flipped cells. | |
1385 const BorderValue& cb = side == kBorderBefore | |
1386 ? primary_cell_style.BorderBefore() | |
1387 : primary_cell_style.BorderAfter(); | |
1388 // FIXME: Don't repeat for the same col group | |
1389 LayoutTableCol* col = | |
1390 Table()->ColElementAtEffectiveColumn(c).InnermostColOrColGroup(); | |
1391 if (col) { | |
1392 const BorderValue& gb = side == kBorderBefore | |
1393 ? col->Style()->BorderBefore() | |
1394 : col->Style()->BorderAfter(); | |
1395 if (gb.Style() == kBorderStyleHidden || cb.Style() == kBorderStyleHidden) | |
1396 continue; | |
1397 all_hidden = false; | |
1398 if (gb.Style() > kBorderStyleHidden && gb.Width() > border_width) | |
1399 border_width = gb.Width(); | |
1400 if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width) | |
1401 border_width = cb.Width(); | |
1402 } else { | |
1403 if (cb.Style() == kBorderStyleHidden) | |
1404 continue; | |
1405 all_hidden = false; | |
1406 if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width) | |
1407 border_width = cb.Width(); | |
1408 } | |
1409 } | |
1410 if (all_hidden) | |
1411 return -1; | |
1412 | |
1413 if (side == kBorderAfter) | |
1414 border_width++; // Distribute rounding error | |
1415 return border_width / 2; | |
1416 } | |
1417 | |
1418 int LayoutTableSection::CalcInlineDirectionOuterBorder( | |
1419 InlineBorderSide side) const { | |
1420 unsigned total_cols = Table()->NumEffectiveColumns(); | |
1421 if (!grid_.size() || !total_cols) | |
1422 return 0; | |
1423 unsigned col_index = side == kBorderStart ? 0 : total_cols - 1; | |
1424 | |
1425 int border_width = 0; | |
1426 | |
1427 const BorderValue& sb = | |
1428 side == kBorderStart ? Style()->BorderStart() : Style()->BorderEnd(); | |
1429 if (sb.Style() == kBorderStyleHidden) | |
1430 return -1; | |
1431 if (sb.Style() > kBorderStyleHidden) | |
1432 border_width = sb.Width(); | |
1433 | |
1434 if (LayoutTableCol* col = Table() | |
1435 ->ColElementAtEffectiveColumn(col_index) | |
1436 .InnermostColOrColGroup()) { | |
1437 const BorderValue& gb = side == kBorderStart ? col->Style()->BorderStart() | |
1438 : col->Style()->BorderEnd(); | |
1439 if (gb.Style() == kBorderStyleHidden) | |
1440 return -1; | |
1441 if (gb.Style() > kBorderStyleHidden && gb.Width() > border_width) | |
1442 border_width = gb.Width(); | |
1443 } | |
1444 | |
1445 bool all_hidden = true; | |
1446 for (unsigned r = 0; r < grid_.size(); r++) { | |
1447 if (col_index >= NumEffectiveColumns(r)) | |
1448 continue; | |
1449 const auto& grid_cell = GridCellAt(r, col_index); | |
1450 if (!grid_cell.HasCells()) | |
1451 continue; | |
1452 // FIXME: Don't repeat for the same cell | |
1453 const ComputedStyle& primary_cell_style = | |
1454 grid_cell.PrimaryCell()->StyleRef(); | |
1455 const ComputedStyle& primary_cell_parent_style = | |
1456 grid_cell.PrimaryCell()->Parent()->StyleRef(); | |
1457 // FIXME: Make this work with perpendicular and flipped cells. | |
1458 const BorderValue& cb = side == kBorderStart | |
1459 ? primary_cell_style.BorderStart() | |
1460 : primary_cell_style.BorderEnd(); | |
1461 const BorderValue& rb = side == kBorderStart | |
1462 ? primary_cell_parent_style.BorderStart() | |
1463 : primary_cell_parent_style.BorderEnd(); | |
1464 if (cb.Style() == kBorderStyleHidden || rb.Style() == kBorderStyleHidden) | |
1465 continue; | |
1466 all_hidden = false; | |
1467 if (cb.Style() > kBorderStyleHidden && cb.Width() > border_width) | |
1468 border_width = cb.Width(); | |
1469 if (rb.Style() > kBorderStyleHidden && rb.Width() > border_width) | |
1470 border_width = rb.Width(); | |
1471 } | |
1472 if (all_hidden) | |
1473 return -1; | |
1474 | |
1475 if ((side == kBorderStart) != Table()->Style()->IsLeftToRightDirection()) | |
1476 border_width++; // Distribute rounding error | |
1477 return border_width / 2; | |
1478 } | |
1479 | |
1480 void LayoutTableSection::RecalcOuterBorder() { | |
1481 outer_border_before_ = CalcBlockDirectionOuterBorder(kBorderBefore); | |
1482 outer_border_after_ = CalcBlockDirectionOuterBorder(kBorderAfter); | |
1483 outer_border_start_ = CalcInlineDirectionOuterBorder(kBorderStart); | |
1484 outer_border_end_ = CalcInlineDirectionOuterBorder(kBorderEnd); | |
1485 } | |
1486 | |
1487 int LayoutTableSection::FirstLineBoxBaseline() const { | 1342 int LayoutTableSection::FirstLineBoxBaseline() const { |
1488 if (!grid_.size()) | 1343 if (!grid_.size()) |
1489 return -1; | 1344 return -1; |
1490 | 1345 |
1491 int first_line_baseline = grid_[0].baseline; | 1346 int first_line_baseline = grid_[0].baseline; |
1492 if (first_line_baseline >= 0) | 1347 if (first_line_baseline >= 0) |
1493 return first_line_baseline + row_pos_[0]; | 1348 return first_line_baseline + row_pos_[0]; |
1494 | 1349 |
1495 for (const auto& grid_cell : grid_[0].grid_cells) { | 1350 for (const auto& grid_cell : grid_[0].grid_cells) { |
1496 if (const auto* cell = grid_cell.PrimaryCell()) { | 1351 if (const auto* cell = grid_cell.PrimaryCell()) { |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2131 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() | 1986 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() |
2132 const { | 1987 const { |
2133 // LayoutTableSection paints background from columns. | 1988 // LayoutTableSection paints background from columns. |
2134 if (Table()->HasColElements()) | 1989 if (Table()->HasColElements()) |
2135 return false; | 1990 return false; |
2136 return LayoutTableBoxComponent:: | 1991 return LayoutTableBoxComponent:: |
2137 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); | 1992 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); |
2138 } | 1993 } |
2139 | 1994 |
2140 } // namespace blink | 1995 } // namespace blink |
OLD | NEW |