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.
All rights reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc.
All rights reserved. |
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
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 24 matching lines...) Expand all Loading... |
35 #include "core/layout/LayoutTableCell.h" | 35 #include "core/layout/LayoutTableCell.h" |
36 #include "core/layout/LayoutTableCol.h" | 36 #include "core/layout/LayoutTableCol.h" |
37 #include "core/layout/LayoutTableSection.h" | 37 #include "core/layout/LayoutTableSection.h" |
38 #include "core/layout/LayoutView.h" | 38 #include "core/layout/LayoutView.h" |
39 #include "core/layout/SubtreeLayoutScope.h" | 39 #include "core/layout/SubtreeLayoutScope.h" |
40 #include "core/layout/TableLayoutAlgorithmAuto.h" | 40 #include "core/layout/TableLayoutAlgorithmAuto.h" |
41 #include "core/layout/TableLayoutAlgorithmFixed.h" | 41 #include "core/layout/TableLayoutAlgorithmFixed.h" |
42 #include "core/layout/TextAutosizer.h" | 42 #include "core/layout/TextAutosizer.h" |
43 #include "core/paint/BoxPainter.h" | 43 #include "core/paint/BoxPainter.h" |
44 #include "core/paint/PaintLayer.h" | 44 #include "core/paint/PaintLayer.h" |
| 45 #include "core/paint/TablePaintInvalidator.h" |
45 #include "core/paint/TablePainter.h" | 46 #include "core/paint/TablePainter.h" |
46 #include "core/style/StyleInheritedData.h" | 47 #include "core/style/StyleInheritedData.h" |
47 #include "wtf/PtrUtil.h" | 48 #include "wtf/PtrUtil.h" |
48 | 49 |
49 namespace blink { | 50 namespace blink { |
50 | 51 |
51 using namespace HTMLNames; | 52 using namespace HTMLNames; |
52 | 53 |
53 LayoutTable::LayoutTable(Element* element) | 54 LayoutTable::LayoutTable(Element* element) |
54 : LayoutBlock(element) | 55 : LayoutBlock(element) |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 | 1416 |
1416 const BorderValue& LayoutTable::tableEndBorderAdjoiningCell(const LayoutTableCel
l* cell) const | 1417 const BorderValue& LayoutTable::tableEndBorderAdjoiningCell(const LayoutTableCel
l* cell) const |
1417 { | 1418 { |
1418 ASSERT(cell->isFirstOrLastCellInRow()); | 1419 ASSERT(cell->isFirstOrLastCellInRow()); |
1419 if (hasSameDirectionAs(cell->row())) | 1420 if (hasSameDirectionAs(cell->row())) |
1420 return style()->borderEnd(); | 1421 return style()->borderEnd(); |
1421 | 1422 |
1422 return style()->borderStart(); | 1423 return style()->borderStart(); |
1423 } | 1424 } |
1424 | 1425 |
| 1426 void LayoutTable::ensureIsReadyForPaintInvalidation() |
| 1427 { |
| 1428 LayoutBlock::ensureIsReadyForPaintInvalidation(); |
| 1429 recalcCollapsedBordersIfNeeded(); |
| 1430 } |
| 1431 |
1425 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(const PaintInvalida
tionState& paintInvalidationState) | 1432 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(const PaintInvalida
tionState& paintInvalidationState) |
1426 { | 1433 { |
1427 // Information of collapsed borders doesn't affect layout and are for painti
ng only. | |
1428 // Do it now instead of during painting to invalidate table cells if needed. | |
1429 recalcCollapsedBordersIfNeeded(); | |
1430 if (collapseBorders() && !m_collapsedBorders.isEmpty()) | 1434 if (collapseBorders() && !m_collapsedBorders.isEmpty()) |
1431 paintInvalidationState.paintingLayer().setNeedsPaintPhaseDescendantBlock
Backgrounds(); | 1435 paintInvalidationState.paintingLayer().setNeedsPaintPhaseDescendantBlock
Backgrounds(); |
1432 | 1436 |
1433 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 1437 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
1434 } | 1438 } |
1435 | 1439 |
1436 void LayoutTable::invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState
& childPaintInvalidationState) | 1440 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(const PaintInvalida
torContext& context) const |
1437 { | 1441 { |
1438 // Table cells paint background from the containing column group, column, se
ction and row. | 1442 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); |
1439 // If background of any of them changed, we need to invalidate all affected
cells. | |
1440 // Here use shouldDoFullPaintInvalidation() as a broader condition of backgr
ound change. | |
1441 | |
1442 // If any col changed background, we'll check all cells for background chang
es. | |
1443 bool hasColChangedBackground = false; | |
1444 for (LayoutTableCol* col = firstColumn(); col; col = col->nextColumn()) { | |
1445 if (col->backgroundChangedSinceLastPaintInvalidation()) { | |
1446 hasColChangedBackground = true; | |
1447 break; | |
1448 } | |
1449 } | |
1450 for (LayoutObject* child = firstChild(); child; child = child->nextSibling()
) { | |
1451 if (!child->isTableSection()) | |
1452 continue; | |
1453 LayoutTableSection* section = toLayoutTableSection(child); | |
1454 if (!hasColChangedBackground && !section->shouldCheckForPaintInvalidatio
nRegardlessOfPaintInvalidationState()) | |
1455 continue; | |
1456 for (LayoutTableRow* row = section->firstRow(); row; row = row->nextRow(
)) { | |
1457 if (!hasColChangedBackground && !section->backgroundChangedSinceLast
PaintInvalidation() && !row->backgroundChangedSinceLastPaintInvalidation()) | |
1458 continue; | |
1459 for (LayoutTableCell* cell = row->firstCell(); cell; cell = cell->ne
xtCell()) { | |
1460 bool invalidated = false; | |
1461 // Table cells paint container's background on the container's b
acking instead of its own (if any), | |
1462 // so we must invalidate it by the containers. | |
1463 if (section->backgroundChangedSinceLastPaintInvalidation()) { | |
1464 section->slowSetPaintingLayerNeedsRepaintAndInvalidateDispla
yItemClient(*cell, PaintInvalidationStyleChange); | |
1465 invalidated = true; | |
1466 } else if (hasColChangedBackground) { | |
1467 ColAndColGroup colAndColGroup = colElementAtAbsoluteColumn(c
ell->absoluteColumnIndex()); | |
1468 LayoutTableCol* column = colAndColGroup.col; | |
1469 LayoutTableCol* columnGroup = colAndColGroup.colgroup; | |
1470 if ((columnGroup && columnGroup->backgroundChangedSinceLastP
aintInvalidation()) | |
1471 || (column && column->backgroundChangedSinceLastPaintInv
alidation())) { | |
1472 section->slowSetPaintingLayerNeedsRepaintAndInvalidateDi
splayItemClient(*cell, PaintInvalidationStyleChange); | |
1473 invalidated = true; | |
1474 } | |
1475 } | |
1476 if ((!invalidated || row->hasSelfPaintingLayer()) && row->backgr
oundChangedSinceLastPaintInvalidation()) | |
1477 row->slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayIte
mClient(*cell, PaintInvalidationStyleChange); | |
1478 } | |
1479 } | |
1480 } | |
1481 LayoutBlock::invalidatePaintOfSubtreesIfNeeded(childPaintInvalidationState); | |
1482 } | 1443 } |
1483 | 1444 |
1484 LayoutUnit LayoutTable::paddingTop() const | 1445 LayoutUnit LayoutTable::paddingTop() const |
1485 { | 1446 { |
1486 if (collapseBorders()) | 1447 if (collapseBorders()) |
1487 return LayoutUnit(); | 1448 return LayoutUnit(); |
1488 | 1449 |
1489 return LayoutBlock::paddingTop(); | 1450 return LayoutBlock::paddingTop(); |
1490 } | 1451 } |
1491 | 1452 |
(...skipping 15 matching lines...) Expand all Loading... |
1507 | 1468 |
1508 LayoutUnit LayoutTable::paddingRight() const | 1469 LayoutUnit LayoutTable::paddingRight() const |
1509 { | 1470 { |
1510 if (collapseBorders()) | 1471 if (collapseBorders()) |
1511 return LayoutUnit(); | 1472 return LayoutUnit(); |
1512 | 1473 |
1513 return LayoutBlock::paddingRight(); | 1474 return LayoutBlock::paddingRight(); |
1514 } | 1475 } |
1515 | 1476 |
1516 } // namespace blink | 1477 } // namespace blink |
OLD | NEW |