B2G/gecko/browser/devtools/shared/LayoutHelpers.jsm
/**
   * Returns iframe content offset (iframe border + padding).
   * Note: this function shouldn't need to exist, had the platform provided a
   * suitable API for determining the offset between the iframe's content and
   * its bounding client rect. Bug 626359 should provide us with such an API.
   *
   * @param aIframe
   *        The iframe.
   * @returns array [offsetTop, offsetLeft]
   *          offsetTop is the distance from the top of the iframe and the
   *            top of the content document.
   *          offsetLeft is the distance from the left of the iframe and the
   *            left of the content document.
   */
Returns iframe content offset (iframe border + padding).
Note: this function shouldn't need to exist, had the platform provided a
suitable API for determining the offset between the iframe's content and
its bounding client rect. Bug 626359 should provide us with such an API.

@param aIframe
The iframe.
@returns array [offsetTop, offsetLeft]
offsetTop is the distance from the top of the iframe and the
top of the content document.
offsetLeft is the distance from the left of the iframe and the
left of the content document.
Returns iframe content offset ( iframe border + padding ) . Note : this function shouldn ' t need to exist had the platform provided a suitable API for determining the offset between the iframe ' s content and its bounding client rect . Bug 626359 should provide us with such an API . @param aIframe The iframe . @returns array [ offsetTop offsetLeft ] offsetTop is the distance from the top of the iframe and the top of the content document . offsetLeft is the distance from the left of the iframe and the left of the content document .
function LH_getIframeContentOffset(aIframe) {
    let style = aIframe.contentWindow.getComputedStyle(aIframe, null);
    if (!style) {
      return [0, 0];
    }
    let paddingTop = parseInt(style.getPropertyValue("padding-top"));
    let paddingLeft = parseInt(style.getPropertyValue("padding-left"));
    let borderTop = parseInt(style.getPropertyValue("border-top-width"));
    let borderLeft = parseInt(style.getPropertyValue("border-left-width"));
    return [borderTop + paddingTop, borderLeft + paddingLeft];
  }
function LH_getIframeContentOffset ( aIframe ) { let style = aIframe . contentWindow . getComputedStyle ( aIframe , null ) ; if ( ! style ) { return [ 0 , 0 ] ; } let paddingTop = parseInt ( style . getPropertyValue ( "padding-top" ) ) ; let paddingLeft = parseInt ( style . getPropertyValue ( "padding-left" ) ) ; let borderTop = parseInt ( style . getPropertyValue ( "border-top-width" ) ) ; let borderLeft = parseInt ( style . getPropertyValue ( "border-left-width" ) ) ; return [ borderTop + paddingTop , borderLeft + paddingLeft ] ; }
Returns iframe content offset (iframe border + padding).
Returns iframe content offset ( iframe border + padding ) .
// In some cases, the computed style is null