1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-values-4/#comp-func">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#percentages">
<link rel="help" href="https://drafts.csswg.org/css-values-4/#calc-serialize">
<link rel="author" title="Xiaocheng Hu" href="mailto:xiaochengh@chromium.org">
<link rel="author" title="Tab Atkins-Bittner" href="https://xanthir.com/contact">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../support/serialize-testcommon.js"></script>
<div style="width: 100px;">
<div id=target></div>
</div>
<script>
function test_serialization(t,s,c,u, {prop}={}) {
test_specified_serialization(prop || 'text-indent', t,s);
test_computed_serialization(prop || 'text-indent', t,c);
if(u) test_used_serialization(prop || 'margin-left', t,u);
}
test_serialization(
'min(1%)',
'calc(1%)',
'1%',
'1px');
test_serialization(
'max(1%)',
'calc(1%)',
'1%',
'1px');
// %s can't be simplified until we resolve them,
// since in some cases they can resolve against a negative value
// (so that 20% is less than 10%),
// and we don't want to try and distinguish between the properties
// where the resolving value is possibly-negative or always non-negative.
test_serialization(
'min(1%, 2%, 3%)',
'min(1%, 2%, 3%)',
'min(1%, 2%, 3%)',
'1px');
test_serialization(
'min(3%, 2%, 1%)',
'min(3%, 2%, 1%)',
'min(3%, 2%, 1%)',
'1px');
test_serialization(
'min(-1%, 1%)',
'min(-1%, 1%)',
'min(-1%, 1%)',
'-1px');
// -0% simplifies and serializes to 0%
// See https://github.com/w3c/csswg-drafts/issues/9750
test_serialization(
'min(-0%, 0%)',
'min(0%, 0%)',
'min(0%, 0%)',
'0px');
test_serialization(
'max(1%, 2%, 3%)',
'max(1%, 2%, 3%)',
'max(1%, 2%, 3%)',
'3px');
test_serialization(
'max(3%, 2%, 1%)',
'max(3%, 2%, 1%)',
'max(3%, 2%, 1%)',
'3px');
test_serialization(
'max(-1%, 1%)',
'max(-1%, 1%)',
'max(-1%, 1%)',
'1px');
test_serialization(
'max(-0%, 0%)',
'max(0%, 0%)',
'max(0%, 0%)',
'0px');
// Also ensure that this works against a possibly-negative resolving value...
test_serialization(
'min(1%, 2%, 3%) 0px',
'min(1%, 2%, 3%) 0px',
'min(1%, 2%, 3%) 0px',
'',
{prop:'background-position'});
test_serialization(
'calc(min(1%, 2%) + max(3%, 4%) + 10%)',
'calc(10% + min(1%, 2%) + max(3%, 4%))',
'calc(10% + min(1%, 2%) + max(3%, 4%))',
'15px');
</script>
|