⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277321 in webkit


Ignore:
Timestamp:
May 11, 2021, 5:49:46 AM (5 years ago)
Author:
cathiechen
Message:

[CSS contain] Support contain:size
https://bugs.webkit.org/show_bug.cgi?id=223570

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

<canvas> and <video> don't support computing aspect ratio from width and height attributes yet,
so the heights are zero when they are with "contain: size".

  • web-platform-tests/css/css-contain/contain-size-grid-003-expected.txt:
  • web-platform-tests/css/css-contain/contain-size-grid-004-expected.txt:
  • web-platform-tests/css/css-contain/contain-size-multicol-as-flex-item-expected.txt:
  • web-platform-tests/css/css-flexbox/flex-item-contains-strict-expected.txt:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt:
  • web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt:

Source/WebCore:

This patch brings initial support of CSS contain:size according to [1].
It adds shouldApplySizeContainment() to indicate whether the object is a size containment box.
The intrinsic sizes of size containment box are determined as if it had no content.
So the implementation need to cooperate with the layout steps:

  • Computing logical width: Size containment boxes skip handling children while computing minLogicalWidth and maxLogicalWidth in computeIntrinsicLogicalWidths. So the logical width is not affected by children.
  • Layout children: The logical height is changed after layout all children.
  • Computing logical height: At the beginning, size containment boxes need to reset logical height to the empty content height if it is not renderGrid. So the logical height is not affected by children.

We also need to calculate the sizes according to the layout algorithms.

  • Grid layout: To calculate the minLogicalWidth and maxLogicalWidth for indefinite size RenderGrid. The widths are calculated by GridTrackSizingAlgorithm: m_minContentSize and m_maxContentSize which are the sum of m_baseSize/m_growthLimit of all GridTracks. The size containment RenderGrid skips handling content in resolveIntrinsicTrackSizes and the m_maxContentSize will be the sum of m_baseSize. The logical height is same to width, but after calculating RenderGrid's logical height, it needs to calculate the track sizes again, to make sure that they are distributed properly. We use computeTrackSizesForDefiniteSize(ForRows, trackBasedLogicalHeight) to recalculate it.
  • MultiColumn layout: According to the specification, size containment boxes should be monolithic, so we need to extend column height for overflow and positioned size containment boxes. m_spaceShortageForSizeContainment is added to indicate the shortage space that need to balance the column heights. adjustSizeContainmentChildForPagination() will calculate the shortage.

[1] https://www.w3.org/TR/css-contain-1/#containment-size

  • rendering/GridTrackSizingAlgorithm.cpp: Add isComputingSizeContainment to indicate if it is calculating sizes for indefinite size RenderGrid which is size containment.

(WebCore::GridTrackSizingAlgorithm::gridAreaBreadthForChild const):
(WebCore::GridTrackSizingAlgorithm::computeGridContainerIntrinsicSizes):

It skips resolveIntrinsicTrackSizes if isComputingSizeContainment, so growthLimit might be undefined,
if so, use track.baseSize() instead.

(WebCore::GridTrackSizingAlgorithm::resolveIntrinsicTrackSizes): Skip resolve the content if isComputingSizeContainment().
(WebCore::GridTrackSizingAlgorithm::advanceNextState): Added RowSizingExtraIterationForSizeContainment.
(WebCore::GridTrackSizingAlgorithm::isValidTransition const):
(WebCore::GridTrackSizingAlgorithm::run): Do not stretch the track sizes if isComputingSizeContainment().

  • rendering/GridTrackSizingAlgorithm.h:
  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::layoutPositionedObject): Calculate m_spaceShortageForSizeContainment for positioned size containment.
(WebCore::RenderBlock::computeIntrinsicLogicalWidths const): Skip computeBlockPreferredLogicalWidths if shouldApplySizeContainment.

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths const): Skip handling the children for size containment box.
(WebCore::RenderBlockFlow::adjustBlockChildForPagination): Calculate m_spaceShortageForSizeContainment for child.
(WebCore::RenderBlockFlow::adjustSizeContainmentChildForPagination): m_spaceShortageForSizeContainment = childOverflowHeight - remainingLogicalHeight.

  • rendering/RenderBlockFlow.h:
  • rendering/RenderBox.cpp:

(WebCore::RenderBox::updateLogicalHeight): Reset the logical height to empty content height for size containment box.
(WebCore::RenderBox::isUnsplittableForPagination const): Size containment box is unsplittable.

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::RenderDeprecatedFlexibleBox::computeIntrinsicLogicalWidths const): Ditto.

  • rendering/RenderFileUploadControl.cpp:

(WebCore::RenderFileUploadControl::computeIntrinsicLogicalWidths const): Ditto.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths const): Ditto.

  • rendering/RenderFragmentedFlow.h:
  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::layoutBlock): If it is size containment with infiniteSize, using trackBasedLogicalHeight
to compute track sizes again to make sure the height is distributed properly.
(WebCore::RenderGrid::computeEmptyTracksForAutoRepeat const): Collapse if shouldApplySizeContainment.

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::computeIntrinsicRatioInformation const): This is handled in RenderReplaced::computeIntrinsicRatioInformation instead.

  • rendering/RenderListBox.cpp:

(WebCore::RenderListBox::computeIntrinsicLogicalWidths const): The widths of size containment boxes are optionsSpacingHorizontal.

  • rendering/RenderMenuList.cpp:

(RenderMenuList::computeIntrinsicLogicalWidths const): The widths of size containment box are theme.minimumMenuListSize.

  • rendering/RenderMultiColumnFlow.cpp:

(WebCore::RenderMultiColumnFlow::updateSpaceShortageForSizeContainment): Set m_spaceShortageForSizeContainment.

  • rendering/RenderMultiColumnFlow.h:
  • rendering/RenderMultiColumnSet.cpp:

(WebCore::RenderMultiColumnSet::RenderMultiColumnSet):
(WebCore::RenderMultiColumnSet::calculateBalancedHeight const): Add m_spaceShortageForSizeContainment to the column height.
(WebCore::RenderMultiColumnSet::prepareForLayout): Reset m_spaceShortageForSizeContainment.

  • rendering/RenderMultiColumnSet.h:
  • rendering/RenderObject.cpp:

(WebCore::shouldApplySizeContainment): Check if the object is a size containment box.

  • rendering/RenderObject.h:

