зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351359 - Make nsGridContainerFrame call ReflowInput::SetBResize(true) because of auto-block-size swapping between measuring reflows and regular reflows. r=mats
This fixes the failure of layout/reftests/css-grid/grid-min-max-content-sizing-002.html with the primary patch in bug 1308876 (which causes a child whose parent is dirty to pick up the dirty bit from the parent only the first reflow of the child if the parent reflows the child multiple times). A simplified testcase for that failure is https://bugzilla.mozilla.org/attachment.cgi?id=8849771 . The failure was caused by an error in height calculation of the first <x> in the test. The div that is the parent of that x has a definite height (presumably due to rules in grid), and the x has a specified height. The div gets three reflows: two measuring reflows (from MinContentContribution and then from MaxContentContribution) and then a final reflow from nsGridContainerFrame::ReflowInFlowChild. Prior to the primary patch in this bug, the div was marked dirty on all three reflows, but with it it is marked dirty only on the first. This means that, without the block-resize flag, the div optimizes away the reflow of its children, since ShouldReflowAllKids returns false because IsBResize() is false, even though NS_FRAME_CONTAINS_RELATIVE_BSIZE is correctly set. In order to fix this, we need to make sure the BResize flag on the reflow state in at least some cases (see the comments in the patch for when, and for how the cases could be optimized in the future). Note that: * when the dirty bit is set on the grid container, the new behavior (with the combination of the patches) is strictly more efficient than the old, since we will sometimes do non-dirty reflows on the grid items (with the b-resize flag) * when the dirty bit is *not* set on the grid container, the new behavior is less efficient than the old, since we will set the b-resize flag when we did not do so before. However, this slowdown fixes existing bugs such as the one in the reftest. Given that I was able to construct a reftest that triggers the failure without the changes from bug 1308876, I've moved this to a separate bug. Without the patch, grid-measuring-reflow-resize-dynamic-001.html fails, but grid-measuring-reflow-resize-static-001.html passes. With the patch both tests pass. (And without the patch, doing a text zoom on the dynamic test fixes the layout error.) MozReview-Commit-ID: JQOdVTQIkU0 --HG-- extra : transplant_source : %8B%2ARO%3B%D0%7B%EC%C9_%B3%60Sp%F9T%14X%85%DC
This commit is contained in:
Родитель
14dccbfd0b
Коммит
28b9e9b1d4
|
@ -3712,6 +3712,16 @@ MeasuringReflow(nsIFrame* aChild,
|
|||
aChild->Properties().Delete(nsIFrame::BClampMarginBoxMinSizeProperty());
|
||||
}
|
||||
ReflowInput childRI(pc, *rs, aChild, aAvailableSize, &aCBSize, riFlags);
|
||||
|
||||
// Because we pass ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE, and the
|
||||
// previous reflow of the child might not have, set the child's
|
||||
// block-resize flag to true.
|
||||
// FIXME (perf): It would be faster to do this only if the previous
|
||||
// reflow of the child was not a measuring reflow, and only if the
|
||||
// child does some of the things that are affected by
|
||||
// ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE.
|
||||
childRI.SetBResize(true);
|
||||
|
||||
ReflowOutput childSize(childRI);
|
||||
nsReflowStatus childStatus;
|
||||
const uint32_t flags = NS_FRAME_NO_MOVE_FRAME | NS_FRAME_NO_SIZE_VIEW;
|
||||
|
@ -5241,6 +5251,15 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild,
|
|||
&percentBasis, flags);
|
||||
childRI.mFlags.mIsTopOfPage = aFragmentainer ? aFragmentainer->mIsTopOfPage : false;
|
||||
|
||||
// Because we pass ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE, and the
|
||||
// previous reflow of the child might not have, set the child's
|
||||
// block-resize flag to true.
|
||||
// FIXME (perf): It would be faster to do this only if the previous
|
||||
// reflow of the child was a measuring reflow, and only if the child
|
||||
// does some of the things that are affected by
|
||||
// ReflowInput::COMPUTE_SIZE_USE_AUTO_BSIZE.
|
||||
childRI.SetBResize(true);
|
||||
|
||||
// A table-wrapper needs to propagate the CB size we give it to its
|
||||
// inner table frame later. @see nsTableWrapperFrame::InitChildReflowInput.
|
||||
if (childType == nsGkAtoms::tableWrapperFrame) {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Testcase simplified from layout/reftests/css-grid/grid-min-max-content-sizing-002.html</title>
|
||||
<style type="text/css">
|
||||
|
||||
html { overflow: hidden }
|
||||
body { margin: 0 }
|
||||
|
||||
div {
|
||||
display: inline-block;
|
||||
border: 1px solid fuchsia;
|
||||
}
|
||||
|
||||
span {
|
||||
display: block;
|
||||
border: 4px solid blue;
|
||||
padding: 0 8px 8px 0;
|
||||
margin: 0 -8px -8px 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<span>blue should overflow fuchsia on right/bottom</span>
|
||||
</div>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Testcase simplified from layout/reftests/css-grid/grid-min-max-content-sizing-002.html</title>
|
||||
<style type="text/css">
|
||||
|
||||
html { overflow: hidden }
|
||||
body { margin: 0 }
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(min-content,max-content);
|
||||
grid-template-rows: minmax(min-content,max-content);
|
||||
}
|
||||
|
||||
.grid > div {
|
||||
border: 1px solid fuchsia;
|
||||
}
|
||||
|
||||
span {
|
||||
display: block;
|
||||
border: 4px solid blue;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="grid">
|
||||
<div>
|
||||
<span id="s"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var s = document.getElementById("s");
|
||||
s.offsetWidth; // flush layout
|
||||
s.textContent = "blue should overflow fuchsia on right/bottom";
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE HTML>
|
||||
<title>Testcase simplified from layout/reftests/css-grid/grid-min-max-content-sizing-002.html</title>
|
||||
<style type="text/css">
|
||||
|
||||
html { overflow: hidden }
|
||||
body { margin: 0 }
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(min-content,max-content);
|
||||
grid-template-rows: minmax(min-content,max-content);
|
||||
}
|
||||
|
||||
.grid > div {
|
||||
border: 1px solid fuchsia;
|
||||
}
|
||||
|
||||
span {
|
||||
display: block;
|
||||
border: 4px solid blue;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<div class="grid">
|
||||
<div>
|
||||
<span>blue should overflow fuchsia on right/bottom</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -275,3 +275,5 @@ asserts(1-10) == grid-fragmentation-dyn4-021.html grid-fragmentation-021-ref.htm
|
|||
== grid-fragmentation-dyn2-031.html grid-fragmentation-031-ref.html
|
||||
== bug1306106.html bug1306106-ref.html
|
||||
== grid-percent-intrinsic-sizing-001.html grid-percent-intrinsic-sizing-001-ref.html
|
||||
== grid-measuring-reflow-resize-static-001.html grid-measuring-reflow-resize-001-ref.html
|
||||
== grid-measuring-reflow-resize-dynamic-001.html grid-measuring-reflow-resize-001-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче