Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QI nsIBrowserBoxObject from nsIBoxObject fails in 4.0 beta 7

17 views
Skip to first unread message

Jens

unread,
Nov 11, 2010, 1:48:00 PM11/11/10
to
I’m trying to get the DocShell related to the “TabSelect” / “TabOpen”
event for the given tab instance. The same logic has worked all the
way from version 2.0 of firefox to 4.0 Beta 6 but broke in 4.0 B7.

It basically boilds down to the fact that I’m unable to QI
“nsIBrowserBoxObject” from the nsIBoxObject.

Sample code:

nsCOMPtr<nsIDOMXULElement> spXULElement = do_QueryInterface(spNode);
nsCOMPtr<nsIBoxObject> spBoxObject;
spXULElement->GetBoxObject(getter_AddRefs(spBoxObject));

// spBoxObject, is valid but QI Fails in FF 4.0 Beta 7
nsCOMPtr<nsIBrowserBoxObject> spBrowserBoxObject =
do_QueryInterface(spBoxObject);
nsCOMPtr<nsIDocShell> spDocShell;
spBrowserBoxObject->GetDocShell(getter_AddRefs(spDocShell));

I also looked at'nsIContainerBoxObject' was unable to QI that as well.

Whats the right way to go about doing this in 4.0 Beta 7 (and forward)

-Jens

Jens

unread,
Nov 12, 2010, 1:49:55 PM11/12/10
to
To answer my own question if someone else runs into the same problem…
The hierarchy changed between the versions thus I was not QI’ing the
on the “xul:browser” node.

The fix was simple, just add

nsCOMPtr<nsIDOMNode> spFirstChild;
spBrowserNode->GetFirstChild( getter_AddRefs(spFirstChild) );

// Proceed as before
nsCOMPtr<nsIDOMXULElement> spXULElement =
do_QueryInterface(spFirstChild);
nsCOMPtr<nsIBoxObject> spBoxObject;

0 new messages