Changeset 272307 in webkit


Ignore:
Timestamp:
Feb 3, 2021 5:05:51 AM (3 years ago)
Author:
commit-queue@webkit.org
Message:

Support aspect-ratio on grid items
https://bugs.webkit.org/show_bug.cgi?id=220977

Patch by Rob Buis <rbuis@igalia.com> on 2021-02-03
Reviewed by Javier Fernandez.

Source/WebCore:

Support aspect-ratio for grid items by correcting
the auto-size determination for row/columns-axis
when the child has aspect-ratio set.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::hasAutoSizeInColumnAxis const):
(WebCore::RenderGrid::hasAutoSizeInRowAxis const):

  • rendering/RenderGrid.h:

LayoutTests:

Enable some tests that pass now.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272304 r272307  
     12021-02-03  Rob Buis  <rbuis@igalia.com>
     2
     3        Support aspect-ratio on grid items
     4        https://bugs.webkit.org/show_bug.cgi?id=220977
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Enable some tests that pass now.
     9
     10        * TestExpectations:
     11
    1122021-02-03  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/LayoutTests/TestExpectations

    r272125 r272307  
    44414441webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-025.html [ ImageOnlyFailure ]
    44424442webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-026.html [ ImageOnlyFailure ]
    4443 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-007.html [ ImageOnlyFailure ]
    4444 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-009.html [ ImageOnlyFailure ]
    4445 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-011.html [ ImageOnlyFailure ]
    4446 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-012.html [ ImageOnlyFailure ]
    44474443webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-001.html [ ImageOnlyFailure ]
    44484444webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r272303 r272307  
     12021-02-03  Rob Buis  <rbuis@igalia.com>
     2
     3        Support aspect-ratio on grid items
     4        https://bugs.webkit.org/show_bug.cgi?id=220977
     5
     6        Reviewed by Javier Fernandez.
     7
     8        Support aspect-ratio for grid items by correcting
     9        the auto-size determination for row/columns-axis
     10        when the child has aspect-ratio set.
     11
     12        * rendering/RenderGrid.cpp:
     13        (WebCore::RenderGrid::hasAutoSizeInColumnAxis const):
     14        (WebCore::RenderGrid::hasAutoSizeInRowAxis const):
     15        * rendering/RenderGrid.h:
     16
    1172021-02-01  Antoine Quint  <graouts@webkit.org>
    218
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r272302 r272307  
    18601860}
    18611861
     1862bool RenderGrid::hasAutoSizeInColumnAxis(const RenderBox& child) const
     1863{
     1864    if (child.style().hasAspectRatio()) {
     1865        if (isHorizontalWritingMode() == child.isHorizontalWritingMode()) {
     1866            // A non-auto inline size means the same for block size (column axis size) because of the aspect ratio.
     1867            if (!child.style().logicalWidth().isAuto())
     1868                return false;
     1869        } else {
     1870            const Length& logicalHeight = child.style().logicalHeight();
     1871            if (logicalHeight.isFixed() || (logicalHeight.isPercentOrCalculated() && child.percentageLogicalHeightIsResolvable()))
     1872                return false;
     1873        }
     1874    }
     1875    return isHorizontalWritingMode() ? child.style().height().isAuto() : child.style().width().isAuto();
     1876}
     1877
     1878bool RenderGrid::hasAutoSizeInRowAxis(const RenderBox& child) const
     1879{
     1880    if (child.style().hasAspectRatio()) {
     1881        if (isHorizontalWritingMode() == child.isHorizontalWritingMode()) {
     1882            // A non-auto block size means the same for inline size (row axis size) because of the aspect ratio.
     1883            const Length& logicalHeight = child.style().logicalHeight();
     1884            if (logicalHeight.isFixed() || (logicalHeight.isPercentOrCalculated() && child.percentageLogicalHeightIsResolvable()))
     1885                return false;
     1886        } else {
     1887            if (!child.style().logicalWidth().isAuto())
     1888                return false;
     1889        }
     1890    }
     1891    return isHorizontalWritingMode() ? child.style().width().isAuto() : child.style().height().isAuto();
     1892}
     1893
    18621894} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderGrid.h

    r264465 r272307  
    160160    StyleSelfAlignmentData alignSelfForChild(const RenderBox&, const RenderStyle* = nullptr) const;
    161161    void applyStretchAlignmentToChildIfNeeded(RenderBox&);
    162     bool hasAutoSizeInColumnAxis(const RenderBox& child) const { return isHorizontalWritingMode() ? child.style().height().isAuto() : child.style().width().isAuto(); }
    163     bool hasAutoSizeInRowAxis(const RenderBox& child) const { return isHorizontalWritingMode() ? child.style().width().isAuto() : child.style().height().isAuto(); }
     162    bool hasAutoSizeInColumnAxis(const RenderBox& child) const;
     163    bool hasAutoSizeInRowAxis(const RenderBox& child) const;
    164164    bool allowedToStretchChildAlongColumnAxis(const RenderBox& child) const { return alignSelfForChild(child).position() == ItemPosition::Stretch && hasAutoSizeInColumnAxis(child) && !hasAutoMarginsInColumnAxis(child); }
    165165    bool allowedToStretchChildAlongRowAxis(const RenderBox& child) const { return justifySelfForChild(child).position() == ItemPosition::Stretch && hasAutoSizeInRowAxis(child) && !hasAutoMarginsInRowAxis(child); }
Note: See TracChangeset for help on using the changeset viewer.