-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
row-005.html
201 lines (185 loc) · 6.56 KB
/
row-005.html
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#intrinsic-sizes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<meta name="assert"
content="min-content width is calculated correctly in a variety of scenarios with multiple flex items" />
<style>
.zero-width {
width: 0px;
height: 100px;
margin-bottom: 20px;
}
.floating-flexbox {
display: flex;
outline: 5px solid blue;
height: 100px;
float: left;
}
.floating-flexbox>div:nth-child(1) {
background: yellow;
}
.floating-flexbox>div:nth-child(2) {
background: orange;
}
.floating-flexbox>div:nth-child(3) {
background: lightblue;
}
.floating-flexbox>div>div {
width: 100px;
}
</style>
<body onload="checkLayout('.floating-flexbox')">
<div id="log"></div>
<div class="zero-width">
<div class="floating-flexbox" data-expected-width="200">
<!-- min contribution: 100 -->
<!-- desired fraction: -0.5 -->
<!-- chosen fraction <=0 and desired fraction <=0 and item can shrink, so it contributes its min-content contribution -->
<div style="flex: 1 1 200px; width:50px; min-width:0px;">
<div></div>
</div>
<!-- chosen fraction <=0 and desired fraction <=0 and item can shrink, so it contributes its min-content contribution -->
<div style="flex: 1 1 400px; width:50px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<div class="floating-flexbox" data-expected-width="200">
<!-- min contribution: 100 -->
<!-- min contribution - flex basis: -100 -->
<!-- desired fraction: -0.5 -->
<!-- chosen fraction <=0 and desired fraction <=0 and item can shrink, so it contributes its min-content contribution -->
<div style="flex: 1 1 200px; width:50px;">
<div></div>
</div>
<!-- min contribution: 100 -->
<!-- min contribution - flex basis: -300 -->
<!-- desired fraction: -300/(2*400) = -0.375 -->
<!-- chosen fraction <=0 and desired fraction <=0 and item can shrink, so it contributes its min-content contribution -->
<div style="flex: 1 2 400px; width:50px;">
<div></div>
</div>
</div>
</div>
<!-- This is same as above except for min-width auto is no longer in
effect. EdgeHTML renders it differently than the above. -->
<div class="zero-width">
<div class="floating-flexbox" data-expected-width="200">
<div style="flex: 1 1 200px; width:50px; min-width: 0px;">
<div></div>
</div>
<div style="flex: 1 2 400px; width:50px; min-width: 0px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<!-- first item contributes 200px. second item contributes 100px -->
<div class="floating-flexbox" data-expected-width="300">
<!-- min contribution: 100 -->
<!-- desired fraction: -inf -->
<!-- chosen fraction <= 0 and item can't shrink, so contribute flex basis -->
<div style="flex: 1 0 200px; width:50px;">
<div></div>
</div>
<!-- min contribution: 100 -->
<!-- desired fraction: -0.75 -->
<!-- chosen fraction <= 0 and item CAN shrink, so contribute min contribution -->
<div style="flex: 1 1 400px; width:50px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<div class="floating-flexbox" data-expected-width="200">
<!-- min contribution: 200 -->
<!-- min contribution - flex basis: 150 -->
<!-- desired fraction: 0 (because flex grow factor is 0) -->
<!-- chosen fraction <= 0 so contribute flex basis 50px -->
<!-- except flex basis is outside of used min/max, so contribute clamped flex basis = 100px -->
<div style="flex: 0 0 50px; width: 200px;">
<div></div>
</div>
<!-- identical to above -->
<div style="flex: 0 0 50px; width: 200px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<!-- 200 + 400 = 600 -->
<div class="floating-flexbox" data-expected-width="600">
<!-- min contribution: 200 -->
<!-- desired fraction: 150px -->
<!-- 50 + 1*150 = 200 -->
<div style="flex: 1 0 50px; width: 200px;">
<div></div>
</div>
<!-- min contribution: 200 -->
<!-- desired fraction: 100px -->
<!-- 100 + 2*150 = 400 -->
<div style="flex: 2 0 100px; width: 200px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<!-- chosen fraction: 50px -->
<div class="floating-flexbox" data-expected-width="400">
<!-- min contribution: 100 -->
<!-- desired fraction: -0.5 -->
<!-- final contribution = flex base size + product = 200px + 50px*0 = 200px -->
<div style="flex: 0 1 200px; width: 50px;">
<div></div>
</div>
<!-- min contribution: 200 -->
<!-- desired fraction: (200px - 100px) / 2 = 50px -->
<!-- final contribution = flex base size + product = 100px + 50px*2 = 200px -->
<div style="flex: 2 0 100px; width: 200px;">
<div></div>
</div>
</div>
</div>
<div class="zero-width">
<!-- chosen fraction: 0 -->
<div class="floating-flexbox" data-expected-width="600">
<!-- min contribution: 250 -->
<!-- wants to grow, but can't -->
<!-- desired fraction: 0 -->
<!-- final contribution: 100 -->
<div style="flex: 0 1 100px; width: 250px;"></div>
<!-- min contribution: 100 -->
<!-- wants to shrink, but can't -->
<!-- desired fraction: -inf -->
<!-- final contribution: 200 -->
<div style="flex: 1 0 200px; width: 100px;"></div>
<!-- min contribution: -->
<!-- doesn't have to change --->
<!-- desired fraction: 0 -->
<!-- final contribution: 300 -->
<div style="flex: 1 1 300px; width: 300px;"></div>
</div>
</div>
<div class="zero-width">
<!-- chosen fraction: 0 -->
<div class="floating-flexbox" data-expected-width="700">
<!-- min contribution: 100 -->
<!-- wants to shrink, but can't -->
<!-- desired fraction: -inf -->
<!-- final contribution: 200 -->
<!-- In legacy and V2, this item gets 0 width. -->
<div style="flex: 0 10 300px; width: 200px;"></div>
<!-- min contribution: -->
<!-- doesn't have to change --->
<!-- desired fraction: 0 -->
<!-- final contribution: 300 -->
<!-- In legacy and V2, this item gets all the width. -->
<div style="flex: 0 1 1000px; width: 500px;">
</div>
</div>
</div>
</body>