(WebCore::RenderObject::isAtomicInlineLevelBox const):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox const):
(WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Use the empty intrinsicSize.

  • rendering/RenderReplaced.h: The intrinsicSize of size containment is (0, 0).
  • rendering/RenderSlider.cpp:

(WebCore::RenderSlider::computeIntrinsicLogicalWidths const): Ditto.

  • rendering/RenderTextControl.cpp:

(WebCore::RenderTextControl::computeIntrinsicLogicalWidths const): Ditto.

  • rendering/RenderVideo.cpp:

(WebCore::RenderVideo::calculateIntrinsicSize): Ditto.

  • rendering/style/RenderStyle.h:

(WebCore::RenderStyle::containsSize const):

  • rendering/svg/RenderSVGRoot.cpp:

(WebCore::RenderSVGRoot::computeIntrinsicRatioInformation const): Handled in RenderReplaced::computeIntrinsicRatioInformation instead.

LayoutTests:

Update the test result for size containment. Added explanations for size containment tests
that depended on other features.

Location:
trunk
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r277320 r277321  
     12021-05-11  Cathie Chen  <cathiechen@igalia.com>
     2
     3        [CSS contain] Support contain:size
     4        https://bugs.webkit.org/show_bug.cgi?id=223570
     5
     6        Reviewed by Alan Bujtas.
     7
     8        Update the test result for size containment. Added explanations for size containment tests
     9        that depended on other features.
     10
     11        * TestExpectations:
     12
    1132021-05-11  Antti Koivisto  <antti@apple.com>
    214
  • trunk/LayoutTests/TestExpectations

    r277091 r277321  
    46474647
    46484648# CSS containment tests that fail
    4649 imported/w3c/web-platform-tests/css/css-contain/contain-animation-001.html [ ImageOnlyFailure ]
    46504649# webkit-ruby-text
    46514650imported/w3c/web-platform-tests/css/css-contain/contain-layout-017.html [ ImageOnlyFailure ]
     
    46644663imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-021.html [ ImageOnlyFailure ]
    46654664imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-022.html [ ImageOnlyFailure ]
    4666 imported/w3c/web-platform-tests/css/css-contain/contain-layout-size-003.html [ ImageOnlyFailure ]
    46674665imported/w3c/web-platform-tests/css/css-contain/contain-paint-001.html [ ImageOnlyFailure ]
    46684666imported/w3c/web-platform-tests/css/css-contain/contain-paint-004.html [ ImageOnlyFailure ]
     
    47064704imported/w3c/web-platform-tests/css/css-contain/contain-paint-table-001.html [ ImageOnlyFailure ]
    47074705imported/w3c/web-platform-tests/css/css-contain/contain-paint-table-002.html [ ImageOnlyFailure ]
    4708 imported/w3c/web-platform-tests/css/css-contain/contain-size-011.html [ ImageOnlyFailure ]
    4709 imported/w3c/web-platform-tests/css/css-contain/contain-size-013.html [ ImageOnlyFailure ]
    4710 imported/w3c/web-platform-tests/css/css-contain/contain-size-021.html [ ImageOnlyFailure ]
    4711 imported/w3c/web-platform-tests/css/css-contain/contain-size-023.html [ ImageOnlyFailure ]
    4712 imported/w3c/web-platform-tests/css/css-contain/contain-size-025.html [ ImageOnlyFailure ]
    4713 imported/w3c/web-platform-tests/css/css-contain/contain-size-027.html [ ImageOnlyFailure ]
    4714 imported/w3c/web-platform-tests/css/css-contain/contain-size-041.html [ ImageOnlyFailure ]
    4715 imported/w3c/web-platform-tests/css/css-contain/contain-size-042.html [ ImageOnlyFailure ]
    4716 imported/w3c/web-platform-tests/css/css-contain/contain-size-056.html [ ImageOnlyFailure ]
    4717 imported/w3c/web-platform-tests/css/css-contain/contain-size-061.html [ ImageOnlyFailure ]
    4718 imported/w3c/web-platform-tests/css/css-contain/contain-size-062.html [ ImageOnlyFailure ]
    4719 imported/w3c/web-platform-tests/css/css-contain/contain-size-063.html [ ImageOnlyFailure ]
    4720 imported/w3c/web-platform-tests/css/css-contain/contain-size-064.html [ ImageOnlyFailure ]
    4721 imported/w3c/web-platform-tests/css/css-contain/contain-size-block-001.html [ ImageOnlyFailure ]
    4722 imported/w3c/web-platform-tests/css/css-contain/contain-size-block-002.html [ ImageOnlyFailure ]
    4723 imported/w3c/web-platform-tests/css/css-contain/contain-size-block-003.html [ ImageOnlyFailure ]
    4724 imported/w3c/web-platform-tests/css/css-contain/contain-size-block-004.html [ ImageOnlyFailure ]
    4725 imported/w3c/web-platform-tests/css/css-contain/contain-size-borders.html [ ImageOnlyFailure ]
    4726 imported/w3c/web-platform-tests/css/css-contain/contain-size-breaks-001.html [ ImageOnlyFailure ]
    4727 imported/w3c/web-platform-tests/css/css-contain/contain-size-button-001.html [ ImageOnlyFailure ]
    4728 imported/w3c/web-platform-tests/css/css-contain/contain-size-button-002.html [ ImageOnlyFailure ]
    4729 imported/w3c/web-platform-tests/css/css-contain/contain-size-fieldset-001.html [ ImageOnlyFailure ]
    4730 imported/w3c/web-platform-tests/css/css-contain/contain-size-fieldset-002.html [ ImageOnlyFailure ]
    4731 imported/w3c/web-platform-tests/css/css-contain/contain-size-fieldset-003.html [ ImageOnlyFailure ]
    4732 imported/w3c/web-platform-tests/css/css-contain/contain-size-fieldset-004.html [ ImageOnlyFailure ]
    4733 imported/w3c/web-platform-tests/css/css-contain/contain-size-flex-001.html [ ImageOnlyFailure ]
    4734 imported/w3c/web-platform-tests/css/css-contain/contain-size-flexbox-001.html [ ImageOnlyFailure ]
    4735 imported/w3c/web-platform-tests/css/css-contain/contain-size-grid-001.html [ ImageOnlyFailure ]
    4736 imported/w3c/web-platform-tests/css/css-contain/contain-size-grid-002.html [ ImageOnlyFailure ]
    4737 imported/w3c/web-platform-tests/css/css-contain/contain-size-grid-005.html [ ImageOnlyFailure ]
    4738 imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-block-001.html [ ImageOnlyFailure ]
    4739 imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-block-002.html [ ImageOnlyFailure ]
    4740 imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-block-003.html [ ImageOnlyFailure ]
    4741 imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-block-004.html [ ImageOnlyFailure ]
    4742 imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-flex-001.html [ ImageOnlyFailure ]
    4743 imported/w3c/web-platform-tests/css/css-contain/contain-size-monolithic-001.html [ ImageOnlyFailure ]
    4744 imported/w3c/web-platform-tests/css/css-contain/contain-size-monolithic-002.html [ ImageOnlyFailure ]
    4745 imported/w3c/web-platform-tests/css/css-contain/contain-size-multicol-001.html [ ImageOnlyFailure ]
    4746 imported/w3c/web-platform-tests/css/css-contain/contain-size-multicol-002.html [ ImageOnlyFailure ]
    4747 imported/w3c/web-platform-tests/css/css-contain/contain-size-multicol-003.html [ ImageOnlyFailure ]
    4748 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-001.html [ ImageOnlyFailure ]
    4749 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-002.html [ ImageOnlyFailure ]
    4750 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-003a.html [ ImageOnlyFailure ]
    4751 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-003b.html [ ImageOnlyFailure ]
    4752 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-003c.html [ ImageOnlyFailure ]
    4753 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-004.html [ ImageOnlyFailure ]
    4754 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-005.html [ ImageOnlyFailure ]
    4755 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-006.html [ ImageOnlyFailure ]
    4756 imported/w3c/web-platform-tests/css/css-contain/contain-size-scrollbars-001.html [ ImageOnlyFailure ]
    4757 imported/w3c/web-platform-tests/css/css-contain/contain-size-scrollbars-002.html [ ImageOnlyFailure ]
    4758 imported/w3c/web-platform-tests/css/css-contain/contain-size-scrollbars-003.html [ ImageOnlyFailure ]
    4759 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-001.html [ ImageOnlyFailure ]
    4760 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-002.html [ ImageOnlyFailure ]
    4761 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-001.html [ ImageOnlyFailure ]
    4762 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-002.html [ ImageOnlyFailure ]
    4763 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-003.html [ ImageOnlyFailure ]
    4764 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-004.html [ ImageOnlyFailure ]
    4765 imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-005.html [ ImageOnlyFailure ]
    4766 imported/w3c/web-platform-tests/css/css-contain/contain-size-table-caption-001.html [ ImageOnlyFailure ]
    47674706imported/w3c/web-platform-tests/css/css-contain/contain-strict-001.html [ ImageOnlyFailure ]
    47684707imported/w3c/web-platform-tests/css/css-contain/contain-strict-002.html [ ImageOnlyFailure ]
    4769 imported/w3c/web-platform-tests/css/css-contain/contain-strict-003.html [ ImageOnlyFailure ]
    47704708imported/w3c/web-platform-tests/css/css-contain/contain-strict-011.html [ ImageOnlyFailure ]
    47714709imported/w3c/web-platform-tests/css/css-contain/contain-style-counters-001.html [ ImageOnlyFailure ]
     
    48024740# Flaky css-contain test
    48034741imported/w3c/web-platform-tests/css/css-contain/content-visibility/animation-display-lock.html [ Failure Pass ]
     4742
     4743# Canvas doesn't get default aspect-ratio for width and height attributes.
     4744webkit.org/b/217529 imported/w3c/web-platform-tests/css/css-flexbox/canvas-contain-size.html [ ImageOnlyFailure ]
     4745
     4746# Content is painted on svg's padding area.
     4747webkit.org/b/425868 imported/w3c/web-platform-tests/css/css-contain/contain-size-replaced-002.html [ ImageOnlyFailure ]
     4748
     4749# Multicolumn does not paint the horizontal overflow area of a relative child.
     4750webkit.org/b/41796 imported/w3c/web-platform-tests/css/css-contain/contain-size-monolithic-002.html [ ImageOnlyFailure ]
     4751
     4752# Buttons with auto width and height has extra margins.
     4753imported/w3c/web-platform-tests/css/css-contain/contain-size-button-001.html [ ImageOnlyFailure ]
     4754imported/w3c/web-platform-tests/css/css-contain/contain-size-button-002.html [ ImageOnlyFailure ]
     4755
     4756# Scrollbar displays are different.
     4757imported/w3c/web-platform-tests/css/css-contain/contain-size-block-003.html [ ImageOnlyFailure ]
     4758imported/w3c/web-platform-tests/css/css-contain/contain-size-inline-block-003.html [ ImageOnlyFailure ]
     4759
     4760# Select with empty content always has root linebox, so the heights are different.
     4761imported/w3c/web-platform-tests/css/css-contain/contain-size-select-001.html [ ImageOnlyFailure ]
     4762imported/w3c/web-platform-tests/css/css-contain/contain-size-select-002.html [ ImageOnlyFailure ]
     4763
     4764# CSS property color is not working in select elements.
     4765imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-001.html [ ImageOnlyFailure ]
     4766imported/w3c/web-platform-tests/css/css-contain/contain-size-select-elem-002.html [ ImageOnlyFailure ]
    48044767
    48054768# Tests that fail because they assume a vertical scrollbar in `writing-mode: vertical-rl` elements will be on the right-hand side
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r277257 r277321  
     12021-05-11  Cathie Chen  <cathiechen@igalia.com>
     2
     3        [CSS contain] Support contain:size
     4        https://bugs.webkit.org/show_bug.cgi?id=223570
     5
     6        Reviewed by Alan Bujtas.
     7
     8        <canvas> and <video> don't support computing aspect ratio from width and height attributes yet,
     9        so the heights are zero when they are with "contain: size".
     10
     11        * web-platform-tests/css/css-contain/contain-size-grid-003-expected.txt:
     12        * web-platform-tests/css/css-contain/contain-size-grid-004-expected.txt:
     13        * web-platform-tests/css/css-contain/contain-size-multicol-as-flex-item-expected.txt:
     14        * web-platform-tests/css/css-flexbox/flex-item-contains-strict-expected.txt:
     15        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt:
     16        * web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt:
     17
    1182021-05-10  Rob Buis  <rbuis@igalia.com>
    219
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-grid-003-expected.txt

    r274620 r277321  
    3737PASS .grid 36
    3838PASS .grid 37
    39 FAIL .grid 38 assert_equals:
    40 <div class="grid" style="grid: repeat(auto-fit, 75px) / repeat(auto-fit, 100px);" data-expected-width="0" data-expected-height="0">
    41     <div></div>
    42   </div>
    43 width expected 0 but got 100
    44 FAIL .grid 39 assert_equals:
    45 <div class="grid" style="grid: auto 50px / 100px auto;" data-expected-width="100" data-expected-height="50">
    46   <div data-expected-width="100" data-expected-height="10" data-offset-x="0" data-offset-y="0">X</div>
    47   <div data-expected-width="40" data-expected-height="10" data-offset-x="100" data-offset-y="0">XX</div>
    48   <div data-expected-width="100" data-expected-height="50" data-offset-x="0" data-offset-y="10">XXX</div>
    49   <div data-expected-width="40" data-expected-height="50" data-offset-x="100" data-offset-y="10">XXXX</div>
    50 </div>
    51 width expected 100 but got 140
     39PASS .grid 38
     40PASS .grid 39
    5241
    5342X
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-grid-004-expected.txt

    r274620 r277321  
    11
    22PASS .grid 1
    3 FAIL .grid 2 assert_equals:
    4 <div class="grid percent min-content" data-expected-height="0" data-expected-width="0">
    5   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    6 </div>
    7 width expected 0 but got 300
     3PASS .grid 2
    84PASS .grid 3
    9 FAIL .grid 4 assert_equals:
    10 <div class="grid percent max-content" data-expected-height="0" data-expected-width="0">
    11   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    12 </div>
    13 width expected 0 but got 300
     5PASS .grid 4
    146PASS .grid 5
    157PASS .grid 6
    168PASS .grid 7
    17 FAIL .grid 8 assert_equals:
    18 <div class="grid calc min-content" data-expected-height="0" data-expected-width="0">
    19   <div data-expected-height="100" data-expected-width="100">XXXX</div>
    20 </div>
    21 width expected 0 but got 300
     9PASS .grid 8
    2210PASS .grid 9
    23 FAIL .grid 10 assert_equals:
    24 <div class="grid calc max-content" data-expected-height="0" data-expected-width="0">
    25   <div data-expected-height="100" data-expected-width="100">XXXX</div>
    26 </div>
    27 width expected 0 but got 300
     11PASS .grid 10
    2812PASS .grid 11
    2913PASS .grid 12
    3014PASS .grid 13
    31 FAIL .grid 14 assert_equals:
    32 <div class="grid minmax-percent-fixed min-content" data-expected-height="100" data-expected-width="0">
    33   <div data-expected-height="100" data-expected-width="0">XXXX</div>
    34 </div>
    35 width expected 0 but got 100
     15PASS .grid 14
    3616PASS .grid 15
    3717PASS .grid 16
     
    4121PASS .grid 20
    4222PASS .grid 21
    43 FAIL .grid 22 assert_equals:
    44 <div class="grid minmax-fixed-percent max-content" data-expected-height="100" data-expected-width="100">
    45   <div data-expected-height="100" data-expected-width="100">XXXX</div>
    46 </div>
    47 width expected 100 but got 300
     23PASS .grid 22
    4824PASS .grid 23
    4925PASS .grid 24
    5026PASS .grid 25
    51 FAIL .grid 26 assert_equals:
    52 <div class="grid minmax-percent-flex min-content" data-expected-height="0" data-expected-width="0">
    53   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    54 </div>
    55 width expected 0 but got 300
     27PASS .grid 26
    5628PASS .grid 27
    57 FAIL .grid 28 assert_equals:
    58 <div class="grid minmax-percent-flex max-content" data-expected-height="0" data-expected-width="0">
    59   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    60 </div>
    61 width expected 0 but got 300
     29PASS .grid 28
    6230PASS .grid 29
    6331PASS .grid 30
    6432PASS .grid 31
    65 FAIL .grid 32 assert_equals:
    66 <div class="grid minmax-intrinsic-percent min-content" data-expected-height="0" data-expected-width="0">
    67   <div data-expected-height="75" data-expected-width="300">XXXX</div>
    68 </div>
    69 width expected 0 but got 300
     33PASS .grid 32
    7034PASS .grid 33
    71 FAIL .grid 34 assert_equals:
    72 <div class="grid minmax-intrinsic-percent max-content" data-expected-height="0" data-expected-width="0">
    73   <div data-expected-height="75" data-expected-width="300">XXXX</div>
    74 </div>
    75 width expected 0 but got 300
     35PASS .grid 34
    7636PASS .grid 35
    7737PASS .grid 36
    7838PASS .grid 37
    79 FAIL .grid 38 assert_equals:
    80 <div class="grid minmax-percent-intrinsic min-content" data-expected-height="0" data-expected-width="0">
    81   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    82 </div>
    83 width expected 0 but got 300
     39PASS .grid 38
    8440PASS .grid 39
    85 FAIL .grid 40 assert_equals:
    86 <div class="grid minmax-percent-intrinsic max-content" data-expected-height="0" data-expected-width="0">
    87   <div data-expected-height="0" data-expected-width="0">XXXX</div>
    88 </div>
    89 width expected 0 but got 300
     41PASS .grid 40
    9042PASS .grid 41
    9143PASS .grid 42
    9244PASS .grid 43
    93 FAIL .grid 44 assert_equals:
    94 <div class="grid fit-content min-content" data-expected-height="0" data-expected-width="0">
    95   <div data-expected-height="75" data-expected-width="300">XXXX</div>
    96 </div>
    97 width expected 0 but got 300
     45PASS .grid 44
    9846PASS .grid 45
    99 FAIL .grid 46 assert_equals:
    100 <div class="grid fit-content max-content" data-expected-height="0" data-expected-width="0">
    101   <div data-expected-height="75" data-expected-width="300">XXXX</div>
    102 </div>
    103 width expected 0 but got 300
     47PASS .grid 46
    10448PASS .grid 47
    10549PASS .grid 48
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-multicol-as-flex-item-expected.txt

    r274620 r277321  
    22
    33
    4 FAIL #flex 1 assert_equals:
    5 <div id="flex">
    6   <div id="multicol" data-expected-width="100" data-expected-height="100">
    7     <div style="width:1000px; height:1px;"></div>
    8   </div>
    9 </div>
    10 width expected 100 but got 784
     4PASS #flex 1
    115
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flex-item-contains-strict-expected.txt

    r267650 r277321  
    1818Row
    1919
    20 FAIL .inline-flex 1 assert_equals:
    21 <div class="inline-flex" style="display: inline-flex; flex-direction: column;" data-expected-width="0" data-expected-height="0">
    22   <div style="contain: strict;" data-expected-width="0" data-expected-height="0">Column</div>
    23 </div>
    24 width expected 0 but got 52
    25 FAIL .inline-flex 2 assert_equals:
    26 <div class="inline-flex" data-expected-width="0" data-expected-height="0">
    27   <div style="contain: strict;" data-expected-width="0" data-expected-height="0">Row</div>
    28 </div>
    29 width expected 0 but got 30
     20PASS .inline-flex 1
     21PASS .inline-flex 2
    3022PASS .inline-flex 3
    3123PASS .inline-flex 4
    32 FAIL .inline-flex 5 assert_equals:
    33 <div class="inline-flex" style="flex-direction: column; align-items: flex-start;" data-expected-width="0" data-expected-height="0">
    34   <div style="contain: strict;" data-expected-width="0" data-expected-height="0">Column</div>
    35 </div>
    36 width expected 0 but got 52
    37 FAIL .inline-flex 6 assert_equals:
    38 <div class="inline-flex" style="align-items: flex-start;" data-expected-width="0" data-expected-height="0">
    39   <div style="contain: strict;" data-expected-width="0" data-expected-height="0">Row</div>
    40 </div>
    41 width expected 0 but got 30
     24PASS .inline-flex 5
     25PASS .inline-flex 6
    4226PASS .inline-flex 7
    4327PASS .inline-flex 8
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/canvas-aspect-ratio-expected.txt

    r276498 r277321  
    11
    22
    3 PASS Canvas width and height attributes are used as the surface size with contain:size
     3FAIL Canvas width and height attributes are used as the surface size with contain:size assert_approx_equals: expected 2.5 +/- 0.001 but got Infinity
    44PASS Canvas width and height attributes are used as the surface size
    55FAIL Computed style test: canvas with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/rendering/replaced-elements/attributes-for-embedded-content-and-images/video-aspect-ratio-expected.txt

    r276498 r277321  
    11
    22
    3 FAIL Video width and height attributes are not used to infer aspect-ratio assert_approx_equals: expected 2.5 +/- 0.001 but got 2
     3FAIL Video width and height attributes are not used to infer aspect-ratio assert_approx_equals: expected 2.5 +/- 0.001 but got Infinity
    44FAIL Computed style test: video with {"width":"10","height":"20"} assert_equals: expected "auto 10 / 20" but got "auto"
    55FAIL Computed style test: video with {"width":"0.5","height":"1.5"} assert_equals: expected "auto 0.5 / 1.5" but got "auto"
  • trunk/Source/WebCore/ChangeLog

    r277320 r277321  
     12021-05-11  Cathie Chen  <cathiechen@igalia.com>
     2
     3        [CSS contain] Support contain:size
     4        https://bugs.webkit.org/show_bug.cgi?id=223570
     5
     6        Reviewed by Alan Bujtas.
     7
     8        This patch brings initial support of CSS contain:size according to [1].
     9        It adds shouldApplySizeContainment() to indicate whether the object is a size containment box.
     10        The intrinsic sizes of size containment box are determined as if it had no content.
     11        So the implementation need to cooperate with the layout steps:
     12          - Computing logical width: Size containment boxes skip handling children while computing minLogicalWidth
     13          and maxLogicalWidth in computeIntrinsicLogicalWidths. So the logical width is not affected by children.
     14          - Layout children: The logical height is changed after layout all children.
     15          - Computing logical height: At the beginning, size containment boxes need to reset logical height to the empty content height
     16          if it is not renderGrid. So the logical height is not affected by children.
     17        We also need to calculate the sizes according to the layout algorithms.
     18        - Grid layout:
     19          To calculate the minLogicalWidth and maxLogicalWidth for indefinite size RenderGrid.
     20          The widths are calculated by GridTrackSizingAlgorithm: m_minContentSize and m_maxContentSize which are the sum of
     21          m_baseSize/m_growthLimit of all GridTracks. The size containment RenderGrid skips handling content in resolveIntrinsicTrackSizes
     22          and the m_maxContentSize will be the sum of m_baseSize. The logical height is same to width, but after calculating
     23          RenderGrid's logical height, it needs to calculate the track sizes again, to make sure that they are distributed properly.
     24          We use computeTrackSizesForDefiniteSize(ForRows, trackBasedLogicalHeight) to recalculate it.
     25        - MultiColumn layout:
     26          According to the specification, size containment boxes should be monolithic, so we need to extend column height
     27          for overflow and positioned size containment boxes. m_spaceShortageForSizeContainment is added to indicate the shortage space
     28          that need to balance the column heights. adjustSizeContainmentChildForPagination() will calculate the shortage.
     29
     30        [1] https://www.w3.org/TR/css-contain-1/#containment-size
     31
     32        * rendering/GridTrackSizingAlgorithm.cpp: Add isComputingSizeContainment to indicate if it is calculating sizes
     33          for indefinite size RenderGrid which is size containment.
     34        (WebCore::GridTrackSizingAlgorithm::gridAreaBreadthForChild const):
     35        (WebCore::GridTrackSizingAlgorithm::computeGridContainerIntrinsicSizes):
     36          It skips resolveIntrinsicTrackSizes if isComputingSizeContainment, so growthLimit might be undefined,
     37          if so, use track.baseSize() instead.
     38        (WebCore::GridTrackSizingAlgorithm::resolveIntrinsicTrackSizes): Skip resolve the content if isComputingSizeContainment().
     39        (WebCore::GridTrackSizingAlgorithm::advanceNextState): Added RowSizingExtraIterationForSizeContainment.
     40        (WebCore::GridTrackSizingAlgorithm::isValidTransition const):
     41        (WebCore::GridTrackSizingAlgorithm::run): Do not stretch the track sizes if isComputingSizeContainment().
     42        * rendering/GridTrackSizingAlgorithm.h:
     43        * rendering/RenderBlock.cpp:
     44        (WebCore::RenderBlock::layoutPositionedObject): Calculate m_spaceShortageForSizeContainment for positioned size containment.
     45        (WebCore::RenderBlock::computeIntrinsicLogicalWidths const): Skip computeBlockPreferredLogicalWidths if shouldApplySizeContainment.
     46        * rendering/RenderBlockFlow.cpp:
     47        (WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths const): Skip handling the children for size containment box.
     48        (WebCore::RenderBlockFlow::adjustBlockChildForPagination): Calculate m_spaceShortageForSizeContainment for child.
     49        (WebCore::RenderBlockFlow::adjustSizeContainmentChildForPagination): m_spaceShortageForSizeContainment = childOverflowHeight - remainingLogicalHeight.
     50        * rendering/RenderBlockFlow.h:
     51        * rendering/RenderBox.cpp:
     52        (WebCore::RenderBox::updateLogicalHeight): Reset the logical height to empty content height for size containment box.
     53        (WebCore::RenderBox::isUnsplittableForPagination const): Size containment box is unsplittable.
     54        * rendering/RenderDeprecatedFlexibleBox.cpp:
     55        (WebCore::RenderDeprecatedFlexibleBox::computeIntrinsicLogicalWidths const): Ditto.
     56        * rendering/RenderFileUploadControl.cpp:
     57        (WebCore::RenderFileUploadControl::computeIntrinsicLogicalWidths const): Ditto.
     58        * rendering/RenderFlexibleBox.cpp:
     59        (WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths const): Ditto.
     60        * rendering/RenderFragmentedFlow.h:
     61        * rendering/RenderGrid.cpp:
     62        (WebCore::RenderGrid::layoutBlock): If it is size containment with infiniteSize, using trackBasedLogicalHeight
     63        to compute track sizes again to make sure the height is distributed properly.
     64        (WebCore::RenderGrid::computeEmptyTracksForAutoRepeat const): Collapse if shouldApplySizeContainment.
     65        * rendering/RenderImage.cpp:
     66        (WebCore::RenderImage::computeIntrinsicRatioInformation const): This is handled in RenderReplaced::computeIntrinsicRatioInformation instead.
     67        * rendering/RenderListBox.cpp:
     68        (WebCore::RenderListBox::computeIntrinsicLogicalWidths const): The widths of size containment boxes are optionsSpacingHorizontal.
     69        * rendering/RenderMenuList.cpp:
     70        (RenderMenuList::computeIntrinsicLogicalWidths const): The widths of size containment box are theme.minimumMenuListSize.
     71        * rendering/RenderMultiColumnFlow.cpp:
     72        (WebCore::RenderMultiColumnFlow::updateSpaceShortageForSizeContainment): Set m_spaceShortageForSizeContainment.
     73        * rendering/RenderMultiColumnFlow.h:
     74        * rendering/RenderMultiColumnSet.cpp:
     75        (WebCore::RenderMultiColumnSet::RenderMultiColumnSet):
     76        (WebCore::RenderMultiColumnSet::calculateBalancedHeight const): Add m_spaceShortageForSizeContainment to the column height.
     77        (WebCore::RenderMultiColumnSet::prepareForLayout): Reset m_spaceShortageForSizeContainment.
     78        * rendering/RenderMultiColumnSet.h:
     79        * rendering/RenderObject.cpp:
     80        (WebCore::shouldApplySizeContainment): Check if the object is a size containment box.
     81        * rendering/RenderObject.h:
     82        (WebCore::RenderObject::isAtomicInlineLevelBox const):
     83        * rendering/RenderReplaced.cpp:
     84        (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox const):
     85        (WebCore::RenderReplaced::computeIntrinsicRatioInformation const): Use the empty intrinsicSize.
     86        * rendering/RenderReplaced.h: The intrinsicSize of size containment is (0, 0).
     87        * rendering/RenderSlider.cpp:
     88        (WebCore::RenderSlider::computeIntrinsicLogicalWidths const): Ditto.
     89        * rendering/RenderTextControl.cpp:
     90        (WebCore::RenderTextControl::computeIntrinsicLogicalWidths const): Ditto.
     91        * rendering/RenderVideo.cpp:
     92        (WebCore::RenderVideo::calculateIntrinsicSize): Ditto.
     93        * rendering/style/RenderStyle.h:
     94        (WebCore::RenderStyle::containsSize const):
     95        * rendering/svg/RenderSVGRoot.cpp:
     96        (WebCore::RenderSVGRoot::computeIntrinsicRatioInformation const): Handled in RenderReplaced::computeIntrinsicRatioInformation instead.
     97
    1982021-05-11  Antti Koivisto  <antti@apple.com>
    299
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp

    r274933 r277321  
    581581{
    582582    bool addContentAlignmentOffset =
    583         direction == ForColumns && m_sizingState == RowSizingFirstIteration;
     583        direction == ForColumns && (m_sizingState == RowSizingFirstIteration || m_sizingState == RowSizingExtraIterationForSizeContainment);
    584584    // To determine the column track's size based on an orthogonal grid item we need it's logical
    585585    // height, which may depend on the row track's size. It's possible that the row tracks sizing
     
    737737    Vector<GridTrack>& allTracks = tracks(m_direction);
    738738    for (auto& track : allTracks) {
    739         ASSERT(!track.infiniteGrowthPotential());
     739        ASSERT(m_strategy->isComputingSizeContainment() || !track.infiniteGrowthPotential());
    740740        m_minContentSize += track.baseSize();
    741         m_maxContentSize += track.growthLimit();
     741        m_maxContentSize += track.growthLimitIsInfinite() ? track.baseSize() : track.growthLimit();
    742742        // The growth limit caps must be cleared now in order to properly sort
    743743        // tracks by growth potential on an eventual "Maximize Tracks".
     
    933933    bool recomputeUsedFlexFractionIfNeeded(double& flexFraction, LayoutUnit& totalGrowth) const override;
    934934    LayoutUnit freeSpaceForStretchAutoTracksStep() const override;
     935    bool isComputingSizeContainment() const override { return shouldApplySizeContainment(*renderGrid()); }
    935936};
    936937
     
    10311032    LayoutUnit minContentForChild(RenderBox&) const override;
    10321033    LayoutUnit minLogicalSizeForChild(RenderBox&, const Length& childMinSize, Optional<LayoutUnit> availableSize) const override;
     1034    bool isComputingSizeContainment() const override { return false; }
    10331035};
    10341036
     
    11471149void GridTrackSizingAlgorithm::resolveIntrinsicTrackSizes()
    11481150{
     1151    Vector<GridTrack>& allTracks = tracks(m_direction);
     1152    auto handleInfinityGrowthLimit = [&]() {
     1153        for (auto trackIndex : m_contentSizedTracksIndex) {
     1154            GridTrack& track = allTracks[trackIndex];
     1155            if (track.growthLimit() == infinity)
     1156                track.setGrowthLimit(track.baseSize());
     1157        }
     1158    };
     1159
     1160    if (m_strategy->isComputingSizeContainment()) {
     1161        handleInfinityGrowthLimit();
     1162        return;
     1163    }
     1164
    11491165    Vector<GridItemWithSpan> itemsSortedByIncreasingSpan;
    11501166    HashSet<RenderBox*> itemsSet;
    1151     Vector<GridTrack>& allTracks = tracks(m_direction);
    11521167    if (m_grid.hasGridItems()) {
    11531168        for (auto trackIndex : m_contentSizedTracksIndex) {
     
    11791194        it = spanGroupRange.rangeEnd;
    11801195    }
    1181 
    1182     for (auto trackIndex : m_contentSizedTracksIndex) {
    1183         GridTrack& track = allTracks[trackIndex];
    1184         if (track.growthLimit() == infinity)
    1185             track.setGrowthLimit(track.baseSize());
    1186     }
     1196    handleInfinityGrowthLimit();
    11871197}
    11881198
     
    12401250        return;
    12411251    case RowSizingFirstIteration:
     1252        m_sizingState = m_strategy->isComputingSizeContainment() ? RowSizingExtraIterationForSizeContainment : ColumnSizingSecondIteration;
     1253        return;
     1254    case RowSizingExtraIterationForSizeContainment:
    12421255        m_sizingState = ColumnSizingSecondIteration;
    12431256        return;
     
    12601273        return m_direction == ForColumns;
    12611274    case RowSizingFirstIteration:
     1275    case RowSizingExtraIterationForSizeContainment:
    12621276    case RowSizingSecondIteration:
    12631277        return m_direction == ForRows;
     
    13471361    // Step 3.
    13481362    m_strategy->maximizeTracks(tracks(m_direction), m_direction == ForColumns ? m_freeSpaceColumns : m_freeSpaceRows);
     1363    if (m_strategy->isComputingSizeContainment())
     1364        return;
    13491365
    13501366    // Step 4.
  • trunk/Source/WebCore/rendering/GridTrackSizingAlgorithm.h

    r274933 r277321  
    225225        ColumnSizingFirstIteration,
    226226        RowSizingFirstIteration,
     227        RowSizingExtraIterationForSizeContainment,
    227228        ColumnSizingSecondIteration,
    228229        RowSizingSecondIteration
     
    262263    virtual bool recomputeUsedFlexFractionIfNeeded(double& flexFraction, LayoutUnit& totalGrowth) const = 0;
    263264    virtual LayoutUnit freeSpaceForStretchAutoTracksStep() const = 0;
     265    virtual bool isComputingSizeContainment() const = 0;
    264266
    265267protected:
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r277124 r277321  
    10741074        r.layoutIfNeeded();
    10751075    }
     1076   
     1077    if (view().frameView().layoutContext().layoutState()->isPaginated() && is<RenderBlockFlow>(*this))
     1078        downcast<RenderBlockFlow>(*this).adjustSizeContainmentChildForPagination(r, r.logicalTop());
    10761079}
    10771080
     
    22832286{
    22842287    ASSERT(!childrenInline());
    2285    
    2286     computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
     2288    if (!shouldApplySizeContainment(*this))
     2289        computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
    22872290
    22882291    maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r276718 r277321  
    340340void RenderBlockFlow::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    341341{
    342     if (childrenInline())
    343         computeInlinePreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
    344     else
    345         computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
     342    if (!shouldApplySizeContainment(*this)) {
     343        if (childrenInline())
     344            computeInlinePreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
     345        else
     346            computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
     347    }
    346348
    347349    maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
     
    16621664        }
    16631665    }
     1666
     1667    if (shouldApplySizeContainment(child))
     1668        adjustSizeContainmentChildForPagination(child, result);
    16641669
    16651670    // For replaced elements and scrolled elements, we want to shift them to the next page if they don't fit on the current one.
     
    20482053}
    20492054
     2055void RenderBlockFlow::adjustSizeContainmentChildForPagination(RenderBox& child, LayoutUnit offset)
     2056{
     2057    if (!shouldApplySizeContainment(child))
     2058        return;
     2059
     2060    LayoutUnit childOverflowHeight = child.isHorizontalWritingMode() ? child.layoutOverflowRect().maxY() : child.layoutOverflowRect().maxX();
     2061    LayoutUnit childLogicalHeight = std::max(child.logicalHeight(), childOverflowHeight);
     2062
     2063    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(offset, ExcludePageBoundary);
     2064
     2065    LayoutUnit spaceShortage = childLogicalHeight - remainingLogicalHeight;
     2066    if (spaceShortage <= 0)
     2067        return;
     2068
     2069    if (RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow())
     2070        fragmentedFlow->updateSpaceShortageForSizeContainment(this, offsetFromLogicalTopOfFirstPage() + offset, spaceShortage);
     2071}
     2072
    20502073void RenderBlockFlow::layoutLineGridBox()
    20512074{
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r276216 r277321  
    399399    void updateMinimumPageHeight(LayoutUnit offset, LayoutUnit minHeight);
    400400
     401    void adjustSizeContainmentChildForPagination(RenderBox& child, LayoutUnit offset);
     402
    401403    void addFloatsToNewParent(RenderBlockFlow& toBlockFlow) const;
    402404   
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r277124 r277321  
    28612861void RenderBox::updateLogicalHeight()
    28622862{
     2863    if (shouldApplySizeContainment(*this) && !isRenderGrid()) {
     2864        // We need the exact width of border and padding here, yet we can't use borderAndPadding* interfaces.
     2865        // Because these interfaces evetually call borderAfter/Before, and RenderBlock::borderBefore
     2866        // adds extra border to fieldset by adding intrinsicBorderForFieldset which is not needed here.
     2867        auto borderAndPadding = RenderBox::borderBefore() + RenderBox::paddingBefore() + RenderBox::borderAfter() + RenderBox::paddingAfter();
     2868        setLogicalHeight(borderAndPadding + scrollbarLogicalHeight());
     2869    }
     2870
    28632871    cacheIntrinsicContentLogicalHeightForFlexItem(contentLogicalHeight());
    28642872    auto computedValues = computeLogicalHeight(logicalHeight(), logicalTop());
     
    48584866        || hasUnsplittableScrollingOverflow()
    48594867        || (parent() && isWritingModeRoot())
    4860         || (isFloating() && style().styleType() == PseudoId::FirstLetter && style().initialLetterDrop() > 0);
     4868        || (isFloating() && style().styleType() == PseudoId::FirstLetter && style().initialLetterDrop() > 0)
     4869        || shouldApplySizeContainment(*this);
    48614870}
    48624871
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r272805 r277321  
    188188void RenderDeprecatedFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    189189{
     190    auto addScrollbarWidth = [&]() {
     191        LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
     192        maxLogicalWidth += scrollbarWidth;
     193        minLogicalWidth += scrollbarWidth;
     194    };
     195
     196    if (shouldApplySizeContainment(*this)) {
     197        addScrollbarWidth();
     198        return;
     199    }
     200
    190201    if (hasMultipleLines() || isVertical()) {
    191202        for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
     
    212223
    213224    maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
    214 
    215     LayoutUnit scrollbarWidth = intrinsicScrollbarLogicalWidth();
    216     maxLogicalWidth += scrollbarWidth;
    217     minLogicalWidth += scrollbarWidth;
     225    addScrollbarWidth();
    218226}
    219227
  • trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp

    r271934 r277321  
    198198void RenderFileUploadControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    199199{
     200    if (shouldApplySizeContainment(*this))
     201        return;
    200202    // Figure out how big the filename space needs to be for a given number of characters
    201203    // (using "0" as the nominal character).
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r277297 r277321  
    8484void RenderFlexibleBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    8585{
     86    auto addScrollbarWidth = [&]() {
     87        LayoutUnit scrollbarWidth(scrollbarLogicalWidth());
     88        maxLogicalWidth += scrollbarWidth;
     89        minLogicalWidth += scrollbarWidth;
     90    };
     91
     92    if (shouldApplySizeContainment(*this)) {
     93        addScrollbarWidth();
     94        return;
     95    }
     96
    8697    LayoutUnit childMinWidth;
    8798    LayoutUnit childMaxWidth;
     
    99110
    100111        LayoutUnit margin = marginIntrinsicLogicalWidthForChild(*child);
    101        
     112
    102113        LayoutUnit minPreferredLogicalWidth;
    103114        LayoutUnit maxPreferredLogicalWidth;
    104115        computeChildPreferredLogicalWidths(*child, minPreferredLogicalWidth, maxPreferredLogicalWidth);
    105        
     116
    106117        minPreferredLogicalWidth += margin;
    107118        maxPreferredLogicalWidth += margin;
     
    140151    }
    141152
    142     LayoutUnit scrollbarWidth(scrollbarLogicalWidth());
    143     maxLogicalWidth += scrollbarWidth;
    144     minLogicalWidth += scrollbarWidth;
     153    addScrollbarWidth();
    145154}
    146155
  • trunk/Source/WebCore/rendering/RenderFragmentedFlow.h

    r261775 r277321  
    103103    virtual void updateMinimumPageHeight(const RenderBlock*, LayoutUnit /*offset*/, LayoutUnit /*minHeight*/) { }
    104104
     105    virtual void updateSpaceShortageForSizeContainment(const RenderBlock*, LayoutUnit /*offset*/, LayoutUnit /*shortage*/) { }
     106
    105107    virtual RenderFragmentContainer* fragmentAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastFragment = false) const;
    106108
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r276356 r277321  
    251251        // 2- Next, the track sizing algorithm resolves the sizes of the grid rows,
    252252        // using the grid column sizes calculated in the previous step.
    253         if (!hasDefiniteLogicalHeight)
     253        bool shouldRecomputeHeight = false;
     254        if (!hasDefiniteLogicalHeight) {
    254255            computeTrackSizesForIndefiniteSize(m_trackSizingAlgorithm, ForRows);
    255         else
     256            if (shouldApplySizeContainment(*this))
     257                shouldRecomputeHeight = true;
     258        } else
    256259            computeTrackSizesForDefiniteSize(ForRows, availableLogicalHeight(ExcludeMarginBorderPadding));
    257260        LayoutUnit trackBasedLogicalHeight = m_trackSizingAlgorithm.computeTrackBasedSize() + borderAndPaddingLogicalHeight() + scrollbarLogicalHeight();
     261        if (shouldRecomputeHeight)
     262            computeTrackSizesForDefiniteSize(ForRows, trackBasedLogicalHeight);
     263
    258264        setLogicalHeight(trackBasedLogicalHeight);
    259265
     
    549555    unsigned lastAutoRepeatTrack = firstAutoRepeatTrack + grid.autoRepeatTracks(direction);
    550556
    551     if (!grid.hasGridItems()) {
     557    if (!grid.hasGridItems() || shouldApplySizeContainment(*this)) {
    552558        emptyTrackIndexes = makeUnique<OrderedTrackIndexSet>();
    553559        for (unsigned trackIndex = firstAutoRepeatTrack; trackIndex < lastAutoRepeatTrack; ++trackIndex)
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r276521 r277321  
    851851void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
    852852{
     853    ASSERT(!shouldApplySizeContainment(*this));
    853854    RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
    854855
  • trunk/Source/WebCore/rendering/RenderListBox.cpp

    r276235 r277321  
    212212void RenderListBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    213213{
    214     maxLogicalWidth = m_optionsWidth + 2 * optionsSpacingHorizontal;
     214    maxLogicalWidth = shouldApplySizeContainment(*this) ? 2 * optionsSpacingHorizontal : m_optionsWidth + 2 * optionsSpacingHorizontal;
    215215    if (m_vBar)
    216216        maxLogicalWidth += m_vBar->width();
  • trunk/Source/WebCore/rendering/RenderMenuList.cpp

    r272805 r277321  
    316316void RenderMenuList::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    317317{
    318     maxLogicalWidth = std::max(m_optionsWidth, theme().minimumMenuListSize(style())) + m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
     318    maxLogicalWidth = shouldApplySizeContainment(*this) ? theme().minimumMenuListSize(style()) : std::max(m_optionsWidth, theme().minimumMenuListSize(style()));
     319    maxLogicalWidth += m_innerBlock->paddingLeft() + m_innerBlock->paddingRight();
    319320    if (!style().width().isPercentOrCalculated())
    320321        minLogicalWidth = maxLogicalWidth;
  • trunk/Source/WebCore/rendering/RenderMultiColumnFlow.cpp

    r275478 r277321  
    204204}
    205205
     206void RenderMultiColumnFlow::updateSpaceShortageForSizeContainment(const RenderBlock* block, LayoutUnit offset, LayoutUnit shortage)
     207{
     208    if (auto* multicolSet = downcast<RenderMultiColumnSet>(fragmentAtBlockOffset(block, offset)))
     209        multicolSet->updateSpaceShortageForSizeContainment(shortage);
     210}
     211
    206212RenderFragmentContainer* RenderMultiColumnFlow::fragmentAtBlockOffset(const RenderBox* box, LayoutUnit offset, bool extendLastFragment) const
    207213{
  • trunk/Source/WebCore/rendering/RenderMultiColumnFlow.h

    r275478 r277321  
    109109    void setPageBreak(const RenderBlock*, LayoutUnit offset, LayoutUnit spaceShortage) override;
    110110    void updateMinimumPageHeight(const RenderBlock*, LayoutUnit offset, LayoutUnit minHeight) override;
     111    void updateSpaceShortageForSizeContainment(const RenderBlock*, LayoutUnit offset, LayoutUnit shortage) override;
    111112    RenderFragmentContainer* fragmentAtBlockOffset(const RenderBox*, LayoutUnit, bool extendLastFragment = false) const override;
    112113    void setFragmentRangeForBox(const RenderBox&, RenderFragmentContainer*, RenderFragmentContainer*) override;
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.cpp

    r276458 r277321  
    5151    , m_minSpaceShortage(RenderFragmentedFlow::maxLogicalHeight())
    5252    , m_minimumColumnHeight(0)
     53    , m_spaceShortageForSizeContainment(0)
    5354{
    5455}
     
    236237    }
    237238
     239    LayoutUnit sizeContainmentShortage = std::max<LayoutUnit>(LayoutUnit(), m_spaceShortageForSizeContainment);
    238240    if (columnCount() <= computedColumnCount()) {
    239241        // With the current column height, the content fits without creating overflowing columns. We're done.
    240         return m_computedColumnHeight;
     242        return m_computedColumnHeight + sizeContainmentShortage;
    241243    }
    242244
     
    244246        // Too many forced breaks to allow any implicit breaks. Initial balancing should already
    245247        // have set a good height. There's nothing more we should do.
    246         return m_computedColumnHeight;
     248        return m_computedColumnHeight + sizeContainmentShortage;
    247249    }
    248250
     
    253255    // ASSERT(m_minSpaceShortage != RenderFragmentedFlow::maxLogicalHeight()); // If this happens, we probably have a bug.
    254256    if (m_minSpaceShortage == RenderFragmentedFlow::maxLogicalHeight())
    255         return m_computedColumnHeight; // So bail out rather than looping infinitely.
    256 
    257     return m_computedColumnHeight + m_minSpaceShortage;
     257        return m_computedColumnHeight + sizeContainmentShortage; // So bail out rather than looping infinitely.
     258
     259    auto toAdd = std::max<LayoutUnit>(sizeContainmentShortage, m_minSpaceShortage);
     260    return m_computedColumnHeight + toAdd;
    258261}
    259262
     
    365368    // Nuke previously stored minimum column height. Contents may have changed for all we know.
    366369    m_minimumColumnHeight = 0;
     370
     371    m_spaceShortageForSizeContainment = 0;
    367372
    368373    // Start with "infinite" flow thread portion height until height is known.
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.h

    r260415 r277321  
    8484    LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
    8585
     86    void updateSpaceShortageForSizeContainment(LayoutUnit shortage)
     87    {
     88        if (m_spaceShortageForSizeContainment <= 0) {
     89            m_spaceShortageForSizeContainment = shortage;
     90            return;
     91        }
     92        m_spaceShortageForSizeContainment = std::min(shortage, m_spaceShortageForSizeContainment);
     93    }
     94
    8695    unsigned forcedBreaksCount() const { return m_contentRuns.size(); }
    8796    void clearForcedBreaks();
     
    199208    LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break.
    200209    LayoutUnit m_minimumColumnHeight;
     210    LayoutUnit m_spaceShortageForSizeContainment; // The shortage space that keeps size containment monolithic.
    201211
    202212    // A run of content without explicit (forced) breaks; i.e. a flow thread portion between two
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r276746 r277321  
    24992499    return renderer.style().containsLayout() && (!renderer.isInline() || renderer.isAtomicInlineLevelBox()) && !renderer.isRubyText() && (!renderer.isTablePart() || renderer.isRenderBlockFlow());
    25002500}
     2501
     2502bool WebCore::shouldApplySizeContainment(const WebCore::RenderObject& renderer)
     2503{
     2504    return renderer.style().containsSize() && (!renderer.isInline() || renderer.isAtomicInlineLevelBox()) && !renderer.isRubyText() && (!renderer.isTablePart() || renderer.isTableCaption()) && !renderer.isTable();
     2505}
  • trunk/Source/WebCore/rendering/RenderObject.h

    r276842 r277321  
    202202    bool isRenderLayerModelObject() const;
    203203
    204     inline bool isAtomicInlineLevelBox() const;
     204    bool isAtomicInlineLevelBox() const;
    205205
    206206    virtual bool isCounter() const { return false; }
     
    11741174}
    11751175
    1176 bool RenderObject::isAtomicInlineLevelBox() const
     1176inline bool RenderObject::isAtomicInlineLevelBox() const
    11771177{
    11781178    return style().isDisplayInlineType() && !(style().display() == DisplayType::Inline && !isReplaced());
     
    11881188
    11891189bool shouldApplyLayoutContainment(const RenderObject&);
     1190bool shouldApplySizeContainment(const RenderObject&);
    11901191
    11911192} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r276947 r277321  
    392392{
    393393    FloatSize intrinsicSize;
    394     if (contentRenderer) {
     394    if (shouldApplySizeContainment(*this))
     395        RenderReplaced::computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
     396    else if (contentRenderer) {
    395397        contentRenderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio);
    396398
     
    497499{
    498500    // If there's an embeddedContentBox() of a remote, referenced document available, this code-path should never be used.
    499     ASSERT(!embeddedContentBox());
     501    ASSERT(!embeddedContentBox() || shouldApplySizeContainment(*this));
    500502    intrinsicSize = FloatSize(intrinsicLogicalWidth(), intrinsicLogicalHeight());
    501503
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r276521 r277321  
    4141    bool setNeedsLayoutIfNeededAfterIntrinsicSizeChange();
    4242
    43     LayoutSize intrinsicSize() const final { return m_intrinsicSize; }
     43    LayoutSize intrinsicSize() const final
     44    {
     45        if (shouldApplySizeContainment(*this))
     46            return LayoutSize();
     47        return m_intrinsicSize;
     48    }
    4449   
    4550    RoundedRect roundedContentBoxRect() const;
  • trunk/Source/WebCore/rendering/RenderSlider.cpp

    r275413 r277321  
    7070void RenderSlider::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    7171{
     72    if (shouldApplySizeContainment(*this))
     73        return;
    7274    maxLogicalWidth = defaultTrackLength * style().effectiveZoom();
    7375    if (!style().width().isPercentOrCalculated())
  • trunk/Source/WebCore/rendering/RenderTextControl.cpp

    r271934 r277321  
    157157void RenderTextControl::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    158158{
     159    if (shouldApplySizeContainment(*this))
     160        return;
    159161    // Use average character width. Matches IE.
    160162    maxLogicalWidth = preferredContentLogicalWidth(const_cast<RenderTextControl*>(this)->getAverageCharWidth());
  • trunk/Source/WebCore/rendering/RenderVideo.cpp

    r274264 r277321  
    124124LayoutSize RenderVideo::calculateIntrinsicSize()
    125125{
     126    if (shouldApplySizeContainment(*this))
     127        return LayoutSize();
     128
    126129    // Spec text from 4.8.6
    127130    //
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r277320 r277321  
    528528    OptionSet<Containment> contain() const { return m_rareNonInheritedData->contain; }
    529529    bool containsLayout() const { return m_rareNonInheritedData->contain.contains(Containment::Layout); }
     530    bool containsSize() const { return m_rareNonInheritedData->contain.contains(Containment::Size); }
    530531    BoxAlignment boxAlign() const { return static_cast<BoxAlignment>(m_rareNonInheritedData->deprecatedFlexibleBox->align); }
    531532    BoxDirection boxDirection() const { return static_cast<BoxDirection>(m_inheritedFlags.boxDirection); }
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r277124 r277321  
    7171void RenderSVGRoot::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio) const
    7272{
     73    ASSERT(!shouldApplySizeContainment(*this));
     74
    7375    // Spec: http://www.w3.org/TR/SVG/coords.html#IntrinsicSizing
    7476    // SVG needs to specify how to calculate some intrinsic sizing properties to enable inclusion within other languages.
Note: See TracChangeset for help on using the changeset viewer.