зеркало из https://github.com/mozilla/gecko-dev.git
clean up of menu code to remove excess code
This commit is contained in:
Родитель
690e6d77d0
Коммит
9349907d3e
|
@ -127,7 +127,7 @@ NS_METHOD nsMenu::Create(nsISupports *aParent, const nsString &aLabel)
|
|||
if(menu)
|
||||
{
|
||||
mMenuParent = menu;
|
||||
NS_RELEASE(menu);
|
||||
NS_RELEASE(menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ NS_METHOD nsMenu::Create(nsISupports *aParent, const nsString &aLabel)
|
|||
|
||||
gtk_signal_connect (GTK_OBJECT (mMenu), "map",
|
||||
GTK_SIGNAL_FUNC(menu_map_handler),
|
||||
this);
|
||||
this);
|
||||
gtk_signal_connect (GTK_OBJECT (mMenu), "unmap",
|
||||
GTK_SIGNAL_FUNC(menu_unmap_handler),
|
||||
this);
|
||||
this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,7 @@ NS_METHOD nsMenu::AddItem(nsISupports * aItem)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// local method used by nsMenu::AddItem
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem)
|
||||
{
|
||||
|
@ -224,6 +225,7 @@ NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// local method used by nsMenu::AddItem
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu)
|
||||
{
|
||||
|
@ -293,6 +295,9 @@ NS_METHOD nsMenu::AddSeparator()
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::GetItemCount(PRUint32 &aCount)
|
||||
{
|
||||
// this should be right.. does it need to be +1 ?
|
||||
aCount = g_list_length(GTK_MENU_SHELL(mMenu)->children);
|
||||
g_print("nsMenu::GetItemCount = %i\n", aCount);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -308,17 +313,9 @@ NS_METHOD nsMenu::InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::InsertSeparator(const PRUint32 aPos)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::RemoveItem(const PRUint32 aPos)
|
||||
{
|
||||
|
||||
|
||||
//gtk_menu_shell_remove (GTK_MENU_SHELL (mMenu), item);
|
||||
|
||||
//delete[] labelStr;
|
||||
|
|
|
@ -67,7 +67,6 @@ public:
|
|||
NS_IMETHOD GetItemCount(PRUint32 &aCount);
|
||||
NS_IMETHOD GetItemAt(const PRUint32 aPos, nsISupports *& aMenuItem);
|
||||
NS_IMETHOD InsertItemAt(const PRUint32 aPos, nsISupports * aMenuItem);
|
||||
NS_IMETHOD InsertSeparator(const PRUint32 aPos);
|
||||
NS_IMETHOD RemoveItem(const PRUint32 aPos);
|
||||
NS_IMETHOD RemoveAll();
|
||||
NS_IMETHOD GetNativeData(void** aData);
|
||||
|
@ -91,7 +90,6 @@ protected:
|
|||
nsIDOMElement * menuElement,
|
||||
nsIDOMNode * menuNode);
|
||||
|
||||
void Create(GtkWidget *aParent, const nsString &aLabel);
|
||||
GtkWidget *GetNativeParent();
|
||||
|
||||
nsString mLabel;
|
||||
|
|
|
@ -31,38 +31,41 @@
|
|||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsWidgetsCID.h"
|
||||
static NS_DEFINE_IID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_IID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
static NS_DEFINE_IID(kMenuBarCID, NS_MENUBAR_CID);
|
||||
static NS_DEFINE_IID(kMenuCID, NS_MENU_CID);
|
||||
static NS_DEFINE_IID(kMenuItemCID, NS_MENUITEM_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIMenuBarIID, NS_IMENUBAR_IID);
|
||||
static NS_DEFINE_IID(kIMenuIID, NS_IMENU_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuBarIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)(nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
nsresult nsMenuBar::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(kIMenuBarIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)(nsIMenuBar*) this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIMenuListenerIID)) {
|
||||
*aInstancePtr = (void*) ((nsIMenuListener*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsMenuBar)
|
||||
|
@ -192,16 +195,16 @@ NS_METHOD nsMenuBar::RemoveAll()
|
|||
if(menu) {
|
||||
//void * gtkmenu= nsnull;
|
||||
//menu->GetNativeData(>kmenu);
|
||||
//if(gtkmenu){
|
||||
//if(gtkmenu){
|
||||
// gtk_container_remove (GTK_CONTAINER (mMenuBar), GTK_WIDGET(gtkmenu) );
|
||||
//}
|
||||
NS_RELEASE(menu);
|
||||
//}
|
||||
NS_RELEASE(menu);
|
||||
|
||||
g_print("menu release \n");
|
||||
int num =((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
while(num) {
|
||||
g_print("menu release again!\n");
|
||||
num = ((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
g_print("menu release \n");
|
||||
int num =((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
while(num) {
|
||||
g_print("menu release again!\n");
|
||||
num = ((nsISupports*)mMenusVoidArray[i-1])->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,72 +259,75 @@ nsEventStatus nsMenuBar::MenuConstruct(
|
|||
void * menubarNode,
|
||||
void * aWebShell)
|
||||
{
|
||||
mWebShell = (nsIWebShell*) aWebShell;
|
||||
mDOMNode = (nsIDOMNode*)menubarNode;
|
||||
mWebShell = (nsIWebShell*) aWebShell;
|
||||
mDOMNode = (nsIDOMNode*)menubarNode;
|
||||
|
||||
nsIMenuBar * pnsMenuBar = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID,
|
||||
nsnull,
|
||||
kIMenuBarIID,
|
||||
(void**)&pnsMenuBar);
|
||||
if (NS_OK == rv) {
|
||||
if (nsnull != pnsMenuBar) {
|
||||
pnsMenuBar->Create(aParentWindow);
|
||||
|
||||
nsIMenuBar * pnsMenuBar = nsnull;
|
||||
nsresult rv = nsComponentManager::CreateInstance(kMenuBarCID, nsnull, kIMenuBarIID, (void**)&pnsMenuBar);
|
||||
if (NS_OK == rv) {
|
||||
if (nsnull != pnsMenuBar) {
|
||||
pnsMenuBar->Create(aParentWindow);
|
||||
|
||||
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
||||
nsCOMPtr<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(kIMenuListenerIID, getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
// set pnsMenuBar as a nsMenuListener on aParentWindow
|
||||
nsCOMPtr<nsIMenuListener> menuListener;
|
||||
pnsMenuBar->QueryInterface(kIMenuListenerIID, getter_AddRefs(menuListener));
|
||||
aParentWindow->AddMenuListener(menuListener);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> menuNode;
|
||||
((nsIDOMNode*)menubarNode)->GetFirstChild(getter_AddRefs(menuNode));
|
||||
while (menuNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
|
||||
if (menuElement) {
|
||||
nsString menuNodeType;
|
||||
nsString menuName;
|
||||
menuElement->GetNodeName(menuNodeType);
|
||||
if (menuNodeType.Equals("menu")) {
|
||||
menuElement->GetAttribute(nsAutoString("name"), menuName);
|
||||
// Don't create the menu yet, just add in the top level names
|
||||
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuBar->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports);
|
||||
nsCOMPtr<nsIDOMNode> menuNode;
|
||||
((nsIDOMNode*)menubarNode)->GetFirstChild(getter_AddRefs(menuNode));
|
||||
while (menuNode) {
|
||||
nsCOMPtr<nsIDOMElement> menuElement(do_QueryInterface(menuNode));
|
||||
if (menuElement) {
|
||||
nsString menuNodeType;
|
||||
nsString menuName;
|
||||
menuElement->GetNodeName(menuNodeType);
|
||||
if (menuNodeType.Equals("menu")) {
|
||||
menuElement->GetAttribute(nsAutoString("name"), menuName);
|
||||
// Don't create the menu yet, just add in the top level names
|
||||
|
||||
pnsMenu->SetLabel(menuName);
|
||||
pnsMenu->SetDOMNode(menuNode);
|
||||
pnsMenu->SetDOMElement(menuElement);
|
||||
pnsMenu->SetWebShell(mWebShell);
|
||||
// Create nsMenu
|
||||
nsIMenu * pnsMenu = nsnull;
|
||||
rv = nsComponentManager::CreateInstance(kMenuCID, nsnull, kIMenuIID, (void**)&pnsMenu);
|
||||
if (NS_OK == rv) {
|
||||
// Call Create
|
||||
nsISupports * supports = nsnull;
|
||||
pnsMenuBar->QueryInterface(kISupportsIID, (void**) &supports);
|
||||
pnsMenu->Create(supports, menuName);
|
||||
NS_RELEASE(supports);
|
||||
|
||||
// Make nsMenu a child of nsMenuBar
|
||||
// nsMenuBar takes ownership of the nsMenu
|
||||
pnsMenuBar->AddMenu(pnsMenu);
|
||||
|
||||
// Release the menu now that the menubar owns it
|
||||
NS_RELEASE(pnsMenu);
|
||||
}
|
||||
}
|
||||
pnsMenu->SetLabel(menuName);
|
||||
pnsMenu->SetDOMNode(menuNode);
|
||||
pnsMenu->SetDOMElement(menuElement);
|
||||
pnsMenu->SetWebShell(mWebShell);
|
||||
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuNode(menuNode);
|
||||
oldmenuNode->GetNextSibling(getter_AddRefs(menuNode));
|
||||
} // end while (nsnull != menuNode)
|
||||
|
||||
// Give the aParentWindow this nsMenuBar to hold onto.
|
||||
// The parent window should take ownership at this point
|
||||
aParentWindow->SetMenuBar(pnsMenuBar);
|
||||
|
||||
// HACK: force a paint for now
|
||||
pnsMenuBar->Paint();
|
||||
|
||||
NS_RELEASE(pnsMenuBar);
|
||||
// Make nsMenu a child of nsMenuBar
|
||||
// nsMenuBar takes ownership of the nsMenu
|
||||
pnsMenuBar->AddMenu(pnsMenu);
|
||||
|
||||
// Release the menu now that the menubar owns it
|
||||
NS_RELEASE(pnsMenu);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
nsCOMPtr<nsIDOMNode> oldmenuNode(menuNode);
|
||||
oldmenuNode->GetNextSibling(getter_AddRefs(menuNode));
|
||||
} // end while (nsnull != menuNode)
|
||||
|
||||
// Give the aParentWindow this nsMenuBar to hold onto.
|
||||
// The parent window should take ownership at this point
|
||||
aParentWindow->SetMenuBar(pnsMenuBar);
|
||||
|
||||
// HACK: force a paint for now
|
||||
pnsMenuBar->Paint();
|
||||
|
||||
NS_RELEASE(pnsMenuBar);
|
||||
} // end if ( nsnull != pnsMenuBar )
|
||||
}
|
||||
|
||||
|
||||
return nsEventStatus_eIgnore;
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
|
|
|
@ -102,50 +102,6 @@ nsMenuItem::~nsMenuItem()
|
|||
g_print("nsMenuItem::~nsMenuItem called\n");
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void nsMenuItem::Create(nsIWidget *aMBParent,
|
||||
GtkWidget *aParent,
|
||||
const nsString &aLabel,
|
||||
PRBool aIsSeparator)
|
||||
{
|
||||
mTarget = aMBParent;
|
||||
mLabel = aLabel;
|
||||
|
||||
if (NULL == aParent || nsnull == aMBParent) {
|
||||
return;
|
||||
}
|
||||
|
||||
char * nameStr = mLabel.ToNewCString();
|
||||
if(aIsSeparator) {
|
||||
mIsSeparator = PR_TRUE;
|
||||
mMenuItem = gtk_menu_item_new();
|
||||
}else{
|
||||
mIsSeparator = PR_FALSE;
|
||||
mMenuItem = gtk_menu_item_new_with_label(nameStr);
|
||||
}
|
||||
gtk_widget_show(mMenuItem);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mMenuItem), "activate",
|
||||
GTK_SIGNAL_FUNC(menu_item_activate_handler),
|
||||
this);
|
||||
delete[] nameStr;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuItem::Create(nsIMenu * aParent)
|
||||
{
|
||||
mIsSeparator = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuItem::Create(nsIPopUpMenu * aParent)
|
||||
{
|
||||
mIsSeparator = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
GtkWidget *nsMenuItem::GetNativeParent()
|
||||
{
|
||||
|
@ -203,48 +159,50 @@ nsIWidget * nsMenuItem::GetMenuBarParent(nsISupports * aParent)
|
|||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuItem::Create(nsISupports * aParent,
|
||||
const nsString & aLabel,
|
||||
PRBool aIsSeparator)
|
||||
NS_METHOD nsMenuItem::Create(nsISupports *aParent,
|
||||
const nsString &aLabel,
|
||||
PRBool aIsSeparator)
|
||||
|
||||
{
|
||||
if (nsnull == aParent) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if(aParent){
|
||||
if(aParent) {
|
||||
nsIMenu * menu;
|
||||
aParent->QueryInterface(kIMenuIID, (void**) &menu);
|
||||
mMenuParent = menu;
|
||||
NS_RELEASE(menu);
|
||||
}
|
||||
nsIWidget * widget = nsnull; // MenuBar's Parent
|
||||
nsISupports * sups;
|
||||
|
||||
nsIWidget *widget = nsnull; // MenuBar's Parent
|
||||
nsISupports *sups;
|
||||
if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) {
|
||||
widget = GetMenuBarParent(sups);
|
||||
//GetMenuBarParent will call release for us
|
||||
//NS_RELEASE(sups);
|
||||
// GetMenuBarParent will call release for us
|
||||
// NS_RELEASE(sups);
|
||||
mTarget = widget;
|
||||
}
|
||||
|
||||
Create(widget, GetNativeParent(), aLabel, aIsSeparator);
|
||||
// aParent->AddMenuItem(this);
|
||||
mIsSeparator = aIsSeparator;
|
||||
mLabel = aLabel;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
// create the native menu item
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuItem::Create(nsIPopUpMenu *aParent,
|
||||
const nsString &aLabel,
|
||||
PRUint32 aCommand)
|
||||
{
|
||||
mPopUpParent = aParent;
|
||||
|
||||
nsIWidget * widget = nsnull;
|
||||
if (NS_OK != aParent->GetParent(widget)) {
|
||||
widget = nsnull;
|
||||
if(mIsSeparator) {
|
||||
mMenuItem = gtk_menu_item_new();
|
||||
} else {
|
||||
char *nameStr = aLabel.ToNewCString();
|
||||
mMenuItem = gtk_menu_item_new_with_label(nameStr);
|
||||
delete[] nameStr;
|
||||
}
|
||||
|
||||
Create(widget, GetNativeParent(), aLabel, PR_FALSE);
|
||||
|
||||
gtk_widget_show(mMenuItem);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (mMenuItem), "activate",
|
||||
GTK_SIGNAL_FUNC(menu_item_activate_handler),
|
||||
this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -274,6 +232,11 @@ NS_METHOD nsMenuItem::SetEnabled(PRBool aIsEnabled)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenuItem::GetEnabled(PRBool *aIsEnabled)
|
||||
{
|
||||
if (GTK_WIDGET_STATE(mMenuItem) == GTK_STATE_INSENSITIVE)
|
||||
aIsEnabled = PR_FALSE;
|
||||
else
|
||||
aIsEnabled = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -356,23 +319,22 @@ nsEventStatus nsMenuItem::MenuSelected(const nsMenuEvent & aMenuEvent)
|
|||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
nsEventStatus nsMenuItem::MenuDeselected(const nsMenuEvent & aMenuEvent)
|
||||
nsEventStatus nsMenuItem::MenuDeselected(const nsMenuEvent &aMenuEvent)
|
||||
{
|
||||
g_print("nsMenuItem::MenuDeselected\n");
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
nsEventStatus nsMenuItem::MenuConstruct(
|
||||
const nsMenuEvent & aMenuEvent,
|
||||
nsIWidget * aParentWindow,
|
||||
void * menuNode,
|
||||
void * aWebShell)
|
||||
nsEventStatus nsMenuItem::MenuConstruct(const nsMenuEvent &aMenuEvent,
|
||||
nsIWidget *aParentWindow,
|
||||
void *menuNode,
|
||||
void *aWebShell)
|
||||
{
|
||||
g_print("nsMenuItem::MenuConstruct\n");
|
||||
return nsEventStatus_eIgnore;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent)
|
||||
nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent &aMenuEvent)
|
||||
{
|
||||
g_print("nsMenuItem::MenuDestruct\n");
|
||||
return nsEventStatus_eIgnore;
|
||||
|
@ -380,20 +342,21 @@ nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent)
|
|||
|
||||
//-------------------------------------------------------------------------
|
||||
/**
|
||||
* Sets the JavaScript Command to be invoked when a "gui" event occurs on a source widget
|
||||
* @param aStrCmd the JS command to be cached for later execution
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_METHOD nsMenuItem::SetCommand(const nsString & aStrCmd)
|
||||
* Sets the JavaScript Command to be invoked when a "gui" event
|
||||
* occurs on a source widget
|
||||
* @param aStrCmd the JS command to be cached for later execution
|
||||
* @return NS_OK
|
||||
*/
|
||||
NS_METHOD nsMenuItem::SetCommand(const nsString &aStrCmd)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
/**
|
||||
* Executes the "cached" JavaScript Command
|
||||
* @return NS_OK if the command was executed properly, otherwise an error code
|
||||
*/
|
||||
* Executes the "cached" JavaScript Command
|
||||
* @return NS_OK if the command was executed properly, otherwise an error code
|
||||
*/
|
||||
NS_METHOD nsMenuItem::DoCommand()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
@ -404,31 +367,31 @@ NS_METHOD nsMenuItem::DoCommand()
|
|||
nsCOMPtr<nsIContentViewerContainer> contentViewerContainer;
|
||||
contentViewerContainer = do_QueryInterface(mWebShell);
|
||||
if (!contentViewerContainer) {
|
||||
NS_ERROR("Webshell doesn't support the content viewer container interface");
|
||||
g_print("Webshell doesn't support the content viewer container interface");
|
||||
return rv;
|
||||
NS_ERROR("Webshell doesn't support the content viewer container interface");
|
||||
g_print("Webshell doesn't support the content viewer container interface");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
||||
if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) {
|
||||
NS_ERROR("Unable to retrieve content viewer.");
|
||||
g_print("Unable to retrieve content viewer.");
|
||||
return rv;
|
||||
NS_ERROR("Unable to retrieve content viewer.");
|
||||
g_print("Unable to retrieve content viewer.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocumentViewer> docViewer;
|
||||
docViewer = do_QueryInterface(contentViewer);
|
||||
if (!docViewer) {
|
||||
NS_ERROR("Document viewer interface not supported by the content viewer.");
|
||||
g_print("Document viewer interface not supported by the content viewer.");
|
||||
return rv;
|
||||
NS_ERROR("Document viewer interface not supported by the content viewer.");
|
||||
g_print("Document viewer interface not supported by the content viewer.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
if (NS_FAILED(rv = docViewer->GetPresContext(*getter_AddRefs(presContext)))) {
|
||||
NS_ERROR("Unable to retrieve the doc viewer's presentation context.");
|
||||
g_print("Unable to retrieve the doc viewer's presentation context.");
|
||||
return rv;
|
||||
NS_ERROR("Unable to retrieve the doc viewer's presentation context.");
|
||||
g_print("Unable to retrieve the doc viewer's presentation context.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
|
@ -439,9 +402,9 @@ NS_METHOD nsMenuItem::DoCommand()
|
|||
nsCOMPtr<nsIContent> contentNode;
|
||||
contentNode = do_QueryInterface(mDOMElement);
|
||||
if (!contentNode) {
|
||||
NS_ERROR("DOM Node doesn't support the nsIContent interface required to handle DOM events.");
|
||||
g_print("DOM Node doesn't support the nsIContent interface required to handle DOM events.");
|
||||
return rv;
|
||||
NS_ERROR("DOM Node doesn't support the nsIContent interface required to handle DOM events.");
|
||||
g_print("DOM Node doesn't support the nsIContent interface required to handle DOM events.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = contentNode->HandleDOMEvent(*presContext, &event, nsnull, NS_EVENT_FLAG_INIT, status);
|
||||
|
|
|
@ -72,21 +72,13 @@ public:
|
|||
nsEventStatus MenuItemSelected(const nsMenuEvent & aMenuEvent);
|
||||
nsEventStatus MenuSelected(const nsMenuEvent & aMenuEvent);
|
||||
nsEventStatus MenuDeselected(const nsMenuEvent & aMenuEvent);
|
||||
nsEventStatus MenuConstruct(
|
||||
const nsMenuEvent & aMenuEvent,
|
||||
nsIWidget * aParentWindow,
|
||||
void * menuNode,
|
||||
void * aWebShell);
|
||||
nsEventStatus MenuConstruct(const nsMenuEvent & aMenuEvent,
|
||||
nsIWidget * aParentWindow,
|
||||
void * menuNode,
|
||||
void * aWebShell);
|
||||
nsEventStatus MenuDestruct(const nsMenuEvent & aMenuEvent);
|
||||
|
||||
protected:
|
||||
NS_IMETHOD Create(nsIPopUpMenu *aParent,
|
||||
const nsString &aLabel,
|
||||
PRUint32 aCommand) ;
|
||||
NS_IMETHOD Create(nsIMenu * aParent);
|
||||
NS_IMETHOD Create(nsIPopUpMenu * aParent);
|
||||
void Create(nsIWidget * aMBParent, GtkWidget *aParent,
|
||||
const nsString &aLabel, PRBool aIsSeparator);
|
||||
nsIWidget *GetMenuBarParent(nsISupports * aParentSupports);
|
||||
GtkWidget *GetNativeParent();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче