layout/reftests/w3c-css/submitted/flexbox/flexbox-basic-img-horiz-1.xhtml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-basic-img-horiz-1.xhtml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,103 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<!--
     1.6 +     Any copyright is dedicated to the Public Domain.
     1.7 +     http://creativecommons.org/publicdomain/zero/1.0/
     1.8 +-->
     1.9 +<!--
    1.10 +     This test checks that img elements behave correctly as flex items.
    1.11 +-->
    1.12 +<html xmlns="http://www.w3.org/1999/xhtml">
    1.13 +  <head>
    1.14 +    <title>CSS Test: Testing flexbox layout algorithm property on img flex items in a horizontal flex container</title>
    1.15 +    <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/>
    1.16 +    <link rel="help" href="http://www.w3.org/TR/css3-flexbox/#layout-algorithm"/>
    1.17 +    <link rel="match" href="flexbox-basic-img-horiz-1-ref.xhtml"/>
    1.18 +    <style>
    1.19 +      div.flexbox {
    1.20 +        width: 200px;
    1.21 +        background: lightgreen;
    1.22 +        display: flex;
    1.23 +        justify-content: space-between;
    1.24 +        margin-bottom: 5px;
    1.25 +        line-height: 8px;
    1.26 +      }
    1.27 +      img {
    1.28 +        min-width: 0;
    1.29 +        width: 10px;
    1.30 +        height: 20px;
    1.31 +        border: 1px dotted green;
    1.32 +      }
    1.33 +    </style>
    1.34 +  </head>
    1.35 +  <body>
    1.36 +
    1.37 +    <!-- A) One flex item -->
    1.38 +    <div class="flexbox">
    1.39 +      <img src="support/solidblue.png"/>
    1.40 +    </div>
    1.41 +
    1.42 +    <!-- B) Text and an img (ensure they aren't merged into one flex item) -->
    1.43 +    <div class="flexbox">
    1.44 +      some words <img src="support/solidblue.png"/>
    1.45 +    </div>
    1.46 +
    1.47 +    <!-- C) Two img elements, getting stretched by different ratios, from 0.
    1.48 +
    1.49 +         Space-to-be-distributed = 200px - borders = 200 - (1 + 1) - (1 + 1)
    1.50 +                                 = 196px
    1.51 +
    1.52 +         1st element gets 5/8 of space: 5/8 * 196px = 122.5px
    1.53 +         1st element gets 3/8 of space: 3/8 * 196px = 73.5px
    1.54 +      -->
    1.55 +    <div class="flexbox">
    1.56 +      <img src="support/solidblue.png" style="flex: 5"/>
    1.57 +      <img src="support/solidblue.png" style="flex: 3"/>
    1.58 +    </div>
    1.59 +
    1.60 +    <!-- D) Two img elements, getting stretched by different ratios, from
    1.61 +         different flex bases.
    1.62 +
    1.63 +         Space-to-be-distributed = 200px - (33 + 1 + 1) - (13 + 1 + 1) = 150px
    1.64 +         1st element gets 2/5 of space: 33px + 2/5 * 150px = 93px
    1.65 +         1st element gets 3/5 of space: 13px + 3/5 * 150px = 103px
    1.66 +      -->
    1.67 +    <div class="flexbox">
    1.68 +      <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
    1.69 +      <img src="support/solidblue.png" style="width: 13px; flex: 3 auto"/>
    1.70 +    </div>
    1.71 +
    1.72 +    <!-- E) Two flex items, getting shrunk by different amounts.
    1.73 +
    1.74 +         Space-to-be-distributed = 200px - (150 + 1 + 1) - (100 + 1 + 1) = -54px
    1.75 +         First element scaled flex ratio = 4 * 150 = 600
    1.76 +         Second element scaled flex ratio = 3 * 100 = 300
    1.77 +           * So, total flexibility is 600 + 300 = 900
    1.78 +
    1.79 +         1st element gets 600/900 of space: 150 + 600/900 * -54 = 114px
    1.80 +         2nd element gets 300/900 of space: 100 + 300/900 * -54 = 82px
    1.81 +      -->
    1.82 +    <div class="flexbox">
    1.83 +      <img src="support/solidblue.png" style="width: 150px; flex: 1 4 auto"/>
    1.84 +      <img src="support/solidblue.png" style="width: 100px; flex: 1 3 auto"/>
    1.85 +    </div>
    1.86 +
    1.87 +    <!-- F) Making sure we don't grow past max-width -->
    1.88 +    <!-- Same as (D), except we've added a max-width on the second element.
    1.89 +      -->
    1.90 +    <div class="flexbox">
    1.91 +      <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
    1.92 +      <img src="support/solidblue.png"
    1.93 +           style="width: 13px; max-width: 90px; flex: 3 auto"/>
    1.94 +    </div>
    1.95 +
    1.96 +    <!-- G) Making sure we grow at least as large as min-width -->
    1.97 +    <!-- Same as (C), except we've added a min-width on the second element.
    1.98 +      -->
    1.99 +    <div class="flexbox">
   1.100 +      <img src="support/solidblue.png" style="width: 33px; flex: 2 auto"/>
   1.101 +      <img src="support/solidblue.png"
   1.102 +           style="width: 13px; min-width: 150px; flex: 3 auto"/>
   1.103 +    </div>
   1.104 +
   1.105 +  </body>
   1.106 +</html>

mercurial