diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-10-28 01:29:36 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-10-28 01:29:36 +0800 |
commit | 7b0fe9305597ff7bd10c4dc468ae00eab155ca36 (patch) | |
tree | 5b8a213e75b8c49a7246abed3ac9e65393517d9d /embed | |
parent | 03518bcc5c5aa9a9149315e932f84a0aee2d44ce (diff) | |
download | gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar.gz gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar.bz2 gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar.lz gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar.xz gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.tar.zst gsoc2013-epiphany-7b0fe9305597ff7bd10c4dc468ae00eab155ca36.zip |
Solving the wrapper mess THE END
2003-10-27 Marco Pesenti Gritti <marco@gnome.org>
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EphyBrowser.h:
* embed/mozilla/mozilla-embed.cpp:
Solving the wrapper mess THE END
An about:blank document is created syncronously
on _init, which means there are no more race conditions !
Mozilla api is CRACK.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 15 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 2 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 51 |
3 files changed, 15 insertions, 53 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index f23f7163a..812ba9b53 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -90,18 +90,20 @@ EphyBrowser::~EphyBrowser () nsresult EphyBrowser::Init (GtkMozEmbed *mozembed) { + nsresult rv; + mGtkMozEmbed = mozembed; gtk_moz_embed_get_nsIWebBrowser (mozembed, getter_AddRefs(mWebBrowser)); if (!mWebBrowser) return NS_ERROR_FAILURE; - return mWebBrowser->GetContentDOMWindow (getter_AddRefs (mDOMWindow)); -} + mWebBrowser->GetContentDOMWindow (getter_AddRefs (mDOMWindow)); -nsresult EphyBrowser::InitDocument () -{ - nsresult rv; + /* This will instantiate an about:blank doc if necessary */ + nsCOMPtr<nsIDOMDocument> domDocument; + rv = mDOMWindow->GetDocument (getter_AddRefs (mDOMDocument)); + if (NS_FAILED (rv)) return NS_ERROR_FAILURE; mEventListener = new EphyEventListener(); @@ -368,7 +370,8 @@ nsresult EphyBrowser::GetZoom (float *aZoom) nsresult EphyBrowser::GetDocument (nsIDOMDocument **aDOMDocument) { - return mDOMWindow->GetDocument (aDOMDocument); + NS_ENSURE_ARG_POINTER(aDOMDocument); + NS_IF_ADDREF(*aDOMDocument = mDOMDocument); } nsresult EphyBrowser::GetTargetDocument (nsIDOMDocument **aDOMDocument) diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index b803ccec8..9d02d87b0 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -46,7 +46,6 @@ public: ~EphyBrowser(); nsresult Init (GtkMozEmbed *mozembed); - nsresult InitDocument (); nsresult Destroy (void); nsresult DoCommand (const char *command); @@ -88,6 +87,7 @@ public: nsCOMPtr<nsIWebBrowser> mWebBrowser; nsCOMPtr<nsIDOMWindow> mDOMWindow; + nsCOMPtr<nsIDOMDocument> mDOMDocument; GtkMozEmbed *mGtkMozEmbed; private: diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index 5a6b11945..e240304d2 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -223,17 +223,9 @@ signal_connections[] = struct MozillaEmbedPrivate { - MozillaEmbedPrivate() : browser(NULL), security_state(-1), no_page(1) - { /* nothing */ } - EphyBrowser *browser; nsCOMPtr<nsIRequest> request; gint security_state; - - /* HACK 1: No page loaded, 0: Loading an empty page, -1: Page loaded */ - gint no_page; - - gboolean browser_document_initialized; }; #define WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1" @@ -440,9 +432,8 @@ mozilla_embed_init (MozillaEmbed *embed) { embed->priv = MOZILLA_EMBED_GET_PRIVATE (embed); - embed->priv->no_page = 1; - embed->priv->browser_document_initialized = FALSE; embed->priv->browser = new EphyBrowser (); + embed->priv->security_state = -1; mozilla_embed_connect_signals (embed); } @@ -1081,19 +1072,11 @@ static void mozilla_embed_location_changed_cb (GtkMozEmbed *embed, MozillaEmbed *membed) { - /* Do not emit signal if we are loading the - * fallback about:blank. We dont want the user - * to know about it. */ - if (membed->priv->no_page != 0) - { - char *location; - - location = gtk_moz_embed_get_location (embed); - g_signal_emit_by_name (membed, "ge_location", location); - g_free (location); - } + char *location; - membed->priv->no_page = -1; + location = gtk_moz_embed_get_location (embed); + g_signal_emit_by_name (membed, "ge_location", location); + g_free (location); } static void @@ -1131,30 +1114,6 @@ mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, const char *aURI, { 0, EMBED_STATE_UNKNOWN } }; - /* No page loaded, default to about:blank */ - if (membed->priv->no_page > 0 && - (state & GTK_MOZ_EMBED_FLAG_STOP) && - (state & GTK_MOZ_EMBED_FLAG_IS_DOCUMENT)) - { - ephy_embed_load_url (EPHY_EMBED(membed), "about:blank"); - membed->priv->no_page = 0; - } - - if (!membed->priv->browser_document_initialized) - { - nsresult rv; - - rv = membed->priv->browser->InitDocument (); - if (NS_FAILED (rv)) - { - g_warning ("Browser document initialization failed"); - } - else - { - membed->priv->browser_document_initialized = TRUE; - } - } - for (i = 0; conversion_map[i].state != 0; i++) { if (state & conversion_map[i].state) |