Changeset 280022 in webkit


Ignore:
Timestamp:
Jul 19, 2021 1:39:01 AM (12 months ago)
Author:
Ziran Sun
Message:

[CSS-grid] Ignore the aspect-ratio of a replaced element if stretch alignments are applied to both axes
https://bugs.webkit.org/show_bug.cgi?id=227573

Reviewed by Javier Fernandez.

Source/WebCore:

As discussed in https://github.com/w3c/csswg-drafts/issues/5713, for the replaced element as a grid item,
when both axes have stretch alignments applied and there is no auto margin(s) presented, the aspect ratio
should be ignored if there is any.

Part of this patch is an import of Chromium CL at
https://chromium-review.googlesource.com/c/chromium/src/+/2651651

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::hasStretchedLogicalHeight const):
(WebCore::RenderBox::shouldComputeLogicalWidthFromAspectRatio const):

  • rendering/RenderBox.h:

LayoutTests:

Two grid WPT tests are now passing.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280017 r280022  
     12021-07-19  Ziran Sun  <zsun@igalia.com>
     2
     3        [CSS-grid] Ignore the aspect-ratio of a replaced element if stretch alignments are applied to both axes
     4        https://bugs.webkit.org/show_bug.cgi?id=227573
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Two grid WPT tests are now passing.
     9
     10        * TestExpectations:
     11
    1122021-07-16  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r279971 r280022  
    14351435imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-001.html [ ImageOnlyFailure ]
    14361436imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-002.html [ ImageOnlyFailure ]
    1437 imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-004.html [ ImageOnlyFailure ]
    1438 imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-005.html [ ImageOnlyFailure ]
    14391437imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-006.html [ ImageOnlyFailure ]
    14401438imported/w3c/web-platform-tests/css/css-grid/alignment/replaced-alignment-with-aspect-ratio-007.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r280020 r280022  
     12021-07-19  Ziran Sun  <zsun@igalia.com>
     2
     3        [CSS-grid] Ignore the aspect-ratio of a replaced element if stretch alignments are applied to both axes
     4        https://bugs.webkit.org/show_bug.cgi?id=227573
     5
     6        Reviewed by Javier Fernandez.
     7
     8        As discussed in https://github.com/w3c/csswg-drafts/issues/5713, for the replaced element as a grid item,
     9        when both axes have stretch alignments applied and there is no auto margin(s) presented, the aspect ratio
     10        should be ignored if there is any.
     11
     12        Part of this patch is an import of Chromium CL at
     13        https://chromium-review.googlesource.com/c/chromium/src/+/2651651
     14
     15        * rendering/RenderBox.cpp:
     16        (WebCore::RenderBox::hasStretchedLogicalHeight const):
     17        (WebCore::RenderBox::shouldComputeLogicalWidthFromAspectRatio const):
     18        * rendering/RenderBox.h:
     19
    1202021-07-18  Sam Weinig  <weinig@apple.com>
    221
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r280017 r280022  
    27612761
    27622762// FIXME: Can/Should we move this inside specific layout classes (flex. grid)? Can we refactor columnFlexItemHasStretchAlignment logic?
     2763bool RenderBox::hasStretchedLogicalHeight() const
     2764{
     2765    auto& style = this->style();
     2766    if (!style.logicalHeight().isAuto() || style.marginBefore().isAuto() || style.marginAfter().isAuto())
     2767        return false;
     2768    RenderBlock* containingBlock = this->containingBlock();
     2769    if (!containingBlock) {
     2770        // We are evaluating align-self/justify-self, which default to 'normal' for the root element.
     2771        // The 'normal' value behaves like 'start' except for Flexbox Items, which obviously should have a container.
     2772        return false;
     2773    }
     2774    if (containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
     2775        return style.resolvedJustifySelf(&containingBlock->style(), containingBlock->selfAlignmentNormalBehavior(this)).position() == ItemPosition::Stretch;
     2776    return style.resolvedAlignSelf(&containingBlock->style(), containingBlock->selfAlignmentNormalBehavior(this)).position() == ItemPosition::Stretch;
     2777}
     2778
     2779// FIXME: Can/Should we move this inside specific layout classes (flex. grid)? Can we refactor columnFlexItemHasStretchAlignment logic?
    27632780bool RenderBox::hasStretchedLogicalWidth() const
    27642781{
     
    52525269        return false;
    52535270
     5271    if (isGridItem() && shouldComputeSizeAsReplaced() && hasStretchedLogicalWidth() && hasStretchedLogicalHeight())
     5272        return false;
     5273
    52545274    auto isResolvablePercentageHeight = [&] {
    52555275        return style().logicalHeight().isPercentOrCalculated() && (isOutOfFlowPositioned() || percentageLogicalHeightIsResolvable());
  • trunk/Source/WebCore/rendering/RenderBox.h

    r279918 r280022  
    437437    bool sizesLogicalWidthToFitContent(SizeType) const;
    438438
     439    bool hasStretchedLogicalHeight() const;
    439440    bool hasStretchedLogicalWidth() const;
    440441    bool isStretchingColumnFlexItem() const;
Note: See TracChangeset for help on using the changeset viewer.