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

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

Issue 2507893002: Fix painting background for composited table cells in a non-composited row. (Closed)
Patch Set: Add test expectations. Created 4 years, 1 month 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, 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
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
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::createCompositedCellDisplayItemClients() {
468 if (!usesCompositedCellDisplayItemClients())
469 return;
470
471 if (row()->styleRef().hasBackground() && !m_rowBackgroundDisplayItemClient) {
Xianzhu 2016/11/16 20:39:03 We should remove the hasbackground() condition for
wkorman 2016/11/16 21:42:45 Done.
472 m_rowBackgroundDisplayItemClient =
473 wrapUnique(new LayoutTableCell::RowBackgroundDisplayItemClient(*row()));
474 }
475 }
476
477 void LayoutTableCell::ensureIsReadyForPaintInvalidation() {
478 LayoutBlockFlow::ensureIsReadyForPaintInvalidation();
479 // Below handles the case where a page starts out in a state where the table
480 // cell compositing state and its container styling is such that one or more
481 // special display item clients are needed.
482 createCompositedCellDisplayItemClients();
Xianzhu 2016/11/16 20:39:03 With the call to createCompositedCellDisplayItemCl
wkorman 2016/11/16 21:42:44 Done.
483 }
484
466 void LayoutTableCell::styleDidChange(StyleDifference diff, 485 void LayoutTableCell::styleDidChange(StyleDifference diff,
467 const ComputedStyle* oldStyle) { 486 const ComputedStyle* oldStyle) {
468 DCHECK_EQ(style()->display(), EDisplay::TableCell); 487 DCHECK_EQ(style()->display(), EDisplay::TableCell);
469 488
470 LayoutBlockFlow::styleDidChange(diff, oldStyle); 489 LayoutBlockFlow::styleDidChange(diff, oldStyle);
471 setHasBoxDecorationBackground(true); 490 setHasBoxDecorationBackground(true);
472 491
473 if (parent() && section() && oldStyle && 492 if (parent() && section() && oldStyle &&
474 style()->height() != oldStyle->height()) 493 style()->height() != oldStyle->height())
475 section()->rowLogicalHeightChanged(row()); 494 section()->rowLogicalHeightChanged(row());
(...skipping 25 matching lines...) Expand all
501 } 520 }
502 if (nextCell()) { 521 if (nextCell()) {
503 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is 522 // TODO(dgrogan) Add a layout test showing that setChildNeedsLayout is
504 // needed instead of setNeedsLayout. 523 // needed instead of setNeedsLayout.
505 nextCell()->setChildNeedsLayout(); 524 nextCell()->setChildNeedsLayout();
506 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis); 525 nextCell()->setPreferredLogicalWidthsDirty(MarkOnlyThis);
507 } 526 }
508 } 527 }
509 } 528 }
510 529
530 LayoutTableCell::RowBackgroundDisplayItemClient::RowBackgroundDisplayItemClient(
531 const LayoutTableRow& layoutTableRow)
532 : m_layoutTableRow(layoutTableRow) {}
533
534 String LayoutTableCell::RowBackgroundDisplayItemClient::debugName() const {
535 return "RowBackground";
536 }
537
538 LayoutRect LayoutTableCell::RowBackgroundDisplayItemClient::visualRect() const {
539 return m_layoutTableRow.visualRect();
540 }
541
511 // The following rules apply for resolving conflicts and figuring out which 542 // The following rules apply for resolving conflicts and figuring out which
512 // border to use. 543 // border to use.
513 // (1) Borders with the 'border-style' of 'hidden' take precedence over all 544 // (1) Borders with the 'border-style' of 'hidden' take precedence over all
514 // other conflicting borders. Any border with this value suppresses all 545 // other conflicting borders. Any border with this value suppresses all
515 // borders at this location. 546 // borders at this location.
516 // (2) Borders with a style of 'none' have the lowest priority. Only if the 547 // (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' 548 // 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 549 // will the border be omitted (but note that 'none' is the default value for
519 // the border style.) 550 // the border style.)
520 // (3) If none of the styles are 'hidden' and at least one of them is not 551 // (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
1409 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect( 1440 bool LayoutTableCell::backgroundIsKnownToBeOpaqueInRect(
1410 const LayoutRect& localRect) const { 1441 const LayoutRect& localRect) const {
1411 // If this object has layer, the area of collapsed borders should be 1442 // If this object has layer, the area of collapsed borders should be
1412 // transparent to expose the collapsed borders painted on the underlying 1443 // transparent to expose the collapsed borders painted on the underlying
1413 // layer. 1444 // layer.
1414 if (hasLayer() && table()->collapseBorders()) 1445 if (hasLayer() && table()->collapseBorders())
1415 return false; 1446 return false;
1416 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect); 1447 return LayoutBlockFlow::backgroundIsKnownToBeOpaqueInRect(localRect);
1417 } 1448 }
1418 1449
1419 bool LayoutTableCell::usesTableAsAdditionalDisplayItemClient() const { 1450 bool LayoutTableCell::usesCompositedCellDisplayItemClients() const {
1420 // In certain cases such as collapsed borders for composited table cells we 1451 // 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 1452 // paint content for the cell into the table graphics layer backing and so
1422 // must use the table's visual rect. 1453 // must use the table's visual rect.
1423 return (hasLayer() && layer()->compositingState() != NotComposited) || 1454 return (hasLayer() && layer()->compositingState() != NotComposited) ||
1424 RuntimeEnabledFeatures::slimmingPaintV2Enabled(); 1455 RuntimeEnabledFeatures::slimmingPaintV2Enabled();
1425 } 1456 }
1426 1457
1427 void LayoutTableCell::invalidateDisplayItemClients( 1458 void LayoutTableCell::invalidateDisplayItemClients(
1428 PaintInvalidationReason reason) const { 1459 PaintInvalidationReason reason) const {
1429 if (m_collapsedBorderValues && usesTableAsAdditionalDisplayItemClient()) { 1460 LayoutBlockFlow::invalidateDisplayItemClients(reason);
1430 ObjectPaintInvalidator(*this).invalidateDisplayItemClient( 1461
1431 *m_collapsedBorderValues, reason); 1462 if (!usesCompositedCellDisplayItemClients())
1463 return;
1464
1465 ObjectPaintInvalidator invalidator(*this);
1466 if (m_collapsedBorderValues)
1467 invalidator.invalidateDisplayItemClient(*m_collapsedBorderValues, reason);
1468 if (m_rowBackgroundDisplayItemClient) {
1469 invalidator.invalidateDisplayItemClient(*m_rowBackgroundDisplayItemClient,
1470 reason);
1432 } 1471 }
1433 LayoutBlockFlow::invalidateDisplayItemClients(reason);
1434 } 1472 }
1435 1473
1436 // 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
1437 // 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
1438 // 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
1439 // are captured by the results. 1477 // are captured by the results.
1440 LayoutRect LayoutTableCell::debugRect() const { 1478 LayoutRect LayoutTableCell::debugRect() const {
1441 LayoutRect rect = LayoutRect( 1479 LayoutRect rect = LayoutRect(
1442 location().x(), location().y() + intrinsicPaddingBefore(), size().width(), 1480 location().x(), location().y() + intrinsicPaddingBefore(), size().width(),
1443 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter()); 1481 size().height() - intrinsicPaddingBefore() - intrinsicPaddingAfter());
1444 1482
1445 LayoutBlock* cb = containingBlock(); 1483 LayoutBlock* cb = containingBlock();
1446 if (cb) 1484 if (cb)
1447 cb->adjustChildDebugRect(rect); 1485 cb->adjustChildDebugRect(rect);
1448 1486
1449 return rect; 1487 return rect;
1450 } 1488 }
1451 1489
1452 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const { 1490 void LayoutTableCell::adjustChildDebugRect(LayoutRect& r) const {
1453 r.move(0, -intrinsicPaddingBefore()); 1491 r.move(0, -intrinsicPaddingBefore());
1454 } 1492 }
1455 1493
1456 } // namespace blink 1494 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698