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