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

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: Improve raster performance 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 // This records if any cell changed collapsed border and the cell is on a
776 // composited layer of the cell itself, the row or the section.
777 bool changedWithChildCompositedLayers = false;
778
779 Vector<CollapsedBorderValue> values;
772 for (LayoutObject* section = firstChild(); section; 780 for (LayoutObject* section = firstChild(); section;
773 section = section->nextSibling()) { 781 section = section->nextSibling()) {
774 if (!section->isTableSection()) 782 if (!section->isTableSection())
775 continue; 783 continue;
784 bool sectionChanged = false;
776 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; 785 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row;
777 row = row->nextRow()) { 786 row = row->nextRow()) {
787 bool rowChanged = false;
778 for (LayoutTableCell* cell = row->firstCell(); cell; 788 for (LayoutTableCell* cell = row->firstCell(); cell;
779 cell = cell->nextCell()) { 789 cell = cell->nextCell()) {
780 ASSERT(cell->table() == this); 790 ASSERT(cell->table() == this);
781 cell->collectBorderValues(m_collapsedBorders); 791 bool cellChanged = cell->collectBorderValues(values);
792 rowChanged |= cellChanged;
793 sectionChanged |= cellChanged;
794 changedWithChildCompositedLayers |=
795 cellChanged && cell->isPaintInvalidationContainer();
782 } 796 }
797 changedWithChildCompositedLayers |=
798 rowChanged && row->isPaintInvalidationContainer();
783 } 799 }
800 changedWithChildCompositedLayers |=
801 sectionChanged && section->isPaintInvalidationContainer();
784 } 802 }
785 LayoutTableCell::sortBorderValues(m_collapsedBorders); 803 if (!values.isEmpty()) {
804 LayoutTableCell::sortBorderValues(values);
805 m_collapsedBordersInfo =
806 wrapUnique(new CollapsedBordersInfo(std::move(values)));
807 }
808
809 if (shouldDoFullPaintInvalidation())
810 return;
811
812 // All collapsed borders are painted on the table's composited layer.
813 // If there is no changed collapsed borders on child composited layer, the
814 // changed cells should have already set paint invalidation flags because of
815 // layout or style change that affected collapsed borders, and their paint
816 // invalidation will invalidate the rects of the cells on the table's layer.
817 // Otherwise we conservatively mark the whole table as needing paint
818 // invalidation to cover any changed cells on the table's composited layer.
819 if (changedWithChildCompositedLayers) {
chrishtr 2016/11/11 19:18:01 How about using invalidatePaintRectangle of the un
Xianzhu 2016/11/11 20:09:30 Done. The new patch issues redundant rectangle pa
820 setShouldDoFullPaintInvalidation();
821 } else if (!shouldDoFullPaintInvalidation()) {
822 ObjectPaintInvalidator(*this)
823 .slowSetPaintingLayerNeedsRepaintAndInvalidateDisplayItemClient(
824 *this, PaintInvalidationStyleChange);
825 }
786 } 826 }
787 827
788 void LayoutTable::addOverflowFromChildren() { 828 void LayoutTable::addOverflowFromChildren() {
789 // Add overflow from borders. 829 // Add overflow from borders.
790 // Technically it's odd that we are incorporating the borders into layout 830 // Technically it's odd that we are incorporating the borders into layout
791 // overflow, which is only supposed to be about overflow from our 831 // overflow, which is only supposed to be about overflow from our
792 // descendant objects, but since tables don't support overflow:auto, this 832 // descendant objects, but since tables don't support overflow:auto, this
793 // works out fine. 833 // works out fine.
794 if (collapseBorders()) { 834 if (collapseBorders()) {
795 int rightBorderOverflow = 835 int rightBorderOverflow =
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 return style()->borderStart(); 1695 return style()->borderStart();
1656 } 1696 }
1657 1697
1658 void LayoutTable::ensureIsReadyForPaintInvalidation() { 1698 void LayoutTable::ensureIsReadyForPaintInvalidation() {
1659 LayoutBlock::ensureIsReadyForPaintInvalidation(); 1699 LayoutBlock::ensureIsReadyForPaintInvalidation();
1660 recalcCollapsedBordersIfNeeded(); 1700 recalcCollapsedBordersIfNeeded();
1661 } 1701 }
1662 1702
1663 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1703 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1664 const PaintInvalidationState& paintInvalidationState) { 1704 const PaintInvalidationState& paintInvalidationState) {
1665 if (collapseBorders() && !m_collapsedBorders.isEmpty()) 1705 if (hasCollapsedBorders()) {
1666 paintInvalidationState.paintingLayer() 1706 paintInvalidationState.paintingLayer()
1667 .setNeedsPaintPhaseDescendantBlockBackgrounds(); 1707 .setNeedsPaintPhaseDescendantBlockBackgrounds();
1668 1708 }
1669 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 1709 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
1670 } 1710 }
1671 1711
1672 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1712 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1673 const PaintInvalidatorContext& context) const { 1713 const PaintInvalidatorContext& context) const {
1674 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); 1714 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded();
1675 } 1715 }
1676 1716
1677 LayoutUnit LayoutTable::paddingTop() const { 1717 LayoutUnit LayoutTable::paddingTop() const {
1678 if (collapseBorders()) 1718 if (collapseBorders())
(...skipping 17 matching lines...) Expand all
1696 } 1736 }
1697 1737
1698 LayoutUnit LayoutTable::paddingRight() const { 1738 LayoutUnit LayoutTable::paddingRight() const {
1699 if (collapseBorders()) 1739 if (collapseBorders())
1700 return LayoutUnit(); 1740 return LayoutUnit();
1701 1741
1702 return LayoutBlock::paddingRight(); 1742 return LayoutBlock::paddingRight();
1703 } 1743 }
1704 1744
1705 } // namespace blink 1745 } // 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