GNUmakefile.am

313313 WebKit/gtk/webkit/webkitwebframe.h \
314314 WebKit/gtk/webkit/webkitwebhistoryitem.h \
315315 WebKit/gtk/webkit/webkitwebsettings.h \
 316 WebKit/gtk/webkit/webkitevent.h \
316317 WebKit/gtk/webkit/webkitwebview.h
317318
318319webkitgtk_built_sources += \

344345 WebKit/gtk/webkit/webkitwebframe.cpp \
345346 WebKit/gtk/webkit/webkitwebhistoryitem.cpp \
346347 WebKit/gtk/webkit/webkitwebsettings.cpp \
347  WebKit/gtk/webkit/webkitwebview.cpp
 348 WebKit/gtk/webkit/webkitwebview.cpp \
 349 WebKit/gtk/webkit/webkitevent.cpp
348350
349351webkitgtk_cppflags += \
350352 -DBUILDING_WEBKIT \
35758

WebKit/gtk/webkit/webkitwebframe.cpp

2626#include "webkitwebframe.h"
2727#include "webkitwebview.h"
2828#include "webkitmarshal.h"
 29#include "webkitevent.h"
2930#include "webkitprivate.h"
3031
3132#include "CString.h"

4041#include "RenderView.h"
4142#include "JSDOMBinding.h"
4243#include "ScriptController.h"
 44#include "WebKit/gtk/webkit/EventListenerHack.h"
4345
 46
4447#include <JavaScriptCore/APICast.h>
4548
4649using namespace WebKit;

5558 LOAD_DONE,
5659 TITLE_CHANGED,
5760 HOVERING_OVER_LINK,
 61 BROWSER_EVENT,
5862 LAST_SIGNAL
5963};
6064

160164 G_TYPE_NONE, 2,
161165 G_TYPE_STRING, G_TYPE_STRING);
162166
 167 webkit_web_frame_signals[BROWSER_EVENT] = g_signal_new("browser-event",
 168 G_TYPE_FROM_CLASS(frameClass),
 169 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
 170 0,
 171 NULL,
 172 NULL,
 173 webkit_marshal_VOID__OBJECT_STRING_BOOLEAN,
 174 G_TYPE_NONE, 3,
 175 WEBKIT_TYPE_EVENT, G_TYPE_STRING, G_TYPE_BOOLEAN);
 176
163177 /*
164178 * implementations of virtual methods
165179 */

292306}
293307
294308/**
 309 * webkit_web_frame_add_event_listener:
 310 * @frame: a #WebKitWebFrame
 311 *
 312 * adds an event listener to the frame's document
 313 *
 314 * Return value: the name of @frame
 315 */
 316gboolean webkit_web_frame_add_event_listener(WebKitWebFrame* frame)
 317{
 318 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), FALSE);
 319
 320 //WebKitWebFramePrivate* priv = frame->priv;
 321
 322 Frame* coreFrame = core(frame);
 323 ASSERT(coreFrame);
 324
 325 return add_window_event_listener(frame, coreFrame, "click");
 326}
 327
 328/**
295329 * webkit_web_frame_get_name:
296330 * @frame: a #WebKitWebFrame
297331 *
35758

WebKit/gtk/webkit/webkitwebframe.h

9393WEBKIT_API JSGlobalContextRef
9494webkit_web_frame_get_global_context (WebKitWebFrame *frame);
9595
 96WEBKIT_API gboolean
 97webkit_web_frame_add_event_listener(WebKitWebFrame* frame);
 98
9699G_END_DECLS
97100
98101#endif
35758

WebKit/gtk/webkit/EventListenerHack.h

 1#ifndef JS_DOM_EVENT_LISTENER_HACK_H
 2#define JS_DOM_EVENT_LISTENER_HACK_H
 3
 4#include <glib.h>
 5#include <webkit/webkitdefines.h>
 6
 7
 8#include <JavaScriptCore/JSObjectRef.h>
 9#include <JavaScriptCore/JSValueRef.h>
 10#include <JavaScriptCore/WebKitAvailability.h>
 11#include "WebCore/page/Frame.h"
 12
 13class WebCore::Frame;
 14
 15gboolean
 16add_window_event_listener(WebKitWebFrame* wf, WebCore::Frame *frame,
 17 const char *name);
 18
 19#endif /*JS_DOM_EVENT_LISTENER_HACK_H */
