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

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

Issue 2430313004: Paint collapsed borders of a table as one display item (Closed)
Patch Set: Rebaseline on mac and win 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, 2010, 2013 Apple Inc. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 745
746 // FIXME: This value isn't the intrinsic content logical height, but we need 746 // FIXME: This value isn't the intrinsic content logical height, but we need
747 // to update the value as its used by flexbox layout. crbug.com/367324 747 // to update the value as its used by flexbox layout. crbug.com/367324
748 setIntrinsicContentLogicalHeight(contentLogicalHeight()); 748 setIntrinsicContentLogicalHeight(contentLogicalHeight());
749 749
750 m_columnLogicalWidthChanged = false; 750 m_columnLogicalWidthChanged = false;
751 clearNeedsLayout(); 751 clearNeedsLayout();
752 } 752 }
753 753
754 void LayoutTable::invalidateCollapsedBorders() { 754 void LayoutTable::invalidateCollapsedBorders() {
755 m_collapsedBorders.clear(); 755 m_collapsedBordersInfo = nullptr;
756 if (!collapseBorders()) 756 if (!collapseBorders())
757 return; 757 return;
758 758
759 m_collapsedBordersValid = false; 759 m_collapsedBordersValid = false;
760 setMayNeedPaintInvalidation(); 760 setMayNeedPaintInvalidation();
761 } 761 }
762 762
763 // Collect all the unique border values that we want to paint in a sorted list. 763 // Collect all the unique border values that we want to paint in a sorted list.
764 // During the collection, each cell saves its recalculated borders into the 764 // During the collection, each cell saves its recalculated borders into the
765 // cache of its containing section, and invalidates itself if any border 765 // cache of its containing section, and invalidates itself if any border
766 // changes. This method doesn't affect layout. 766 // changes. This method doesn't affect layout.
767 void LayoutTable::recalcCollapsedBordersIfNeeded() { 767 void LayoutTable::recalcCollapsedBordersIfNeeded() {
768 if (m_collapsedBordersValid || !collapseBorders()) 768 if (m_collapsedBordersValid)
769 return; 769 return;
770 m_collapsedBordersValid = true; 770 m_collapsedBordersValid = true;
771 m_collapsedBorders.clear(); 771 m_collapsedBordersInfo = nullptr;
772 if (!collapseBorders())
773 return;
774
775 LayoutRect boundsOfChangedCells;
776 Vector<CollapsedBorderValue> values;
772 for (LayoutObject* section = firstChild(); section; 777 for (LayoutObject* section = firstChild(); section;
773 section = section->nextSibling()) { 778 section = section->nextSibling()) {
774 if (!section->isTableSection()) 779 if (!section->isTableSection())
775 continue; 780 continue;
776 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; 781 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row;
777 row = row->nextRow()) { 782 row = row->nextRow()) {
778 for (LayoutTableCell* cell = row->firstCell(); cell; 783 for (LayoutTableCell* cell = row->firstCell(); cell;
779 cell = cell->nextCell()) { 784 cell = cell->nextCell()) {
780 ASSERT(cell->table() == this); 785 DCHECK(cell->table() == this);
781 cell->collectBorderValues(m_collapsedBorders); 786 if (cell->collectBorderValues(values) &&
787 !shouldDoFullPaintInvalidation()) {
788 LayoutRect cellRect = cell->localVisualRect();
789 cell->mapToVisualRectInAncestorSpace(this, cellRect);
790 boundsOfChangedCells.unite(cellRect);
791 }
782 } 792 }
783 } 793 }
784 } 794 }
785 LayoutTableCell::sortBorderValues(m_collapsedBorders); 795 if (!values.isEmpty()) {
796 LayoutTableCell::sortBorderValues(values);
797 m_collapsedBordersInfo =
798 wrapUnique(new CollapsedBordersInfo(std::move(values)));
799 }
800
801 invalidatePaintRectangle(boundsOfChangedCells);
786 } 802 }
787 803
788 void LayoutTable::addOverflowFromChildren() { 804 void LayoutTable::addOverflowFromChildren() {
789 // Add overflow from borders. 805 // Add overflow from borders.
790 // Technically it's odd that we are incorporating the borders into layout 806 // Technically it's odd that we are incorporating the borders into layout
791 // overflow, which is only supposed to be about overflow from our 807 // overflow, which is only supposed to be about overflow from our
792 // descendant objects, but since tables don't support overflow:auto, this 808 // descendant objects, but since tables don't support overflow:auto, this
793 // works out fine. 809 // works out fine.
794 if (collapseBorders()) { 810 if (collapseBorders()) {
795 int rightBorderOverflow = 811 int rightBorderOverflow =
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 return style()->borderStart(); 1671 return style()->borderStart();
1656 } 1672 }
1657 1673
1658 void LayoutTable::ensureIsReadyForPaintInvalidation() { 1674 void LayoutTable::ensureIsReadyForPaintInvalidation() {
1659 LayoutBlock::ensureIsReadyForPaintInvalidation(); 1675 LayoutBlock::ensureIsReadyForPaintInvalidation();
1660 recalcCollapsedBordersIfNeeded(); 1676 recalcCollapsedBordersIfNeeded();
1661 } 1677 }
1662 1678
1663 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1679 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1664 const PaintInvalidationState& paintInvalidationState) { 1680 const PaintInvalidationState& paintInvalidationState) {
1665 if (collapseBorders() && !m_collapsedBorders.isEmpty()) 1681 if (hasCollapsedBorders()) {
1666 paintInvalidationState.paintingLayer() 1682 paintInvalidationState.paintingLayer()
1667 .setNeedsPaintPhaseDescendantBlockBackgrounds(); 1683 .setNeedsPaintPhaseDescendantBlockBackgrounds();
1668 1684 }
1669 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 1685 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
1670 } 1686 }
1671 1687
1672 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1688 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1673 const PaintInvalidatorContext& context) const { 1689 const PaintInvalidatorContext& context) const {
1674 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); 1690 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded();
1675 } 1691 }
1676 1692
1677 LayoutUnit LayoutTable::paddingTop() const { 1693 LayoutUnit LayoutTable::paddingTop() const {
1678 if (collapseBorders()) 1694 if (collapseBorders())
(...skipping 17 matching lines...) Expand all
1696 } 1712 }
1697 1713
1698 LayoutUnit LayoutTable::paddingRight() const { 1714 LayoutUnit LayoutTable::paddingRight() const {
1699 if (collapseBorders()) 1715 if (collapseBorders())
1700 return LayoutUnit(); 1716 return LayoutUnit();
1701 1717
1702 return LayoutBlock::paddingRight(); 1718 return LayoutBlock::paddingRight();
1703 } 1719 }
1704 1720
1705 } // namespace blink 1721 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutTable.h ('k') | third_party/WebKit/Source/core/layout/LayoutTableCell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698