Bug 1682686 - Fix grid-item measurement cache to actually update the cache when the old value is no longer suitable r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D139068
This commit is contained in:
Sean Feng 2022-02-18 20:27:39 +00:00
parent f4a370a601
commit 2590fe3e7e
4 changed files with 112 additions and 6 deletions

View File

@ -0,0 +1,60 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<body onload="document.body.style.width = '95%'">
<div style="padding: 10px; display: grid; grid-template-rows: min-content auto;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<div style="display: grid;">
<span>TEST</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<style>
.grid {
display: grid;
border-left: 1px solid blue;
margin-left: 0.5em;
}
</style>
<body onload="document.body.style.width = '95%'">
<div class="grid">1
<div class="grid">2
<div class="grid">3
<div class="grid">4
<div class="grid">5
<div class="grid">6
<div class="grid">7
<div class="grid">8
<div class="grid">9
<div class="grid">10
<div class="grid">11
<div class="grid">12
<div class="grid">13
<div class="grid">14
<div class="grid">15
<div class="grid">16
<div class="grid">17
<div class="grid">18
<div class="grid">19
<div class="grid">20
<div class="grid">21
<div class="grid">22
<div class="grid">23
<div class="grid">24
<div class="grid">25
<div class="grid">26

View File

@ -791,6 +791,8 @@ HTTP load 1677518-1.html
load 1679794.html
load 1680406.html
load 1681788.html
load 1682686-1.html
load 1682686-2.html
HTTP load 1682882.html
load 1683126.html
load 1697262-1.html

View File

@ -5036,8 +5036,11 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
childSize.ISize(wm) = aChild->ISize(wm);
nsContainerFrame::FinishReflowChild(aChild, pc, childSize, &childRI, wm,
LogicalPoint(wm), nsSize(), flags);
GRID_LOG("[perf] MeasuringReflow accepted cached value=%d, child=%p",
cachedMeasurement.BSize(), aChild);
GRID_LOG(
"[perf] MeasuringReflow accepted cached value=%d, child=%p, "
"aCBSize.ISize=%d",
cachedMeasurement.BSize(), aChild,
aCBSize.ISize(aChild->GetWritingMode()));
return cachedMeasurement.BSize();
}
}
@ -5060,16 +5063,22 @@ static nscoord MeasuringReflow(nsIFrame* aChild,
childSize.BSize(wm));
aChild->SetProperty(GridItemCachedBAxisMeasurement::Prop(),
cachedMeasurement);
GRID_LOG("[perf] MeasuringReflow created new cached value=%d, child=%p",
cachedMeasurement.BSize(), aChild);
GRID_LOG(
"[perf] MeasuringReflow created new cached value=%d, child=%p, "
"aCBSize.ISize=%d",
cachedMeasurement.BSize(), aChild,
aCBSize.ISize(aChild->GetWritingMode()));
} else if (found) {
if (GridItemCachedBAxisMeasurement::CanCacheMeasurement(aChild,
aCBSize)) {
cachedMeasurement.Update(aChild, aCBSize, childSize.BSize(wm));
GRID_LOG(
"[perf] MeasuringReflow rejected but updated cached value=%d, "
"child=%p",
cachedMeasurement.BSize(), aChild);
"child=%p, aCBSize.ISize=%d",
cachedMeasurement.BSize(), aChild,
aCBSize.ISize(aChild->GetWritingMode()));
aChild->SetProperty(GridItemCachedBAxisMeasurement::Prop(),
cachedMeasurement);
} else {
aChild->RemoveProperty(GridItemCachedBAxisMeasurement::Prop());
GRID_LOG(