Changeset 280078 in webkit


Ignore:
Timestamp:
Jul 20, 2021 4:26:28 AM (12 months ago)
Author:
Ziran Sun
Message:

Images as grid items should use the overridingLogicalWidth when defined to compute the logical Height
https://bugs.webkit.org/show_bug.cgi?id=228022

Reviewed by Javier Fernandez.

LayoutTests/imported/w3c:

Update test expectations as the sub-tests are now passing.

  • web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-029-expected.txt:
  • web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-030-expected.txt:
  • web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-031-expected.txt:
  • web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-035-expected.txt:
  • web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-036-expected.txt:

Source/WebCore:

When computing the logical height using an intrinsic aspect ratio, RenderReplaced should use the
overridingLogicalWidth whenever defined just as how it does for flex items. This change is to
replace the use of intrinsic (non-stretched) logical width in current code with the overridingLogicalWidth.

The current code doesn't set overringLogicalWidth while the width changes while stretches along Row Axis.
This change adds the logic in.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalHeight const):

LayoutTests:

Update TestExpectations as 3 failed grid WPT tests are now passing.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280075 r280078  
     12021-07-20  Ziran Sun  <zsun@igalia.com>
     2
     3        Images as grid items should use the overridingLogicalWidth when defined to compute the logical Height
     4        https://bugs.webkit.org/show_bug.cgi?id=228022
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Update TestExpectations as 3 failed grid WPT tests are now passing.
     9
     10        * TestExpectations:
     11
    1122021-07-20  Rob Buis  <rbuis@igalia.com>
    213
  • trunk/LayoutTests/TestExpectations

    r280075 r280078  
    14441444webkit.org/b/216146 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-baseline-align-001.html [ ImageOnlyFailure ]
    14451445webkit.org/b/216146 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-baseline-justify-001.html [ ImageOnlyFailure ]
    1446 imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.html [ ImageOnlyFailure ]
    1447 imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-007.html [ ImageOnlyFailure ]
    1448 imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-008.html [ ImageOnlyFailure ]
    14491446
    14501447imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-auto-repeat-aspect-ratio-001.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r280075 r280078  
     12021-07-20  Ziran Sun  <zsun@igalia.com>
     2
     3        Images as grid items should use the overridingLogicalWidth when defined to compute the logical Height
     4        https://bugs.webkit.org/show_bug.cgi?id=228022
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Update test expectations as the sub-tests are now passing.
     9
     10        * web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-029-expected.txt:
     11        * web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-030-expected.txt:
     12        * web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-031-expected.txt:
     13        * web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-035-expected.txt:
     14        * web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-036-expected.txt:
     15
    1162021-07-20  Rob Buis  <rbuis@igalia.com>
    217
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-029-expected.txt

    r279269 r280078  
    11
    22
    3 FAIL .before 1 assert_equals:
    4 <img id="item" src="support/100x100-green.png" class=" before" data-expected-width="200" data-expected-height="200">
    5 height expected 200 but got 100
     3PASS .before 1
    64PASS .after 2
    75
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-030-expected.txt

    r279269 r280078  
    22
    33PASS .before 1
    4 FAIL .after 2 assert_equals:
    5 <img id="item" src="support/100x100-green.png" class=" before after" data-expected-width="200" data-expected-height="200">
    6 height expected 200 but got 100
     4PASS .after 2
    75
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-031-expected.txt

    r279269 r280078  
    11
    22
    3 FAIL .before 1 assert_equals:
    4 <img id="item" src="support/100x100-green.png" class=" before" data-expected-width="200" data-expected-height="200">
    5 height expected 200 but got 100
     3PASS .before 1
    64PASS .after 2
    75
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-035-expected.txt

    r279269 r280078  
    22
    33PASS .before 1
    4 FAIL .after 2 assert_equals:
    5 <img id="item" src="support/100x100-green.png" class=" before after" data-expected-width="80" data-expected-height="80">
    6 height expected 80 but got 100
     4PASS .after 2
    75
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-implies-size-change-036-expected.txt

    r279269 r280078  
    11
    22
    3 FAIL .before 1 assert_equals:
    4 <img id="item" src="support/100x100-green.png" class=" before" data-expected-width="80" data-expected-height="80">
    5 height expected 80 but got 100
     3PASS .before 1
    64PASS .after 2
    75
  • trunk/Source/WebCore/ChangeLog

    r280075 r280078  
     12021-07-20  Ziran Sun  <zsun@igalia.com>
     2
     3        Images as grid items should use the overridingLogicalWidth when defined to compute the logical Height
     4        https://bugs.webkit.org/show_bug.cgi?id=228022
     5
     6        Reviewed by Javier Fernandez.
     7
     8        When computing the logical height using an intrinsic aspect ratio, RenderReplaced should use the
     9        overridingLogicalWidth whenever defined just as how it does for flex items. This change is to
     10        replace the use of intrinsic (non-stretched) logical width in current code with the overridingLogicalWidth.
     11
     12        The current code doesn't set overringLogicalWidth while the width changes while stretches along Row Axis.
     13        This change adds the logic in.
     14               
     15        * rendering/RenderGrid.cpp:
     16        (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
     17        * rendering/RenderReplaced.cpp:
     18        (WebCore::RenderReplaced::computeReplacedLogicalHeight const):
     19
    1202021-07-20  Rob Buis  <rbuis@igalia.com>
    221
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r280075 r280078  
    11501150{
    11511151    ASSERT(child.overridingContainingBlockContentLogicalHeight());
    1152 
    1153     // We clear height override values because we will decide now whether it's allowed or
     1152    ASSERT(child.overridingContainingBlockContentLogicalWidth());
     1153
     1154    // We clear height and width override values because we will decide now whether it's allowed or
    11541155    // not, evaluating the conditions which might have changed since the old values were set.
    11551156    child.clearOverridingLogicalHeight();
     1157    child.clearOverridingLogicalWidth();
    11561158
    11571159    GridTrackSizingDirection childBlockDirection = GridLayoutFunctions::flowAwareDirectionForChild(*this, child, ForRows);
     1160    GridTrackSizingDirection childInlineDirection = GridLayoutFunctions::flowAwareDirectionForChild(*this, child, ForColumns);
    11581161    bool blockFlowIsColumnAxis = childBlockDirection == ForRows;
    11591162    bool allowedToStretchChildBlockSize = blockFlowIsColumnAxis ? allowedToStretchChildAlongColumnAxis(child) : allowedToStretchChildAlongRowAxis(child);
     
    11711174            child.setNeedsLayout(MarkOnlyThis);
    11721175        }
    1173     }
     1176    } else if (!allowedToStretchChildBlockSize && allowedToStretchChildAlongRowAxis(child)) {
     1177        LayoutUnit stretchedLogicalWidth = availableAlignmentSpaceForChildBeforeStretching(GridLayoutFunctions::overridingContainingBlockContentSizeForChild(child, childInlineDirection).value(), child);
     1178        LayoutUnit desiredLogicalWidth = constrainLogicalWidthInFragmentByMinMax(stretchedLogicalWidth, contentWidth(), *this, nullptr);
     1179        child.setOverridingLogicalWidth(desiredLogicalWidth);
     1180        if (desiredLogicalWidth != child.logicalWidth()) {
     1181            child.setLogicalWidth(0_lu);
     1182            child.setNeedsLayout(MarkOnlyThis);
     1183        }
     1184    }
    11741185}
    11751186
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r280024 r280078  
    624624
    625625    // See computeReplacedLogicalHeight() for a similar check for heights.
    626     if (intrinsicRatio && isFlexItem() && hasOverridingLogicalWidth() && hasIntrinsicHeight && hasIntrinsicWidth)
     626    if (intrinsicRatio && (isFlexItem() || isGridItem()) && hasOverridingLogicalWidth() && hasIntrinsicHeight && hasIntrinsicWidth)
    627627        return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(overridingContentLogicalWidth() / intrinsicRatio)));
    628628
Note: See TracChangeset for help on using the changeset viewer.