tor-browser

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

layout-child-worklet.js (752B)


      1 import {areArraysEqual} from '/common/arrays.js';
      2 
      3 registerLayout('test', class {
      4  static get inputProperties() {
      5    return [ '--child-expected'];
      6  }
      7 
      8  static get childInputProperties() {
      9    return [ '--child' ];
     10  }
     11 
     12  async intrinsicSizes() {}
     13  async layout(children, edges, constraints, styleMap) {
     14    const expected = JSON.parse(styleMap.get('--child-expected').toString());
     15    const actual = children.map((child) => {
     16      return child.styleMap.get('--child').toString().trim();
     17    });
     18 
     19    const childFragments = await Promise.all(children.map(child => child.layoutNextFragment({})));
     20 
     21    if (!areArraysEqual(expected, actual))
     22      return {autoBlockSize: 0, childFragments};
     23 
     24    return {autoBlockSize: 100, childFragments};
     25  }
     26 });