aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-01-16 02:08:26 +0800
committerChristian Persch <chpe@src.gnome.org>2004-01-16 02:08:26 +0800
commit216c6fa203c77b1ea3aa21dd822c3688783cac42 (patch)
tree4fcc01185a3bc213497bfcf90fbdc47b6044becf /embed
parent5e2c715ab1b0ae755542a02914b2377fd0878d99 (diff)
downloadgsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.gz
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.bz2
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.lz
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.xz
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.tar.zst
gsoc2013-epiphany-216c6fa203c77b1ea3aa21dd822c3688783cac42.zip
Make EphyEmbedEvent abstract, implemented by MozillaEmbedEvent. Port
2004-01-15 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed-event.c: (ephy_embed_event_get_type), (ephy_embed_event_base_init), (ephy_embed_event_get_event_type), (ephy_embed_event_get_context), (ephy_embed_event_get_modifier), (ephy_embed_event_get_coords), (ephy_embed_event_get_property), (ephy_embed_event_has_property), (ephy_embed_event_get_dom_event): * embed/ephy-embed-event.h: * embed/mozilla/EventContext.cpp: * embed/mozilla/EventContext.h: * embed/mozilla/Makefile.am: * embed/mozilla/mozilla-embed-event.cpp: * embed/mozilla/mozilla-embed-event.h: * embed/mozilla/mozilla-embed.cpp: * src/ephy-window.c: (popup_menu_at_coords): * src/popup-commands.c: (popup_cmd_copy_link_address): Make EphyEmbedEvent abstract, implemented by MozillaEmbedEvent. Port callers to the new api. Fix some callers in src/ which were using private fields of EphyEmbedEvent struct.
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-event.c124
-rw-r--r--embed/ephy-embed-event.h67
-rw-r--r--embed/mozilla/EventContext.cpp14
-rw-r--r--embed/mozilla/EventContext.h10
-rw-r--r--embed/mozilla/Makefile.am2
-rw-r--r--embed/mozilla/mozilla-embed-event.cpp208
-rw-r--r--embed/mozilla/mozilla-embed-event.h74
-rw-r--r--embed/mozilla/mozilla-embed.cpp24
8 files changed, 377 insertions, 146 deletions
diff --git a/embed/ephy-embed-event.c b/embed/ephy-embed-event.c
index bc99b81bf..1271e29ed 100644
--- a/embed/ephy-embed-event.c
+++ b/embed/ephy-embed-event.c
@@ -30,122 +30,66 @@ struct EphyEmbedEventPrivate
GHashTable *props;
};
-static void
-ephy_embed_event_class_init (EphyEmbedEventClass *klass);
-static void
-ephy_embed_event_init (EphyEmbedEvent *ges);
-static void
-ephy_embed_event_finalize (GObject *object);
-
-static GObjectClass *parent_class = NULL;
+static void ephy_embed_event_base_init (gpointer g_class);
GType
ephy_embed_event_get_type (void)
{
- static GType ephy_embed_event_type = 0;
+ static GType type = 0;
- if (ephy_embed_event_type == 0)
+ if (type == 0)
{
static const GTypeInfo our_info =
{
- sizeof (EphyEmbedEventClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) ephy_embed_event_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EphyEmbedEvent),
- 0, /* n_preallocs */
- (GInstanceInitFunc) ephy_embed_event_init
+ sizeof (EphyEmbedEventIFace),
+ ephy_embed_event_base_init,
+ NULL,
};
- ephy_embed_event_type = g_type_register_static (G_TYPE_OBJECT,
- "EphyEmbedEvent",
- &our_info, 0);
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "EphyEmbedEvent",
+ &our_info,
+ (GTypeFlags) 0);
}
- return ephy_embed_event_type;
-}
-
-static void
-ephy_embed_event_class_init (EphyEmbedEventClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- parent_class = g_type_class_peek_parent (klass);
-
- object_class->finalize = ephy_embed_event_finalize;
-
- g_type_class_add_private (object_class, sizeof(EphyEmbedEventPrivate));
-}
-
-static void
-free_g_value (gpointer value)
-{
- g_value_unset (value);
- g_free (value);
+ return type;
}
static void
-ephy_embed_event_init (EphyEmbedEvent *event)
+ephy_embed_event_base_init (gpointer g_class)
{
- event->priv = EPHY_EMBED_EVENT_GET_PRIVATE (event);
+ static gboolean initialised = FALSE;
- event->priv->props = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, free_g_value);
+ initialised = TRUE;
}
-static void
-ephy_embed_event_finalize (GObject *object)
+EphyEmbedEventType
+ephy_embed_event_get_event_type (EphyEmbedEvent *event)
{
- EphyEmbedEvent *event = EPHY_EMBED_EVENT (object);
-
- g_hash_table_destroy (event->priv->props);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ return iface->get_type (event);
}
-
-EphyEmbedEvent *
-ephy_embed_event_new (void)
+EmbedEventContext
+ephy_embed_event_get_context (EphyEmbedEvent *event)
{
- return EPHY_EMBED_EVENT (g_object_new (EPHY_TYPE_EMBED_EVENT, NULL));
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ return iface->get_context (event);
}
guint
ephy_embed_event_get_modifier (EphyEmbedEvent *event)
{
- return event->modifier;
-}
-
-EphyEmbedEventType
-ephy_embed_event_get_event_type (EphyEmbedEvent *event)
-{
- return event->type;
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ return iface->get_modifier (event);
}
void
ephy_embed_event_get_coords (EphyEmbedEvent *event,
guint *x, guint *y)
{
- *x = event->x;
- *y = event->y;
-}
-
-EmbedEventContext
-ephy_embed_event_get_context (EphyEmbedEvent *event)
-{
- return event->context;
-}
-
-void
-ephy_embed_event_set_property (EphyEmbedEvent *event,
- const char *name,
- GValue *value)
-{
- g_hash_table_insert (event->priv->props,
- g_strdup (name),
- value);
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ iface->get_coordinates (event, x, y);
}
void
@@ -153,17 +97,21 @@ ephy_embed_event_get_property (EphyEmbedEvent *event,
const char *name,
const GValue **value)
{
- *value = g_hash_table_lookup (event->priv->props, name);
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ iface->get_property (event, name, value);
}
gboolean
ephy_embed_event_has_property (EphyEmbedEvent *event,
const char *name)
{
- gpointer tmp;
-
- tmp = g_hash_table_lookup (event->priv->props,
- name);
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ return iface->has_property (event, name);
+}
- return tmp != NULL;
+gpointer
+ephy_embed_event_get_dom_event (EphyEmbedEvent *event)
+{
+ EphyEmbedEventIFace *iface = EPHY_EMBED_EVENT_GET_IFACE (event);
+ return iface->get_dom_event (event);
}
diff --git a/embed/ephy-embed-event.h b/embed/ephy-embed-event.h
index a056082f1..0cd3c58c6 100644
--- a/embed/ephy-embed-event.h
+++ b/embed/ephy-embed-event.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2000, 2001, 2002 Marco Pesenti Gritti
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 2004 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,6 +15,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
*/
#ifndef EPHY_EMBED_EVENT_H
@@ -24,16 +27,15 @@
G_BEGIN_DECLS
-#define EPHY_TYPE_EMBED_EVENT (ephy_embed_event_get_type ())
-#define EPHY_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEvent))
-#define EPHY_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventClass))
-#define EPHY_IS_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_EVENT))
-#define EPHY_IS_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_EVENT))
-#define EPHY_EMBED_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventClass))
+#define EPHY_TYPE_EMBED_EVENT (ephy_embed_event_get_type ())
+#define EPHY_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_EMBED_EVENT, EphyEmbedEvent))
+#define EPHY_EMBED_EVENT_IFACE(k) (G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventIFace))
+#define EPHY_IS_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_EMBED_EVENT))
+#define EPHY_IS_EMBED_EVENT_IFACE(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_EMBED_EVENT))
+#define EPHY_EMBED_EVENT_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), EPHY_TYPE_EMBED_EVENT, EphyEmbedEventIFace))
-typedef struct EphyEmbedEventClass EphyEmbedEventClass;
-typedef struct EphyEmbedEvent EphyEmbedEvent;
-typedef struct EphyEmbedEventPrivate EphyEmbedEventPrivate;
+typedef struct EphyEmbedEventIFace EphyEmbedEventIFace;
+typedef struct EphyEmbedEvent EphyEmbedEvent;
typedef enum
{
@@ -55,42 +57,37 @@ typedef enum
EPHY_EMBED_EVENT_KEY
} EphyEmbedEventType;
-struct EphyEmbedEvent
+struct EphyEmbedEventIFace
{
- GObject parent;
-
- /*< private >*/
- EphyEmbedEventPrivate *priv;
-
- /* Public to the embed implementations */
- guint modifier;
- EphyEmbedEventType type;
- guint context;
- guint x, y;
- guint keycode;
-};
-
-struct EphyEmbedEventClass
-{
- GObjectClass parent_class;
+ GTypeInterface parent_iface;
+
+ /* Methods */
+ EphyEmbedEventType (* get_type) (EphyEmbedEvent *event);
+ EmbedEventContext (* get_context) (EphyEmbedEvent *event);
+ guint (* get_modifier) (EphyEmbedEvent *event);
+ void (* get_coordinates) (EphyEmbedEvent *event,
+ guint *x,
+ guint *y);
+ void (* get_property) (EphyEmbedEvent *event,
+ const char *name,
+ const GValue **value);
+ gboolean (* has_property) (EphyEmbedEvent *event,
+ const char *name);
+ gpointer (* get_dom_event) (EphyEmbedEvent *event);
};
GType ephy_embed_event_get_type (void);
-EphyEmbedEvent *ephy_embed_event_new (void);
+EphyEmbedEventType ephy_embed_event_get_event_type (EphyEmbedEvent *event);
+
+EmbedEventContext ephy_embed_event_get_context (EphyEmbedEvent *event);
guint ephy_embed_event_get_modifier (EphyEmbedEvent *event);
-EphyEmbedEventType ephy_embed_event_get_event_type (EphyEmbedEvent *event);
void ephy_embed_event_get_coords (EphyEmbedEvent *event,
guint *x, guint *y);
-EmbedEventContext ephy_embed_event_get_context (EphyEmbedEvent *event);
-
-void ephy_embed_event_set_property (EphyEmbedEvent *event,
- const char *name,
- GValue *value);
void ephy_embed_event_get_property (EphyEmbedEvent *event,
const char *name,
@@ -99,6 +96,8 @@ void ephy_embed_event_get_property (EphyEmbedEvent *event,
gboolean ephy_embed_event_has_property (EphyEmbedEvent *event,
const char *name);
+gpointer ephy_embed_event_get_dom_event (EphyEmbedEvent *event);
+
G_END_DECLS
#endif
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index ea209a3c7..3bfa2d97d 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -188,7 +188,7 @@ nsresult EventContext::ResolveDocumentURL (nsIDocument *doc, const nsAString &re
}
nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
- EphyEmbedEvent *info)
+ MozillaEmbedEvent *info)
{
nsresult rv;
@@ -635,7 +635,7 @@ nsresult EventContext::GetCSSBackground (nsIDOMNode *node, nsAutoString& url)
return NS_OK;
}
-nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, EphyEmbedEvent *info)
+nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, MozillaEmbedEvent *info)
{
nsresult result;
@@ -718,7 +718,7 @@ nsresult EventContext::GetMouseEventInfo (nsIDOMMouseEvent *aMouseEvent, EphyEmb
return NS_OK;
}
-nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, EphyEmbedEvent *info)
+nsresult EventContext::GetKeyEventInfo (nsIDOMKeyEvent *aKeyEvent, MozillaEmbedEvent *info)
{
nsresult rv;
@@ -838,9 +838,7 @@ nsresult EventContext::SetIntProperty (const char *name, int value)
g_value_set_int (val, value);
- ephy_embed_event_set_property (mEmbedEvent,
- name,
- val);
+ mozilla_embed_event_set_property (mEmbedEvent, name, val);
return NS_OK;
}
@@ -853,9 +851,7 @@ nsresult EventContext::SetStringProperty (const char *name, const char *value)
g_value_set_string (val, value);
- ephy_embed_event_set_property (mEmbedEvent,
- name,
- val);
+ mozilla_embed_event_set_property (mEmbedEvent, name, val);
return NS_OK;
}
diff --git a/embed/mozilla/EventContext.h b/embed/mozilla/EventContext.h
index 5953e4810..a2deba41b 100644
--- a/embed/mozilla/EventContext.h
+++ b/embed/mozilla/EventContext.h
@@ -34,7 +34,7 @@
#include "EphyBrowser.h"
#include "ephy-embed.h"
-#include "ephy-embed-event.h"
+#include "mozilla-embed-event.h"
class EventContext
{
@@ -44,8 +44,8 @@ public:
nsresult Init (EphyBrowser *wrapper);
- nsresult GetMouseEventInfo (nsIDOMMouseEvent *event, EphyEmbedEvent *info);
- nsresult GetKeyEventInfo (nsIDOMKeyEvent *event, EphyEmbedEvent *info);
+ nsresult GetMouseEventInfo (nsIDOMMouseEvent *event, MozillaEmbedEvent *info);
+ nsresult GetKeyEventInfo (nsIDOMKeyEvent *event, MozillaEmbedEvent *info);
nsresult GetTargetDocument (nsIDOMDocument **domDoc);
private:
@@ -56,14 +56,14 @@ private:
nsresult ResolveBaseURL (nsIDocument *doc, const nsAString &relurl, nsACString &url);
nsresult ResolveDocumentURL (nsIDocument *doc, const nsAString &relurl, nsACString &url);
nsresult GetEventContext (nsIDOMEventTarget *EventTarget,
- EphyEmbedEvent *info);
+ MozillaEmbedEvent *info);
nsresult GetCSSBackground (nsIDOMNode *node, nsAutoString& url);
nsresult IsPageFramed (nsIDOMNode *node, PRBool *Framed);
nsresult CheckLinkScheme (const nsAString &link);
nsresult SetIntProperty (const char *name, int value);
nsresult SetStringProperty (const char *name, const char *value);
nsresult SetStringProperty (const char *name, const nsAString &value);
- EphyEmbedEvent *mEmbedEvent;
+ MozillaEmbedEvent *mEmbedEvent;
};
#endif
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 25d63176d..1340ef216 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -87,6 +87,8 @@ libephymozillaembed_la_SOURCES = \
mozilla-download.h \
mozilla-embed.cpp \
mozilla-embed.h \
+ mozilla-embed-event.cpp \
+ mozilla-embed-event.h \
mozilla-embed-persist.cpp \
mozilla-embed-persist.h \
mozilla-embed-single.cpp \
diff --git a/embed/mozilla/mozilla-embed-event.cpp b/embed/mozilla/mozilla-embed-event.cpp
new file mode 100644
index 000000000..9300457a9
--- /dev/null
+++ b/embed/mozilla/mozilla-embed-event.cpp
@@ -0,0 +1,208 @@
+/*
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#include "mozilla-embed-event.h"
+
+#include <nsCOMPtr.h>
+#include <nsIDOMEvent.h>
+
+#include <glib/ghash.h>
+#include <gtk/gtktypeutils.h>
+
+#define MOZILLA_EMBED_EVENT_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEventPrivate))
+
+struct MozillaEmbedEventPrivate
+{
+ nsCOMPtr<nsIDOMEvent> dom_event;
+ GHashTable *props;
+};
+
+static void mozilla_embed_event_class_init (MozillaEmbedEventClass *klass);
+static void mozilla_embed_event_init (MozillaEmbedEvent *event);
+static void ephy_embed_event_iface_init (EphyEmbedEventIFace *iface);
+
+static GObjectClass *parent_class = NULL;
+
+GType
+mozilla_embed_event_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0)
+ {
+ static const GTypeInfo our_info =
+ {
+ sizeof (MozillaEmbedEventClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) mozilla_embed_event_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (MozillaEmbedEvent),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) mozilla_embed_event_init
+ };
+
+ static const GInterfaceInfo embed_event_info =
+ {
+ (GInterfaceInitFunc) ephy_embed_event_iface_init,
+ NULL,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "MozillaEmbedEvent",
+ &our_info, (GTypeFlags) 0);
+
+ g_type_add_interface_static (type,
+ EPHY_TYPE_EMBED_EVENT,
+ &embed_event_info);
+ }
+
+ return type;
+}
+
+MozillaEmbedEvent *
+mozilla_embed_event_new (gpointer dom_event)
+{
+ MozillaEmbedEvent *event;
+
+ event = MOZILLA_EMBED_EVENT (g_object_new (MOZILLA_TYPE_EMBED_EVENT, NULL));
+
+ event->priv->dom_event = static_cast<nsIDOMEvent*>(dom_event);
+
+ return event;
+}
+
+void
+mozilla_embed_event_set_property (MozillaEmbedEvent *event,
+ const char *name,
+ GValue *value)
+{
+ g_hash_table_insert (event->priv->props,
+ g_strdup (name),
+ value);
+}
+
+static EphyEmbedEventType
+impl_get_type (EphyEmbedEvent *event)
+{
+ return ((MozillaEmbedEvent *) event)->type;
+}
+
+static EmbedEventContext
+impl_get_context (EphyEmbedEvent *event)
+{
+ return (EmbedEventContext) ((MozillaEmbedEvent *) event)->context;
+}
+
+static guint
+impl_get_modifier (EphyEmbedEvent *event)
+{
+ return ((MozillaEmbedEvent *) event)->modifier;
+}
+
+static void
+impl_get_coordinates (EphyEmbedEvent *event,
+ guint *x,
+ guint *y)
+{
+ *x = ((MozillaEmbedEvent *) event)->x;
+ *y = ((MozillaEmbedEvent *) event)->y;
+}
+
+static void
+impl_get_property (EphyEmbedEvent *event,
+ const char *name,
+ const GValue **value)
+{
+ *value = (const GValue *) g_hash_table_lookup (((MozillaEmbedEvent *) event)->priv->props, name);
+}
+
+static gboolean
+impl_has_property (EphyEmbedEvent *event,
+ const char *name)
+{
+ gpointer tmp;
+
+ tmp = g_hash_table_lookup (((MozillaEmbedEvent *) event)->priv->props, name);
+
+ return tmp != NULL;
+}
+
+static gpointer
+impl_get_dom_event (EphyEmbedEvent *event)
+{
+ return NS_STATIC_CAST (gpointer, ((MozillaEmbedEvent *) event)->priv->dom_event);
+}
+
+static void
+free_g_value (gpointer value)
+{
+ g_value_unset ((GValue *) value);
+ g_free (value);
+}
+
+static void
+mozilla_embed_event_init (MozillaEmbedEvent *event)
+{
+ event->priv = MOZILLA_EMBED_EVENT_GET_PRIVATE (event);
+
+ event->priv->dom_event = nsnull;
+ event->priv->props = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, free_g_value);
+}
+
+static void
+mozilla_embed_event_finalize (GObject *object)
+{
+ MozillaEmbedEvent *event = MOZILLA_EMBED_EVENT (object);
+
+ g_hash_table_destroy (event->priv->props);
+
+ event->priv->dom_event = nsnull;
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+ephy_embed_event_iface_init (EphyEmbedEventIFace *iface)
+{
+ iface->get_type = impl_get_type;
+ iface->get_context = impl_get_context;
+ iface->get_modifier = impl_get_modifier;
+ iface->get_coordinates = impl_get_coordinates;
+ iface->get_property = impl_get_property;
+ iface->has_property = impl_has_property;
+ iface->get_dom_event = impl_get_dom_event;
+}
+
+static void
+mozilla_embed_event_class_init (MozillaEmbedEventClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ parent_class = (GObjectClass *) g_type_class_peek_parent (klass);
+
+ object_class->finalize = mozilla_embed_event_finalize;
+
+ g_type_class_add_private (object_class, sizeof (MozillaEmbedEventPrivate));
+}
diff --git a/embed/mozilla/mozilla-embed-event.h b/embed/mozilla/mozilla-embed-event.h
new file mode 100644
index 000000000..b3be2a557
--- /dev/null
+++ b/embed/mozilla/mozilla-embed-event.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2000-2003 Marco Pesenti Gritti
+ * Copyright (C) 2004 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+
+#ifndef MOZILLA_EMBED_EVENT_H
+#define MOZILLA_EMBED_EVENT_H
+
+#include "ephy-embed-event.h"
+
+#include <glib-object.h>
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define MOZILLA_TYPE_EMBED_EVENT (mozilla_embed_event_get_type ())
+#define MOZILLA_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEvent))
+#define MOZILLA_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEventClass))
+#define MOZILLA_IS_EMBED_EVENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MOZILLA_TYPE_EMBED_EVENT))
+#define MOZILLA_IS_EMBED_EVENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MOZILLA_TYPE_EMBED_EVENT))
+#define MOZILLA_EMBED_EVENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MOZILLA_TYPE_EMBED_EVENT, MozillaEmbedEventClass))
+
+typedef struct MozillaEmbedEventClass MozillaEmbedEventClass;
+typedef struct MozillaEmbedEvent MozillaEmbedEvent;
+typedef struct MozillaEmbedEventPrivate MozillaEmbedEventPrivate;
+
+struct MozillaEmbedEventClass
+{
+ GObjectClass parent_class;
+};
+
+struct MozillaEmbedEvent
+{
+ GObject parent;
+
+ /*< private >*/
+ MozillaEmbedEventPrivate *priv;
+
+ /*< private >*/ /* public to the embed implementation */
+ EphyEmbedEventType type;
+ guint context;
+ guint modifier;
+ guint x;
+ guint y;
+ guint keycode;
+};
+
+GType mozilla_embed_event_get_type (void);
+
+MozillaEmbedEvent *mozilla_embed_event_new (gpointer dom_event);
+
+void mozilla_embed_event_set_property (MozillaEmbedEvent *event,
+ const char *name,
+ GValue *value);
+
+G_END_DECLS
+
+#endif
diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp
index 15b88938b..65d28a5d8 100644
--- a/embed/mozilla/mozilla-embed.cpp
+++ b/embed/mozilla/mozilla-embed.cpp
@@ -19,6 +19,7 @@
*/
#include "mozilla-embed.h"
+#include "mozilla-embed-event.h"
#include "ephy-embed-shell.h"
#include "ephy-command-manager.h"
#include "ephy-string.h"
@@ -29,7 +30,6 @@
#include "EventContext.h"
#include <gtkmozembed.h>
-#include <gtkmozembed_internal.h>
#include <nsIWindowWatcher.h>
#include <nsIURI.h>
#include <nsIURL.h>
@@ -864,8 +864,8 @@ mozilla_embed_dom_key_down_cb (GtkMozEmbed *embed, gpointer dom_event,
return FALSE;
}
- EphyEmbedEvent *info;
- info = ephy_embed_event_new ();
+ MozillaEmbedEvent *info;
+ info = mozilla_embed_event_new (dom_event);
gboolean ret = FALSE;
@@ -913,7 +913,7 @@ static gint
mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event,
MozillaEmbed *membed)
{
- EphyEmbedEvent *info;
+ MozillaEmbedEvent *info;
EventContext event_context;
gint return_value = FALSE;
nsresult result;
@@ -925,10 +925,12 @@ mozilla_embed_dom_mouse_click_cb (GtkMozEmbed *embed, gpointer dom_event,
return FALSE;
}
- info = ephy_embed_event_new ();
+ info = mozilla_embed_event_new (dom_event);
event_context.Init (mpriv->browser);
- result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info);
+ result = event_context.GetMouseEventInfo
+ (static_cast<nsIDOMMouseEvent*>(dom_event),
+ MOZILLA_EMBED_EVENT (info));
if (NS_SUCCEEDED(result))
{
@@ -956,7 +958,7 @@ static gint
mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
MozillaEmbed *membed)
{
- EphyEmbedEvent *info;
+ MozillaEmbedEvent *info;
EventContext event_context;
gint return_value = FALSE;
nsresult result;
@@ -969,13 +971,15 @@ mozilla_embed_dom_mouse_down_cb (GtkMozEmbed *embed, gpointer dom_event,
return FALSE;
}
- info = ephy_embed_event_new ();
+ info = mozilla_embed_event_new (dom_event);
event_context.Init (mpriv->browser);
- result = event_context.GetMouseEventInfo (static_cast<nsIDOMMouseEvent*>(dom_event), info);
+ result = event_context.GetMouseEventInfo
+ (static_cast<nsIDOMMouseEvent*>(dom_event),
+ MOZILLA_EMBED_EVENT (info));
if (NS_FAILED (result)) return FALSE;
- type = ephy_embed_event_get_event_type (info);
+ type = ephy_embed_event_get_event_type ((EphyEmbedEvent *) info);
nsCOMPtr<nsIDOMDocument> domDoc;
result = event_context.GetTargetDocument (getter_AddRefs(domDoc));