-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[css-grid] Grid track sizing algorithm logical height computation unn…
…ecessarily dirties grid items. https://bugs.webkit.org/show_bug.cgi?id=271083 rdar://124713418 Reviewed by Matt Woodrow. In certain situations when trying to compute the logical height for a grid item, the grid track sizing algorithm will update the grid item's overriding containing block size and mark it dirty for layout. This dirtying would occur even it we end up setting the override size to the same value and could result in bad performance with particular types of content. For example, nested grid content would run grid layout multiple times which is currently expensive. In this patch we avoid this extra call to layout by checking to see if the override size is already set to the value we are attempting to set it to. If it is then we will avoid dirtying the renderer. This also ended up exposing an invalidation bug in which we were not properly invalidating the grid items when there was a style change on the grid related to its column or row sizes. This was demonstrated with new failures in css-grid/layout-algorithm/grid-intrinsic-track-sizes-001.html which was performing this behavior. Now when the grid style changes we will check to see if any of the sizes for the columns or the rows are different. If this occurs we should mark the grid items as dirty. This is likely to be more than necessary since we could probably try to identify the exact set of grid items that need to be invalidated, but this approach is the least risky for now. Future patches should attempt to reign this invalidation in a bit more. Without this patch I was getting about 2 runs/s and afterwards I was able to get about ~690 runs/s. * PerformanceTests/Layout/nested-grid-subgrid-free-space-columns.html: Added. * Source/WebCore/Headers.cmake: * Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp: (WebCore::GridTrackSizingAlgorithmStrategy::logicalHeightForChild const): * Source/WebCore/rendering/RenderGrid.cpp: (WebCore::RenderGrid::styleDidChange): * Source/WebCore/rendering/style/RenderStyle.h: * Source/WebCore/rendering/style/RenderStyleInlines.h: (WebCore::RenderStyle::gridTrackSizes const): Canonical link: https://commits.webkit.org/276633@main
- Loading branch information
Showing
6 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
PerformanceTests/Layout/nested-grid-subgrid-free-space-columns.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<html> | ||
<head> | ||
<style> | ||
.grid { | ||
display: grid; | ||
grid-template-columns: [start] 1fr 1fr [end]; | ||
border: 1px solid blue; | ||
} | ||
|
||
.subgrid { | ||
display: grid; | ||
grid-template-columns: subgrid; | ||
grid-column: start / end; | ||
padding-inline: 10px; | ||
padding-block: 10px; | ||
border: 1px solid black; | ||
} | ||
</style> | ||
<script src="../resources/runner.js"></script> | ||
<script> | ||
function startTest() { | ||
document.body.offsetHeight; | ||
|
||
var index = 0; | ||
PerfTestRunner.measureRunsPerSecond({run: function() { | ||
document.body.style.width = ++index % 2 ? "99%" : "98%"; | ||
document.body.offsetHeight; | ||
}}); | ||
} | ||
</script> | ||
</head> | ||
<body onload="startTest()"> | ||
<div class="grid"> | ||
<div class="subgrid"> | ||
<div class="grid"> | ||
<div class="subgrid"> | ||
<div class="subgrid"> | ||
<div class="grid"> | ||
<div class="subgrid"> | ||
<div class="subgrid"> | ||
<div class="grid"> | ||
<div class="subgrid"> | ||
<div class="grid"> | ||
<div class="subgrid"> | ||
<div class="subgrid"> | ||
<div class="grid"> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters