many times I have had an issue and post for help and so many times QueryInterface is the solution. I have been addon programming for a long time now but never understood QueryInterface. It seems like magic, like it holds the solution to everything.
like:
window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
So my question is I see a QueryInterface chain, I don't get why the chain, and I definitely don't get how to create my own chain. I don't get how do you know to chain from nsiInterfaceRequester to nsiWebNavigation and not from nsiInterfaceRequester straight to nsiDOMWindow