fune/testing/web-platform/tests/css/css-display/display-with-float.html
Alison Maher 8c68d69611 Bug 1647826 [wpt PR 24316] - Reland "Don't reset computed 'float' for flex and grid items", a=testonly
Automatic update from web-platform-tests
Reland "Don't reset computed 'float' for flex and grid items"

This is a reland of 906abd41e4f6c786a1927f6edd69d6926e20317b

Original change :
https://chromium-review.googlesource.com/c/chromium/src/+/2157889

Revert of original change :
https://chromium-review.googlesource.com/c/chromium/src/+/2256772

-----

The original change was reverted due to a DCHECK being triggered. See
the following CRBug for more details:
https://bugs.chromium.org/p/chromium/issues/detail?id=1097595

The original change no longer adjusted the ComputedStyle for floats
based on whether or not it was a flex/grid item. This adjustment was
left for the LayoutBox to handle. However, there was code on the layout
side that depended on IsFloating() getting adjusted for the style, as
well. This resulted in the DCHEK mentioned above getting hit.

To fix this, I updated all cases that used the style's IsFloating()
function and either updated it to also take the style's
IsFlexOrGridItem() function into account or updated the code to use
LayoutObject's IsFloating() function instead.

-----

Original change's description:
> Don't reset computed 'float' for flex and grid items
>
> Floated flex and grid items have their 'float' incorrectly computed to
> "none". This change fixes this by adjusting IsFloating() for flex and
> grid items inside LayoutBox::UpdateFromStyle() instead of inside
> StyleAdjuster::AdjustStyleForDisplay().
>
> Beyond this, legend elements are not allowed to be rendered legends
> if they are floating. However, if legends are flex items, we
> adjust IsFloating() to be false. This causes legends to be
> used as rendered legends when they are flex items, even if they
> were styled as a float.
>
> This is fixed by checking ComputedStyle::IsFloating() instead
> of LayoutObject::IsFloating() when finding the rendered legend in
> order to get its non-adjusted floating value.
>
> Bug: 875235,350505
> Change-Id: Ia1e7f7c244cc0c443cd58be42854866884b7f7e7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157889
> Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
> Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
> Reviewed-by: Christian Biesinger <cbiesinger@chromium.org>
> Commit-Queue: Alison Maher <almaher@microsoft.com>
> Cr-Commit-Position: refs/heads/master@{#763988}

Bug: 875235, 350505
Change-Id: I915e045db7fda94d99cfdae33911d8b5f6df26de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261412
Reviewed-by: Morten Stenshorne <mstensho@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Alison Maher <almaher@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#785456}

--

wpt-commits: d33bc572d46eab7d3db2f67c24ab7e132344e22f
wpt-pr: 24316
2020-07-10 10:38:10 +00:00

24 lines
925 B
HTML

<!DOCTYPE html>
<meta charset="utf-8">
<title>Computed float value of flex/grid items</title>
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#flex-containers">
<link rel="help" href="https://drafts.csswg.org/css-grid-1/#grid-containers">
<meta name="assert" content="computed float value of flex/grid items should be as specified">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div style="display:flex;">
<div id="flex-item" style="float:left;"></div>
</div>
<div style="display:grid;">
<div id="grid-item" style="float:right;"></div>
</div>
<script>
function getFloatFor(id) {
return window.getComputedStyle(document.getElementById(id)).getPropertyValue("float");
}
test(function() {
assert_equals(getFloatFor("flex-item"), "left");
assert_equals(getFloatFor("grid-item"), "right");
}, "computed style for float");
</script>