Skip to content

Commit 23be5f0

Browse files
bfgeekchromium-wpt-export-bot
authored andcommitted
[flex] Avoid overflow of flexbox with non-zero flex-factors.
Lets say we have three-items with flex-factors of A, B, C. Previously in flexbox we divided up the free-space within LineFlexer (effectively) by performing: - A/(A+B+C) - B/(A+B+C) - C/(A+B+C) This approach can lead to overflow/underflow of the flexing which isn't ideal. Instead we can iteratively reduce the free-space within the loop, and multiply by the what share each item should receive of the *remaining* free-space. E.g. - C/(A+B+C) - B/(A+B) - A/(A) This means that there isn't any overflow/underflow of the free-space. Fixed: 40804774 Change-Id: I1c8e311c6e80deebd3735eae439a71e720877545 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7139011 Auto-Submit: Ian Kilpatrick <[email protected]> Reviewed-by: Ian Kilpatrick <[email protected]> Reviewed-by: David Grogan <[email protected]> Commit-Queue: Ian Kilpatrick <[email protected]> Cr-Commit-Position: refs/heads/main@{#1543117}
1 parent da1ad2b commit 23be5f0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

css/css-flexbox/flex-rounding.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<link rel="help" href="https://issues.chromium.org/issues/40804774">
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<style>
6+
body { margin: 0; }
7+
#flex {
8+
display: flex;
9+
width: 55px;
10+
}
11+
#flex > div {
12+
flex-grow: 1;
13+
}
14+
</style>
15+
<div id="flex">
16+
<div></div>
17+
<div></div>
18+
<div></div>
19+
<div></div>
20+
<div></div>
21+
<div></div>
22+
<div id="last"></div>
23+
</div>
24+
<script>
25+
test(function() {
26+
assert_true(last.getBoundingClientRect().right <= flex.getBoundingClientRect().right);
27+
}, 'The last item shouldn\'t overflow the flexbox.');
28+
</script>

0 commit comments

Comments
 (0)