mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 13:18:45 +02:00
Automatic update from web-platform-tests Implement CSS clamp() This patch implements CSS clamp() as a combination of min() and max() according to how it's defined: https://www.w3.org/TR/css-values-4/#calc-notation Note: clamp() in 'sizes' attribute uses a different independent code path, which will be covered by a separate CL. Bug: 825895 Change-Id: Ifd3cdaf1f3e31e10594d95158c2c730f34689924 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815850 Reviewed-by: Emil A Eklund <eae@chromium.org> Reviewed-by: Rune Lillesveen <futhark@chromium.org> Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org> Cr-Commit-Position: refs/heads/master@{#699239} -- wpt-commits: 74b1ccb82ef5d0ddf72f9fbbf66c07ae6555ab18 wpt-pr: 19232
30 lines
1.1 KiB
HTML
30 lines
1.1 KiB
HTML
<!DOCTYPE html>
|
|
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
|
|
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="../support/computed-testcommon.js"></script>
|
|
<div id="container" style="font-size: 20px">
|
|
<div id="target"></div>
|
|
<div id="reference"></div>
|
|
</div>
|
|
<script>
|
|
const property = 'letter-spacing';
|
|
|
|
function test_length_equals(value, expected) {
|
|
const reference = document.getElementById('reference');
|
|
reference.style[property] = '';
|
|
reference.style[property] = expected;
|
|
const computed = getComputedStyle(reference)[property];
|
|
test_computed_value(property, value, computed);
|
|
}
|
|
|
|
test_length_equals('clamp(10px, 20px, 30px)', '20px');
|
|
test_length_equals('clamp(10px, 5px, 30px)', '10px');
|
|
test_length_equals('clamp(10px, 35px, 30px)', '30px');
|
|
|
|
// clamp(MIN, VAL, MAX) is identical to max(MIN, min(VAL, MAX)),
|
|
// so MIN wins over MAX if they are in the wrong order.
|
|
test_length_equals('clamp(30px, 100px, 20px)', '30px');
|
|
|
|
</script>
|