Skip to content

Commit

Permalink
Crash in GridBaselineAlignment::baselineGroupForChild
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=257509
rdar://110027455

Reviewed by Alan Baradlay.

Certain baseline properties are not properly handled in CSS Masonry.
We will just disable these calculations for now and then remove this in the future.

* LayoutTests/fast/css-grid-layout/baseline-masonry-crash-expected.html: Added.
* LayoutTests/fast/css-grid-layout/baseline-masonry-crash.html: Added.
* Source/WebCore/rendering/RenderGrid.cpp:
(WebCore::RenderGrid::columnAxisBaselineOffsetForChild const):
(WebCore::RenderGrid::rowAxisBaselineOffsetForChild const):

Canonical link: https://commits.webkit.org/259548.835@safari-7615-branch
  • Loading branch information
stwrt committed Jun 16, 2023
1 parent 5989e11 commit b63d456
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<style>
grid {
display: inline-grid;
grid-template-columns: auto;
grid-template-rows: repeat(4,auto);
}
</style>

<p>This test passes if it does not crash.</p>

<grid>
<<item>3</item>/item>
<item>4</item>
<item style="-webkit-align-self: baseline;">
</grid>
15 changes: 15 additions & 0 deletions LayoutTests/fast/css-grid-layout/baseline-masonry-crash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<style>
grid {
display: inline-grid;
grid-template-columns: masonry;
grid-template-rows: repeat(4,auto);
}
</style>

<p>This test passes if it does not crash.</p>

<grid>
<<item>3</item>/item>
<item>4</item>
<item style="-webkit-align-self: baseline;">
</grid>
10 changes: 10 additions & 0 deletions Source/WebCore/rendering/RenderGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,11 @@ std::optional<LayoutUnit> RenderGrid::inlineBlockBaseline(LineDirectionMode) con

LayoutUnit RenderGrid::columnAxisBaselineOffsetForChild(const RenderBox& child) const
{
// FIXME : CSS Masonry does not properly handle baseline calculations currently.
// We will just skip this running this step if we detect the RenderGrid is Masonry for now.
if (isMasonry())
return LayoutUnit { };

if (isSubgridRows()) {
RenderGrid* outer = downcast<RenderGrid>(parent());
if (GridLayoutFunctions::isOrthogonalChild(*outer, *this))
Expand All @@ -1658,6 +1663,11 @@ LayoutUnit RenderGrid::columnAxisBaselineOffsetForChild(const RenderBox& child)

LayoutUnit RenderGrid::rowAxisBaselineOffsetForChild(const RenderBox& child) const
{
// FIXME : CSS Masonry does not properly handle baseline calculations currently.
// We will just skip this running this step if we detect the RenderGrid is Masonry for now.
if (isMasonry())
return LayoutUnit { };

if (isSubgridColumns()) {
RenderGrid* outer = downcast<RenderGrid>(parent());
if (GridLayoutFunctions::isOrthogonalChild(*outer, *this))
Expand Down

0 comments on commit b63d456

Please sign in to comment.