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

Changeset 280290 in webkit


Ignore:
Timestamp:
Jul 26, 2021, 12:42:45 AM (5 years ago)
Author:
Ziran Sun
Message:

[css-grid] svg image as grid items should use the overriding logical width/height when defined to compute the logical height/width
https://bugs.webkit.org/show_bug.cgi?id=228105

Source/WebCore:

As discussed at https://github.com/w3c/csswg-drafts/issues/6286#issuecomment-866986544, degenerate
aspect ratios derived from SVG width/height attributes fall back to viewbox aspect ratio
(whether due to negative values or zero values).

When computing the logical height/width using an intrinsic aspect ratio, RenderReplaced uses the
overridingLogicalWidth/overridingLogicalHeight whenever defined as long as the flex or
grid item has an intrinsic size. For an SVG graphic though, it's common to have an intrinsic aspect
ratio but not to have an intrinsic width or height. For this special case, we still should use
overridingLogicalWidth/overridingLogicalHeight for logical height/width calculations.

Reviewed by Javier Fernandez.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalWidth const):
(WebCore::RenderReplaced::computeReplacedLogicalHeight const):

LayoutTests:

Reviewed by Javier Fernandez.

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280289 r280290  
     12021-07-26  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] svg image as grid items should use the overriding logical width/height when defined to compute the logical height/width
     4        https://bugs.webkit.org/show_bug.cgi?id=228105
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Update TestExpectations as 4 failed grid WPT tests are now passing.
     9 
     10        * TestExpectations:
     11
    1122021-07-25  Alexey Shvayka  <shvaikalesh@gmail.com>
    213
  • trunk/LayoutTests/TestExpectations

    r280196 r280290  
    42744274webkit.org/b/209460 imported/w3c/web-platform-tests/css/css-grid/abspos/descendant-static-position-003.html [ ImageOnlyFailure ]
    42754275webkit.org/b/212201 imported/w3c/web-platform-tests/css/css-grid/grid-definition/grid-limits-001.html [ Skip ]
    4276 webkit.org/b/227900 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-stretch-1.html [ ImageOnlyFailure ]
    4277 webkit.org/b/227900 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-stretch-2.html [ ImageOnlyFailure ]
    4278 webkit.org/b/227900 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-stretch-3.html [ ImageOnlyFailure ]
    4279 webkit.org/b/227900 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-aspect-ratio-stretch-4.html [ ImageOnlyFailure ]
    42804276webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-baseline-align-cycles-001.html [ ImageOnlyFailure ]
    42814277webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-item-content-baseline-001.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r280284 r280290  
     12021-07-26  Ziran Sun  <zsun@igalia.com>
     2
     3        [css-grid] svg image as grid items should use the overriding logical width/height when defined to compute the logical height/width
     4        https://bugs.webkit.org/show_bug.cgi?id=228105
     5
     6        As discussed at https://github.com/w3c/csswg-drafts/issues/6286#issuecomment-866986544, degenerate
     7        aspect ratios derived from SVG width/height attributes fall back to viewbox aspect ratio
     8        (whether due to negative values or zero values).
     9
     10        When computing the logical height/width using an intrinsic aspect ratio, RenderReplaced uses the
     11        overridingLogicalWidth/overridingLogicalHeight whenever defined as long as the flex or
     12        grid item has an intrinsic size. For an SVG graphic though, it's common to have an intrinsic aspect
     13        ratio but not to have an intrinsic width or height. For this special case, we still should use
     14        overridingLogicalWidth/overridingLogicalHeight for logical height/width calculations.       
     15
     16        Reviewed by Javier Fernandez.
     17
     18        * rendering/RenderReplaced.cpp:
     19        (WebCore::RenderReplaced::computeReplacedLogicalWidth const):
     20        (WebCore::RenderReplaced::computeReplacedLogicalHeight const):
     21
    1222021-07-24  Devin Rousso  <drousso@apple.com>
    223
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r280078 r280290  
    554554        // grid item has an intrinsic size. It is possible (indeed, common) for an SVG graphic to have an intrinsic aspect ratio but not to have an intrinsic
    555555        // width or height. There are also elements with intrinsic sizes but without intrinsic ratio (like an iframe).
    556         if (intrinsicRatio && (isFlexItem() || isGridItem()) && hasOverridingLogicalHeight() && hasIntrinsicWidth && hasIntrinsicHeight)
     556        if (intrinsicRatio && (isFlexItem() || isGridItem()) && hasOverridingLogicalHeight() && ((hasIntrinsicWidth && hasIntrinsicHeight) || (contentRenderer && contentRenderer->isSVGRoot() && (hasIntrinsicWidth || hasIntrinsicHeight))))
    557557            return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(overridingContentLogicalHeight() * intrinsicRatio)), shouldComputePreferred);
    558558
     
    624624
    625625    // See computeReplacedLogicalHeight() for a similar check for heights.
    626     if (intrinsicRatio && (isFlexItem() || isGridItem()) && hasOverridingLogicalWidth() && hasIntrinsicHeight && hasIntrinsicWidth)
     626    if (intrinsicRatio && (isFlexItem() || isGridItem()) && hasOverridingLogicalWidth() && ((hasIntrinsicWidth && hasIntrinsicHeight) || (contentRenderer && contentRenderer->isSVGRoot() && (hasIntrinsicWidth || hasIntrinsicHeight))))
    627627        return computeReplacedLogicalHeightRespectingMinMaxHeight(roundToInt(round(overridingContentLogicalWidth() / intrinsicRatio)));
    628628
Note: See TracChangeset for help on using the changeset viewer.