diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 48 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 6 |
3 files changed, 29 insertions, 34 deletions
@@ -1,5 +1,14 @@ 2004-08-01 Christian Persch <chpe@cvs.gnome.org> + * 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 <chpe@cvs.gnome.org> + * configure.in: Post-release version bump. 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<nsIDOMWindow> domWindowExternal; mWebBrowser->GetContentDOMWindow (getter_AddRefs(domWindowExternal)); @@ -269,11 +270,8 @@ EphyBrowser::GetListener (void) nsCOMPtr<nsIDOMWindow2> domWindow (do_QueryInterface (domWindowExternal)); NS_ENSURE_TRUE (domWindow, NS_ERROR_FAILURE); - nsCOMPtr<nsIDOMEventTarget> 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<nsIDOMEventTarget> 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<nsIDOMEventTarget> 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 <gtkmozembed.h> #include <nsCOMPtr.h> #include <nsIDOMEventListener.h> +#include <nsIDOMEventTarget.h> #include <nsIWebNavigation.h> #include <nsISHistory.h> #include <nsIWebBrowser.h> @@ -36,8 +37,7 @@ #include <nsIRequest.h> #ifdef ALLOW_PRIVATE_API -#include <nsIDocShell.h> -#include <nsIDOMEventReceiver.h> +#include "nsIContentViewer.h" #endif class EphyEventListener : public nsIDOMEventListener @@ -134,7 +134,7 @@ public: private: nsCOMPtr<nsIDOMDocument> mTargetDocument; - nsCOMPtr<nsIDOMEventReceiver> mEventReceiver; + nsCOMPtr<nsIDOMEventTarget> mEventTarget; nsCOMPtr<nsIDOMWindow> mDOMWindow; nsCOMPtr<nsISupports> mSecurityInfo; EphyFaviconEventListener *mFaviconEventListener; |