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 LayoutBlockFlow::ensureIsReadyForPaintInvalidation(); |
| 469 if (!usesCompositedCellDisplayItemClients()) |
| 470 return; |
| 471 if (!m_rowBackgroundDisplayItemClient) { |
| 472 m_rowBackgroundDisplayItemClient = |
| 473 wrapUnique(new LayoutTableCell::RowBackgroundDisplayItemClient(*row())); |
| 474 } |
| 475 } |
| 476 |
466 void LayoutTableCell::styleDidChange(StyleDifference diff, | 477 void LayoutTableCell::styleDidChange(StyleDifference diff, |
467 const ComputedStyle* oldStyle) { | 478 const ComputedStyle* oldStyle) { |
468 DCHECK_EQ(style()->display(), EDisplay::TableCell); | 479 DCHECK_EQ(style()->display(), EDisplay::TableCell); |
469 | 480 |
470 LayoutBlockFlow::styleDidChange(diff, oldStyle); | 481 LayoutBlockFlow::styleDidChange(diff, oldStyle); |
471 setHasBoxDecorationBackground(true); | 482 setHasBoxDecorationBackground(true); |
472 | 483 |
473 if (parent() && section() && oldStyle && | 484 if (parent() && section() && oldStyle && |
474 style()->height() != oldStyle->height()) | 485 style()->height() != oldStyle->height()) |
475 section()->rowLogicalHeightChanged(row()); | 486 section()->rowLogicalHeightChanged(row()); |
(...skipping 25 matching lines...) Expand all Loading... |
501 } | 512 } |
502 if (nextCell()) { | 513 if (nextCell()) { |
503 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is | 514 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is |
504 // needed instead of setNeedsLayout. | 515 // needed instead of setNeedsLayout. |
505 nextCell()->setChildNeedsLayout(); | 516 nextCell()->setChildNeedsLayout(); |
506 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); | 517 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
507 } | 518 } |
508 } | 519 } |
509 } | 520 } |
510 | 521 |
| 522 LayoutTableCell::RowBackgroundDisplayItemClient::RowBackgroundDisplayItemClient( |
| 523 const LayoutTableRow& layoutTableRow) |
| 524 : m_layoutTableRow(layoutTableRow) {} |
| 525 |
| 526 String LayoutTableCell::RowBackgroundDisplayItemClient::debugName() const { |
| 527 return "RowBackground"; |
| 528 } |
| 529 |
| 530 LayoutRect LayoutTableCell::RowBackgroundDisplayItemClient::visualRect() const { |
| 531 return m_layoutTableRow.visualRect(); |
| 532 } |
| 533 |
511 // The following rules apply for resolving conflicts and figuring out which | 534 // The following rules apply for resolving conflicts and figuring out which |
512 // border to use. | 535 // border to use. |
513 // (1) Borders with the 'border-style' of 'hidden' take precedence over all | 536 // (1) Borders with the 'border-style' of 'hidden' take precedence over all |
514 // other conflicting borders. Any border with this value suppresses all | 537 // other conflicting borders. Any border with this value suppresses all |
515 // borders at this location. | 538 // borders at this location. |
516 // (2) Borders with a style of 'none' have the lowest priority. Only if the | 539 // (2) Borders with a style of 'none' have the lowest priority. Only if the |
517 // border properties of all the elements meeting at this edge are 'none' | 540 // border properties of all the elements meeting at this edge are 'none' |
518 // will the border be omitted (but note that 'none' is the default value for | 541 // will the border be omitted (but note that 'none' is the default value for |
519 // the border style.) | 542 // the border style.) |
520 // (3) If none of the styles are 'hidden' and at least one of them is not | 543 // (3) If none of the styles are 'hidden' and at least one of them is not |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( | 1432 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( |
1410 const LayoutRect& localRect) const { | 1433 const LayoutRect& localRect) const { |
1411 // If this object has layer, the area of collapsed borders should be | 1434 // If this object has layer, the area of collapsed borders should be |
1412 // transparent to expose the collapsed borders painted on the underlying | 1435 // transparent to expose the collapsed borders painted on the underlying |
1413 // layer. | 1436 // layer. |
1414 if (hasLayer() && table()->collapseBorders()) | 1437 if (hasLayer() && table()->collapseBorders()) |
1415 return false; | 1438 return false; |
1416 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); | 1439 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); |
1417 } | 1440 } |
1418 | 1441 |
1419 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const { | 1442 bool LayoutTableCell::usesCompositedCellDisplayItemClients() const { |
1420 // In certain cases such as collapsed borders for composited table cells we | 1443 // In certain cases such as collapsed borders for composited table cells we |
1421 // paint content for the cell into the table graphics layer backing and so | 1444 // paint content for the cell into the table graphics layer backing and so |
1422 // must use the table's visual rect. | 1445 // must use the table's visual rect. |
1423 return (hasLayer() && layer()->compositingState() != NotComposited) || | 1446 return (hasLayer() && layer()->compositingState() != NotComposited) || |
1424 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); | 1447 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); |
1425 } | 1448 } |
1426 | 1449 |
1427 void LayoutTableCell::invalidateDisplayItemClients( | 1450 void LayoutTableCell::invalidateDisplayItemClients( |
1428 PaintInvalidationReason reason) const { | 1451 PaintInvalidationReason reason) const { |
1429 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) { | 1452 LayoutBlockFlow::invalidateDisplayItemClients(reason); |
1430 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( | 1453 |
1431 *m_collapsedBorderValues, reason); | 1454 if (!usesCompositedCellDisplayItemClients()) |
| 1455 return; |
| 1456 |
| 1457 ObjectPaintInvalidator invalidator(*this); |
| 1458 if (m_collapsedBorderValues) |
| 1459 invalidator.invalidateDisplayItemClient(*m_collapsedBorderValues, reason); |
| 1460 if (m_rowBackgroundDisplayItemClient) { |
| 1461 invalidator.invalidateDisplayItemClient(*m_rowBackgroundDisplayItemClient, |
| 1462 reason); |
1432 } | 1463 } |
1433 LayoutBlockFlow::invalidateDisplayItemClients(reason); | |
1434 } | 1464 } |
1435 | 1465 |
1436 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that | 1466 // TODO(lunalu): Deliberately dump the "inner" box of table cells, since that |
1437 // is what current results reflect. We'd like to clean up the results to dump | 1467 // is what current results reflect. We'd like to clean up the results to dump |
1438 // both the outer box and the intrinsic padding so that both bits of information | 1468 // both the outer box and the intrinsic padding so that both bits of information |
1439 // are captured by the results. | 1469 // are captured by the results. |
1440 LayoutRect LayoutTableCell::debugRect() const { | 1470 LayoutRect LayoutTableCell::debugRect() const { |
1441 LayoutRect rect = LayoutRect( | 1471 LayoutRect rect = LayoutRect( |
1442 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), | 1472 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), |
1443 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); | 1473 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); |
1444 | 1474 |
1445 LayoutBlock* cb = containingBlock(); | 1475 LayoutBlock* cb = containingBlock(); |
1446 if (cb) | 1476 if (cb) |
1447 cb->adjustChildDebugRect(rect); | 1477 cb->adjustChildDebugRect(rect); |
1448 | 1478 |
1449 return rect; | 1479 return rect; |
1450 } | 1480 } |
1451 | 1481 |
1452 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { | 1482 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { |
1453 r.move(0, -intrinsicPaddingBefore()); | 1483 r.move(0, -intrinsicPaddingBefore()); |
1454 } | 1484 } |
1455 | 1485 |
1456 } // namespace blink | 1486 } // namespace blink |
OLD | NEW |