0

WebKit/gtk/webkit/webkitevent.cpp

 1/*
 2 * Copyright (C) 2007 Holger Hans Peter Freyther
 3 * Copyright (C) 2008 Luke Kenneth Casson Leighton
 4 *
 5 * This library is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU Library General Public
 7 * License as published by the Free Software Foundation; either
 8 * version 2 of the License, or (at your option) any later version.
 9 *
 10 * This library is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 * Library General Public License for more details.
 14 *
 15 * You should have received a copy of the GNU Library General Public License
 16 * along with this library; see the file COPYING.LIB. If not, write to
 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 * Boston, MA 02110-1301, USA.
 19 */
 20
 21#include "config.h"
 22
 23#include "webkitevent.h"
 24#include "WebCore/dom/Event.h"
 25#include "WebCore/platform/text/CString.h"
 26#include "WebCore/platform/text/StringImpl.h"
 27
 28
 29#include "config.h"
 30#include "HTMLDocument.h"
 31
 32
 33#include "DocumentLoader.h"
 34#include "Element.h"
 35#include "EventListener.h"
 36#include "EventNames.h"
 37#include "FrameLoader.h"
 38#include "FrameView.h"
 39#include "HTMLNames.h"
 40#include "Settings.h"
 41#include "JavaScriptCore/API/JSValueRef.h"
 42#include "JavaScriptCore/kjs/JSValue.h"
 43#include "EventListenerHack.h"
 44#include "DerivedSources/JSHTMLDocument.h"
 45#include "JavaScriptCore/API/APICast.h"
 46#include "WebCore/html/HTMLDocument.h"
 47#include "WebCore/platform/text/CString.h"
 48#include "WebCore/platform/text/StringImpl.h"
 49
 50#include <glib-object.h>
 51
 52
 53using namespace WebCore;
 54
 55extern "C" {
 56
 57G_DEFINE_TYPE(WebKitEvent, webkit_event, G_TYPE_OBJECT);
 58
 59struct _WebKitEventPrivate {
 60 Event* event;
 61};
 62
 63#define WEBKIT_EVENT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_EVENT, WebKitEventPrivate))
 64
 65static void webkit_event_finalize(GObject* object)
 66{
 67 //WebKitEvent* request = WEBKIT_EVENT(object);
 68 //WebKitEventPrivate* priv = request->priv;
 69
 70 //g_free(priv->uri);
 71
 72 G_OBJECT_CLASS(webkit_event_parent_class)->finalize(object);
 73}
 74
 75static void webkit_event_class_init(WebKitEventClass* requestClass)
 76{
 77 G_OBJECT_CLASS(requestClass)->finalize = webkit_event_finalize;
 78
 79 g_type_class_add_private(requestClass, sizeof(WebKitEventPrivate));
 80}
 81
 82static void webkit_event_init(WebKitEvent* request)
 83{
 84 WebKitEventPrivate* priv = WEBKIT_EVENT_GET_PRIVATE(request);
 85 request->priv = priv;
 86}
 87
 88WebKitEvent* webkit_event_new(void)
 89{
 90 WebKitEvent* request = WEBKIT_EVENT(g_object_new(WEBKIT_TYPE_EVENT, NULL));
 91 //priv->event = event;
 92
 93 return request;
 94}
 95
 96/*
 97void webkit_event_set_uri(WebKitEvent* request, const gchar* uri)
 98{
 99 g_return_if_fail(WEBKIT_IS_EVENT(request));
 100 g_return_if_fail(uri);
 101
 102 WebKitEventPrivate* priv = request->priv;
 103
 104 g_free(priv->uri);
 105 priv->uri = g_strdup(uri);
 106}
 107*/
 108G_CONST_RETURN gchar* webkit_event_get_event_type(WebKitEvent* request)
 109{
 110 g_return_val_if_fail(WEBKIT_IS_EVENT(request), NULL);
 111
 112 WebKitEventPrivate* priv = request->priv;
 113 return g_strdup(priv->event->type().string().utf8().data());
 114}
 115
 116}
 117
 118class HackEventListener : public EventListener {
 119public:
 120 static PassRefPtr<HackEventListener> create(WebKitWebFrame* wf) { return adoptRef(new HackEventListener(wf)); }
 121 virtual void handleEvent(Event*, bool isWindowEvent);
 122
 123 private:
 124 HackEventListener(WebKitWebFrame* wf) : m_wf(wf) { }
 125 WebKitWebFrame* m_wf;
 126};
 127
 128void HackEventListener::handleEvent(Event* event, bool isWindowEvent)
 129{
 130 gboolean retval;
 131 printf("hack handleEvent %s\n", event->type().string().utf8().data());
 132 WebKitEvent *wev = webkit_event_new();
 133 WebKitEventPrivate* priv = wev->priv;
 134 priv->event = event;
 135
 136 g_signal_emit_by_name(m_wf, "browser-event",
 137 wev, event->type().string().utf8().data(), isWindowEvent, &retval);
 138 /* TODO: stop event propagating if True returned */
 139}
 140
 141gboolean add_window_event_listener(WebKitWebFrame *wf, Frame *frame,
 142 const char *name)
 143{
 144 Document* doc = frame->document();
 145
 146 RefPtr<EventListener> listener = HackEventListener::create(wf);
 147 doc->addWindowEventListener(name, listener, true);
 148
 149 return TRUE;
 150
 151}
 152
