From c1e420fdbee904f2bbff89b1e918b3ad898e9424 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Tue, 16 Jun 2009 19:07:56 +0300 Subject: [PATCH] Bug 496317 - Remove nsPopupBlockedEvent, r+sr=sicking --HG-- extra : rebase_source : 354385de35d48a6f2c911c20175b1715c89c9196 --- content/events/public/nsIPrivateDOMEvent.h | 2 +- content/events/src/nsDOMEvent.cpp | 6 -- content/events/src/nsDOMPopupBlockedEvent.cpp | 84 +++---------------- content/events/src/nsDOMPopupBlockedEvent.h | 10 ++- content/events/src/nsEventDispatcher.cpp | 4 - widget/public/nsGUIEvent.h | 20 +---- 6 files changed, 23 insertions(+), 103 deletions(-) diff --git a/content/events/public/nsIPrivateDOMEvent.h b/content/events/public/nsIPrivateDOMEvent.h index 1617c054ec15..1cd82b81f9cd 100644 --- a/content/events/public/nsIPrivateDOMEvent.h +++ b/content/events/public/nsIPrivateDOMEvent.h @@ -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 diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 705b18a78175..06b788c659b5 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -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); diff --git a/content/events/src/nsDOMPopupBlockedEvent.cpp b/content/events/src/nsDOMPopupBlockedEvent.cpp index ae335785b6ae..c927ec45bf73 100644 --- a/content/events/src/nsDOMPopupBlockedEvent.cpp +++ b/content/events/src/nsDOMPopupBlockedEvent.cpp @@ -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(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(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(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(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(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(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) { diff --git a/content/events/src/nsDOMPopupBlockedEvent.h b/content/events/src/nsDOMPopupBlockedEvent.h index c26bc686d1f0..3f197f1321df 100644 --- a/content/events/src/nsDOMPopupBlockedEvent.h +++ b/content/events/src/nsDOMPopupBlockedEvent.h @@ -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 mPopupWindowURI; + nsString mPopupWindowFeatures; + nsString mPopupWindowName; }; #endif // nsDOMPopupBlockedEvent_h__ diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index 05278cc0a2be..813865320fe3 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -640,10 +640,6 @@ nsEventDispatcher::CreateEvent(nsPresContext* aPresContext, case NS_DRAG_EVENT: return NS_NewDOMDragEvent(aDOMEvent, aPresContext, static_cast(aEvent)); - case NS_POPUPBLOCKED_EVENT: - return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, - static_cast - (aEvent)); case NS_TEXT_EVENT: return NS_NewDOMTextEvent(aDOMEvent, aPresContext, static_cast(aEvent)); diff --git a/widget/public/nsGUIEvent.h b/widget/public/nsGUIEvent.h index a48e246848fa..4123baa07a59 100644 --- a/widget/public/nsGUIEvent.h +++ b/widget/public/nsGUIEvent.h @@ -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 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 */