tor-browser

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

css-grid-utils.js (1606B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 /**
      8 * Returns the grid fragment array with all the grid fragment data stringifiable.
      9 *
     10 * @param  {object} fragments
     11 *         Grid fragment object.
     12 * @return {Array} representation with the grid fragment data stringifiable.
     13 */
     14 function getStringifiableFragments(fragments = []) {
     15  if (fragments[0] && Cu.isDeadWrapper(fragments[0])) {
     16    return {};
     17  }
     18 
     19  return fragments.map(getStringifiableFragment);
     20 }
     21 
     22 function getStringifiableFragment(fragment) {
     23  return {
     24    areas: getStringifiableAreas(fragment.areas),
     25    cols: getStringifiableDimension(fragment.cols),
     26    rows: getStringifiableDimension(fragment.rows),
     27  };
     28 }
     29 
     30 function getStringifiableAreas(areas) {
     31  return [...areas].map(getStringifiableArea);
     32 }
     33 
     34 function getStringifiableDimension(dimension) {
     35  return {
     36    lines: [...dimension.lines].map(getStringifiableLine),
     37    tracks: [...dimension.tracks].map(getStringifiableTrack),
     38  };
     39 }
     40 
     41 function getStringifiableArea({
     42  columnEnd,
     43  columnStart,
     44  name,
     45  rowEnd,
     46  rowStart,
     47  type,
     48 }) {
     49  return { columnEnd, columnStart, name, rowEnd, rowStart, type };
     50 }
     51 
     52 function getStringifiableLine({ breadth, names, number, start, type }) {
     53  return { breadth, names, number, start, type };
     54 }
     55 
     56 function getStringifiableTrack({ breadth, start, state, type }) {
     57  return { breadth, start, state, type };
     58 }
     59 
     60 exports.getStringifiableFragments = getStringifiableFragments;