Bug 496317 - Remove nsPopupBlockedEvent, r+sr=sicking

--HG--
extra : rebase_source : 354385de35d48a6f2c911c20175b1715c89c9196
This commit is contained in:
Olli Pettay 2009-06-16 19:07:56 +03:00
parent b40171b242
commit c1e420fdbe
6 changed files with 23 additions and 103 deletions

View File

@ -88,7 +88,7 @@ NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresCon
nsresult
NS_NewDOMMutationEvent(nsIDOMEvent** aResult NS_OUTPARAM, nsPresContext* aPresContext, class nsMutationEvent* aEvent);
nsresult
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsPopupBlockedEvent* aEvent);
NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
nsresult
NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);
nsresult

View File

@ -943,12 +943,6 @@ NS_METHOD nsDOMEvent::DuplicatePrivateData()
NS_ENSURE_TRUE(newEvent, NS_ERROR_OUT_OF_MEMORY);
break;
}
case NS_POPUPBLOCKED_EVENT:
{
NS_WARNING("nsPopupBlockedEvent should never be an external event!");
newEvent = new nsPopupBlockedEvent(PR_FALSE, msg);
break;
}
case NS_BEFORE_PAGE_UNLOAD_EVENT:
{
newEvent = new nsBeforePageUnloadEvent(PR_FALSE, msg);

View File

@ -41,35 +41,6 @@
#include "nsIURI.h"
#include "nsContentUtils.h"
nsDOMPopupBlockedEvent::nsDOMPopupBlockedEvent(nsPresContext* aPresContext,
nsPopupBlockedEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent ? aEvent :
new nsPopupBlockedEvent(PR_FALSE, 0))
{
NS_ASSERTION(mEvent->eventStructType == NS_POPUPBLOCKED_EVENT, "event type mismatch");
if (aEvent) {
mEventIsInternal = PR_FALSE;
}
else {
mEventIsInternal = PR_TRUE;
mEvent->time = PR_Now();
}
}
nsDOMPopupBlockedEvent::~nsDOMPopupBlockedEvent()
{
if (mEventIsInternal) {
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
NS_IF_RELEASE(event->mPopupWindowURI);
delete event;
mEvent = nsnull;
}
}
}
NS_IMPL_ADDREF_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
NS_IMPL_RELEASE_INHERITED(nsDOMPopupBlockedEvent, nsDOMEvent)
@ -89,22 +60,10 @@ nsDOMPopupBlockedEvent::InitPopupBlockedEvent(const nsAString & aTypeArg,
nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
NS_ENSURE_SUCCESS(rv, rv);
switch (mEvent->eventStructType)
{
case NS_POPUPBLOCKED_EVENT:
{
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
event->mRequestingWindow = do_GetWeakReference(aRequestingWindow);
event->mPopupWindowURI = aPopupWindowURI;
NS_IF_ADDREF(event->mPopupWindowURI);
event->mPopupWindowFeatures = aPopupWindowFeatures;
event->mPopupWindowName = aPopupWindowName;
break;
}
default:
break;
}
mRequestingWindow = do_GetWeakReference(aRequestingWindow);
mPopupWindowURI = aPopupWindowURI;
mPopupWindowFeatures = aPopupWindowFeatures;
mPopupWindowName = aPopupWindowName;
return NS_OK;
}
@ -112,12 +71,8 @@ NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetRequestingWindow(nsIDOMWindow **aRequestingWindow)
{
*aRequestingWindow = nsnull;
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
if (event->mRequestingWindow) {
CallQueryReferent(event->mRequestingWindow.get(), aRequestingWindow);
}
}
if (mRequestingWindow)
CallQueryReferent(mRequestingWindow.get(), aRequestingWindow);
return NS_OK; // Don't throw an exception
}
@ -126,43 +81,30 @@ NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowURI(nsIURI **aPopupWindowURI)
{
NS_ENSURE_ARG_POINTER(aPopupWindowURI);
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
*aPopupWindowURI = event->mPopupWindowURI;
NS_IF_ADDREF(*aPopupWindowURI);
return NS_OK;
}
*aPopupWindowURI = 0;
*aPopupWindowURI = mPopupWindowURI;
NS_IF_ADDREF(*aPopupWindowURI);
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowFeatures(nsAString &aPopupWindowFeatures)
{
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
aPopupWindowFeatures = event->mPopupWindowFeatures;
return NS_OK;
}
aPopupWindowFeatures.Truncate();
aPopupWindowFeatures = mPopupWindowFeatures;
return NS_OK; // Don't throw an exception
}
NS_IMETHODIMP
nsDOMPopupBlockedEvent::GetPopupWindowName(nsAString &aPopupWindowName)
{
if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
aPopupWindowName = event->mPopupWindowName;
return NS_OK;
}
aPopupWindowName.Truncate();
aPopupWindowName = mPopupWindowName;
return NS_OK; // Don't throw an exception
}
nsresult NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aInstancePtrResult,
nsPresContext* aPresContext,
nsPopupBlockedEvent *aEvent)
nsEvent *aEvent)
{
nsDOMPopupBlockedEvent* it = new nsDOMPopupBlockedEvent(aPresContext, aEvent);
if (nsnull == it) {

View File

@ -41,14 +41,15 @@
#include "nsIDOMPopupBlockedEvent.h"
#include "nsDOMEvent.h"
#include "nsIURI.h"
class nsDOMPopupBlockedEvent : public nsIDOMPopupBlockedEvent,
public nsDOMEvent
{
public:
nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsPopupBlockedEvent* aEvent);
virtual ~nsDOMPopupBlockedEvent();
nsDOMPopupBlockedEvent(nsPresContext* aPresContext, nsEvent* aEvent)
: nsDOMEvent(aPresContext, aEvent) {}
NS_DECL_ISUPPORTS_INHERITED
@ -57,6 +58,11 @@ public:
// nsIDOMPopupBlockedEvent Interface
NS_DECL_NSIDOMPOPUPBLOCKEDEVENT
protected:
nsWeakPtr mRequestingWindow;
nsCOMPtr<nsIURI> mPopupWindowURI;
nsString mPopupWindowFeatures;
nsString mPopupWindowName;
};
#endif // nsDOMPopupBlockedEvent_h__

View File

@ -640,10 +640,6 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext,
case NS_DRAG_EVENT:
return NS_NewDOMDragEvent(aDOMEvent, aPresContext,
static_cast<nsDragEvent*>(aEvent));
case NS_POPUPBLOCKED_EVENT:
return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext,
static_cast<nsPopupBlockedEvent*>
(aEvent));
case NS_TEXT_EVENT:
return NS_NewDOMTextEvent(aDOMEvent, aPresContext,
static_cast<nsTextEvent*>(aEvent));

View File

@ -89,7 +89,7 @@ class nsHashKey;
#define NS_FORM_EVENT 21
#define NS_POPUP_EVENT 23
#define NS_COMMAND_EVENT 24
#define NS_POPUPBLOCKED_EVENT 25
#define NS_BEFORE_PAGE_UNLOAD_EVENT 26
#define NS_UI_EVENT 27
#define NS_PAGETRANSITION_EVENT 29
@ -1205,24 +1205,6 @@ public:
nsCOMPtr<nsIAtom> command;
};
/**
* blocked popup window event
*/
class nsPopupBlockedEvent : public nsEvent
{
public:
nsPopupBlockedEvent(PRBool isTrusted, PRUint32 msg)
: nsEvent(isTrusted, msg, NS_POPUPBLOCKED_EVENT),
mPopupWindowURI(nsnull)
{
}
nsWeakPtr mRequestingWindow;
nsIURI* mPopupWindowURI; // owning reference
nsString mPopupWindowFeatures;
nsString mPopupWindowName;
};
/**
* DOM UIEvent
*/