tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

replaced-element-042.html (3451B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSS aspect-ratio: replaced element with box-sizing</title>
      4 <link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
      5 <link rel="help" href="https://drafts.csswg.org/css2/visudet.html#min-max-widths">
      6 <link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
      7 
      8 <style>
      9 canvas {
     10  box-sizing: border-box;
     11  aspect-ratio: 1;
     12  width: auto;
     13  height: auto;
     14  background: black;
     15 }
     16 </style>
     17 
     18 <div id="log"></div>
     19 
     20 <!--
     21 From https://drafts.csswg.org/css2/visudet.html#min-max-widths
     22 
     23 > for replaced elements with an intrinsic ratio and both `width` and `height` specified as `auto`,
     24 > the algorithm is as follows:
     25 >
     26 > Select from the table the resolved height and width values for the appropriate constraint violation.
     27 > Take the max-width and max-height as max(min, max) so that min ≤ max holds true.
     28 > In this table w and h stand for the results of the width and height computations
     29 > ignoring the `min-width`, `min-height`, `max-width` and `max-height` properties.
     30 > Normally these are the intrinsic width and height, but they may not be
     31 > in the case of replaced elements with intrinsic ratios.
     32 
     33 Note the testcases below ensure that w/h is 1 to match the provided `aspect-ratio`,
     34 which didn't exist in CSS2.
     35 
     36 Also note that `aspect-ratio: 1` refers to the border-box due to `box-sizing`,
     37 so we need to perform all calculations using border-box sizes.
     38 -->
     39 
     40 <!--
     41 w = 100 + 0 = 100
     42 h = 50 + 50 = 100
     43 max-width = 50
     44 max-height = 70
     45 Constraint Violation = "(w > max-width) and (h > max-height), where (max-width/w ≤ max-height/h)"
     46 Resolved Width = max-width = 50
     47 Resolved Height = max(min-height, max-width * h/w) = max(0, 50*100/100) = 50
     48 -->
     49 <canvas width="100" height="50" style="max-width: 50px; max-height: 70px; padding-top: 50px"
     50        data-expected-width="50" data-expected-height="50"></canvas>
     51 
     52 <!--
     53 w = 50 + 50 = 100
     54 h = 100 + 0 = 100
     55 max-width = 70
     56 max-height = 50
     57 Constraint Violation = "(w > max-width) and (h > max-height), where (max-width/w > max-height/h)"
     58 Resolved Width = max(min-width, max-height * w/h) = max(0, 50*100/100) = 50
     59 Resolved Height = max-height = 50
     60 -->
     61 <canvas width="50" height="100" style="max-width: 70px; max-height: 50px; padding-left: 50px"
     62        data-expected-width="50" data-expected-height="50"></canvas>
     63 
     64 <!--
     65 w = 50 + 50 = 100
     66 h = 100 + 0 = 100
     67 min-width = 150
     68 min-height = 175
     69 Constraint Violation = "(w < min-width) and (h < min-height), where (min-width/w ≤ min-height/h)"
     70 Resolved Width = min(max-width, min-height * w/h) = min(∞, 175*100/100) = 175
     71 Resolved Height = min-height = 175
     72 -->
     73 <canvas width="50" height="100" style="min-width: 150px; min-height: 175px; padding-left: 50px"
     74        data-expected-width="175" data-expected-height="175"></canvas>
     75 
     76 <!--
     77 w = 100 + 0 = 100
     78 h = 50 + 50 = 100
     79 min-width = 175
     80 min-height = 150
     81 Constraint Violation = "(w < min-width) and (h < min-height), where (min-width/w > min-height/h)"
     82 Resolved Width = min-width = 175
     83 Resolved Height = min(max-height, min-width * h/w) = min(∞, 175*100/100) = 175
     84 -->
     85 <canvas width="100" height="50" style="min-width: 175px; min-height: 150px; padding-top: 50px"
     86        data-expected-width="175" data-expected-height="175"></canvas>
     87 
     88 <script src="/resources/testharness.js"></script>
     89 <script src="/resources/testharnessreport.js"></script>
     90 <script src="/resources/check-layout-th.js"></script>
     91 <script>
     92 checkLayout("canvas");
     93 </script>