Changeset 223955 in webkit
- Timestamp:
- Oct 25, 2017 9:38:14 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r223954 r223955 1 2017-10-25 Javier Fernandez <jfernandez@igalia.com> 2 3 [css-grid] Avoid clearing the overrideContainingBlockWidth if possible 4 https://bugs.webkit.org/show_bug.cgi?id=178260 5 6 Reviewed by Sergio Villar Senin. 7 8 Since the intrinsic width computation uses the same logic than the 9 track sizing algorithm we are clearing the overrideContainingBlockWidth 10 of some grid items that are required to laid out them properly. 11 12 It's very uncommon that any intrinsic size computation isn't performed 13 as part of a layout process. However, if it happens, once cleared the 14 overrideContainingBlockWidth it may lead to an incorrect layout of the 15 affected grid items. 16 17 This change is a defensive approach to avoid the issues caused by 18 such off-layout preferred size requests, which may imply recomputing 19 the grid container intrinsic size. 20 21 No new tests, because we are only removing some redundant logic. 22 23 * rendering/GridTrackSizingAlgorithm.cpp: 24 (WebCore::GridTrackSizingAlgorithmStrategy::minContentForChild const): 25 (WebCore::GridTrackSizingAlgorithmStrategy::maxContentForChild const): 26 (WebCore::GridTrackSizingAlgorithmStrategy::minSizeForChild const): 27 (WebCore::GridTrackSizingAlgorithmStrategy::updateOverrideContainingBlockContentSizeForChild const): 28 (WebCore::IndefiniteSizeStrategy::minLogicalWidthForChild const): 29 (WebCore::DefiniteSizeStrategy::minLogicalWidthForChild const): 30 * rendering/GridTrackSizingAlgorithm.h: 31 1 32 2017-10-25 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> 2 33 -
trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
r222556 r223955 743 743 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(renderGrid(), child, ForColumns); 744 744 if (direction() == childInlineDirection) { 745 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is746 // what we are interested in here. Thus we need to set the override logical width to std::nullopt (no possible resolution).747 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColumns))748 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection, std::nullopt);749 750 745 // FIXME: It's unclear if we should return the intrinsic width or the preferred width. 751 746 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html … … 763 758 GridTrackSizingDirection childInlineDirection = flowAwareDirectionForChild(renderGrid(), child, ForColumns); 764 759 if (direction() == childInlineDirection) { 765 // If |child| has a relative logical width, we shouldn't let it override its intrinsic width, which is766 // what we are interested in here. Thus we need to set the inline-axis override size to -1 (no possible resolution).767 if (shouldClearOverrideContainingBlockContentSizeForChild(child, ForColumns))768 setOverrideContainingBlockContentSizeForChild(child, childInlineDirection, std::nullopt);769 770 760 // FIXME: It's unclear if we should return the intrinsic width or the preferred width. 771 761 // See http://lists.w3.org/Archives/Public/www-style/2013Jan/0245.html … … 790 780 return minContentForChild(child); 791 781 792 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChild(child, childInlineDirection); 793 782 LayoutUnit gridAreaSize = m_algorithm.gridAreaBreadthForChild(child, childInlineDirection); 794 783 if (isRowAxis) 795 return minLogicalWidthForChild(child, childMinSize, childInlineDirection); 796 784 return minLogicalWidthForChild(child, childMinSize, gridAreaSize); 785 786 bool overrideSizeHasChanged = updateOverrideContainingBlockContentSizeForChild(child, childInlineDirection, gridAreaSize); 797 787 layoutGridItemForMinSizeComputation(child, overrideSizeHasChanged); 798 788 … … 800 790 } 801 791 802 bool GridTrackSizingAlgorithmStrategy::updateOverrideContainingBlockContentSizeForChild(RenderBox& child, GridTrackSizingDirection direction) const 803 { 804 LayoutUnit overrideSize = m_algorithm.gridAreaBreadthForChild(child, direction); 792 bool GridTrackSizingAlgorithmStrategy::updateOverrideContainingBlockContentSizeForChild(RenderBox& child, GridTrackSizingDirection direction, std::optional<LayoutUnit> overrideSize) const 793 { 794 if (!overrideSize) 795 overrideSize = m_algorithm.gridAreaBreadthForChild(child, direction); 805 796 if (hasOverrideContainingBlockContentSizeForChild(child, direction) && overrideContainingBlockContentSizeForChild(child, direction) == overrideSize) 806 797 return false; … … 816 807 817 808 private: 818 LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, GridTrackSizingDirection) const override;809 LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, LayoutUnit availableSize) const override; 819 810 void layoutGridItemForMinSizeComputation(RenderBox&, bool overrideSizeHasChanged) const override; 820 811 void maximizeTracks(Vector<GridTrack>&, std::optional<LayoutUnit>& freeSpace) override; … … 823 814 }; 824 815 825 LayoutUnit IndefiniteSizeStrategy::minLogicalWidthForChild(RenderBox& child, Length childMinSize, GridTrackSizingDirection childInlineDirection) const826 { 827 return child.computeLogicalWidthInFragmentUsing(MinSize, childMinSize, overrideContainingBlockContentSizeForChild(child, childInlineDirection).value_or(0), *renderGrid(), nullptr) + marginIntrinsicLogicalWidthForChild(renderGrid(), child);816 LayoutUnit IndefiniteSizeStrategy::minLogicalWidthForChild(RenderBox& child, Length childMinSize, LayoutUnit availableSize) const 817 { 818 return child.computeLogicalWidthInFragmentUsing(MinSize, childMinSize, availableSize, *renderGrid(), nullptr) + marginIntrinsicLogicalWidthForChild(renderGrid(), child); 828 819 } 829 820 … … 913 904 914 905 private: 915 LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, GridTrackSizingDirection) const override;906 LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, LayoutUnit availableSize) const override; 916 907 void layoutGridItemForMinSizeComputation(RenderBox&, bool overrideSizeHasChanged) const override; 917 908 void maximizeTracks(Vector<GridTrack>&, std::optional<LayoutUnit>& freeSpace) override; … … 920 911 }; 921 912 922 LayoutUnit DefiniteSizeStrategy::minLogicalWidthForChild(RenderBox& child, Length childMinSize, GridTrackSizingDirection childInlineDirection) const913 LayoutUnit DefiniteSizeStrategy::minLogicalWidthForChild(RenderBox& child, Length childMinSize, LayoutUnit availableSize) const 923 914 { 924 915 LayoutUnit marginLogicalWidth = 925 computeMarginLogicalSizeForChild( childInlineDirection, *renderGrid(), child);926 return child.computeLogicalWidthInFragmentUsing(MinSize, childMinSize, overrideContainingBlockContentSizeForChild(child, childInlineDirection).value_or(0), *renderGrid(), nullptr) + marginLogicalWidth;916 computeMarginLogicalSizeForChild(flowAwareDirectionForChild(renderGrid(), child, ForColumns), *renderGrid(), child); 917 return child.computeLogicalWidthInFragmentUsing(MinSize, childMinSize, availableSize, *renderGrid(), nullptr) + marginLogicalWidth; 927 918 } 928 919 -
trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.h
r223728 r223955 229 229 : m_algorithm(algorithm) { } 230 230 231 virtual LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, GridTrackSizingDirection) const = 0;231 virtual LayoutUnit minLogicalWidthForChild(RenderBox&, Length childMinSize, LayoutUnit availableSize) const = 0; 232 232 virtual void layoutGridItemForMinSizeComputation(RenderBox&, bool overrideSizeHasChanged) const = 0; 233 233 234 234 LayoutUnit logicalHeightForChild(RenderBox&) const; 235 bool updateOverrideContainingBlockContentSizeForChild(RenderBox&, GridTrackSizingDirection ) const;235 bool updateOverrideContainingBlockContentSizeForChild(RenderBox&, GridTrackSizingDirection, std::optional<LayoutUnit> = std::nullopt) const; 236 236 237 237 // GridTrackSizingAlgorithm accessors for subclasses.
Note: See TracChangeset
for help on using the changeset viewer.