Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 #include "platform/geometry/TransformState.h" | 39 #include "platform/geometry/TransformState.h" |
| 40 #include "wtf/PtrUtil.h" | 40 #include "wtf/PtrUtil.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 using namespace HTMLNames; | 44 using namespace HTMLNames; |
| 45 | 45 |
| 46 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow { | 46 struct SameSizeAsLayoutTableCell : public LayoutBlockFlow { |
| 47 unsigned bitfields; | 47 unsigned bitfields; |
| 48 int paddings[2]; | 48 int paddings[2]; |
| 49 void* pointer; | 49 void* pointer1; |
| 50 void* pointer2; | |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), | 53 static_assert(sizeof(LayoutTableCell) == sizeof(SameSizeAsLayoutTableCell), |
| 53 "LayoutTableCell should stay small"); | 54 "LayoutTableCell should stay small"); |
| 54 static_assert(sizeof(CollapsedBorderValue) == 8, | 55 static_assert(sizeof(CollapsedBorderValue) == 8, |
| 55 "CollapsedBorderValue should stay small"); | 56 "CollapsedBorderValue should stay small"); |
| 56 | 57 |
| 57 LayoutTableCell::LayoutTableCell(Element* element) | 58 LayoutTableCell::LayoutTableCell(Element* element) |
| 58 : LayoutBlockFlow(element), | 59 : LayoutBlockFlow(element), |
| 59 m_absoluteColumnIndex(unsetColumnIndex), | 60 m_absoluteColumnIndex(unsetColumnIndex), |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 // The baseline of a cell is the baseline of the first in-flow line box in the | 457 // The baseline of a cell is the baseline of the first in-flow line box in the |
| 457 // cell, or the first in-flow table-row in the cell, whichever comes first. If | 458 // cell, or the first in-flow table-row in the cell, whichever comes first. If |
| 458 // there is no such line box or table-row, the baseline is the bottom of | 459 // there is no such line box or table-row, the baseline is the bottom of |
| 459 // content edge of the cell box. | 460 // content edge of the cell box. |
| 460 int firstLineBaseline = firstLineBoxBaseline(); | 461 int firstLineBaseline = firstLineBoxBaseline(); |
| 461 if (firstLineBaseline != -1) | 462 if (firstLineBaseline != -1) |
| 462 return firstLineBaseline; | 463 return firstLineBaseline; |
| 463 return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt(); | 464 return (borderBefore() + paddingBefore() + contentLogicalHeight()).toInt(); |
| 464 } | 465 } |
| 465 | 466 |
| 467 void LayoutTableCell::ensureIsReadyForPaintInvalidation() { | |
| 468 if (!m_rowBackgroundDisplayItemClient && | |
| 469 usesCompositedCellDisplayItemClients()) { | |
| 470 m_rowBackgroundDisplayItemClient = | |
| 471 wrapUnique(new LayoutTableCell::RowBackgroundDisplayItemClient(*row())); | |
| 472 } | |
| 473 LayoutBlockFlow::ensureIsReadyForPaintInvalidation(); | |
| 474 } | |
| 475 | |
| 466 void LayoutTableCell::styleDidChange(StyleDifference diff, | 476 void LayoutTableCell::styleDidChange(StyleDifference diff, |
| 467 const ComputedStyle* oldStyle) { | 477 const ComputedStyle* oldStyle) { |
| 468 DCHECK_EQ(style()->display(), EDisplay::TableCell); | 478 DCHECK_EQ(style()->display(), EDisplay::TableCell); |
| 469 | 479 |
| 470 LayoutBlockFlow::styleDidChange(diff, oldStyle); | 480 LayoutBlockFlow::styleDidChange(diff, oldStyle); |
| 471 setHasBoxDecorationBackground(true); | 481 setHasBoxDecorationBackground(true); |
| 472 | 482 |
| 473 if (parent() && section() && oldStyle && | 483 if (parent() && section() && oldStyle && |
| 474 style()->height() != oldStyle->height()) | 484 style()->height() != oldStyle->height()) |
| 475 section()->rowLogicalHeightChanged(row()); | 485 section()->rowLogicalHeightChanged(row()); |
| (...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1425 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
| 1416 const LayoutRect& localRect) const { | 1426 const LayoutRect& localRect) const { |
| 1417 // If this object has layer, the area of collapsed borders should be | 1427 // If this object has layer, the area of collapsed borders should be |
| 1418 // transparent to expose the collapsed borders painted on the underlying | 1428 // transparent to expose the collapsed borders painted on the underlying |
| 1419 // layer. | 1429 // layer. |
| 1420 if (hasLayer() && table()->collapseBorders()) | 1430 if (hasLayer() && table()->collapseBorders()) |
| 1421 return false; | 1431 return false; |
| 1422 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1432 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
| 1423 } | 1433 } |
| 1424 | 1434 |
| 1425 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const { | 1435 LayoutTableCell::RowBackgroundDisplayItemClient::RowBackgroundDisplayItemClient( |
| 1426 // In certain cases such as collapsed borders for composited table cells we | 1436 const LayoutTableRow& layoutTableRow) |
| 1427 // paint content for the cell into the table graphics layer backing and so | 1437 : m_layoutTableRow(layoutTableRow) {} |
| 1428 // must use the table's visual rect. | 1438 |
| 1439 String LayoutTableCell::RowBackgroundDisplayItemClient::debugName() const { | |
| 1440 return "RowBackground"; | |
| 1441 } | |
| 1442 | |
| 1443 LayoutRect LayoutTableCell::RowBackgroundDisplayItemClient::visualRect() const { | |
| 1444 return m_layoutTableRow.visualRect(); | |
| 1445 } | |
| 1446 | |
| 1447 bool LayoutTableCell::usesCompositedCellDisplayItemClients() const { | |
|
wkorman
2016/11/03 01:41:25
This is a bit of a misnomer since it's also true f
Xianzhu
2016/11/03 03:06:48
I think this is OK. When we remove non-SPv2 code,
| |
| 1448 // Table cells are painted in two special ways that require the use of custom | |
| 1449 // display item clients when the cell is composited: | |
| 1450 // | |
| 1451 // 1. When painting row background we paint content for the cell into the | |
| 1452 // table row graphics layer backing and so must use the row's visual rect. | |
| 1453 // | |
| 1454 // 2. When painting collapsed borders we paint content for the cell into the | |
| 1455 // table graphics layer backing and so must use the table's visual rect. | |
| 1429 return (hasLayer() && layer()->compositingState() != NotComposited) || | 1456 return (hasLayer() && layer()->compositingState() != NotComposited) || |
| 1430 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 1457 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
| 1431 } | 1458 } |
| 1432 | 1459 |
| 1433 void LayoutTableCell::invalidateDisplayItemClients( | 1460 void LayoutTableCell::invalidateDisplayItemClients( |
| 1434 PaintInvalidationReason reason) const { | 1461 PaintInvalidationReason reason) const { |
| 1435 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) { | 1462 if (usesCompositedCellDisplayItemClients()) { |
| 1436 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( | 1463 ObjectPaintInvalidator invalidator(*this); |
| 1437 *m_collapsedBorderValues, reason); | 1464 DCHECK(m_rowBackgroundDisplayItemClient); |
| 1465 if (m_collapsedBorderValues) { | |
| 1466 invalidator.invalidateDisplayItemClient(*m_collapsedBorderValues, reason); | |
| 1467 } | |
| 1468 invalidator.invalidateDisplayItemClient(*m_rowBackgroundDisplayItemClient, | |
|
wkorman
2016/11/03 01:41:25
This wasn't necessary for all tests to pass but I
| |
| 1469 reason); | |
| 1438 } | 1470 } |
| 1439 LayoutBlockFlow::invalidateDisplayItemClients(reason); | 1471 LayoutBlockFlow::invalidateDisplayItemClients(reason); |
| 1440 } | 1472 } |
| 1441 | 1473 |
| 1442 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1474 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
| 1443 // is what current results reflect. We'd like to clean up the results to dump | 1475 // is what current results reflect. We'd like to clean up the results to dump |
| 1444 // both the outer box and the intrinsic padding so that both bits of information | 1476 // both the outer box and the intrinsic padding so that both bits of information |
| 1445 // are captured by the results. | 1477 // are captured by the results. |
| 1446 LayoutRect LayoutTableCell::debugRect() const { | 1478 LayoutRect LayoutTableCell::debugRect() const { |
| 1447 LayoutRect rect = LayoutRect( | 1479 LayoutRect rect = LayoutRect( |
| 1448 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1480 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
| 1449 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1481 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
| 1450 | 1482 |
| 1451 LayoutBlock* cb = containingBlock(); | 1483 LayoutBlock* cb = containingBlock(); |
| 1452 if (cb) | 1484 if (cb) |
| 1453 cb->adjustChildDebugRect(rect); | 1485 cb->adjustChildDebugRect(rect); |
| 1454 | 1486 |
| 1455 return rect; | 1487 return rect; |
| 1456 } | 1488 } |
| 1457 | 1489 |
| 1458 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1490 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
| 1459 r.move(0, -intrinsicPaddingBefore()); | 1491 r.move(0, -intrinsicPaddingBefore()); |
| 1460 } | 1492 } |
| 1461 | 1493 |
| 1462 } // namespace blink | 1494 } // namespace blink |
| OLD | NEW |