aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyBrowser.cpp
diff options
context:
space:
mode:
authorJean-François Rameau <jframeau@cvs.gnome.org>2005-05-13 05:53:05 +0800
committerJean-François Rameau <jframeau@src.gnome.org>2005-05-13 05:53:05 +0800
commit6a817a5731527cb9fd77524cdd2956eae6f794c2 (patch)
treeeaf137876a37a5bbd6311fd623c9fb170bf24fb2 /embed/mozilla/EphyBrowser.cpp
parent58addfabc1ee4b84459117e2b73e575f9c792165 (diff)
downloadgsoc2013-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/mozilla/EphyBrowser.cpp')
-rw-r--r--embed/mozilla/EphyBrowser.cpp31
1 files changed, 31 insertions, 0 deletions
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),