Skip to content

Commit

Permalink
Remove DCHECK() that is no longer valid with calc-size().
Browse files Browse the repository at this point in the history
The rules for animation of calc-size() intentionally allow animation
between calc-size() expressions typed as something other than a
percentage (e.g., a sizing keyword) and a percentage.  This animation
erases the percentage-ness from the type at all intermediate values.
This means the animation works correctly when the percentage basis is
definite, but is incorrect when the percentage basis is indefinite.
This is an intentional behavior compromise discussed in
w3c/csswg-drafts#10220 .

This adds a few tests that would hit the removed DCHECK().

Bug: 313072
Change-Id: If5abd44475742272a4635293ddc12837f3ae7153
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5480311
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1292038}
  • Loading branch information
dbaron authored and chromium-wpt-export-bot committed Apr 24, 2024
1 parent a21872e commit 368b403
Showing 1 changed file with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
test_interpolation({
property: 'height',
from: 'calc-size(37px, 200px)',
to: `calc-size(37px, size * 2 + 3% + 17px)`, /* adds to 100px */
to: 'calc-size(37px, size * 2 + 3% + 17px)', /* adds to 100px */
}, [
{ at: -0.25, expect: '225px' },
{ at: 0, expect: '200px' },
Expand All @@ -189,4 +189,43 @@
{ at: 1.25, expect: '75px' },
]);

test_interpolation({
property: 'height',
from: 'calc-size(auto, size)',
to: '50%',
}, [
{ at: -0.25, expect: '87.5px' },
{ at: 0, expect: '100px' },
{ at: 0.75, expect: '137.5px' },
{ at: 1, expect: '150px' },
{ at: 1.25, expect: '162.5px' },
]);

// Rerun roughly the same test with an auto height container.
let auto_style_text = `
.parent {
height: auto;
}
`;
let auto_style_element = document.createElement("style");
auto_style_element.append(document.createTextNode(auto_style_text));
document.head.append(auto_style_element);

test_interpolation({
property: 'height',
from: 'calc-size(auto, size * 2)',
to: '50%',
}, [
{ at: -0.25, expect: '250px' },
{ at: 0, expect: '200px' },
{ at: 0.75, expect: '50px' },
/* TODO(https://crbug.com/40339056): It's questionable whether this should
* be the case, particularly for transitions. Perhaps the value at the
* end should have its percentage-ness back and be 100px here? */
{ at: 1, expect: '0px' },
{ at: 1.25, expect: '0px' },
]);

auto_style_element.remove();

</script>

0 comments on commit 368b403

Please sign in to comment.