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

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

Issue 2906253003: Replace call sites to BorderValue functions to save the BorderValue construction cost (Closed)
Patch Set: rune@ renames Created 3 years, 6 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, 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 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 } 1353 }
1354 } 1354 }
1355 1355
1356 int LayoutTableSection::CalcBlockDirectionOuterBorder( 1356 int LayoutTableSection::CalcBlockDirectionOuterBorder(
1357 BlockBorderSide side) const { 1357 BlockBorderSide side) const {
1358 if (!grid_.size() || !Table()->NumEffectiveColumns()) 1358 if (!grid_.size() || !Table()->NumEffectiveColumns())
1359 return 0; 1359 return 0;
1360 1360
1361 int border_width = 0; 1361 int border_width = 0;
1362 1362
1363 const BorderValue& sb = 1363 EBorderStyle section_border_style = side == kBorderBefore
1364 side == kBorderBefore ? Style()->BorderBefore() : Style()->BorderAfter(); 1364 ? Style()->BorderBeforeStyle()
1365 if (sb.Style() == EBorderStyle::kHidden) 1365 : Style()->BorderAfterStyle();
1366 if (section_border_style == EBorderStyle::kHidden)
1366 return -1; 1367 return -1;
1367 if (ComputedStyle::BorderStyleIsVisible(sb.Style())) 1368 if (ComputedStyle::BorderStyleIsVisible(section_border_style)) {
1368 border_width = sb.Width(); 1369 border_width = side == kBorderBefore ? Style()->BorderBeforeWidth()
1370 : Style()->BorderAfterWidth();
1371 }
1369 1372
1370 const BorderValue& rb = side == kBorderBefore 1373 EBorderStyle row_border_style = side == kBorderBefore
1371 ? FirstRow()->Style()->BorderBefore() 1374 ? FirstRow()->Style()->BorderBeforeStyle()
1372 : LastRow()->Style()->BorderAfter(); 1375 : LastRow()->Style()->BorderAfterStyle();
1373 if (rb.Style() == EBorderStyle::kHidden) 1376 float row_border_width = side == kBorderBefore
1377 ? FirstRow()->Style()->BorderBeforeWidth()
1378 : LastRow()->Style()->BorderAfterWidth();
1379 if (row_border_style == EBorderStyle::kHidden)
1374 return -1; 1380 return -1;
1375 if (ComputedStyle::BorderStyleIsVisible(rb.Style()) && 1381 if (ComputedStyle::BorderStyleIsVisible(row_border_style) &&
1376 rb.Width() > border_width) 1382 row_border_width > border_width)
1377 border_width = rb.Width(); 1383 border_width = row_border_width;
1378
1379 bool all_hidden = true; 1384 bool all_hidden = true;
1380 unsigned r = side == kBorderBefore ? 0 : grid_.size() - 1; 1385 unsigned r = side == kBorderBefore ? 0 : grid_.size() - 1;
1381 unsigned n_cols = NumCols(r); 1386 unsigned n_cols = NumCols(r);
1382 for (unsigned c = 0; c < n_cols; c++) { 1387 for (unsigned c = 0; c < n_cols; c++) {
1383 const auto& grid_cell = GridCellAt(r, c); 1388 const auto& grid_cell = GridCellAt(r, c);
1384 if (grid_cell.InColSpan() || !grid_cell.HasCells()) 1389 if (grid_cell.InColSpan() || !grid_cell.HasCells())
1385 continue; 1390 continue;
1386 const ComputedStyle& primary_cell_style = 1391 const ComputedStyle& primary_cell_style =
1387 grid_cell.PrimaryCell()->StyleRef(); 1392 grid_cell.PrimaryCell()->StyleRef();
1388 // FIXME: Make this work with perpendicular and flipped cells. 1393 // FIXME: Make this work with perpendicular and flipped cells.
1389 const BorderValue& cb = side == kBorderBefore 1394 EBorderStyle cell_border_style =
1390 ? primary_cell_style.BorderBefore() 1395 side == kBorderBefore ? primary_cell_style.BorderBeforeStyle()
1391 : primary_cell_style.BorderAfter(); 1396 : primary_cell_style.BorderAfterStyle();
1397 float cell_border_width = side == kBorderBefore
1398 ? primary_cell_style.BorderBeforeWidth()
1399 : primary_cell_style.BorderAfterWidth();
1392 // FIXME: Don't repeat for the same col group 1400 // FIXME: Don't repeat for the same col group
1393 LayoutTableCol* col = 1401 LayoutTableCol* col =
1394 Table()->ColElementAtAbsoluteColumn(c).InnermostColOrColGroup(); 1402 Table()->ColElementAtAbsoluteColumn(c).InnermostColOrColGroup();
1395 if (col) { 1403 if (col) {
1396 const BorderValue& gb = side == kBorderBefore 1404 EBorderStyle col_border_style = side == kBorderBefore
1397 ? col->Style()->BorderBefore() 1405 ? col->Style()->BorderBeforeStyle()
1398 : col->Style()->BorderAfter(); 1406 : col->Style()->BorderAfterStyle();
1399 if (gb.Style() == EBorderStyle::kHidden || 1407 const float col_border_width = side == kBorderBefore
1400 cb.Style() == EBorderStyle::kHidden) 1408 ? col->Style()->BorderBeforeWidth()
1409 : col->Style()->BorderAfterWidth();
1410 if (col_border_style == EBorderStyle::kHidden ||
1411 cell_border_style == EBorderStyle::kHidden)
1401 continue; 1412 continue;
1402 all_hidden = false; 1413 all_hidden = false;
1403 if (ComputedStyle::BorderStyleIsVisible(gb.Style()) && 1414 if (ComputedStyle::BorderStyleIsVisible(col_border_style) &&
1404 gb.Width() > border_width) 1415 col_border_width > border_width)
1405 border_width = gb.Width(); 1416 border_width = col_border_width;
1406 if (ComputedStyle::BorderStyleIsVisible(cb.Style()) && 1417 if (ComputedStyle::BorderStyleIsVisible(cell_border_style) &&
1407 cb.Width() > border_width) 1418 cell_border_width > border_width)
1408 border_width = cb.Width(); 1419 border_width = cell_border_width;
1409 } else { 1420 } else {
1410 if (cb.Style() == EBorderStyle::kHidden) 1421 if (cell_border_style == EBorderStyle::kHidden)
1411 continue; 1422 continue;
1412 all_hidden = false; 1423 all_hidden = false;
1413 if (ComputedStyle::BorderStyleIsVisible(cb.Style()) && 1424 if (ComputedStyle::BorderStyleIsVisible(cell_border_style) &&
1414 cb.Width() > border_width) 1425 cell_border_width > border_width)
1415 border_width = cb.Width(); 1426 border_width = cell_border_width;
1416 } 1427 }
1417 } 1428 }
1418 if (all_hidden) 1429 if (all_hidden)
1419 return -1; 1430 return -1;
1420 1431
1421 if (side == kBorderAfter) 1432 if (side == kBorderAfter)
1422 border_width++; // Distribute rounding error 1433 border_width++; // Distribute rounding error
1423 return border_width / 2; 1434 return border_width / 2;
1424 } 1435 }
1425 1436
1426 int LayoutTableSection::CalcInlineDirectionOuterBorder( 1437 int LayoutTableSection::CalcInlineDirectionOuterBorder(
1427 InlineBorderSide side) const { 1438 InlineBorderSide side) const {
1428 unsigned total_cols = Table()->NumEffectiveColumns(); 1439 unsigned total_cols = Table()->NumEffectiveColumns();
1429 if (!grid_.size() || !total_cols) 1440 if (!grid_.size() || !total_cols)
1430 return 0; 1441 return 0;
1431 unsigned col_index = side == kBorderStart ? 0 : total_cols - 1; 1442 unsigned col_index = side == kBorderStart ? 0 : total_cols - 1;
1432 1443
1433 int border_width = 0; 1444 int border_width = 0;
1434 1445
1435 const BorderValue& sb = 1446 EBorderStyle section_border_style = side == kBorderStart
1436 side == kBorderStart ? Style()->BorderStart() : Style()->BorderEnd(); 1447 ? Style()->BorderStartStyle()
1437 if (sb.Style() == EBorderStyle::kHidden) 1448 : Style()->BorderEndStyle();
1449 const float section_border_width = side == kBorderStart
1450 ? Style()->BorderStartWidth()
1451 : Style()->BorderEndWidth();
1452 if (section_border_style == EBorderStyle::kHidden)
1438 return -1; 1453 return -1;
1439 if (ComputedStyle::BorderStyleIsVisible(sb.Style())) 1454 if (ComputedStyle::BorderStyleIsVisible(section_border_style))
1440 border_width = sb.Width(); 1455 border_width = section_border_width;
1441 1456
1442 if (LayoutTableCol* col = Table() 1457 if (LayoutTableCol* col = Table()
1443 ->ColElementAtAbsoluteColumn(col_index) 1458 ->ColElementAtAbsoluteColumn(col_index)
1444 .InnermostColOrColGroup()) { 1459 .InnermostColOrColGroup()) {
1445 const BorderValue& gb = side == kBorderStart ? col->Style()->BorderStart() 1460 EBorderStyle col_border_style = side == kBorderStart
1446 : col->Style()->BorderEnd(); 1461 ? col->Style()->BorderStartStyle()
1447 if (gb.Style() == EBorderStyle::kHidden) 1462 : col->Style()->BorderEndStyle();
1463 const float col_border_width = side == kBorderStart
1464 ? col->Style()->BorderStartWidth()
1465 : col->Style()->BorderEndWidth();
1466 if (col_border_style == EBorderStyle::kHidden)
1448 return -1; 1467 return -1;
1449 if (ComputedStyle::BorderStyleIsVisible(gb.Style()) && 1468 if (ComputedStyle::BorderStyleIsVisible(col_border_style) &&
1450 gb.Width() > border_width) 1469 col_border_width > border_width)
1451 border_width = gb.Width(); 1470 border_width = col_border_width;
1452 } 1471 }
1453 1472
1454 bool all_hidden = true; 1473 bool all_hidden = true;
1455 for (unsigned r = 0; r < grid_.size(); r++) { 1474 for (unsigned r = 0; r < grid_.size(); r++) {
1456 if (col_index >= NumCols(r)) 1475 if (col_index >= NumCols(r))
1457 continue; 1476 continue;
1458 const auto& grid_cell = GridCellAt(r, col_index); 1477 const auto& grid_cell = GridCellAt(r, col_index);
1459 if (!grid_cell.HasCells()) 1478 if (!grid_cell.HasCells())
1460 continue; 1479 continue;
1461 // FIXME: Don't repeat for the same cell 1480 // FIXME: Don't repeat for the same cell
1462 const ComputedStyle& primary_cell_style = 1481 const ComputedStyle& primary_cell_style =
1463 grid_cell.PrimaryCell()->StyleRef(); 1482 grid_cell.PrimaryCell()->StyleRef();
1464 const ComputedStyle& primary_cell_parent_style = 1483 const ComputedStyle& primary_cell_parent_style =
1465 grid_cell.PrimaryCell()->Parent()->StyleRef(); 1484 grid_cell.PrimaryCell()->Parent()->StyleRef();
1466 // FIXME: Make this work with perpendicular and flipped cells. 1485 // FIXME: Make this work with perpendicular and flipped cells.
1467 const BorderValue& cb = side == kBorderStart 1486 EBorderStyle cell_border_style = side == kBorderStart
1468 ? primary_cell_style.BorderStart() 1487 ? primary_cell_style.BorderStartStyle()
1469 : primary_cell_style.BorderEnd(); 1488 : primary_cell_style.BorderEndStyle();
1470 const BorderValue& rb = side == kBorderStart 1489 EBorderStyle row_border_style =
1471 ? primary_cell_parent_style.BorderStart() 1490 side == kBorderStart ? primary_cell_parent_style.BorderStartStyle()
1472 : primary_cell_parent_style.BorderEnd(); 1491 : primary_cell_parent_style.BorderEndStyle();
1473 if (cb.Style() == EBorderStyle::kHidden || 1492 const float cell_border_width = side == kBorderStart
1474 rb.Style() == EBorderStyle::kHidden) 1493 ? primary_cell_style.BorderStartWidth()
1494 : primary_cell_style.BorderEndWidth();
1495 const float row_border_width =
1496 side == kBorderStart ? primary_cell_parent_style.BorderStartWidth()
1497 : primary_cell_parent_style.BorderEndWidth();
1498 if (cell_border_style == EBorderStyle::kHidden ||
1499 row_border_style == EBorderStyle::kHidden)
1475 continue; 1500 continue;
1476 all_hidden = false; 1501 all_hidden = false;
1477 if (ComputedStyle::BorderStyleIsVisible(cb.Style()) && 1502 if (ComputedStyle::BorderStyleIsVisible(cell_border_style) &&
1478 cb.Width() > border_width) 1503 cell_border_width > border_width)
1479 border_width = cb.Width(); 1504 border_width = cell_border_width;
1480 if (ComputedStyle::BorderStyleIsVisible(rb.Style()) && 1505 if (ComputedStyle::BorderStyleIsVisible(row_border_style) &&
1481 rb.Width() > border_width) 1506 row_border_width > border_width)
1482 border_width = rb.Width(); 1507 border_width = row_border_width;
1483 } 1508 }
1484 if (all_hidden) 1509 if (all_hidden)
1485 return -1; 1510 return -1;
1486 1511
1487 if ((side == kBorderStart) != Table()->Style()->IsLeftToRightDirection()) 1512 if ((side == kBorderStart) != Table()->Style()->IsLeftToRightDirection())
1488 border_width++; // Distribute rounding error 1513 border_width++; // Distribute rounding error
1489 return border_width / 2; 1514 return border_width / 2;
1490 } 1515 }
1491 1516
1492 void LayoutTableSection::RecalcOuterBorder() { 1517 void LayoutTableSection::RecalcOuterBorder() {
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize() 2169 bool LayoutTableSection::PaintedOutputOfObjectHasNoEffectRegardlessOfSize()
2145 const { 2170 const {
2146 // LayoutTableSection paints background from columns. 2171 // LayoutTableSection paints background from columns.
2147 if (Table()->HasColElements()) 2172 if (Table()->HasColElements())
2148 return false; 2173 return false;
2149 return LayoutTableBoxComponent:: 2174 return LayoutTableBoxComponent::
2150 PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); 2175 PaintedOutputOfObjectHasNoEffectRegardlessOfSize();
2151 } 2176 }
2152 2177
2153 } // namespace blink 2178 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTableCell.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698