else if( NS_OK == parent->QueryInterface( nsIContextMenu::GetIID(),
else if( NS_OK == parent->QueryInterface( NS_GET_IID(nsIContextMenu),
static nsIWidget *FindWidget( nsISupports *aParent){   nsIWidget      *widget  = nsnull;   nsIMenu        *menu    = nsnull;   nsIMenuBar     *menuBar = nsnull;   nsIContextMenu *popup   = nsnull;   nsISupports    *parent  = aParent;   // Bump the ref count on the parent, since it gets released unconditionally..   NS_ADDREF(parent);   for( ;;)   {      if( NS_OK == parent->QueryInterface( nsIMenu::GetIID(), (void**) &menu))      {         NS_RELEASE(parent);         if( NS_OK != menu->GetParent(parent))         {            NS_RELEASE(menu);            return nsnull;         }         NS_RELEASE(menu);      }      else if( NS_OK == parent->QueryInterface( nsIContextMenu::GetIID(),                                                (void**) &popup))      {         nsISupports *pThing = 0;         if( NS_OK != popup->GetParent( pThing))         {            widget = nsnull;         }         pThing->QueryInterface( nsIWidget::GetIID(), (void**) &widget);         NS_RELEASE(parent);         NS_RELEASE(popup);         return widget;      }      else if( NS_OK == parent->QueryInterface( nsIMenuBar::GetIID(),                                                (void**) &menuBar))      {         if( NS_OK != menuBar->GetParent(widget))         {            widget =  nsnull;         }         NS_RELEASE(parent);         NS_RELEASE(menuBar);         return widget;      }      else      {         NS_RELEASE(parent);         return nsnull;      }   }   return nsnull;}