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, 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // explicit width is specified on the table. Auto width implies auto table | 92 // explicit width is specified on the table. Auto width implies auto table |
93 // layout. | 93 // layout. |
94 if (style()->isFixedTableLayout()) | 94 if (style()->isFixedTableLayout()) |
95 m_tableLayout = makeUnique<TableLayoutAlgorithmFixed>(this); | 95 m_tableLayout = makeUnique<TableLayoutAlgorithmFixed>(this); |
96 else | 96 else |
97 m_tableLayout = makeUnique<TableLayoutAlgorithmAuto>(this); | 97 m_tableLayout = makeUnique<TableLayoutAlgorithmAuto>(this); |
98 } | 98 } |
99 | 99 |
100 // If border was changed, invalidate collapsed borders cache. | 100 // If border was changed, invalidate collapsed borders cache. |
101 if (!needsLayout() && oldStyle && oldStyle->border() != style()->border()) | 101 if (!needsLayout() && oldStyle && oldStyle->border() != style()->border()) |
102 invalidateCollapsedBorders(); | 102 invalidateCollapsedBorders(PaintInvalidationStyleChange); |
| 103 |
103 if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *this, diff, | 104 if (LayoutTableBoxComponent::doCellsHaveDirtyWidth(*this, *this, diff, |
104 *oldStyle)) | 105 *oldStyle)) |
105 markAllCellsWidthsDirtyAndOrNeedsLayout(MarkDirtyAndNeedsLayout); | 106 markAllCellsWidthsDirtyAndOrNeedsLayout(MarkDirtyAndNeedsLayout); |
106 } | 107 } |
107 | 108 |
108 static inline void resetSectionPointerIfNotBefore(LayoutTableSection*& ptr, | 109 static inline void resetSectionPointerIfNotBefore(LayoutTableSection*& ptr, |
109 LayoutObject* before) { | 110 LayoutObject* before) { |
110 if (!before || !ptr) | 111 if (!before || !ptr) |
111 return; | 112 return; |
112 LayoutObject* o = before->previousSibling(); | 113 LayoutObject* o = before->previousSibling(); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 updateLogicalHeight(); | 726 updateLogicalHeight(); |
726 | 727 |
727 // table can be containing block of positioned elements. | 728 // table can be containing block of positioned elements. |
728 bool dimensionChanged = oldLogicalWidth != logicalWidth() || | 729 bool dimensionChanged = oldLogicalWidth != logicalWidth() || |
729 oldLogicalHeight != logicalHeight(); | 730 oldLogicalHeight != logicalHeight(); |
730 layoutPositionedObjects(dimensionChanged); | 731 layoutPositionedObjects(dimensionChanged); |
731 | 732 |
732 updateLayerTransformAfterLayout(); | 733 updateLayerTransformAfterLayout(); |
733 | 734 |
734 // Layout was changed, so probably borders too. | 735 // Layout was changed, so probably borders too. |
735 invalidateCollapsedBorders(); | 736 invalidateCollapsedBorders(PaintInvalidationForcedByLayout); |
736 | 737 |
737 computeOverflow(clientLogicalBottom()); | 738 computeOverflow(clientLogicalBottom()); |
738 updateAfterLayout(); | 739 updateAfterLayout(); |
739 | 740 |
740 if (state.isPaginated() && isPageLogicalHeightKnown()) { | 741 if (state.isPaginated() && isPageLogicalHeightKnown()) { |
741 m_blockOffsetToFirstRepeatableHeader = state.pageLogicalOffset( | 742 m_blockOffsetToFirstRepeatableHeader = state.pageLogicalOffset( |
742 *this, topSection ? topSection->logicalTop() : LayoutUnit()); | 743 *this, topSection ? topSection->logicalTop() : LayoutUnit()); |
743 } | 744 } |
744 } | 745 } |
745 | 746 |
746 // FIXME: This value isn't the intrinsic content logical height, but we need | 747 // 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 | 748 // to update the value as its used by flexbox layout. crbug.com/367324 |
748 setIntrinsicContentLogicalHeight(contentLogicalHeight()); | 749 setIntrinsicContentLogicalHeight(contentLogicalHeight()); |
749 | 750 |
750 m_columnLogicalWidthChanged = false; | 751 m_columnLogicalWidthChanged = false; |
751 clearNeedsLayout(); | 752 clearNeedsLayout(); |
752 } | 753 } |
753 | 754 |
754 void LayoutTable::invalidateCollapsedBorders() { | 755 void LayoutTable::invalidateCollapsedBorders(PaintInvalidationReason reason) { |
755 m_collapsedBorders.clear(); | 756 DCHECK(reason == PaintInvalidationStyleChange || |
| 757 reason == PaintInvalidationForcedByLayout); |
| 758 |
| 759 m_collapsedBordersInfo = nullptr; |
756 if (!collapseBorders()) | 760 if (!collapseBorders()) |
757 return; | 761 return; |
758 | 762 |
759 m_collapsedBordersValid = false; | 763 m_collapsedBordersValid = false; |
760 setMayNeedPaintInvalidation(); | 764 if (reason == PaintInvalidationForcedByLayout) |
| 765 setShouldDoFullPaintInvalidation(reason); |
| 766 else |
| 767 setMayNeedPaintInvalidation(); |
761 } | 768 } |
762 | 769 |
763 // Collect all the unique border values that we want to paint in a sorted list. | 770 // 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 | 771 // During the collection, each cell saves its recalculated borders into the |
765 // cache of its containing section, and invalidates itself if any border | 772 // cache of its containing section, and invalidates itself if any border |
766 // changes. This method doesn't affect layout. | 773 // changes. This method doesn't affect layout. |
767 void LayoutTable::recalcCollapsedBordersIfNeeded() { | 774 void LayoutTable::recalcCollapsedBordersIfNeeded() { |
768 if (m_collapsedBordersValid || !collapseBorders()) | 775 if (m_collapsedBordersValid) |
769 return; | 776 return; |
770 m_collapsedBordersValid = true; | 777 m_collapsedBordersValid = true; |
771 m_collapsedBorders.clear(); | 778 m_collapsedBordersInfo = nullptr; |
| 779 if (!collapseBorders()) |
| 780 return; |
| 781 |
| 782 LayoutRect boundsOfChangedCells; |
| 783 Vector<CollapsedBorderValue> values; |
772 for (LayoutObject* section = firstChild(); section; | 784 for (LayoutObject* section = firstChild(); section; |
773 section = section->nextSibling()) { | 785 section = section->nextSibling()) { |
774 if (!section->isTableSection()) | 786 if (!section->isTableSection()) |
775 continue; | 787 continue; |
776 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; | 788 for (LayoutTableRow* row = toLayoutTableSection(section)->firstRow(); row; |
777 row = row->nextRow()) { | 789 row = row->nextRow()) { |
778 for (LayoutTableCell* cell = row->firstCell(); cell; | 790 for (LayoutTableCell* cell = row->firstCell(); cell; |
779 cell = cell->nextCell()) { | 791 cell = cell->nextCell()) { |
780 ASSERT(cell->table() == this); | 792 DCHECK(cell->table() == this); |
781 cell->collectBorderValues(m_collapsedBorders); | 793 bool cellChanged = cell->collectBorderValues(values); |
| 794 if (cellChanged && !shouldDoFullPaintInvalidation()) { |
| 795 LayoutRect cellRect = cell->localVisualRect(); |
| 796 cell->mapToVisualRectInAncestorSpace(this, cellRect); |
| 797 boundsOfChangedCells.unite(cellRect); |
| 798 } |
782 } | 799 } |
783 } | 800 } |
784 } | 801 } |
785 LayoutTableCell::sortBorderValues(m_collapsedBorders); | 802 if (!values.isEmpty()) { |
| 803 LayoutTableCell::sortBorderValues(values); |
| 804 m_collapsedBordersInfo = |
| 805 wrapUnique(new CollapsedBordersInfo(std::move(values))); |
| 806 } |
| 807 |
| 808 invalidatePaintRectangle(boundsOfChangedCells); |
786 } | 809 } |
787 | 810 |
788 void LayoutTable::addOverflowFromChildren() { | 811 void LayoutTable::addOverflowFromChildren() { |
789 // Add overflow from borders. | 812 // Add overflow from borders. |
790 // Technically it's odd that we are incorporating the borders into layout | 813 // Technically it's odd that we are incorporating the borders into layout |
791 // overflow, which is only supposed to be about overflow from our | 814 // overflow, which is only supposed to be about overflow from our |
792 // descendant objects, but since tables don't support overflow:auto, this | 815 // descendant objects, but since tables don't support overflow:auto, this |
793 // works out fine. | 816 // works out fine. |
794 if (collapseBorders()) { | 817 if (collapseBorders()) { |
795 int rightBorderOverflow = | 818 int rightBorderOverflow = |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 return style()->borderStart(); | 1678 return style()->borderStart(); |
1656 } | 1679 } |
1657 | 1680 |
1658 void LayoutTable::ensureIsReadyForPaintInvalidation() { | 1681 void LayoutTable::ensureIsReadyForPaintInvalidation() { |
1659 LayoutBlock::ensureIsReadyForPaintInvalidation(); | 1682 LayoutBlock::ensureIsReadyForPaintInvalidation(); |
1660 recalcCollapsedBordersIfNeeded(); | 1683 recalcCollapsedBordersIfNeeded(); |
1661 } | 1684 } |
1662 | 1685 |
1663 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( | 1686 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( |
1664 const PaintInvalidationState& paintInvalidationState) { | 1687 const PaintInvalidationState& paintInvalidationState) { |
1665 if (collapseBorders() && !m_collapsedBorders.isEmpty()) | 1688 if (hasCollapsedBorders()) { |
1666 paintInvalidationState.paintingLayer() | 1689 paintInvalidationState.paintingLayer() |
1667 .setNeedsPaintPhaseDescendantBlockBackgrounds(); | 1690 .setNeedsPaintPhaseDescendantBlockBackgrounds(); |
1668 | 1691 } |
1669 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); | 1692 return LayoutBlock::invalidatePaintIfNeeded(paintInvalidationState); |
1670 } | 1693 } |
1671 | 1694 |
1672 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( | 1695 PaintInvalidationReason LayoutTable::invalidatePaintIfNeeded( |
1673 const PaintInvalidatorContext& context) const { | 1696 const PaintInvalidatorContext& context) const { |
1674 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); | 1697 return TablePaintInvalidator(*this, context).invalidatePaintIfNeeded(); |
1675 } | 1698 } |
1676 | 1699 |
1677 LayoutUnit LayoutTable::paddingTop() const { | 1700 LayoutUnit LayoutTable::paddingTop() const { |
1678 if (collapseBorders()) | 1701 if (collapseBorders()) |
(...skipping 17 matching lines...) Expand all Loading... |
1696 } | 1719 } |
1697 | 1720 |
1698 LayoutUnit LayoutTable::paddingRight() const { | 1721 LayoutUnit LayoutTable::paddingRight() const { |
1699 if (collapseBorders()) | 1722 if (collapseBorders()) |
1700 return LayoutUnit(); | 1723 return LayoutUnit(); |
1701 | 1724 |
1702 return LayoutBlock::paddingRight(); | 1725 return LayoutBlock::paddingRight(); |
1703 } | 1726 } |
1704 | 1727 |
1705 } // namespace blink | 1728 } // namespace blink |
OLD | NEW |