From c66c64145b28c44bd19cb6fa9b7781ddf6c57ff8 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sun, 1 Aug 2004 21:59:08 +0000 Subject: Don't QI the event target to nsIDOMEventReceiver and back to 2004-08-01 Christian Persch * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: Don't QI the event target to nsIDOMEventReceiver and back to nsIDOMEventTarget when using it, just store it as-is. Thanks to Crispin for noticing this. --- ChangeLog | 9 ++++++++ embed/mozilla/EphyBrowser.cpp | 48 +++++++++++++++---------------------------- embed/mozilla/EphyBrowser.h | 6 +++--- 3 files changed, 29 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index d15cf9d10..ed71fec72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-08-01 Christian Persch + + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EphyBrowser.h: + + Don't QI the event target to nsIDOMEventReceiver and back + to nsIDOMEventTarget when using it, just store it as-is. + Thanks to Crispin for noticing this. + 2004-08-01 Christian Persch * configure.in: diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index ecdd3c5f8..690a5e24c 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -70,6 +70,7 @@ #include "nsIChannel.h" #ifdef ALLOW_PRIVATE_API +#include "nsIDocShell.h" #include "nsIMarkupDocumentViewer.h" #ifdef HAVE_MOZILLA_PSM /* not sure about this one: */ @@ -261,7 +262,7 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed) nsresult EphyBrowser::GetListener (void) { - if (mEventReceiver) return NS_ERROR_FAILURE; + if (mEventTarget) return NS_ERROR_FAILURE; nsCOMPtr domWindowExternal; mWebBrowser->GetContentDOMWindow (getter_AddRefs(domWindowExternal)); @@ -269,11 +270,8 @@ EphyBrowser::GetListener (void) nsCOMPtr domWindow (do_QueryInterface (domWindowExternal)); NS_ENSURE_TRUE (domWindow, NS_ERROR_FAILURE); - nsCOMPtr rootWindow; - domWindow->GetWindowRoot (getter_AddRefs(rootWindow)); - - mEventReceiver = do_QueryInterface (rootWindow); - NS_ENSURE_TRUE (mEventReceiver, NS_ERROR_FAILURE); + domWindow->GetWindowRoot (getter_AddRefs(mEventTarget)); + NS_ENSURE_TRUE (mEventTarget, NS_ERROR_FAILURE); return NS_OK; } @@ -281,19 +279,13 @@ EphyBrowser::GetListener (void) nsresult EphyBrowser::AttachListeners(void) { - nsresult rv; - - NS_ENSURE_TRUE (mEventReceiver, NS_ERROR_FAILURE); - - nsCOMPtr target; - target = do_QueryInterface (mEventReceiver); - - rv = target->AddEventListener(nsEmbedString(DOMLinkAdded), - mFaviconEventListener, PR_FALSE); - NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + NS_ENSURE_TRUE (mEventTarget, NS_ERROR_FAILURE); - rv = target->AddEventListener(nsEmbedString(DOMPopupBlocked), - mPopupBlockEventListener, PR_FALSE); + nsresult rv; + rv = mEventTarget->AddEventListener(nsEmbedString(DOMLinkAdded), + mFaviconEventListener, PR_FALSE); + rv |= mEventTarget->AddEventListener(nsEmbedString(DOMPopupBlocked), + mPopupBlockEventListener, PR_FALSE); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); return NS_OK; @@ -302,21 +294,15 @@ EphyBrowser::AttachListeners(void) nsresult EphyBrowser::DetachListeners(void) { - nsresult rv; - - if (!mEventReceiver) return NS_OK; + if (!mEventTarget) return NS_OK; - nsCOMPtr target; - target = do_QueryInterface (mEventReceiver); - NS_ENSURE_TRUE (target, NS_ERROR_FAILURE); - - rv = target->RemoveEventListener(nsEmbedString(DOMLinkAdded), - mFaviconEventListener, PR_FALSE); + nsresult rv; + rv = mEventTarget->RemoveEventListener(nsEmbedString(DOMLinkAdded), + mFaviconEventListener, PR_FALSE); + rv |= mEventTarget->RemoveEventListener(nsEmbedString(DOMPopupBlocked), + mPopupBlockEventListener, PR_FALSE); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); - rv = target->RemoveEventListener(nsEmbedString(DOMPopupBlocked), - mPopupBlockEventListener, PR_FALSE); - return NS_OK; } @@ -413,7 +399,7 @@ nsresult EphyBrowser::Destroy () mWebBrowser = nsnull; mDOMWindow = nsnull; - mEventReceiver = nsnull; + mEventTarget = nsnull; mInitialized = PR_FALSE; diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index 9d3cd8979..99a15f002 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -36,8 +37,7 @@ #include #ifdef ALLOW_PRIVATE_API -#include -#include +#include "nsIContentViewer.h" #endif class EphyEventListener : public nsIDOMEventListener @@ -134,7 +134,7 @@ public: private: nsCOMPtr mTargetDocument; - nsCOMPtr mEventReceiver; + nsCOMPtr mEventTarget; nsCOMPtr mDOMWindow; nsCOMPtr mSecurityInfo; EphyFaviconEventListener *mFaviconEventListener; -- cgit v1.2.3