Changeset 282267 in webkit


Ignore:
Timestamp:
Sep 10, 2021 7:26:56 AM (10 months ago)
Author:
svillar@igalia.com
Message:

[css-flexbox] Add support for self-start & self-end css-align-3 positional alignment properties
https://bugs.webkit.org/show_bug.cgi?id=229996

Reviewed by Manuel Rego Casasnovas.

Source/WebCore:

Added support for SelfStart and SelfEnd positional alignment properties from
https://drafts.csswg.org/css-align-3/#positional-values. These two properties
align the alignment subject (flex item) to be flush with the edge of the alignment container (flex line)
corresponding to the alignment subject's start side in the appropriate axis. This allows authors to align
the flex items based on their writing modes instead of the writing mode of the container.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::alignmentOffset):
(WebCore::RenderFlexibleBox::alignmentForChild const):

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r282266 r282267  
     12021-09-07  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Add support for self-start & self-end css-align-3 positional alignment properties
     4        https://bugs.webkit.org/show_bug.cgi?id=229996
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        * TestExpectations: Removed a couple of tests that are now passing.
     9
    1102021-09-10  Alan Bujtas  <zalan@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r282264 r282267  
    41684168webkit.org/b/221474 imported/w3c/web-platform-tests/css/css-flexbox/svg-root-as-flex-item-003.html [ ImageOnlyFailure ]
    41694169
     4170# The test works fine but the expected result fails due to a missing layout.
    41704171webkit.org/b/221468 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-align-self-horiz-002.xhtml [ ImageOnlyFailure ]
    4171 webkit.org/b/221468 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-align-self-vert-002.xhtml [ ImageOnlyFailure ]
    4172 webkit.org/b/221468 imported/w3c/web-platform-tests/css/css-flexbox/flexbox-align-self-vert-rtl-005.xhtml [ ImageOnlyFailure ]
    41734172
    41744173# align baseline in flexbox.
  • trunk/Source/WebCore/ChangeLog

    r282266 r282267  
     12021-09-07  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        [css-flexbox] Add support for self-start & self-end css-align-3 positional alignment properties
     4        https://bugs.webkit.org/show_bug.cgi?id=229996
     5
     6        Reviewed by Manuel Rego Casasnovas.
     7
     8        Added support for SelfStart and SelfEnd positional alignment properties from
     9        https://drafts.csswg.org/css-align-3/#positional-values. These two properties
     10        align the alignment subject (flex item) to be flush with the edge of the alignment container (flex line)
     11        corresponding to the alignment subject's start side in the appropriate axis. This allows authors to align
     12        the flex items based on their writing modes instead of the writing mode of the container.
     13
     14        * rendering/RenderFlexibleBox.cpp:
     15        (WebCore::alignmentOffset):
     16        (WebCore::RenderFlexibleBox::alignmentForChild const):
     17
    1182021-09-10  Alan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r282078 r282267  
    4040#include "RenderStyleConstants.h"
    4141#include "RenderView.h"
     42#include "WritingMode.h"
    4243#include <limits>
    4344#include <wtf/IsoMallocInlines.h>
     
    15711572    case ItemPosition::Start:
    15721573    case ItemPosition::End:
     1574    case ItemPosition::SelfStart:
     1575    case ItemPosition::SelfEnd:
    15731576    case ItemPosition::Left:
    15741577    case ItemPosition::Right:
     
    15971600        return maxAscent - ascent;
    15981601    case ItemPosition::LastBaseline:
    1599     case ItemPosition::SelfStart:
    1600     case ItemPosition::SelfEnd:
    16011602        // FIXME: Implement last baseline.
    16021603        break;
     
    17221723    if (align == ItemPosition::End)
    17231724        return ItemPosition::FlexEnd;
     1725
     1726    if (align == ItemPosition::SelfStart || align == ItemPosition::SelfEnd) {
     1727        // self-start corresponds to flex-start (and self-end to flex-end) in the majority of the cases
     1728        // for orthogonal layouts except when the container is flipped blocks writing mode (vrl/hbt) and
     1729        // the child is ltr or the other way around. For example:
     1730        // 1) htb ltr child inside a vrl container: self-start corresponds to flex-end
     1731        // 2) htb rtl child inside a vlr container: self-end corresponds to flex-start
     1732        bool isOrthogonal = style().isHorizontalWritingMode() != child.style().isHorizontalWritingMode();
     1733        if (isOrthogonal && (style().isFlippedBlocksWritingMode() == child.style().isLeftToRightDirection()))
     1734            return align == ItemPosition::SelfStart ? ItemPosition::FlexEnd : ItemPosition::FlexStart;
     1735
     1736        if (!isOrthogonal) {
     1737            if (style().isFlippedLinesWritingMode() != child.style().isFlippedLinesWritingMode())
     1738                return align == ItemPosition::SelfStart ? ItemPosition::FlexEnd : ItemPosition::FlexStart;
     1739            if (style().isLeftToRightDirection() != child.style().isLeftToRightDirection())
     1740                return align == ItemPosition::SelfStart ? ItemPosition::FlexEnd : ItemPosition::FlexStart;
     1741        }
     1742
     1743        return align == ItemPosition::SelfStart ? ItemPosition::FlexStart : ItemPosition::FlexEnd;
     1744    }
    17241745
    17251746    if (style().flexWrap() == FlexWrap::Reverse) {
Note: See TracChangeset for help on using the changeset viewer.