tor-browser

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

transforms-support-calc.html (2136B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>CSS Transform Module Level 2: calc values</title>
      6 <link rel="help" href="https://drafts.csswg.org/css-transforms-2/">
      7 <link rel="help" href="https://drafts.csswg.org/css-values-3/#calc-notation">
      8 <meta name="assert" content="calc values are supported in css-transforms properties.">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <style>
     12  #container {
     13    width: 600px;
     14    height: 500px;
     15    transform-style: preserve-3d;
     16  }
     17  #target {
     18    width: 300px;
     19    height: 200px;
     20    font-size: 20px;
     21  }
     22 </style>
     23 </head>
     24 <body>
     25 <div id="container">
     26  <div id="target"></div>
     27 </div>
     28 <script>
     29 'use strict';
     30 
     31 test(function(){
     32  target.style = 'translate: calc(30px + 20%) calc(-200px + 100%);';
     33  assert_equals(getComputedStyle(target).translate, 'calc(20% + 30px) calc(100% - 200px)');
     34 }, 'translate supports calc');
     35 
     36 test(function(){
     37  target.style = 'rotate: calc(1turn - 100grad);';
     38  assert_equals(getComputedStyle(target).rotate, '270deg');
     39 }, 'rotate supports calc');
     40 
     41 test(function(){
     42  target.style = 'scale: calc(5 + 2) calc(5 - 2) calc(5 * 2);';
     43  assert_equals(getComputedStyle(target).scale, '7 3 10');
     44 }, 'scale supports calc');
     45 
     46 test(function(){
     47  target.style = 'perspective: calc(100px - 3em);';
     48  assert_equals(getComputedStyle(target).perspective, '40px');
     49 }, 'perspective supports calc');
     50 
     51 test(function(){
     52  target.style = 'perspective-origin: calc(30px + 20%) calc(-200px + 100%);';
     53  assert_equals(getComputedStyle(target).perspectiveOrigin, '90px 0px');
     54 }, 'perspective-origin supports calc');
     55 
     56 test(function(){
     57  target.style = 'transform: translate(calc(30px + 20%), calc(-200px + 100%)) rotate(calc(1turn - 400grad)) scale(calc(5 + 2), calc(5 - 2));';
     58  assert_equals(getComputedStyle(target).transform, 'matrix(7, 0, 0, 3, 90, 0)');
     59 }, 'transform supports calc');
     60 
     61 test(function(){
     62  target.style = 'transform-origin: calc(30px + 20%) calc(-200px + 100%);';
     63  assert_equals(getComputedStyle(target).transformOrigin, '90px 0px');
     64 }, 'transform-origin supports calc');
     65 
     66 </script>
     67 </body>
     68 </html>