diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-01-29 06:51:20 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-01-29 06:51:20 +0800 |
commit | 6489ead25062142ab0dd9fc7285dc65cb438b284 (patch) | |
tree | 439c1a6fae5f2bd764ebe10bdb1a037f9c1630c1 /embed/mozilla/mozilla-embed.cpp | |
parent | 8ed0c8f6318e7800ad3968f6e3cd19a53dcd5c8c (diff) | |
download | gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar.gz gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar.bz2 gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar.lz gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar.xz gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.tar.zst gsoc2013-epiphany-6489ead25062142ab0dd9fc7285dc65cb438b284.zip |
Refactored to elimiate code duplication.
2005-01-28 Christian Persch <chpe@cvs.gnome.org>
* embed/mozilla/mozilla-embed.cpp:
Refactored to elimiate code duplication.
Diffstat (limited to 'embed/mozilla/mozilla-embed.cpp')
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 87 |
1 files changed, 28 insertions, 59 deletions
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index f3e0aac40..54db6067c 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -57,10 +57,10 @@ static void mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, gint state, guint status, MozillaEmbed *membed); -static gint mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, +static gboolean mozilla_embed_dom_mouse_click_cb(GtkMozEmbed *embed, gpointer dom_event, MozillaEmbed *membed); -static gint mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, +static gboolean mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, MozillaEmbed *membed); static void mozilla_embed_new_window_cb (GtkMozEmbed *embed, @@ -871,21 +871,18 @@ mozilla_embed_net_state_all_cb (GtkMozEmbed *embed, const char *aURI, g_signal_emit_by_name (membed, "ge_net_state", aURI, estate); } -static gint -mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, - MozillaEmbed *membed) +static gboolean +mozilla_embed_emit_mouse_signal (MozillaEmbed *embed, + gpointer dom_event, + const char *signal_name) { + MozillaEmbedPrivate *mpriv = embed->priv; MozillaEmbedEvent *info; EventContext event_context; gint return_value = FALSE; nsresult rv; - MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - if (dom_event == NULL) - { - g_warning ("mozilla_embed_dom_mouse_click_cb: domevent NULL"); - return FALSE; - } + if (dom_event == NULL) return FALSE; nsCOMPtr<nsIDOMMouseEvent> ev = static_cast<nsIDOMMouseEvent*>(dom_event); NS_ENSURE_TRUE (ev, FALSE); @@ -896,65 +893,20 @@ mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event, event_context.Init (mpriv->browser); rv = event_context.GetMouseEventInfo (ev, MOZILLA_EMBED_EVENT (info)); - - if (NS_SUCCEEDED (rv)) - { - nsCOMPtr<nsIDOMDocument> domDoc; - rv = event_context.GetTargetDocument (getter_AddRefs(domDoc)); - if (NS_SUCCEEDED (rv)) - { - rv = mpriv->browser->PushTargetDocument (domDoc); - if (NS_SUCCEEDED (rv)) - { - g_signal_emit_by_name (membed, "ge_dom_mouse_click", - info, &return_value); - mpriv->browser->PopTargetDocument (); - } - } - - } - - g_object_unref (info); - - return return_value; -} - -static gint -mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, - MozillaEmbed *membed) -{ - MozillaEmbedEvent *info; - EventContext event_context; - gint return_value = FALSE; - nsresult rv; - MozillaEmbedPrivate *mpriv = MOZILLA_EMBED(embed)->priv; - - if (dom_event == NULL) + if (NS_FAILED (rv)) { - g_warning ("mozilla_embed_dom_mouse_down_cb: domevent NULL"); + g_object_unref (info); return FALSE; } - nsCOMPtr<nsIDOMMouseEvent> ev = static_cast<nsIDOMMouseEvent*>(dom_event); - NS_ENSURE_TRUE (ev, FALSE); - nsCOMPtr<nsIDOMEvent> dev = do_QueryInterface (ev); - NS_ENSURE_TRUE (dev, FALSE); - - info = mozilla_embed_event_new (NS_STATIC_CAST (gpointer, dev)); - - event_context.Init (mpriv->browser); - rv = event_context.GetMouseEventInfo (ev, MOZILLA_EMBED_EVENT (info)); - if (NS_FAILED (rv)) return FALSE; - nsCOMPtr<nsIDOMDocument> domDoc; rv = event_context.GetTargetDocument (getter_AddRefs(domDoc)); if (NS_SUCCEEDED (rv)) { mpriv->browser->PushTargetDocument (domDoc); - g_signal_emit_by_name (membed, "ge_dom_mouse_down", + g_signal_emit_by_name (embed, signal_name, info, &return_value); - mpriv->browser->PopTargetDocument (); } @@ -963,6 +915,23 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, return return_value; } +static gboolean +mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, + gpointer dom_event, + MozillaEmbed *membed) +{ + return mozilla_embed_emit_mouse_signal (membed, dom_event, + "ge_dom_mouse_click"); +} + +static gboolean +mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event, + MozillaEmbed *membed) +{ + return mozilla_embed_emit_mouse_signal (membed, dom_event, + "ge_dom_mouse_down"); +} + static void mozilla_embed_new_window_cb (GtkMozEmbed *embed, GtkMozEmbed **newEmbed, |