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

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: - 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 setShouldDoFullPaintInvalidation();
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 Vector<CollapsedBorderValue> values;
772 for (LayoutObject* section = firstChild(); section; 776 for (LayoutObject* section = firstChild(); section;
773 section = section->nextSibling()) { 777 section = section->nextSibling()) {
774 if (!section->isTableSection()) 778 if (!section->isTableSection())
775 continue; 779 continue;
776 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; 780 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row;
777 row = row->nextRow()) { 781 row = row->nextRow()) {
778 for (LayoutTableCell* cell = row->firstCell(); cell; 782 for (LayoutTableCell* cell = row->firstCell(); cell;
779 cell = cell->nextCell()) { 783 cell = cell->nextCell()) {
780 ASSERT(cell->table() == this); 784 ASSERT(cell->table() == this);
781 cell->collectBorderValues(m_collapsedBorders); 785 cell->collectBorderValues(values);
782 } 786 }
783 } 787 }
784 } 788 }
785 LayoutTableCell::sortBorderValues(m_collapsedBorders); 789 if (!values.isEmpty()) {
790 LayoutTableCell::sortBorderValues(values);
791 m_collapsedBordersInfo =
792 wrapUnique(new CollapsedBordersInfo(std::move(values)));
793 }
786 } 794 }
787 795
788 void LayoutTable::addOverflowFromChildren() { 796 void LayoutTable::addOverflowFromChildren() {
789 // Add overflow from borders. 797 // Add overflow from borders.
790 // Technically it's odd that we are incorporating the borders into layout 798 // Technically it's odd that we are incorporating the borders into layout
791 // overflow, which is only supposed to be about overflow from our 799 // overflow, which is only supposed to be about overflow from our
792 // descendant objects, but since tables don't support overflow:auto, this 800 // descendant objects, but since tables don't support overflow:auto, this
793 // works out fine. 801 // works out fine.
794 if (collapseBorders()) { 802 if (collapseBorders()) {
795 int rightBorderOverflow = 803 int rightBorderOverflow =
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 return style()->borderStart(); 1663 return style()->borderStart();
1656 } 1664 }
1657 1665
1658 void LayoutTable::ensureIsReadyForPaintInvalidation() { 1666 void LayoutTable::ensureIsReadyForPaintInvalidation() {
1659 LayoutBlock::ensureIsReadyForPaintInvalidation(); 1667 LayoutBlock::ensureIsReadyForPaintInvalidation();
1660 recalcCollapsedBordersIfNeeded(); 1668 recalcCollapsedBordersIfNeeded();
1661 } 1669 }
1662 1670
1663 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1671 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1664 const PaintInvalidationState& paintInvalidationState) { 1672 const PaintInvalidationState& paintInvalidationState) {
1665 if (collapseBorders() && !m_collapsedBorders.isEmpty()) 1673 if (hasCollapsedBorders()) {
1666 paintInvalidationState.paintingLayer() 1674 paintInvalidationState.paintingLayer()
1667 .setNeedsPaintPhaseDescendantBlockBackgrounds(); 1675 .setNeedsPaintPhaseDescendantBlockBackgrounds();
1668 1676 }
1669 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); 1677 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState);
1670 } 1678 }
1671 1679
1672 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( 1680 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded(
1673 const PaintInvalidatorContext& context) const { 1681 const PaintInvalidatorContext& context) const {
1674 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); 1682 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded();
1675 } 1683 }
1676 1684
1677 LayoutUnit LayoutTable::paddingTop() const { 1685 LayoutUnit LayoutTable::paddingTop() const {
1678 if (collapseBorders()) 1686 if (collapseBorders())
(...skipping 17 matching lines...) Expand all
1696 } 1704 }
1697 1705
1698 LayoutUnit LayoutTable::paddingRight() const { 1706 LayoutUnit LayoutTable::paddingRight() const {
1699 if (collapseBorders()) 1707 if (collapseBorders())
1700 return LayoutUnit(); 1708 return LayoutUnit();
1701 1709
1702 return LayoutBlock::paddingRight(); 1710 return LayoutBlock::paddingRight();
1703 } 1711 }
1704 1712
1705 } // namespace blink 1713 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698