tor-browser

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

child-size-01.https.html (1603B)


      1 <!DOCTYPE html>
      2 <html class=reftest-wait>
      3 <link rel="help" href="https://drafts.css-houdini.org/css-layout-api/#intrinsic-sizes">
      4 <link rel="match" href="child-size-01-ref.html">
      5 <meta name="assert" content="This test checks that passing child intrinsicSizes to a parent works correctly." />
      6 <style>
      7 .test {
      8  background: red;
      9  height: 100px;
     10  width: min-content;
     11 }
     12 
     13 @supports (display: layout(parent)) {
     14  .test {
     15    display: layout(parent);
     16    background: green;
     17  }
     18 
     19  .child {
     20    display: layout(child);
     21  }
     22 }
     23 </style>
     24 <script src="/common/reftest-wait.js"></script>
     25 <script src="/common/worklet-reftest.js"></script>
     26 
     27 <div class="test">
     28  <div class="child"></div>
     29 </div>
     30 
     31 <script id="code" type="text/worklet">
     32 const MAX_CONTENT_SIZE = 100;
     33 const MIN_CONTENT_SIZE = 50;
     34 
     35 registerLayout('parent', class {
     36  async intrinsicSizes(children, edges, styleMap) {
     37    const childrenSizes = await Promise.all(children.map((child) => {
     38        return child.intrinsicSizes();
     39    }));
     40 
     41    if (childrenSizes[0].minContentSize == MIN_CONTENT_SIZE &&
     42        childrenSizes[0].maxContentSize == MAX_CONTENT_SIZE) {
     43      return { maxContentSize: MAX_CONTENT_SIZE, minContentSize: MIN_CONTENT_SIZE };
     44    }
     45    return { maxContentSize: 0, minContentSize: 0 };
     46  }
     47  async layout() {}
     48 });
     49 
     50 registerLayout('child', class {
     51  async intrinsicSizes() {
     52    return { maxContentSize: MAX_CONTENT_SIZE, minContentSize: MIN_CONTENT_SIZE };
     53  }
     54  async layout() {}
     55 });
     56 </script>
     57 
     58 <script>
     59 importWorkletAndTerminateTestAfterAsyncPaint(CSS.layoutWorklet, document.getElementById('code').textContent);
     60 </script>
     61 </html>