Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: b7b43b9bf044a2edb16f3fc873f69f1bdf3d8379 https://github.com/WebKit/WebKit/commit/b7b43b9bf044a2edb16f3fc873f69f1bdf3d8379 Author: Sammy Gill <sammy.g...@apple.com> Date: 2023-07-28 (Fri, 28 Jul 2023)
Changed paths: M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-001-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-002-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-003-expected.txt M LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-004-expected.txt M Source/WebCore/rendering/BaselineAlignment.cpp M Source/WebCore/rendering/BaselineAlignment.h M Source/WebCore/rendering/RenderFlexibleBox.cpp M Source/WebCore/rendering/RenderFlexibleBox.h Log Message: ----------- [css-flexbox][baseline-alignment] Use BaslineContext/BaselineGroup to perform baseline alignment. https://bugs.webkit.org/show_bug.cgi?id=256793 rdar://109362699 Reviewed by Alan Baradlay. The BaselineContext and BaselineGroup classes provide us with the ability to represent baseline alignment contexts and baseline sharing groups as described in css-align-3. The main purpose of this patch is to replace the data structures we use in flex layout to hold state for baseline alignment with these new objects. Previously, we were storing our baseline alignment state, in particular the max ascent for baseline and last baseline alignment, for each flex line inside of LineContext. The maxAscent value was computed off of all of the items which had baseline alignment specified and lastBaselineMaxAscent was computed off of all of the items which had last baseline alignment specified. This was not quite right since the spec mentions ways in which items there are baseline and last baseline aligned could get placed in the same baseline sharing group and should get aligned together. In the following example the two flex items are placed in the same baseline sharing group: <div style="display: flex; flex-direction: column; align-items: last-baseline; width: 200px;"> <div style="align-self: first baseline; writing-mode: vertical-rl;">line1<br>line2</div> <div style="writing-mode: vertical-lr;">line1<br>line2</div> </div> With the new addition of the BaselineContext and BaselineGroup objects we can now place items into the correct baseline sharing group as described in the spec and the max ascent values are now kept track of within the baseline sharing group. However, the above example does still not render correctly because there are still some outstanding bugs related to baseline alignment, but this serves as a good starting point for addressing them. In order to perform baseline alignment with these new classes, a slight refactoring was needed. Instead of iterating over all of the children on the flex line we instead iterate over all of the baseline sharing groups on the line and perform the alignment for each group. We do this by checking to see if the LineContext has a BaselineContext early in alignChildren() and for into performBaselineAlignment(). This is a little more intuitive and will be useful as we address the rest of the portions of the spec in css-align-3 as it mentions working with baseline sharing groups as a whole. Since we have not added any new functionality in regards to baseline alignment besides just separating items into baseline sharing groups, we should ideally not be regressing any scenarios in which we perform baseline and last baseline alignment correctly. * LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-001-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-002-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-003-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/alignment/flex-align-baseline-004-expected.txt: * Source/WebCore/rendering/BaselineAlignment.cpp: (WebCore::BaselineAlignmentState::sharedGroups): * Source/WebCore/rendering/BaselineAlignment.h: (WebCore::BaselineGroup::begin): (WebCore::BaselineGroup::end): * Source/WebCore/rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::LineState::LineState): (WebCore::alignmentOffset): (WebCore::RenderFlexibleBox::staticCrossAxisPositionForPositionedChild): (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): (WebCore::RenderFlexibleBox::alignChildren): (WebCore::RenderFlexibleBox::performBaselineAlignment): * Source/WebCore/rendering/RenderFlexibleBox.h: Canonical link: https://commits.webkit.org/266387@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes