Commit 311fea64 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Fieldset NG: Fix relayout result of a percent-height fieldset

We should assume a percent-height fieldset is
HasDescendantThatDependsOnPercentageBlockSize() because the fieldset
content box has a kind of a percent-height if the fieldset has a
percent-height.

Bug: 1138204
Change-Id: Ic9307c190e5aacb8bc47485059d1bdeefa0fedd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2479482Reviewed-by: default avatarMorten Stenshorne <mstensho@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818337}
parent 5793e224
......@@ -192,6 +192,10 @@ class CORE_EXPORT NGContainerFragmentBuilder : public NGFragmentBuilder {
block_end_annotation_space_ = space;
}
void SetHasDescendantThatDependsOnPercentageBlockSize() {
has_descendant_that_depends_on_percentage_block_size_ = true;
}
const NGConstraintSpace* ConstraintSpace() const { return space_; }
#if DCHECK_IS_ON()
......
......@@ -131,6 +131,16 @@ scoped_refptr<const NGLayoutResult> NGFieldsetLayoutAlgorithm::Layout() {
NGOutOfFlowLayoutPart(Node(), ConstraintSpace(), &container_builder_).Run();
const auto& style = Style();
if (style.LogicalHeight().IsPercentOrCalc() ||
style.LogicalMinHeight().IsPercentOrCalc() ||
style.LogicalMaxHeight().IsPercentOrCalc()) {
// The height of the fieldset content box depends on the percent-height of
// the fieldset. So we should assume the fieldset has a percent-height
// descendant.
container_builder_.SetHasDescendantThatDependsOnPercentageBlockSize();
}
return container_builder_.ToBoxFragment();
}
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<table cellspacing="0" cellpadding="0" style="width:100px; height:60px;">
<tr>
<td>
<fieldset style="border:none; padding:0; height:100%; margin:0; margin-top:13px;">
<div><div id="elm"></div></div>
</fieldset>
</td>
</tr>
</table>
<script>
// crbug.com/1138204. Though the specification doesn't mention this behavior,
// there must be no doubt about the expected behavior.
test(() => {
const fieldset = document.querySelector('fieldset');
const initialHeight = fieldset.offsetHeight;
document.querySelector('#elm').style.display = 'none';
assert_equals(fieldset.offsetHeight, initialHeight);
}, 'Fieldset with a percent height should not increase the height on every reflow.');
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment