File:  [mozdev] / checkyesss / src / snippets.txt
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Mon Apr 17 16:43:57 2006 UTC (11 years, 7 months ago) by treitmayr
Branches: MAIN
CVS tags: snapshot-0-6-15-20080217, snapshot-0-6-15-20080216, snapshot-0-5-1-20060419, snapshot-0-5-1-20060418, release-0-6-9, release-0-6-8-20060303, release-0-6-8, release-0-6-7, release-0-6-6, release-0-6-5, release-0-6-4-20061106, release-0-6-4, release-0-6-34, release-0-6-33, release-0-6-32, release-0-6-31-20091123, release-0-6-31-20091122, release-0-6-31, release-0-6-30, release-0-6-3, release-0-6-29, release-0-6-28, release-0-6-27, release-0-6-26, release-0-6-25, release-0-6-24, release-0-6-23, release-0-6-22, release-0-6-20, release-0-6-2-20061027, release-0-6-19, release-0-6-18, release-0-6-17, release-0-6-16, release-0-6-15, release-0-6-14, release-0-6-13, release-0-6-12, release-0-6-11, release-0-6-10, release-0-6-1, release-0-6, release-0-5-7, release-0-5-6, release-0-5-5, release-0-5-4, release-0-5-3, release-0-5-2, prerelease-0-5-7-20060909, HEAD
merged from multicard-branch

Code to go from a window object to its nsIXULWindow (taken from Venkman extension):

function getBaseWindowFromWindow (win) {
    var rv;
    //dd ("getBaseWindowFromWindow: before: getInterface is " + win.getInterface);
    try
    {
	var requestor = win.QueryInterface(nsIInterfaceRequestor);
	var nav = requestor.getInterface(nsIWebNavigation);
	var dsti = nav.QueryInterface(nsIDocShellTreeItem);
	var owner = dsti.treeOwner;
	requestor = owner.QueryInterface(nsIInterfaceRequestor);
	rv = requestor.getInterface(nsIBaseWindow);
    }
    catch (ex)
    {
	rv = null;
	//dd ("not a nsIXULWindow: " + formatException(ex));
	/* ignore no-interface exception */
    }

    //dd ("getBaseWindowFromWindow: after: getInterface is " + win.getInterface);
    return rv;
}

==========================================================================

Code to go from a nsIXULWindow to its window object (reverse to above)

var docshell = xulwin.docShell;
var requestor = docshell.QueryInterface(nsIInterfaceRequestor);
var win = requestor.getInterface(nsIDOMWindow);

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>