tor-browser

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

edges.js (893B)


      1 import {areArraysEqual} from '/common/arrays.js';
      2 
      3 function parseNumber(value) {
      4  const num = parseInt(value.toString());
      5  if (isNaN(num)) return 0;
      6  return num;
      7 }
      8 
      9 registerLayout('test', class {
     10  static get inputProperties() {
     11    return [
     12      '--edges-inline-start-expected',
     13      '--edges-inline-end-expected',
     14      '--edges-block-start-expected',
     15      '--edges-block-end-expected',
     16    ];
     17  }
     18 
     19  async intrinsicSizes() {}
     20  async layout(children, edges, constraints, styleMap) {
     21    const actual = this.constructor.inputProperties.map(
     22      prop => parseNumber(styleMap.get(prop))
     23    );
     24 
     25    const expected = [
     26      edges.inlineStart,
     27      edges.inlineEnd,
     28      edges.blockStart,
     29      edges.blockEnd,
     30    ];
     31 
     32    if (!areArraysEqual(expected, actual)) {
     33      return {autoBlockSize: 0, childFragments: []};
     34    }
     35 
     36    return {autoBlockSize: 100, childFragment: []};
     37  }
     38 });