third_party/js/mozmill/shared-modules/localization.js
function checkDimensions(child) {
  if (!child.boxObject)
    return [];
  var childBox = child.boxObject;
  var parent = childBox.parentBox;

  // toplevel element or hidden elements, like script tags
  if (!parent || parent == child.element || !parent.boxObject) {
    return [];
  }
  var parentBox = parent.boxObject;

  var badRects = [];

  // check width
  if (childBox.height && childBox.screenX < parentBox.screenX) {
    badRects.push([childBox.x, childBox.y, parentBox.x - childBox.x,
                   childBox.height]);
    jumlib.assert(false, 'Node is cut off at the left: ' +
                  _reportNode(child) + '. Parent node: ' + _reportNode(parent));
  }
  if (childBox.height && childBox.screenX + childBox.width >
      parentBox.screenX + parentBox.width) {
    badRects.push([parentBox.x + parentBox.width, childBox.y,
                   childBox.x + childBox.width - parentBox.x - parentBox.width,
                   childBox.height]);
    jumlib.assert(false, 'Node is cut off at the right: ' +
                  _reportNode(child) + '. Parent node: ' + _reportNode(parent));
  }

  // check height
  // We don't want to test menupopup's, as they always report the full height
  // of all items in the popup
  if (child.nodeName != 'menupopup' && parent.nodeName != 'menupopup') {
    if (childBox.width && childBox.screenY < parentBox.screenY) {
      badRects.push([childBox.x, childBox.y, parentBox.y - childBox.y,
                     childBox.width]);
      jumlib.assert(false, 'Node is cut off at the top: ' +
                    _reportNode(child) + '. Parent node: ' + _reportNode(parent));
    }
    if (childBox.width && childBox.screenY + childBox.height >
        parentBox.screenY + parentBox.height) {
      badRects.push([childBox.x, parentBox.y + parentBox.height,
                     childBox.width,
                     childBox.y + childBox.height - parentBox.y - parentBox.height]);
      jumlib.assert(false, 'Node is cut off at the bottom: ' +
                    _reportNode(child) + '. Parent node: ' + _reportNode(parent));
    }
  }

  return badRects;
}
function checkDimensions(child) {
  if (!child.boxObject)
    return [];
  var childBox = child.boxObject;
  var parent = childBox.parentBox;

  // toplevel element or hidden elements, like script tags
  if (!parent || parent == child.element || !parent.boxObject) {
    return [];
  }
  var parentBox = parent.boxObject;

  var badRects = [];

  // check width
  if (childBox.height && childBox.screenX < parentBox.screenX) {
    badRects.push([childBox.x, childBox.y, parentBox.x - childBox.x,
                   childBox.height]);
    jumlib.assert(false, 'Node is cut off at the left: ' +
                  _reportNode(child) + '. Parent node: ' + _reportNode(parent));
  }
  if (childBox.height && childBox.screenX + childBox.width >
      parentBox.screenX + parentBox.width) {
    badRects.push([parentBox.x + parentBox.width, childBox.y,
                   childBox.x + childBox.width - parentBox.x - parentBox.width,
                   childBox.height]);
    jumlib.assert(false, 'Node is cut off at the right: ' +
                  _reportNode(child) + '. Parent node: ' + _reportNode(parent));
  }

  // check height
  // We don't want to test menupopup's, as they always report the full height
  // of all items in the popup
  if (child.nodeName != 'menupopup' && parent.nodeName != 'menupopup') {
    if (childBox.width && childBox.screenY < parentBox.screenY) {
      badRects.push([childBox.x, childBox.y, parentBox.y - childBox.y,
                     childBox.width]);
      jumlib.assert(false, 'Node is cut off at the top: ' +
                    _reportNode(child) + '. Parent node: ' + _reportNode(parent));
    }
    if (childBox.width && childBox.screenY + childBox.height >
        parentBox.screenY + parentBox.height) {
      badRects.push([childBox.x, parentBox.y + parentBox.height,
                     childBox.width,
                     childBox.y + childBox.height - parentBox.y - parentBox.height]);
      jumlib.assert(false, 'Node is cut off at the bottom: ' +
                    _reportNode(child) + '. Parent node: ' + _reportNode(parent));
    }
  }

  return badRects;
}
function checkDimensions ( child ) { if ( ! child . boxObject ) return [ ] ; var childBox = child . boxObject ; var parent = childBox . parentBox ; // toplevel element or hidden elements, like script tags if ( ! parent || parent == child . element || ! parent . boxObject ) { return [ ] ; } var parentBox = parent . boxObject ; var badRects = [ ] ; // check width if ( childBox . height && childBox . screenX < parentBox . screenX ) { badRects . push ( [ childBox . x , childBox . y , parentBox . x - childBox . x , childBox . height ] ) ; jumlib . assert ( false , 'Node is cut off at the left: ' + _reportNode ( child ) + '. Parent node: ' + _reportNode ( parent ) ) ; } if ( childBox . height && childBox . screenX + childBox . width > parentBox . screenX + parentBox . width ) { badRects . push ( [ parentBox . x + parentBox . width , childBox . y , childBox . x + childBox . width - parentBox . x - parentBox . width , childBox . height ] ) ; jumlib . assert ( false , 'Node is cut off at the right: ' + _reportNode ( child ) + '. Parent node: ' + _reportNode ( parent ) ) ; } // check height // We don't want to test menupopup's, as they always report the full height // of all items in the popup if ( child . nodeName != 'menupopup' && parent . nodeName != 'menupopup' ) { if ( childBox . width && childBox . screenY < parentBox . screenY ) { badRects . push ( [ childBox . x , childBox . y , parentBox . y - childBox . y , childBox . width ] ) ; jumlib . assert ( false , 'Node is cut off at the top: ' + _reportNode ( child ) + '. Parent node: ' + _reportNode ( parent ) ) ; } if ( childBox . width && childBox . screenY + childBox . height > parentBox . screenY + parentBox . height ) { badRects . push ( [ childBox . x , parentBox . y + parentBox . height , childBox . width , childBox . y + childBox . height - parentBox . y - parentBox . height ] ) ; jumlib . assert ( false , 'Node is cut off at the bottom: ' + _reportNode ( child ) + '. Parent node: ' + _reportNode ( parent ) ) ; } } return badRects ; }
Callback function for testing for cropped elements.

Checks if the XUL boxObject has screen coordinates outside of
the screen coordinates of its parent. If there's no parent, return.

@param {node} child
@returns List of boxes that can be highlighted on a screenshot
@type {array of array of int}
Callback function for testing for cropped elements .