0

WebKit/gtk/webkit/webkitdefines.h

4040
4141G_BEGIN_DECLS
4242
 43typedef struct _WebKitEvent WebKitEvent;
 44typedef struct _WebKitEventClass WebKitEventClass;
 45
4346typedef struct _WebKitNetworkRequest WebKitNetworkRequest;
4447typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass;
4548
35758

WebKit/gtk/webkit/webkitevent.h

 1/*
 2 * Copyright (C) 2007 Holger Hans Peter Freyther
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#ifndef WEBKIT_EVENT_H
 21#define WEBKIT_EVENT_H
 22
 23#include <glib-object.h>
 24
 25#include <webkit/webkitdefines.h>
 26
 27G_BEGIN_DECLS
 28
 29#define WEBKIT_TYPE_EVENT (webkit_event_get_type())
 30#define WEBKIT_EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_EVENT, WebKitEvent))
 31#define WEBKIT_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_EVENT, WebKitEventClass))
 32#define WEBKIT_IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_EVENT))
 33#define WEBKIT_IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_EVENT))
 34#define WEBKIT_EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_EVENT, WebKitEventClass))
 35
 36typedef struct _WebKitEventPrivate WebKitEventPrivate;
 37
 38struct _WebKitEvent {
 39 GObject parent_instance;
 40
 41 WebKitEventPrivate *priv;
 42};
 43
 44struct _WebKitEventClass {
 45 GObjectClass parent_class;
 46};
 47
 48WEBKIT_API GType
 49webkit_event_get_type (void);
 50
 51WEBKIT_API WebKitEvent *
 52webkit_event_new (void);
 53
 54/*WEBKIT_API void
 55webkit_event_set_uri (WebKitEvent *request,
 56 const gchar* uri);*/
 57
 58WEBKIT_API G_CONST_RETURN gchar *
 59webkit_event_get_event_type (WebKitEvent *request);
 60
 61G_END_DECLS
 62
 63#endif
0