Skip to content

Commit

Permalink
[layout] Perform replaced aspect-ratio calculation in LayoutUnits.
Browse files Browse the repository at this point in the history
See bug for more detailed information.

Basically the site in the bug had images all with an aspect ratio of 1/1.
With browser zoom, we hit a situation where the width != height due to
a loss of precision in the conversion from:

LayoutUnit -> float -> LayoutUnit.

Resulting in a LayoutUnit(1) difference in the width and height.

This patch changes the aspect-ratio calculation to all be in LayoutUnits
this means we don't have the loss of precision when converting to/from
floats.

Bug: 1052370
Change-Id: Ic242c224fec17eeec8f1469c0a6c1fe2ed85c4d2
  • Loading branch information
bfgeek authored and chromium-wpt-export-bot committed Mar 25, 2020
1 parent a82dbcb commit f72468b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions css/css-sizing/replaced-fractional-height-from-aspect-ratio.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1052370" >
<meta name="assert" content="When determining the size of a replaced element, if it has an aspect ratio of 1/1 then the final height should be exactly equal to its width." />
<script src="../../resources/check-layout.js"></script>
<style>
canvas {
float: left;
background: green;
}
</style>
<div style="position: relative; width: 254px; zoom: 0.8;">
<canvas style="width: 30%;" width="1" height="1"></canvas>
<canvas style="width: 30%;" width="708" height="708"></canvas>
<canvas id="target" style="width: 60%;" width="2" height="1" data-offset-x="0"></canvas>
</div>
<script>
checkLayout('#target');
</script>

0 comments on commit f72468b

Please sign in to comment.