tor-browser

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

flex-basis-013.html (2240B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>CSS Test: flex base size that depends on cross size</title>
      4 <link rel="author" title="Oriol Brufau" href="obrufau@igalia.com">
      5 <link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#flex-base-size">
      6 <link rel="help" href="https://drafts.csswg.org/css-flexbox-1/#definite-sizes">
      7 <link rel="help" href="https://github.com/w3c/csswg-drafts/issues/11791">
      8 <meta name="assert" content="The flex item has a definite cross size of 100px
      9  because it stretches. So the canvas can resolve its percentage against that,
     10  and thus the intrinsic flex basis results in a flex base size of 100px.">
     11 
     12 <style>
     13 .container {
     14  display: inline-flex;
     15  vertical-align: top;
     16  width: 50px;
     17  height: 50px;
     18  background: red;
     19  margin: 5px;
     20 }
     21 .container.column {
     22  flex-direction: column;
     23 }
     24 .item {
     25  min-width: 0;
     26  min-height: 0;
     27  background: green;
     28 }
     29 .container.column .stretch-size {
     30  width: -moz-available;
     31  width: -webkit-fill-available;
     32  width: stretch;
     33 }
     34 .container.row .stretch-size {
     35  height: -moz-available;
     36  height: -webkit-fill-available;
     37  height: stretch;
     38 }
     39 .container.column canvas {
     40  display: block;
     41  width: 100%;
     42 }
     43 .container.row canvas {
     44  display: block;
     45  height: 100%;
     46 }
     47 </style>
     48 
     49 <div id="tests"></div>
     50 <div id="log"></div>
     51 
     52 <script src="/resources/testharness.js"></script>
     53 <script src="/resources/testharnessreport.js"></script>
     54 <script src="/resources/check-layout-th.js"></script>
     55 <script>
     56 let canvas = document.createElement("canvas");
     57 canvas.width = canvas.height = "5";
     58 
     59 let item = document.createElement("div");
     60 item.appendChild(canvas);
     61 item.dataset.expectedWidth = item.dataset.expectedHeight = "50";
     62 
     63 let container = document.createElement("div");
     64 container.appendChild(item);
     65 
     66 let tests = document.getElementById("tests");
     67 
     68 for (let direction of ["row", "column"]) {
     69  container.className = "container " + direction;
     70  for (let stretchSize of [false, true]) {
     71    item.className = "item" + (stretchSize ? " stretch-size" : "");
     72    for (let flexBasis of ["auto", "content", "min-content", "fit-content", "max-content"]) {
     73      item.style.flexBasis = flexBasis;
     74      tests.appendChild(container.cloneNode(true));
     75    }
     76  }
     77 }
     78 
     79 checkLayout(".container");
     80 </script>