tor-browser

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

flexbox-basic-canvas-vert-001v.xhtml (3566B)


      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!--
      3     Any copyright is dedicated to the Public Domain.
      4     http://creativecommons.org/publicdomain/zero/1.0/
      5 -->
      6 <!--
      7     This test checks that canvas elements behave correctly as flex items.
      8 -->
      9 <html xmlns="http://www.w3.org/1999/xhtml">
     10  <head>
     11    <title>
     12      CSS Test: Testing flexbox layout algorithm property on canvas flex items in a vertical flex container
     13      (with a vertical writing-mode on the canvas flex items).
     14    </title>
     15    <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/>
     16    <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#layout-algorithm"/>
     17    <link rel="match" href="flexbox-basic-canvas-vert-001-ref.xhtml"/>
     18    <style>
     19      div.flexbox {
     20        height: 200px;
     21        background: lightgreen;
     22        display: flex;
     23        justify-content: space-between;
     24        flex-direction: column;
     25        float: left;
     26        margin-right: 10px;
     27        font: 8px monospace;
     28      }
     29      canvas {
     30        width: 20px;
     31        height: 10px;
     32        min-height: 0;
     33        border: 1px dotted green;
     34        writing-mode: vertical-lr;
     35      }
     36    </style>
     37  </head>
     38  <body>
     39 
     40    <!-- A) One flex item -->
     41    <div class="flexbox">
     42      <canvas/>
     43    </div>
     44 
     45    <!-- B) Text and a canvas (ensure they aren't merged into one flex item) -->
     46    <div class="flexbox">
     47      a b <canvas/>
     48    </div>
     49 
     50    <!-- C) Two canvas elements, getting stretched by different ratios, from 0.
     51 
     52         Space-to-be-distributed = 200px - borders = 200 - (1 + 1) - (1 + 1)
     53                                 = 196px
     54 
     55         1st element gets 5/9 of space: 5/9 * 196px = 108.8px
     56         1st element gets 4/9 of space: 4/9 * 196px = 87.1px
     57      -->
     58    <div class="flexbox">
     59      <canvas style="flex: 5"/>
     60      <canvas style="flex: 4"/>
     61    </div>
     62 
     63    <!-- D) Two canvas elements, getting stretched by different ratios, from
     64         different flex bases.
     65 
     66         Space-to-be-distributed = 200px - (33 + 1 + 1) - (13 + 1 + 1) = 150px
     67         1st element gets 2/5 of space: 33px + 2/5 * 150px = 93px
     68         1st element gets 3/5 of space: 13px + 3/5 * 150px = 103px
     69      -->
     70    <div class="flexbox">
     71      <canvas style="height: 33px; flex: 2 auto"/>
     72      <canvas style="height: 13px; flex: 3 auto"/>
     73    </div>
     74 
     75    <!-- E) Two flex items, getting shrunk by different amounts.
     76 
     77         Space-to-be-distributed = 200px - (150 + 1 + 1) - (100 + 1 + 1) = -54px
     78         First element scaled flex ratio = 4 * 150 = 600
     79         Second element scaled flex ratio = 3 * 100 = 300
     80           * So, total flexibility is 600 + 300 = 900
     81 
     82         1st element gets 600/900 of space: 150 + 600/900 * -54 = 114px
     83         2nd element gets 300/900 of space: 100 + 300/900 * -54 = 82px
     84      -->
     85    <div class="flexbox">
     86      <canvas style="height: 150px; flex: 1 4 auto"/>
     87      <canvas style="height: 100px; flex: 1 3 auto"/>
     88    </div>
     89 
     90    <!-- F) Making sure we don't grow past max-height -->
     91    <!-- Same as (D), except we've added a max-height on the second element.
     92      -->
     93    <div class="flexbox">
     94      <canvas style="height: 33px; flex: 2 auto"/>
     95      <canvas style="height: 13px; max-height: 90px; flex: 3 auto"/>
     96    </div>
     97 
     98    <!-- G) Making sure we grow at least as large as min-height -->
     99    <!-- Same as (C), except we've added a min-height on the second element.
    100      -->
    101    <div class="flexbox">
    102      <canvas style="height: 33px; flex: 2 auto"/>
    103      <canvas style="height: 13px; min-height: 150px; flex: 3 auto"/>
    104    </div>
    105 
    106  </body>
    107 </html>