diff options
author | Jean-François Rameau <jframeau@cvs.gnome.org> | 2005-05-13 05:53:05 +0800 |
---|---|---|
committer | Jean-François Rameau <jframeau@src.gnome.org> | 2005-05-13 05:53:05 +0800 |
commit | 6a817a5731527cb9fd77524cdd2956eae6f794c2 (patch) | |
tree | eaf137876a37a5bbd6311fd623c9fb170bf24fb2 /embed | |
parent | 58addfabc1ee4b84459117e2b73e575f9c792165 (diff) | |
download | gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar.gz gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar.bz2 gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar.lz gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar.xz gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.tar.zst gsoc2013-epiphany-6a817a5731527cb9fd77524cdd2956eae6f794c2.zip |
Add handling of DOMContentLoaded event from Gecko. It is an event that
2005-05-12 Jean-François Rameau <jframeau@cvs.gnome.org>
* embed/ephy-embed.h:
* embed/ephy-embed.c:
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EventContext.cpp:
Add handling of DOMContentLoaded event from Gecko.
It is an event that Gecko throws when the dom’s content is loaded,
that is, before all the images and what not have loaded.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed.c | 17 | ||||
-rw-r--r-- | embed/ephy-embed.h | 2 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 31 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 8 |
4 files changed, 58 insertions, 0 deletions
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 1fbed68e2..f6547f8fc 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -332,6 +332,23 @@ ephy_embed_base_init (gpointer g_class) G_TYPE_NONE, 1, EPHY_TYPE_EMBED_DOCUMENT_TYPE); +/** + * EphyEmbed::dom-content-loaded: + * @embed: + * + * The ::dom-content-loaded signal is emitted when + * the document has been loaded (excluding images and other loads initiated by this document). + * That's true also for frameset and all the frames within it. + **/ + g_signal_new ("dom_content_loaded", + EPHY_TYPE_EMBED, + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EphyEmbedIface, dom_content_loaded), + NULL, NULL, + g_cclosure_marshal_VOID__POINTER, + G_TYPE_NONE, + 1, + G_TYPE_POINTER); initialized = TRUE; } diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 014aa6cd8..b16a25e86 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -129,6 +129,8 @@ struct _EphyEmbedIface EphyEmbedEvent *event); gboolean (* dom_mouse_down) (EphyEmbed *embed, EphyEmbedEvent *event); + void (* dom_content_loaded) (EphyEmbed *embed, + gpointer event); void (* popup_blocked) (EphyEmbed *embed, const char *address, const char *features); diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 0f70367a3..f0147ed33 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -101,6 +101,7 @@ #endif const static PRUnichar kDOMLinkAdded[] = { 'D', 'O', 'M', 'L', 'i', 'n', 'k', 'A', 'd', 'd', 'e', 'd', '\0' }; +const static PRUnichar kDOMContentLoaded[] = { 'D', 'O', 'M', 'C', 'o', 'n', 't', 'e', 'n', 't', 'L', 'o', 'a', 'd', 'e', 'd', '\0' }; const static PRUnichar kContextMenu[] = { 'c', 'o', 'n', 't', 'e', 'x', 't', 'm', 'e', 'n', 'u', '\0' }; const static PRUnichar kDOMPopupBlocked[] = { 'D', 'O', 'M', 'P', 'o', 'p', 'u', 'p', 'B', 'l', 'o', 'c', 'k', 'e', 'd', '\0' }; const static PRUnichar kDOMWillOpenModalDialog[] = { 'D', 'O', 'M', 'W', 'i', 'l', 'l', 'O', 'p', 'e', 'n', 'M', 'o', 'd', 'a', 'l', 'D', 'i', 'a', 'l', 'o', 'g', '\0' }; @@ -287,6 +288,25 @@ EphyDOMLinkEventListener::HandleEvent (nsIDOMEvent* aDOMEvent) return NS_OK; } +NS_IMETHODIMP +EphyDOMContentLoadedEventListener::HandleEvent (nsIDOMEvent* aDOMEvent) +{ + LOG ("DOMContentLoaded event fired up"); + +#ifdef MOZ_NSIDOMNSEVENT_GETISTRUSTED + /* make sure the event is trusted */ + nsCOMPtr<nsIDOMNSEvent> nsEvent (do_QueryInterface (aDOMEvent)); + NS_ENSURE_TRUE (nsEvent, NS_ERROR_FAILURE); + PRBool isTrusted = PR_FALSE; + nsEvent->GetIsTrusted (&isTrusted); + if (!isTrusted) return NS_OK; +#endif /* MOZ_NSIDOMNSEVENT_GETISTRUSTED */ + + g_signal_emit_by_name (mOwner->mEmbed, "dom_content_loaded", (gpointer)aDOMEvent); + + return NS_OK; +} + nsresult EphyDOMLinkEventListener::GetDocURI (nsIDOMElement *aElement, nsIURI **aDocURI) @@ -489,6 +509,7 @@ EphyContextMenuListener::HandleEvent (nsIDOMEvent* aDOMEvent) EphyBrowser::EphyBrowser () : mDOMLinkEventListener(nsnull) +, mDOMContentLoadedEventListener(nsnull) , mPopupBlockEventListener(nsnull) , mModalAlertListener(nsnull) , mContextMenuListener(nsnull) @@ -527,6 +548,12 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed) rv = mDOMLinkEventListener->Init (this); NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + mDOMContentLoadedEventListener = new EphyDOMContentLoadedEventListener(); + if (!mDOMContentLoadedEventListener) return NS_ERROR_OUT_OF_MEMORY; + + rv = mDOMContentLoadedEventListener->Init (this); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + mPopupBlockEventListener = new EphyPopupBlockEventListener(); if (!mPopupBlockEventListener) return NS_ERROR_OUT_OF_MEMORY; @@ -632,6 +659,8 @@ EphyBrowser::AttachListeners(void) nsresult rv; rv = mEventTarget->AddEventListener(nsEmbedString(kDOMLinkAdded), mDOMLinkEventListener, PR_FALSE); + rv |= mEventTarget->AddEventListener(nsEmbedString(kDOMContentLoaded), + mDOMContentLoadedEventListener, PR_FALSE); rv |= mEventTarget->AddEventListener(nsEmbedString(kDOMPopupBlocked), mPopupBlockEventListener, PR_FALSE); rv |= mEventTarget->AddEventListener(nsEmbedString(kDOMWillOpenModalDialog), @@ -653,6 +682,8 @@ EphyBrowser::DetachListeners(void) nsresult rv; rv = mEventTarget->RemoveEventListener(nsEmbedString(kDOMLinkAdded), mDOMLinkEventListener, PR_FALSE); + rv |= mEventTarget->RemoveEventListener(nsEmbedString(kDOMContentLoaded), + mDOMContentLoadedEventListener, PR_FALSE); rv |= mEventTarget->RemoveEventListener(nsEmbedString(kDOMPopupBlocked), mPopupBlockEventListener, PR_FALSE); rv |= mEventTarget->RemoveEventListener(nsEmbedString(kDOMWillOpenModalDialog), diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index ffb11e11f..195d26f64 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -89,6 +89,12 @@ public: NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); }; +class EphyDOMContentLoadedEventListener : public EphyEventListener +{ +public: + NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); +}; + class EphyContextMenuListener : public nsIDOMContextMenuListener { public: @@ -112,6 +118,7 @@ class EphyBrowser { friend class EphyEventListener; friend class EphyDOMLinkEventListener; +friend class EphyDOMContentLoadedEventListener; friend class EphyPopupBlockEventListener; friend class EphyModalAlertEventListener; friend class EphyContextMenuListener; @@ -182,6 +189,7 @@ private: nsCOMPtr<nsIDOMEventTarget> mEventTarget; nsCOMPtr<nsIDOMWindow> mDOMWindow; EphyDOMLinkEventListener *mDOMLinkEventListener; + EphyDOMContentLoadedEventListener *mDOMContentLoadedEventListener; EphyPopupBlockEventListener *mPopupBlockEventListener; EphyModalAlertEventListener *mModalAlertListener; EphyContextMenuListener *mContextMenuListener; |