B2G/gecko/toolkit/content/tests/fennec-tile-testapp/chrome/content/WidgetStack.js
/**
   * Similar to (and most code stolen from) intersect().  A restriction
   * is an intersection, but this modifies the receiving object instead
   * of returning a new rect.
   */
Similar to (and most code stolen from) intersect().  A restriction
is an intersection, but this modifies the receiving object instead
of returning a new rect.
Similar to ( and most code stolen from ) intersect () . A restriction is an intersection but this modifies the receiving object instead of returning a new rect .
function restrictTo(r2) {
    let xmost1 = this.right;
    let xmost2 = r2.right;
    let x = Math.max(this.left, r2.left);
    let temp = Math.min(xmost1, xmost2);
    if (temp <= x)
      throw "Intersection is empty but rects cannot be empty";
    let width = temp - x;
    let ymost1 = this.bottom;
    let ymost2 = r2.bottom;
    let y = Math.max(this.top, r2.top);
    temp = Math.min(ymost1, ymost2);
    if (temp <= y)
      throw "Intersection is empty but rects cannot be empty";
    let height = temp - y;
    return this.setRect(x, y, width, height);
  }
function restrictTo ( r2 ) { let xmost1 = this . right ; let xmost2 = r2 . right ; let x = Math . max ( this . left , r2 . left ) ; let temp = Math . min ( xmost1 , xmost2 ) ; if ( temp <= x ) throw "Intersection is empty but rects cannot be empty" ; let width = temp - x ; let ymost1 = this . bottom ; let ymost2 = r2 . bottom ; let y = Math . max ( this . top , r2 . top ) ; temp = Math . min ( ymost1 , ymost2 ) ; if ( temp <= y ) throw "Intersection is empty but rects cannot be empty" ; let height = temp - y ; return this . setRect ( x , y , width , height ) ; }
Similar to (and most code stolen from) intersect().
Similar to ( and most code stolen from ) intersect () .