more cleanup for bug 329337. bump iid, fix memory leak, check event creation return. b=329337 r=biesi

This commit is contained in:
joshmoz%gmail.com 2006-03-15 16:52:31 +00:00
Родитель 6f1486e3be
Коммит b77c27f1df
3 изменённых файлов: 19 добавлений и 12 удалений

Просмотреть файл

@ -45,11 +45,10 @@
#include "nsIDocShell.h"
#include "nsIDOMElement.h"
// {f2e79600-1700-11d5-bb6f-90f240fe493c}
// {F5E4F801-DFD2-4DE3-8708-7914F2D4710D}
#define NS_IMENUITEM_IID \
{ 0xf2e79600, 0x1700, 0x11d5, \
{ 0xbb, 0x6f, 0x90, 0xf2, 0x40, 0xfe, 0x49, 0x3c } }
{ 0xF5E4F801, 0xDFD2, 0x4DE3, \
{ 0x87, 0x08, 0x79, 0x14, 0xF2, 0xD4, 0x71, 0x0D } }
class nsIMenu;
class nsIWidget;

Просмотреть файл

@ -301,8 +301,12 @@ NS_IMETHODIMP nsMenuItemX::DispatchDOMEvent(const nsString &eventName, PRBool *p
}
// create DOM event
nsIDOMEvent* event;
DOMEventFactory->CreateEvent(NS_LITERAL_STRING("Events"), &event);
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = DOMEventFactory->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to create nsIDOMEvent");
return rv;
}
event->InitEvent(eventName, PR_TRUE, PR_TRUE);
// mark DOM event as trusted
@ -311,10 +315,10 @@ NS_IMETHODIMP nsMenuItemX::DispatchDOMEvent(const nsString &eventName, PRBool *p
// send DOM event
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(mContent);
nsresult rv = eventTarget->DispatchEvent(event, preventDefaultCalled);
rv = eventTarget->DispatchEvent(event, preventDefaultCalled);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to send DOM event via nsIDOMEventTarget");
return NS_ERROR_FAILURE;
return rv;
}
return NS_OK;

Просмотреть файл

@ -288,8 +288,12 @@ NS_IMETHODIMP nsMenuItemX::DispatchDOMEvent(const nsString &eventName, PRBool *p
}
// create DOM event
nsIDOMEvent* event;
DOMEventFactory->CreateEvent(NS_LITERAL_STRING("Events"), &event);
nsCOMPtr<nsIDOMEvent> event;
nsresult rv = DOMEventFactory->CreateEvent(NS_LITERAL_STRING("Events"), getter_AddRefs(event));
if (NS_FAILED(rv)) {
NS_WARNING("Failed to create nsIDOMEvent");
return rv;
}
event->InitEvent(eventName, PR_TRUE, PR_TRUE);
// mark DOM event as trusted
@ -298,10 +302,10 @@ NS_IMETHODIMP nsMenuItemX::DispatchDOMEvent(const nsString &eventName, PRBool *p
// send DOM event
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(mContent);
nsresult rv = eventTarget->DispatchEvent(event, preventDefaultCalled);
rv = eventTarget->DispatchEvent(event, preventDefaultCalled);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to send DOM event via nsIDOMEventTarget");
return NS_ERROR_FAILURE;
return rv;
}
return NS_OK;