B2G/gecko/browser/base/content/browser.js
/**
 * Given a starting docshell and a URI to look up, find the docshell the URI
 * is loaded in.
 * @param   aDocument
 *          A document to find instead of using just a URI - this is more specific.
 * @param   aDocShell
 *          The doc shell to start at
 * @param   aSoughtURI
 *          The URI that we're looking for
 * @returns The doc shell that the sought URI is loaded in. Can be in
 *          subframes.
 */
Given a starting docshell and a URI to look up, find the docshell the URI
is loaded in.
@param   aDocument
A document to find instead of using just a URI - this is more specific.
@param   aDocShell
The doc shell to start at
@param   aSoughtURI
The URI that we're looking for
@returns The doc shell that the sought URI is loaded in. Can be in
subframes.
Given a starting docshell and a URI to look up find the docshell the URI is loaded in . @param aDocument A document to find instead of using just a URI - this is more specific . @param aDocShell The doc shell to start at @param aSoughtURI The URI that we ' re looking for @returns The doc shell that the sought URI is loaded in . Can be in subframes .
function findChildShell(aDocument, aDocShell, aSoughtURI) {
  aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation);
  aDocShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
  var doc = aDocShell.getInterface(Components.interfaces.nsIDOMDocument);
  if ((aDocument && doc == aDocument) ||
      (aSoughtURI && aSoughtURI.spec == aDocShell.currentURI.spec))
    return aDocShell;
  var node = aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeNode);
  for (var i = 0; i < node.childCount; ++i) {
    var docShell = node.getChildAt(i);
    docShell = findChildShell(aDocument, docShell, aSoughtURI);
    if (docShell)
      return docShell;
  }
  return null;
}
function findChildShell ( aDocument , aDocShell , aSoughtURI ) { aDocShell . QueryInterface ( Components . interfaces . nsIWebNavigation ) ; aDocShell . QueryInterface ( Components . interfaces . nsIInterfaceRequestor ) ; var doc = aDocShell . getInterface ( Components . interfaces . nsIDOMDocument ) ; if ( ( aDocument && doc == aDocument ) || ( aSoughtURI && aSoughtURI . spec == aDocShell . currentURI . spec ) ) return aDocShell ; var node = aDocShell . QueryInterface ( Components . interfaces . nsIDocShellTreeNode ) ; for ( var i = 0 ; i < node . childCount ; ++ i ) { var docShell = node . getChildAt ( i ) ; docShell = findChildShell ( aDocument , docShell , aSoughtURI ) ; if ( docShell ) return docShell ; } return null ; }
Given a starting docshell and a URI to look up, find the docshell the URI
 is loaded in.
Given a starting docshell and a URI to look up find the docshell the URI is loaded in .