[GTK] Using a native window for the WebView breaks GtkOverlay
[WebKit-https.git] / Source / WebKit / gtk / webkit / webkitwebview.cpp
1 /*
2  *  Copyright (C) 2007, 2008 Holger Hans Peter Freyther
3  *  Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com>
4  *  Copyright (C) 2007 Xan Lopez <xan@gnome.org>
5  *  Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
6  *  Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
7  *  Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
8  *  Copyright (C) 2008 Nuanti Ltd.
9  *  Copyright (C) 2008, 2009, 2010 Collabora Ltd.
10  *  Copyright (C) 2009, 2010, 2012 Igalia S.L.
11  *  Copyright (C) 2009 Movial Creative Technologies Inc.
12  *  Copyright (C) 2009 Bobby Powers
13  *  Copyright (C) 2010 Joone Hur <joone@kldp.org>
14  *  Copyright (C) 2012 Igalia S.L.
15  *
16  *  This library is free software; you can redistribute it and/or
17  *  modify it under the terms of the GNU Lesser General Public
18  *  License as published by the Free Software Foundation; either
19  *  version 2 of the License, or (at your option) any later version.
20  *
21  *  This library is distributed in the hope that it will be useful,
22  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  *  Lesser General Public License for more details.
25  *
26  *  You should have received a copy of the GNU Lesser General Public
27  *  License along with this library; if not, write to the Free Software
28  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
29  */
30
31 #include "config.h"
32 #include "webkitwebview.h"
33
34 #include "AXObjectCache.h"
35 #include "AbstractDatabase.h"
36 #include "BackForwardListImpl.h"
37 #include "CairoUtilities.h"
38 #include "Chrome.h"
39 #include "ChromeClientGtk.h"
40 #include "ClipboardUtilitiesGtk.h"
41 #include "ContextMenu.h"
42 #include "ContextMenuClientGtk.h"
43 #include "ContextMenuController.h"
44 #include "Cursor.h"
45 #include "Document.h"
46 #include "DocumentLoader.h"
47 #include "DragActions.h"
48 #include "DragClientGtk.h"
49 #include "DragController.h"
50 #include "DragData.h"
51 #include "DragSession.h"
52 #include "DumpRenderTreeSupportGtk.h"
53 #include "Editor.h"
54 #include "EditorClientGtk.h"
55 #include "EventHandler.h"
56 #include "FloatQuad.h"
57 #include "FocusController.h"
58 #include "FrameLoader.h"
59 #include "FrameLoaderClient.h"
60 #include "FrameLoaderTypes.h"
61 #include "FrameView.h"
62 #include "GOwnPtrGtk.h"
63 #include "GeolocationClientGtk.h"
64 #include "GeolocationController.h"
65 #include "GraphicsContext.h"
66 #include "GtkUtilities.h"
67 #include "GtkVersioning.h"
68 #include "HTMLNames.h"
69 #include "HitTestRequest.h"
70 #include "HitTestResult.h"
71 #include "InspectorClientGtk.h"
72 #include "MemoryCache.h"
73 #include "MouseEventWithHitTestResults.h"
74 #include "NotImplemented.h"
75 #include "PageCache.h"
76 #include "Pasteboard.h"
77 #include "PasteboardHelper.h"
78 #include "PlatformKeyboardEvent.h"
79 #include "PlatformWheelEvent.h"
80 #include "ProgressTracker.h"
81 #include "RenderView.h"
82 #include "ResourceHandle.h"
83 #include "ScriptValue.h"
84 #include "Settings.h"
85 #include "webkit/WebKitDOMDocumentPrivate.h"
86 #include "webkitdownload.h"
87 #include "webkitdownloadprivate.h"
88 #include "webkitenumtypes.h"
89 #include "webkitfavicondatabase.h"
90 #include "webkitgeolocationpolicydecision.h"
91 #include "webkitglobalsprivate.h"
92 #include "webkithittestresultprivate.h"
93 #include "webkiticondatabase.h"
94 #include "webkitmarshal.h"
95 #include "webkitnetworkrequest.h"
96 #include "webkitnetworkresponse.h"
97 #include "webkitviewportattributes.h"
98 #include "webkitviewportattributesprivate.h"
99 #include "webkitwebbackforwardlist.h"
100 #include "webkitwebframeprivate.h"
101 #include "webkitwebhistoryitem.h"
102 #include "webkitwebhistoryitemprivate.h"
103 #include "webkitwebinspector.h"
104 #include "webkitwebinspectorprivate.h"
105 #include "webkitwebpolicydecision.h"
106 #include "webkitwebresource.h"
107 #include "webkitwebsettingsprivate.h"
108 #include "webkitwebplugindatabaseprivate.h"
109 #include "webkitwebwindowfeatures.h"
110 #include "webkitwebviewprivate.h"
111 #include <gdk/gdkkeysyms.h>
112 #include <glib/gi18n-lib.h>
113 #include <wtf/gobject/GOwnPtr.h>
114 #include <wtf/text/CString.h>
115
116 #if ENABLE(DEVICE_ORIENTATION)
117 #include "DeviceMotionClientGtk.h"
118 #include "DeviceOrientationClientGtk.h"
119 #endif
120
121 /**
122  * SECTION:webkitwebview
123  * @short_description: The central class of the WebKitGTK+ API
124  * @see_also: #WebKitWebSettings, #WebKitWebFrame
125  *
126  * #WebKitWebView is the central class of the WebKitGTK+ API. It is a
127  * #GtkWidget implementing the scrolling interface which means you can
128  * embed in a #GtkScrolledWindow. It is responsible for managing the
129  * drawing of the content, forwarding of events. You can load any URI
130  * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings
131  * you can control various aspects of the rendering and loading of the content.
132  * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A
133  * #WebKitWebFrame can have n children.
134  *
135  * <programlisting>
136  * /<!-- -->* Create the widgets *<!-- -->/
137  * GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
138  * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
139  * GtkWidget *web_view = webkit_web_view_new ();
140  *
141  * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/
142  * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
143  * gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
144  *
145  * /<!-- -->* Open a webpage *<!-- -->/
146  * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
147  *
148  * /<!-- -->* Show the result *<!-- -->/
149  * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
150  * gtk_widget_show_all (main_window);
151  * </programlisting>
152  */
153
154 using namespace WebKit;
155 using namespace WebCore;
156
157 enum {
158     /* normal signals */
159     NAVIGATION_REQUESTED,
160     NEW_WINDOW_POLICY_DECISION_REQUESTED,
161     NAVIGATION_POLICY_DECISION_REQUESTED,
162     MIME_TYPE_POLICY_DECISION_REQUESTED,
163     CREATE_WEB_VIEW,
164     WEB_VIEW_READY,
165     WINDOW_OBJECT_CLEARED,
166     LOAD_STARTED,
167     LOAD_COMMITTED,
168     LOAD_PROGRESS_CHANGED,
169     LOAD_ERROR,
170     LOAD_FINISHED,
171     TITLE_CHANGED,
172     HOVERING_OVER_LINK,
173     POPULATE_POPUP,
174     STATUS_BAR_TEXT_CHANGED,
175     ICON_LOADED,
176     SELECTION_CHANGED,
177     CONSOLE_MESSAGE,
178     SCRIPT_ALERT,
179     SCRIPT_CONFIRM,
180     SCRIPT_PROMPT,
181     SELECT_ALL,
182     COPY_CLIPBOARD,
183     PASTE_CLIPBOARD,
184     CUT_CLIPBOARD,
185     DOWNLOAD_REQUESTED,
186     MOVE_CURSOR,
187     PRINT_REQUESTED,
188     PLUGIN_WIDGET,
189     CLOSE_WEB_VIEW,
190     UNDO,
191     REDO,
192     DATABASE_QUOTA_EXCEEDED,
193     RESOURCE_REQUEST_STARTING,
194     DOCUMENT_LOAD_FINISHED,
195     GEOLOCATION_POLICY_DECISION_REQUESTED,
196     GEOLOCATION_POLICY_DECISION_CANCELLED,
197     ONLOAD_EVENT,
198     FRAME_CREATED,
199     SHOULD_BEGIN_EDITING,
200     SHOULD_END_EDITING,
201     SHOULD_INSERT_NODE,
202     SHOULD_INSERT_TEXT,
203     SHOULD_DELETE_RANGE,
204     SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT,
205     SHOULD_CHANGE_SELECTED_RANGE,
206     SHOULD_APPLY_STYLE,
207     EDITING_BEGAN,
208     USER_CHANGED_CONTENTS,
209     EDITING_ENDED,
210     VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED,
211     VIEWPORT_ATTRIBUTES_CHANGED,
212     RESOURCE_RESPONSE_RECEIVED,
213     RESOURCE_LOAD_FINISHED,
214     RESOURCE_CONTENT_LENGTH_RECEIVED,
215     RESOURCE_LOAD_FAILED,
216     ENTERING_FULLSCREEN,
217     LEAVING_FULLSCREEN,
218     CONTEXT_MENU,
219     RUN_FILE_CHOOSER,
220
221     LAST_SIGNAL
222 };
223
224 enum {
225     PROP_0,
226
227     PROP_TITLE,
228     PROP_URI,
229     PROP_COPY_TARGET_LIST,
230     PROP_PASTE_TARGET_LIST,
231     PROP_EDITABLE,
232     PROP_SETTINGS,
233     PROP_WEB_INSPECTOR,
234     PROP_VIEWPORT_ATTRIBUTES,
235     PROP_WINDOW_FEATURES,
236     PROP_TRANSPARENT,
237     PROP_ZOOM_LEVEL,
238     PROP_FULL_CONTENT_ZOOM,
239     PROP_LOAD_STATUS,
240     PROP_PROGRESS,
241     PROP_ENCODING,
242     PROP_CUSTOM_ENCODING,
243     PROP_ICON_URI,
244     PROP_IM_CONTEXT,
245 #ifdef GTK_API_VERSION_2
246     PROP_VIEW_MODE,
247 #else
248     PROP_VIEW_MODE,
249     PROP_HADJUSTMENT,
250     PROP_VADJUSTMENT,
251     PROP_HSCROLL_POLICY,
252     PROP_VSCROLL_POLICY,
253 #endif
254
255     // Undocumented. Leave these properties at the end of the list
256     // so that we can remove them without breaking ABI compatibility.
257     PROP_SELF_SCROLLING
258 };
259
260 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
261
262 #ifdef GTK_API_VERSION_2
263 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
264 #else
265 G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
266                         G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0))
267 #endif
268
269 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
270 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
271
272 #if ENABLE(CONTEXT_MENUS)
273 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
274 {
275     WebKitWebView* view = WEBKIT_WEB_VIEW(userData);
276     WebKitWebViewPrivate* priv = view->priv;
277     GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view));
278     GtkRequisition menuSize;
279
280 #ifdef GTK_API_VERSION_2
281     gtk_widget_size_request(GTK_WIDGET(menu), &menuSize);
282 #else
283     gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, NULL);
284 #endif
285
286     *x = priv->lastPopupXPosition;
287     if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
288       *x -= menuSize.width;
289
290     *y = priv->lastPopupYPosition;
291     if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
292       *y -= menuSize.height;
293
294     *pushIn = FALSE;
295 }
296 #endif
297
298 static Node* getFocusedNode(Frame* frame)
299 {
300     if (Document* doc = frame->document())
301         return doc->focusedNode();
302     return 0;
303 }
304
305 #if ENABLE(CONTEXT_MENUS)
306 static void contextMenuItemActivated(GtkMenuItem* item, ContextMenuController* controller)
307 {
308     ContextMenuItem contextItem(item);
309     controller->contextMenuItemSelected(&contextItem);
310 }
311
312 static void contextMenuConnectActivate(GtkMenuItem* item, ContextMenuController* controller)
313 {
314     if (GTK_IS_SEPARATOR_MENU_ITEM(item))
315         return;
316
317     if (GtkWidget* menu = gtk_menu_item_get_submenu(item)) {
318         gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller);
319         return;
320     }
321
322     g_signal_connect(item, "activate", G_CALLBACK(contextMenuItemActivated), controller);
323 }
324
325 static MouseEventWithHitTestResults prepareMouseEventForFrame(Frame* frame, const PlatformMouseEvent& event)
326 {
327     HitTestRequest request(HitTestRequest::Active);
328     IntPoint point = frame->view()->windowToContents(event.position());
329     return frame->document()->prepareMouseEvent(request, point, event);
330 }
331
332 // Check enable-default-context-menu setting for compatibility.
333 static bool defaultContextMenuEnabled(WebKitWebView* webView)
334 {
335     gboolean enableDefaultContextMenu;
336     g_object_get(webkit_web_view_get_settings(webView), "enable-default-context-menu", &enableDefaultContextMenu, NULL);
337     return enableDefaultContextMenu;
338 }
339
340 static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event, bool triggeredWithKeyboard)
341 {
342     Page* page = core(webView);
343     page->contextMenuController()->clearContextMenu();
344     Frame* focusedFrame;
345     Frame* mainFrame = page->mainFrame();
346     gboolean mousePressEventResult = FALSE;
347     GRefPtr<WebKitHitTestResult> hitTestResult;
348
349     if (!mainFrame->view())
350         return FALSE;
351
352     mainFrame->view()->setCursor(pointerCursor());
353     if (page->frameCount()) {
354         MouseEventWithHitTestResults mev = prepareMouseEventForFrame(mainFrame, event);
355         Frame* targetFrame = EventHandler::subframeForHitTestResult(mev);
356         if (!targetFrame)
357             targetFrame = mainFrame;
358
359         focusedFrame = page->focusController()->focusedOrMainFrame();
360         if (targetFrame != focusedFrame) {
361             page->focusController()->setFocusedFrame(targetFrame);
362             focusedFrame = targetFrame;
363         }
364         if (focusedFrame == mainFrame)
365             hitTestResult = adoptGRef(kit(mev.hitTestResult()));
366     } else
367         focusedFrame = mainFrame;
368
369     if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event))
370         mousePressEventResult = TRUE;
371
372     bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event);
373     if (!handledEvent)
374         return FALSE;
375
376     // If coreMenu is NULL, this means WebCore decided to not create
377     // the default context menu; this may happen when the page is
378     // handling the right-click for reasons other than the context menu.
379     ContextMenuController* controller = page->contextMenuController();
380     ContextMenu* coreMenu = controller->contextMenu();
381     if (!coreMenu)
382         return mousePressEventResult;
383
384     GtkMenu* defaultMenu = coreMenu->platformDescription();
385     ASSERT(defaultMenu);
386
387     // We connect the "activate" signal here rather than in ContextMenuGtk to avoid
388     // a layering violation. ContextMenuGtk should not know about the ContextMenuController.
389     gtk_container_foreach(GTK_CONTAINER(defaultMenu), reinterpret_cast<GtkCallback>(contextMenuConnectActivate), controller);
390
391     if (!hitTestResult) {
392         MouseEventWithHitTestResults mev = prepareMouseEventForFrame(focusedFrame, event);
393         hitTestResult = adoptGRef(kit(mev.hitTestResult()));
394     }
395
396     gboolean handled;
397     g_signal_emit(webView, webkit_web_view_signals[CONTEXT_MENU], 0, defaultMenu, hitTestResult.get(), triggeredWithKeyboard, &handled);
398     if (handled)
399         return TRUE;
400
401     // Return now if default context menu is disabled by enable-default-context-menu setting.
402     // Check enable-default-context-menu setting for compatibility.
403     if (!defaultContextMenuEnabled(webView))
404         return FALSE;
405
406     // Emit populate-popup signal for compatibility.
407     g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, defaultMenu);
408
409     // If the context menu is now empty, don't show it.
410     GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(defaultMenu)));
411     if (!items)
412         return FALSE;
413
414     WebKitWebViewPrivate* priv = webView->priv;
415     priv->currentMenu = defaultMenu;
416     priv->lastPopupXPosition = event.globalPosition().x();
417     priv->lastPopupYPosition = event.globalPosition().y();
418
419     gtk_menu_popup(defaultMenu, 0, 0, &PopupMenuPositionFunc, webView, event.button() + 1, gtk_get_current_event_time());
420     return TRUE;
421 }
422
423 static const int gContextMenuMargin = 1;
424 static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame)
425 {
426     FrameSelection* selection = frame->selection();
427     if (!selection->selection().isNonOrphanedCaretOrRange()
428          || (selection->selection().isCaret() && !selection->selection().isContentEditable())) {
429         if (Node* focusedNode = getFocusedNode(frame))
430             return focusedNode->getPixelSnappedRect().location();
431
432         // There was no selection and no focused node, so just put the context
433         // menu into the corner of the view, offset slightly.
434         return IntPoint(gContextMenuMargin, gContextMenuMargin);
435     }
436
437     // selection->selection().firstRange can return 0 here, but if that was the case
438     // selection->selection().isNonOrphanedCaretOrRange() would have returned false
439     // above, so we do not have to check it.
440     IntRect firstRect = frame->editor()->firstRectForRange(selection->selection().firstRange().get());
441     return IntPoint(firstRect.x(), firstRect.maxY());
442 }
443
444 static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
445 {
446     Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController()->focusedOrMainFrame();
447     IntPoint location = getLocationForKeyboardGeneratedContextMenu(frame);
448
449     FrameView* view = frame->view();
450     if (!view)
451         return FALSE;
452
453     // Never let the context menu touch the very edge of the view.
454     location = view->contentsToWindow(location);
455     location.expandedTo(IntPoint(gContextMenuMargin, gContextMenuMargin));
456     location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin));
457
458     IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location));
459     PlatformMouseEvent event(location, globalPoint, RightButton, PlatformEvent::MousePressed, 0, false, false, false, false, gtk_get_current_event_time());
460     return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event, true);
461 }
462 #endif // ENABLE(CONTEXT_MENUS)
463
464 static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
465 {
466     // This may be called after the page has been destroyed, in which case we do nothing.
467     Page* page = core(webView);
468     if (page)
469         static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setHorizontalAdjustment(adjustment);
470 }
471
472 static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
473 {
474     // This may be called after the page has been destroyed, in which case we do nothing.
475     Page* page = core(webView);
476     if (page)
477         static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setVerticalAdjustment(adjustment);
478 }
479
480 #ifndef GTK_API_VERSION_2
481 static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
482 {
483     Page* page = core(webView);
484     if (page)
485         return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->horizontalAdjustment();
486     return 0;
487 }
488
489 static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
490 {
491     Page* page = core(webView);
492     if (page)
493         return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->verticalAdjustment();
494     return 0;
495 }
496
497 static void setHorizontalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
498 {
499     webView->priv->horizontalScrollingPolicy = policy;
500     gtk_widget_queue_resize(GTK_WIDGET(webView));
501 }
502
503 static void setVerticalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
504 {
505     webView->priv->verticalScrollingPolicy = policy;
506     gtk_widget_queue_resize(GTK_WIDGET(webView));
507 }
508
509 static GtkScrollablePolicy getHorizontalScrollPolicy(WebKitWebView* webView)
510 {
511     return webView->priv->horizontalScrollingPolicy;
512 }
513
514 static GtkScrollablePolicy getVerticalScrollPolicy(WebKitWebView* webView)
515 {
516     return webView->priv->verticalScrollingPolicy;
517 }
518
519 #endif
520
521 static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
522 {
523     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
524
525     switch(prop_id) {
526     case PROP_TITLE:
527         g_value_set_string(value, webkit_web_view_get_title(webView));
528         break;
529     case PROP_URI:
530         g_value_set_string(value, webkit_web_view_get_uri(webView));
531         break;
532     case PROP_COPY_TARGET_LIST:
533         g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView));
534         break;
535     case PROP_PASTE_TARGET_LIST:
536         g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
537         break;
538     case PROP_EDITABLE:
539         g_value_set_boolean(value, webkit_web_view_get_editable(webView));
540         break;
541     case PROP_SETTINGS:
542         g_value_set_object(value, webkit_web_view_get_settings(webView));
543         break;
544     case PROP_WEB_INSPECTOR:
545         g_value_set_object(value, webkit_web_view_get_inspector(webView));
546         break;
547     case PROP_VIEWPORT_ATTRIBUTES:
548         g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView));
549         break;
550     case PROP_WINDOW_FEATURES:
551         g_value_set_object(value, webkit_web_view_get_window_features(webView));
552         break;
553     case PROP_TRANSPARENT:
554         g_value_set_boolean(value, webkit_web_view_get_transparent(webView));
555         break;
556     case PROP_ZOOM_LEVEL:
557         g_value_set_float(value, webkit_web_view_get_zoom_level(webView));
558         break;
559     case PROP_FULL_CONTENT_ZOOM:
560         g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView));
561         break;
562     case PROP_ENCODING:
563         g_value_set_string(value, webkit_web_view_get_encoding(webView));
564         break;
565     case PROP_CUSTOM_ENCODING:
566         g_value_set_string(value, webkit_web_view_get_custom_encoding(webView));
567         break;
568     case PROP_LOAD_STATUS:
569         g_value_set_enum(value, webkit_web_view_get_load_status(webView));
570         break;
571     case PROP_PROGRESS:
572         g_value_set_double(value, webkit_web_view_get_progress(webView));
573         break;
574     case PROP_ICON_URI:
575         g_value_set_string(value, webkit_web_view_get_icon_uri(webView));
576         break;
577     case PROP_IM_CONTEXT:
578         g_value_set_object(value, webView->priv->imFilter.context());
579         break;
580     case PROP_VIEW_MODE:
581         g_value_set_enum(value, webkit_web_view_get_view_mode(webView));
582         break;
583 #ifndef GTK_API_VERSION_2
584     case PROP_HADJUSTMENT:
585         g_value_set_object(value, getHorizontalAdjustment(webView));
586         break;
587     case PROP_VADJUSTMENT:
588         g_value_set_object(value, getVerticalAdjustment(webView));
589         break;
590     case PROP_HSCROLL_POLICY:
591         g_value_set_enum(value, getHorizontalScrollPolicy(webView));
592         break;
593     case PROP_VSCROLL_POLICY:
594         g_value_set_enum(value, getVerticalScrollPolicy(webView));
595         break;
596 #endif
597     case PROP_SELF_SCROLLING:
598         g_value_set_boolean(value, webView->priv->selfScrolling);
599         break;
600     default:
601         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
602     }
603 }
604
605 static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec)
606 {
607     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
608
609     switch(prop_id) {
610     case PROP_EDITABLE:
611         webkit_web_view_set_editable(webView, g_value_get_boolean(value));
612         break;
613     case PROP_SETTINGS:
614         webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value)));
615         break;
616     case PROP_WINDOW_FEATURES:
617         webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value)));
618         break;
619     case PROP_TRANSPARENT:
620         webkit_web_view_set_transparent(webView, g_value_get_boolean(value));
621         break;
622     case PROP_ZOOM_LEVEL:
623         webkit_web_view_set_zoom_level(webView, g_value_get_float(value));
624         break;
625     case PROP_FULL_CONTENT_ZOOM:
626         webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value));
627         break;
628     case PROP_CUSTOM_ENCODING:
629         webkit_web_view_set_custom_encoding(webView, g_value_get_string(value));
630         break;
631     case PROP_VIEW_MODE:
632         webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value)));
633         break;
634 #ifndef GTK_API_VERSION_2
635     case PROP_HADJUSTMENT:
636         setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
637         break;
638     case PROP_VADJUSTMENT:
639         setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
640         break;
641     case PROP_HSCROLL_POLICY:
642         setHorizontalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
643         break;
644     case PROP_VSCROLL_POLICY:
645         setVerticalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
646         break;
647 #endif
648     case PROP_SELF_SCROLLING:
649         webView->priv->selfScrolling = g_value_get_boolean(value);
650         break;
651     default:
652         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
653     }
654 }
655
656 #ifdef GTK_API_VERSION_2
657 static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
658 {
659     int rectCount;
660     GOwnPtr<GdkRectangle> rects;
661     gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
662
663     RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window));
664     for (int i = 0; i < rectCount; i++) {
665         copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(),
666                                           cr.get(), IntSize(), IntRect(rects.get()[i]));
667     }
668
669     // Chaining up to the parent forces child widgets to be drawn.
670     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->expose_event(widget, event);
671     return FALSE;
672 }
673 #else
674 static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
675 {
676     GdkRectangle clipRect;
677     if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
678         return FALSE;
679
680     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
681 #if USE(TEXTURE_MAPPER)
682     if (priv->acceleratedCompositingContext->renderLayersToWindow(cr, clipRect)) {
683         GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr);
684         return FALSE;
685     }
686 #endif
687
688     cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
689     if (rectList->status || !rectList->num_rectangles) {
690         cairo_rectangle_list_destroy(rectList);
691         return FALSE;
692     }
693
694     Vector<IntRect> rects;
695     for (int i = 0; i < rectList->num_rectangles; i++) {
696         copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(),
697                                           enclosingIntRect(FloatRect(rectList->rectangles[i])));
698     }
699     cairo_rectangle_list_destroy(rectList);
700
701     // Chaining up to the parent forces child widgets to be drawn.
702     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr);
703     return FALSE;
704 }
705 #endif // GTK_API_VERSION_2
706
707 static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event)
708 {
709     if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event))
710         return TRUE;
711     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event);
712 }
713
714 static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event)
715 {
716     if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event))
717         return TRUE;
718     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event);
719 }
720
721 static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
722 {
723     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
724     WebKitWebViewPrivate* priv = webView->priv;
725
726     // FIXME: need to keep track of subframe focus for key events
727     gtk_widget_grab_focus(widget);
728
729     if (!priv->clickCounter.shouldProcessButtonEvent(event))
730         return TRUE;
731
732     PlatformMouseEvent platformEvent(event);
733     int count = priv->clickCounter.clickCountForGdkButtonEvent(widget, event);
734     platformEvent.setClickCount(count);
735
736 #if ENABLE(CONTEXT_MENUS)
737     if (event->button == 3)
738         return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event), false);
739 #endif
740
741     Frame* frame = core(webView)->mainFrame();
742     if (!frame->view())
743         return FALSE;
744
745     priv->imFilter.notifyMouseButtonPress();
746     gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent);
747
748 #if PLATFORM(X11)
749     /* Copy selection to the X11 selection clipboard */
750     if (event->button == 2) {
751         PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
752         bool wasUsingPrimary = helper->usePrimarySelectionClipboard();
753         helper->setUsePrimarySelectionClipboard(true);
754
755         Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
756         result = result || editor->canPaste() || editor->canDHTMLPaste();
757         editor->paste();
758
759         helper->setUsePrimarySelectionClipboard(wasUsingPrimary);
760     }
761 #endif
762
763     return result;
764 }
765
766 static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
767 {
768     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
769
770     Frame* mainFrame = core(webView)->mainFrame();
771     if (mainFrame->view())
772         mainFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
773
774     /* We always return FALSE here because WebKit can, for the same click, decide
775      * to not handle press-event but handle release-event, which can totally confuse
776      * some GTK+ containers when there are no other events in between. This way we
777      * guarantee that this case never happens, and that if press-event goes through
778      * release-event also goes through.
779      */
780
781     return FALSE;
782 }
783
784 static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event)
785 {
786     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
787
788     Frame* frame = core(webView)->mainFrame();
789     if (!frame->view())
790         return FALSE;
791
792     return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
793 }
794
795 static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event)
796 {
797     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
798
799     Frame* frame = core(webView)->mainFrame();
800     if (!frame->view())
801         return FALSE;
802
803     PlatformWheelEvent wheelEvent(event);
804     return frame->eventHandler()->handleWheelEvent(wheelEvent);
805 }
806
807 #ifdef GTK_API_VERSION_2
808 static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)
809 {
810     WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
811     Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
812     if (!coreFrame)
813         return;
814
815     FrameView* view = coreFrame->view();
816     if (!view)
817         return;
818
819     requisition->width = view->contentsWidth();
820     requisition->height = view->contentsHeight();
821 }
822 #else
823 static void webkit_web_view_get_preferred_width(GtkWidget* widget, gint* minimum, gint* natural)
824 {
825     WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
826     Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
827     if (!coreFrame)
828         return;
829
830     FrameView* view = coreFrame->view();
831     if (!view)
832         return;
833
834     *minimum = *natural = view->contentsWidth();
835 }
836
837 static void webkit_web_view_get_preferred_height(GtkWidget* widget, gint* minimum, gint* natural)
838 {
839     WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
840     Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
841     if (!coreFrame)
842         return;
843
844     FrameView* view = coreFrame->view();
845     if (!view)
846         return;
847
848     *minimum = *natural = view->contentsHeight();
849 }
850 #endif
851
852 static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
853 {
854     if (!gtk_widget_get_visible(child))
855         return;
856
857     GtkAllocation* allocation = static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(child), "delayed-allocation"));
858     if (!allocation)
859         return;
860
861     g_object_set_data(G_OBJECT(child), "delayed-allocation", 0);
862     gtk_widget_size_allocate(child, allocation);
863     *allocation = IntRect();
864 }
865
866 static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation)
867 {
868     Page* page = core(webView);
869     IntSize oldSize;
870     if (FrameView* frameView = page->mainFrame()->view()) {
871         oldSize = frameView->size();
872         frameView->resize(allocation->width, allocation->height);
873     }
874
875     gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0);
876
877     WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
878     chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
879     chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
880 }
881
882 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
883 {
884     GtkAllocation oldAllocation;
885     gtk_widget_get_allocation(widget, &oldAllocation);
886
887     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
888     if (allocation->width == oldAllocation.width && allocation->height == oldAllocation.height)
889         return;
890
891     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
892     if (!gtk_widget_get_mapped(widget)) {
893         webView->priv->needsResizeOnMap = true;
894         return;
895     }
896     resizeWebViewFromAllocation(webView, allocation);
897 }
898
899 static void webkitWebViewMap(GtkWidget* widget)
900 {
901     GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget);
902
903     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
904     if (!webView->priv->needsResizeOnMap)
905         return;
906
907     GtkAllocation allocation;
908     gtk_widget_get_allocation(widget, &allocation);
909     resizeWebViewFromAllocation(webView, &allocation);
910     webView->priv->needsResizeOnMap = false;
911 }
912
913 static void webkit_web_view_grab_focus(GtkWidget* widget)
914 {
915
916     if (gtk_widget_is_sensitive(widget)) {
917         WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
918         FocusController* focusController = core(webView)->focusController();
919
920         focusController->setActive(true);
921
922         if (focusController->focusedFrame())
923             focusController->setFocused(true);
924         else
925             focusController->setFocusedFrame(core(webView)->mainFrame());
926     }
927
928     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget);
929 }
930
931 static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event)
932 {
933     // TODO: Improve focus handling as suggested in
934     // http://bugs.webkit.org/show_bug.cgi?id=16910
935     GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
936     if (!widgetIsOnscreenToplevelWindow(toplevel) || !gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel)))
937         return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
938
939     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
940     FocusController* focusController = core(webView)->focusController();
941
942     focusController->setActive(true);
943     if (focusController->focusedFrame())
944         focusController->setFocused(true);
945     else
946         focusController->setFocusedFrame(core(webView)->mainFrame());
947
948     if (focusController->focusedFrame()->editor()->canEdit())
949         webView->priv->imFilter.notifyFocusedIn();
950     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
951 }
952
953 static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event)
954 {
955     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
956
957     // We may hit this code while destroying the widget, and we might
958     // no longer have a page, then.
959     if (Page* page = core(webView)) {
960         page->focusController()->setActive(false);
961         page->focusController()->setFocused(false);
962     }
963
964     webView->priv->imFilter.notifyFocusedOut();
965     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
966 }
967
968 static void webkit_web_view_realize(GtkWidget* widget)
969 {
970     gtk_widget_set_realized(widget, TRUE);
971
972     GtkAllocation allocation;
973 #if GTK_CHECK_VERSION(2, 18, 0)
974     gtk_widget_get_allocation(widget, &allocation);
975 #else
976     allocation = widget->allocation;
977 #endif
978
979     GdkWindowAttr attributes;
980     attributes.window_type = GDK_WINDOW_CHILD;
981     attributes.x = allocation.x;
982     attributes.y = allocation.y;
983     attributes.width = allocation.width;
984     attributes.height = allocation.height;
985     attributes.wclass = GDK_INPUT_OUTPUT;
986     attributes.visual = gtk_widget_get_visual(widget);
987 #ifdef GTK_API_VERSION_2
988     attributes.colormap = gtk_widget_get_colormap(widget);
989 #endif
990     attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
991                             | GDK_EXPOSURE_MASK
992                             | GDK_BUTTON_PRESS_MASK
993                             | GDK_BUTTON_RELEASE_MASK
994                             | GDK_SCROLL_MASK
995                             | GDK_POINTER_MOTION_MASK
996                             | GDK_KEY_PRESS_MASK
997                             | GDK_KEY_RELEASE_MASK
998                             | GDK_BUTTON_MOTION_MASK
999                             | GDK_BUTTON1_MOTION_MASK
1000                             | GDK_BUTTON2_MOTION_MASK
1001                             | GDK_BUTTON3_MOTION_MASK;
1002
1003     gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
1004 #ifdef GTK_API_VERSION_2
1005     attributes_mask |= GDK_WA_COLORMAP;
1006 #endif
1007     GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
1008
1009     gtk_widget_set_window(widget, window);
1010     gdk_window_set_user_data(window, widget);
1011
1012 #ifdef GTK_API_VERSION_2
1013 #if GTK_CHECK_VERSION(2, 20, 0)
1014     gtk_widget_style_attach(widget);
1015 #else
1016     widget->style = gtk_style_attach(gtk_widget_get_style(widget), window);
1017 #endif
1018     gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL);
1019 #else
1020     gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
1021 #endif
1022 }
1023
1024 #ifdef GTK_API_VERSION_2
1025 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* horizontalAdjustment, GtkAdjustment* verticalAdjustment)
1026 {
1027     setHorizontalAdjustment(webView, horizontalAdjustment);
1028     setVerticalAdjustment(webView, verticalAdjustment);
1029 }
1030 #endif
1031
1032 static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget)
1033 {
1034     WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1035     WebKitWebViewPrivate* priv = webView->priv;
1036
1037     priv->children.add(widget);
1038     gtk_widget_set_parent(widget, GTK_WIDGET(container));
1039 }
1040
1041 static void webkit_web_view_container_remove(GtkContainer* container, GtkWidget* widget)
1042 {
1043     WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1044     WebKitWebViewPrivate* priv = webView->priv;
1045
1046     if (priv->children.contains(widget)) {
1047         gtk_widget_unparent(widget);
1048         priv->children.remove(widget);
1049     }
1050 }
1051
1052 static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData)
1053 {
1054     WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1055     WebKitWebViewPrivate* priv = webView->priv;
1056
1057     HashSet<GtkWidget*> children = priv->children;
1058     HashSet<GtkWidget*>::const_iterator end = children.end();
1059     for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current)
1060         (*callback)(*current, callbackData);
1061 }
1062
1063 static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*)
1064 {
1065     return 0;
1066 }
1067
1068 static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*)
1069 {
1070     return FALSE;
1071 }
1072
1073 static gboolean webkit_web_view_real_close_web_view(WebKitWebView*)
1074 {
1075     return FALSE;
1076 }
1077
1078 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*)
1079 {
1080     return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
1081 }
1082
1083 static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
1084 {
1085     notImplemented();
1086 }
1087
1088 static gchar* webkit_web_view_real_choose_file(WebKitWebView*, WebKitWebFrame*, const gchar* old_name)
1089 {
1090     notImplemented();
1091     return g_strdup(old_name);
1092 }
1093
1094 typedef enum {
1095     WEBKIT_SCRIPT_DIALOG_ALERT,
1096     WEBKIT_SCRIPT_DIALOG_CONFIRM,
1097     WEBKIT_SCRIPT_DIALOG_PROMPT
1098  } WebKitScriptDialogType;
1099
1100 static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, WebKitScriptDialogType type, const gchar* defaultValue, gchar** value)
1101 {
1102     GtkMessageType messageType;
1103     GtkButtonsType buttons;
1104     gint defaultResponse;
1105     GtkWidget* window;
1106     GtkWidget* dialog;
1107     GtkWidget* entry = 0;
1108     gboolean didConfirm = FALSE;
1109
1110     switch (type) {
1111     case WEBKIT_SCRIPT_DIALOG_ALERT:
1112         messageType = GTK_MESSAGE_WARNING;
1113         buttons = GTK_BUTTONS_CLOSE;
1114         defaultResponse = GTK_RESPONSE_CLOSE;
1115         break;
1116     case WEBKIT_SCRIPT_DIALOG_CONFIRM:
1117         messageType = GTK_MESSAGE_QUESTION;
1118         buttons = GTK_BUTTONS_OK_CANCEL;
1119         defaultResponse = GTK_RESPONSE_OK;
1120         break;
1121     case WEBKIT_SCRIPT_DIALOG_PROMPT:
1122         messageType = GTK_MESSAGE_QUESTION;
1123         buttons = GTK_BUTTONS_OK_CANCEL;
1124         defaultResponse = GTK_RESPONSE_OK;
1125         break;
1126     default:
1127         g_warning("Unknown value for WebKitScriptDialogType.");
1128         return FALSE;
1129     }
1130
1131     window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
1132     dialog = gtk_message_dialog_new(widgetIsOnscreenToplevelWindow(window) ? GTK_WINDOW(window) : 0,
1133                                     GTK_DIALOG_DESTROY_WITH_PARENT,
1134                                     messageType,
1135                                     buttons,
1136                                     "%s",
1137                                     message);
1138     gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL);
1139     gtk_window_set_title(GTK_WINDOW(dialog), title);
1140     g_free(title);
1141
1142     if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) {
1143         entry = gtk_entry_new();
1144         gtk_entry_set_text(GTK_ENTRY(entry), defaultValue);
1145         gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
1146         gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
1147         gtk_widget_show(entry);
1148     }
1149
1150     gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
1151     gint response = gtk_dialog_run(GTK_DIALOG(dialog));
1152
1153     switch (response) {
1154     case GTK_RESPONSE_OK:
1155         didConfirm = TRUE;
1156         if (entry)
1157             *value = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
1158         break;
1159     case GTK_RESPONSE_CANCEL:
1160         didConfirm = FALSE;
1161         break;
1162
1163     }
1164     gtk_widget_destroy(GTK_WIDGET(dialog));
1165     return didConfirm;
1166 }
1167
1168 static gboolean webkit_web_view_real_script_alert(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message)
1169 {
1170     webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_ALERT, 0, 0);
1171     return TRUE;
1172 }
1173
1174 static gboolean webkit_web_view_real_script_confirm(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm)
1175 {
1176     *didConfirm = webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_CONFIRM, 0, 0);
1177     return TRUE;
1178 }
1179
1180 static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value)
1181 {
1182     if (!webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_PROMPT, defaultValue, value))
1183         *value = NULL;
1184     return TRUE;
1185 }
1186
1187 static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId)
1188 {
1189     g_message("console message: %s @%d: %s\n", sourceId, line, message);
1190     return TRUE;
1191 }
1192
1193 static void webkit_web_view_real_select_all(WebKitWebView* webView)
1194 {
1195     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1196     frame->editor()->command("SelectAll").execute();
1197 }
1198
1199 static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView)
1200 {
1201     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1202     frame->editor()->command("Cut").execute();
1203 }
1204
1205 static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
1206 {
1207     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1208     frame->editor()->command("Copy").execute();
1209 }
1210
1211 static void webkit_web_view_real_undo(WebKitWebView* webView)
1212 {
1213     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1214     frame->editor()->command("Undo").execute();
1215 }
1216
1217 static void webkit_web_view_real_redo(WebKitWebView* webView)
1218 {
1219     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1220     frame->editor()->command("Redo").execute();
1221 }
1222
1223 static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
1224 {
1225     g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
1226     g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
1227                          step == GTK_MOVEMENT_DISPLAY_LINES ||
1228                          step == GTK_MOVEMENT_PAGES ||
1229                          step == GTK_MOVEMENT_BUFFER_ENDS, FALSE);
1230     g_return_val_if_fail(count == 1 || count == -1, FALSE);
1231
1232     ScrollDirection direction;
1233     ScrollGranularity granularity;
1234
1235     switch (step) {
1236     case GTK_MOVEMENT_DISPLAY_LINES:
1237         granularity = ScrollByLine;
1238         if (count == 1)
1239             direction = ScrollDown;
1240         else
1241             direction = ScrollUp;
1242         break;
1243     case GTK_MOVEMENT_VISUAL_POSITIONS:
1244         granularity = ScrollByLine;
1245         if (count == 1)
1246             direction = ScrollRight;
1247         else
1248             direction = ScrollLeft;
1249         break;
1250     case GTK_MOVEMENT_PAGES:
1251         granularity = ScrollByPage;
1252         if (count == 1)
1253             direction = ScrollDown;
1254         else
1255             direction = ScrollUp;
1256         break;
1257     case GTK_MOVEMENT_BUFFER_ENDS:
1258         granularity = ScrollByDocument;
1259         if (count == 1)
1260             direction = ScrollDown;
1261         else
1262             direction = ScrollUp;
1263         break;
1264     default:
1265         g_assert_not_reached();
1266         return false;
1267     }
1268
1269     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1270     if (!frame->eventHandler()->scrollOverflow(direction, granularity))
1271         frame->view()->scroll(direction, granularity);
1272
1273     return true;
1274 }
1275
1276 static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
1277 {
1278     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1279     frame->editor()->command("Paste").execute();
1280 }
1281
1282 static gboolean webkit_web_view_real_should_allow_editing_action(WebKitWebView*)
1283 {
1284     return TRUE;
1285 }
1286
1287 static gboolean webkit_web_view_real_entering_fullscreen(WebKitWebView* webView)
1288 {
1289     return FALSE;
1290 }
1291
1292 static gboolean webkit_web_view_real_leaving_fullscreen(WebKitWebView* webView)
1293 {
1294     return FALSE;
1295 }
1296
1297 static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request)
1298 {
1299     GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request);
1300     if (responseID == GTK_RESPONSE_ACCEPT) {
1301         GOwnPtr<GSList> filesList(gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)));
1302         GRefPtr<GPtrArray> filesArray = adoptGRef(g_ptr_array_new());
1303         for (GSList* file = filesList.get(); file; file = g_slist_next(file))
1304             g_ptr_array_add(filesArray.get(), file->data);
1305         g_ptr_array_add(filesArray.get(), 0);
1306         webkit_file_chooser_request_select_files(adoptedRequest.get(), reinterpret_cast<const gchar* const*>(filesArray->pdata));
1307     }
1308
1309     gtk_widget_destroy(GTK_WIDGET(dialog));
1310 }
1311
1312 static gboolean webkitWebViewRealRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request)
1313 {
1314     GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView));
1315     if (!widgetIsOnscreenToplevelWindow(toplevel))
1316         toplevel = 0;
1317
1318     gboolean allowsMultipleSelection = webkit_file_chooser_request_get_select_multiple(request);
1319     GtkWidget* dialog = gtk_file_chooser_dialog_new(allowsMultipleSelection ? _("Select Files") : _("Select File"),
1320                                                     toplevel ? GTK_WINDOW(toplevel) : 0,
1321                                                     GTK_FILE_CHOOSER_ACTION_OPEN,
1322                                                     GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1323                                                     GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1324                                                     NULL);
1325
1326     if (GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(request))
1327         gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
1328     gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), allowsMultipleSelection);
1329
1330     if (const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(request))
1331         gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), selectedFiles[0]);
1332
1333     g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request));
1334     gtk_widget_show(dialog);
1335
1336     return TRUE;
1337 }
1338
1339 static void webkit_web_view_dispose(GObject* object)
1340 {
1341     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
1342     WebKitWebViewPrivate* priv = webView->priv;
1343
1344     priv->disposing = TRUE;
1345
1346     // Make sure GtkAdjustmentWatcher won't be reacting to adjustment changes after the
1347     // WebView is destroyed.
1348     setHorizontalAdjustment(webView, 0);
1349     setVerticalAdjustment(webView, 0);
1350
1351     // These smart pointers are cleared manually, because some cleanup operations are
1352     // very sensitive to their value. We may crash if these are done in the wrong order.
1353     priv->backForwardList.clear();
1354
1355     if (priv->corePage) {
1356         webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
1357         core(priv->mainFrame)->loader()->detachFromParent();
1358         delete priv->corePage;
1359         priv->corePage = 0;
1360     }
1361
1362     if (priv->webSettings) {
1363         g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView);
1364         priv->webSettings.clear();
1365     }
1366
1367     if (priv->currentMenu) {
1368         gtk_widget_destroy(GTK_WIDGET(priv->currentMenu));
1369         priv->currentMenu = 0;
1370     }
1371
1372     priv->webInspector.clear();
1373     priv->viewportAttributes.clear();
1374     priv->webWindowFeatures.clear();
1375     priv->mainResource.clear();
1376     priv->subResources.clear();
1377
1378     G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
1379 }
1380
1381 static void webkit_web_view_finalize(GObject* object)
1382 {
1383     // We need to manually call the destructor here, since this object's memory is managed
1384     // by GLib. This calls all C++ members' destructors and prevents memory leaks.
1385     WEBKIT_WEB_VIEW(object)->priv->~WebKitWebViewPrivate();
1386     G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
1387 }
1388
1389 static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1390 {
1391     gpointer newWebView = g_value_get_object(handlerReturn);
1392     g_value_set_object(returnAccu, newWebView);
1393
1394     // Continue if we don't have a newWebView
1395     return !newWebView;
1396 }
1397
1398 static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1399 {
1400     WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn);
1401     g_value_set_enum(returnAccu, navigationResponse);
1402
1403     if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)
1404         return FALSE;
1405
1406     return TRUE;
1407 }
1408
1409 static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
1410 {
1411     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1412     if (!core(webView))
1413         return 0;
1414
1415     if (!AXObjectCache::accessibilityEnabled())
1416         AXObjectCache::enableAccessibility();
1417
1418     Frame* coreFrame = core(webView)->mainFrame();
1419     if (!coreFrame)
1420         return 0;
1421
1422     Document* doc = coreFrame->document();
1423     if (!doc)
1424         return 0;
1425
1426     AccessibilityObject* rootAccessible = doc->axObjectCache()->rootObject();
1427     if (!rootAccessible)
1428         return 0;
1429
1430     AtkObject* axRoot = rootAccessible->wrapper();
1431     if (!axRoot || !ATK_IS_OBJECT(axRoot))
1432         return 0;
1433
1434     // Ensure the parent is set to make top-down and bottom-up navigation work.
1435     GtkWidget* parentWidget = gtk_widget_get_parent(widget);
1436     AtkObject* axParent = parentWidget ? gtk_widget_get_accessible(parentWidget) : 0;
1437     if (axParent)
1438         atk_object_set_parent(axRoot, axParent);
1439
1440     return axRoot;
1441 }
1442
1443 static double screenDPI(GdkScreen* screen)
1444 {
1445     // gdk_screen_get_resolution() returns -1 when no DPI is set.
1446     double dpi = gdk_screen_get_resolution(screen);
1447     if (dpi != -1)
1448         return dpi;
1449
1450     static const double kMillimetresPerInch = 25.4;
1451     double diagonalSizeInPixels = hypot(gdk_screen_get_width(screen), gdk_screen_get_height(screen));
1452     double diagonalSizeInInches = hypot(gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm(screen)) / kMillimetresPerInch;
1453     return diagonalSizeInPixels / diagonalSizeInInches;
1454 }
1455
1456 static gdouble webViewGetDPI(WebKitWebView* webView)
1457 {
1458     if (webView->priv->webSettings->priv->enforce96DPI)
1459         return 96;
1460
1461     static const double defaultDPI = 96;
1462     GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
1463     return screen ? screenDPI(screen) : defaultDPI;
1464 }
1465
1466 static inline gint webViewConvertFontSizeToPixels(WebKitWebView* webView, double fontSize)
1467 {
1468     return fontSize / 72.0 * webViewGetDPI(webView);
1469 }
1470
1471 static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen)
1472 {
1473     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1474     WebKitWebViewPrivate* priv = webView->priv;
1475
1476     if (priv->disposing)
1477         return;
1478
1479     WebKitWebSettings* webSettings = priv->webSettings.get();
1480     Settings* settings = core(webView)->settings();
1481     guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
1482
1483     g_object_get(webSettings,
1484                  "default-font-size", &defaultFontSize,
1485                  "default-monospace-font-size", &defaultMonospaceFontSize,
1486                  "minimum-font-size", &minimumFontSize,
1487                  "minimum-logical-font-size", &minimumLogicalFontSize,
1488                  NULL);
1489
1490     settings->setDefaultFontSize(webViewConvertFontSizeToPixels(webView, defaultFontSize));
1491     settings->setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, defaultMonospaceFontSize));
1492     settings->setMinimumFontSize(webViewConvertFontSizeToPixels(webView, minimumFontSize));
1493     settings->setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, minimumLogicalFontSize));
1494 }
1495
1496 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
1497 {
1498     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1499     if (!webView->priv->dragAndDropHelper.handleDragEnd(context))
1500         return;
1501
1502     Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1503     if (!frame)
1504         return;
1505
1506     // Synthesize a button release event to send with the drag end action.
1507     GOwnPtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_RELEASE));
1508     int x, y, xRoot, yRoot;
1509     GdkModifierType modifiers = static_cast<GdkModifierType>(0);
1510 #ifdef GTK_API_VERSION_2
1511     GdkDisplay* display = gdk_display_get_default();
1512     gdk_display_get_pointer(display, 0, &xRoot, &yRoot, &modifiers);
1513     event->button.window = gdk_display_get_window_at_pointer(display, &x, &y);
1514 #else
1515     GdkDevice* device = gdk_drag_context_get_device(context);
1516     event->button.window = gdk_device_get_window_at_position(device, &x, &y);
1517     gdk_device_get_position(device, 0, &xRoot, &yRoot);
1518 #endif
1519
1520     if (event->button.window)
1521         g_object_ref(event->button.window);
1522     event->button.x = x;
1523     event->button.y = y;
1524     event->button.x_root = xRoot;
1525     event->button.y_root = yRoot;
1526     event->button.state = modifiers;
1527
1528     PlatformMouseEvent platformEvent(&event->button);
1529     frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
1530 }
1531
1532 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint)
1533 {
1534     WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
1535 }
1536
1537 static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened)
1538 {
1539     // Don't call dragExited if we have just received a drag-drop signal. This
1540     // happens in the case of a successful drop onto the view.
1541     if (!dropHappened)
1542         core(WEBKIT_WEB_VIEW(widget))->dragController()->dragExited(dragData);
1543     core(WEBKIT_WEB_VIEW(widget))->dragController()->dragEnded();
1544 }
1545
1546 static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time)
1547 {
1548     WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback);
1549 }
1550
1551 static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1552 {
1553     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1554     OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragMotion(context, IntPoint(x, y), time));
1555     if (!dragData)
1556         return TRUE;
1557
1558     DragOperation operation = core(webView)->dragController()->dragUpdated(dragData.get()).operation;
1559     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1560     return TRUE;
1561 }
1562
1563 static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time)
1564 {
1565     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1566     OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info));
1567     if (!dragData)
1568         return;
1569
1570     DragOperation operation = core(webView)->dragController()->dragEntered(dragData.get()).operation;
1571     gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1572 }
1573
1574 static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1575 {
1576     WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1577     OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragDrop(context, IntPoint(x, y)));
1578     if (!dragData)
1579         return FALSE;
1580
1581     core(webView)->dragController()->performDrag(dragData.get());
1582     gtk_drag_finish(context, TRUE, FALSE, time);
1583     return TRUE;
1584 }
1585
1586 #if GTK_CHECK_VERSION(2, 12, 0)
1587 static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip)
1588 {
1589     WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
1590
1591     if (keyboard_mode) {
1592         WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1593
1594         // Get the title of the current focused element.
1595         Frame* coreFrame = core(webView)->focusController()->focusedOrMainFrame();
1596         if (!coreFrame)
1597             return FALSE;
1598
1599         Node* node = getFocusedNode(coreFrame);
1600         if (!node)
1601             return FALSE;
1602
1603         for (Node* titleNode = node; titleNode; titleNode = titleNode->parentNode()) {
1604             if (titleNode->isElementNode()) {
1605                 String title = static_cast<Element*>(titleNode)->title();
1606                 if (!title.isEmpty()) {
1607                     if (FrameView* view = coreFrame->view()) {
1608                         GdkRectangle area = view->contentsToWindow(node->getPixelSnappedRect());
1609                         gtk_tooltip_set_tip_area(tooltip, &area);
1610                     }
1611                     gtk_tooltip_set_text(tooltip, title.utf8().data());
1612
1613                     return TRUE;
1614                 }
1615             }
1616         }
1617
1618         return FALSE;
1619     }
1620
1621     if (priv->tooltipText.length() > 0) {
1622         if (!keyboard_mode) {
1623             if (!priv->tooltipArea.isEmpty()) {
1624                 GdkRectangle area = priv->tooltipArea;
1625                 gtk_tooltip_set_tip_area(tooltip, &area);
1626             } else
1627                 gtk_tooltip_set_tip_area(tooltip, 0);
1628         }
1629         gtk_tooltip_set_text(tooltip, priv->tooltipText.data());
1630         return TRUE;
1631     }
1632
1633     return FALSE;
1634 }
1635
1636 static gboolean webkit_web_view_show_help(GtkWidget* widget, GtkWidgetHelpType help_type)
1637 {
1638     if (help_type == GTK_WIDGET_HELP_TOOLTIP)
1639         gtk_widget_set_has_tooltip(widget, TRUE);
1640
1641     return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->show_help(widget, help_type);
1642 }
1643 #endif
1644
1645 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
1646 {
1647     GtkBindingSet* binding_set;
1648
1649     webkitInit();
1650
1651     /*
1652      * Signals
1653      */
1654
1655     /**
1656      * WebKitWebView::create-web-view:
1657      * @web_view: the object on which the signal is emitted
1658      * @frame: the #WebKitWebFrame
1659      *
1660      * Emitted when the creation of a new window is requested.
1661      * If this signal is handled the signal handler should return the
1662      * newly created #WebKitWebView.
1663      *
1664      * The new #WebKitWebView should not be displayed to the user
1665      * until the #WebKitWebView::web-view-ready signal is emitted.
1666      *
1667      * The signal handlers should not try to deal with the reference count for
1668      * the new #WebKitWebView. The widget to which the widget is added will
1669      * handle that.
1670      *
1671      * Return value: (transfer full): a newly allocated #WebKitWebView, or %NULL
1672      *
1673      * Since: 1.0.3
1674      */
1675     webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
1676             G_TYPE_FROM_CLASS(webViewClass),
1677             (GSignalFlags)G_SIGNAL_RUN_LAST,
1678             G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view),
1679             webkit_signal_accumulator_object_handled,
1680             NULL,
1681             webkit_marshal_OBJECT__OBJECT,
1682             WEBKIT_TYPE_WEB_VIEW , 1,
1683             WEBKIT_TYPE_WEB_FRAME);
1684
1685     /**
1686      * WebKitWebView::web-view-ready:
1687      * @web_view: the object on which the signal is emitted
1688      *
1689      * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView
1690      * should be displayed to the user. When this signal is emitted
1691      * all the information about how the window should look, including
1692      * size, position, whether the location, status and scroll bars
1693      * should be displayed, is already set on the
1694      * #WebKitWebWindowFeatures object contained by the #WebKitWebView.
1695      *
1696      * Notice that some of that information may change during the life
1697      * time of the window, so you may want to connect to the ::notify
1698      * signal of the #WebKitWebWindowFeatures object to handle those.
1699      *
1700      * Return value: %TRUE to stop handlers from being invoked for the event or
1701      * %FALSE to propagate the event furter
1702      *
1703      * Since: 1.0.3
1704      */
1705     webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
1706             G_TYPE_FROM_CLASS(webViewClass),
1707             (GSignalFlags)G_SIGNAL_RUN_LAST,
1708             G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready),
1709             g_signal_accumulator_true_handled,
1710             NULL,
1711             webkit_marshal_BOOLEAN__VOID,
1712             G_TYPE_BOOLEAN, 0);
1713
1714     /**
1715      * WebKitWebView::close-web-view:
1716      * @web_view: the object on which the signal is emitted
1717      *
1718      * Emitted when closing a #WebKitWebView is requested. This occurs when a
1719      * call is made from JavaScript's window.close function. The default
1720      * signal handler does not do anything. It is the owner's responsibility
1721      * to hide or delete the web view, if necessary.
1722      *
1723      * Return value: %TRUE to stop handlers from being invoked for the event or
1724      * %FALSE to propagate the event furter
1725      *
1726      * Since: 1.1.11
1727      */
1728     webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
1729             G_TYPE_FROM_CLASS(webViewClass),
1730             (GSignalFlags)G_SIGNAL_RUN_LAST,
1731             G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view),
1732             g_signal_accumulator_true_handled,
1733             NULL,
1734             webkit_marshal_BOOLEAN__VOID,
1735             G_TYPE_BOOLEAN, 0);
1736
1737     /**
1738      * WebKitWebView::navigation-requested:
1739      * @web_view: the object on which the signal is emitted
1740      * @frame: the #WebKitWebFrame that required the navigation
1741      * @request: a #WebKitNetworkRequest
1742      *
1743      * Emitted when @frame requests a navigation to another page.
1744      *
1745      * Return value: a #WebKitNavigationResponse
1746      *
1747      * Deprecated: Use WebKitWebView::navigation-policy-decision-requested
1748      * instead
1749      */
1750     webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
1751             G_TYPE_FROM_CLASS(webViewClass),
1752             (GSignalFlags)G_SIGNAL_RUN_LAST,
1753             G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
1754             webkit_navigation_request_handled,
1755             NULL,
1756             webkit_marshal_ENUM__OBJECT_OBJECT,
1757             WEBKIT_TYPE_NAVIGATION_RESPONSE, 2,
1758             WEBKIT_TYPE_WEB_FRAME,
1759             WEBKIT_TYPE_NETWORK_REQUEST);
1760
1761     /**
1762      * WebKitWebView::new-window-policy-decision-requested:
1763      * @web_view: the object on which the signal is emitted
1764      * @frame: the #WebKitWebFrame that required the navigation
1765      * @request: a #WebKitNetworkRequest
1766      * @navigation_action: a #WebKitWebNavigationAction
1767      * @policy_decision: a #WebKitWebPolicyDecision
1768      *
1769      * Emitted when @frame requests opening a new window. With this
1770      * signal the browser can use the context of the request to decide
1771      * about the new window. If the request is not handled the default
1772      * behavior is to allow opening the new window to load the URI,
1773      * which will cause a create-web-view signal emission where the
1774      * browser handles the new window action but without information
1775      * of the context that caused the navigation. The following
1776      * navigation-policy-decision-requested emissions will load the
1777      * page after the creation of the new window just with the
1778      * information of this new navigation context, without any
1779      * information about the action that made this new window to be
1780      * opened.
1781      *
1782      * Notice that if you return TRUE, meaning that you handled the
1783      * signal, you are expected to have decided what to do, by calling
1784      * webkit_web_policy_decision_ignore(),
1785      * webkit_web_policy_decision_use(), or
1786      * webkit_web_policy_decision_download() on the @policy_decision
1787      * object.
1788      *
1789      * Return value: %TRUE if a decision was made, %FALSE to have the
1790      * default behavior apply
1791      *
1792      * Since: 1.1.4
1793      */
1794     webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] =
1795         g_signal_new("new-window-policy-decision-requested",
1796             G_TYPE_FROM_CLASS(webViewClass),
1797             (GSignalFlags)G_SIGNAL_RUN_LAST,
1798             0,
1799             g_signal_accumulator_true_handled,
1800             NULL,
1801             webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1802             G_TYPE_BOOLEAN, 4,
1803             WEBKIT_TYPE_WEB_FRAME,
1804             WEBKIT_TYPE_NETWORK_REQUEST,
1805             WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1806             WEBKIT_TYPE_WEB_POLICY_DECISION);
1807
1808     /**
1809      * WebKitWebView::navigation-policy-decision-requested:
1810      * @web_view: the object on which the signal is emitted
1811      * @frame: the #WebKitWebFrame that required the navigation
1812      * @request: a #WebKitNetworkRequest
1813      * @navigation_action: a #WebKitWebNavigationAction
1814      * @policy_decision: a #WebKitWebPolicyDecision
1815      *
1816      * Emitted when @frame requests a navigation to another page.
1817      * If this signal is not handled, the default behavior is to allow the
1818      * navigation.
1819      *
1820      * Notice that if you return TRUE, meaning that you handled the
1821      * signal, you are expected to have decided what to do, by calling
1822      * webkit_web_policy_decision_ignore(),
1823      * webkit_web_policy_decision_use(), or
1824      * webkit_web_policy_decision_download() on the @policy_decision
1825      * object.
1826      *
1827      * Return value: %TRUE if a decision was made, %FALSE to have the
1828      * default behavior apply
1829      *
1830      * Since: 1.0.3
1831      */
1832     webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested",
1833             G_TYPE_FROM_CLASS(webViewClass),
1834             (GSignalFlags)G_SIGNAL_RUN_LAST,
1835             0,
1836             g_signal_accumulator_true_handled,
1837             NULL,
1838             webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1839             G_TYPE_BOOLEAN, 4,
1840             WEBKIT_TYPE_WEB_FRAME,
1841             WEBKIT_TYPE_NETWORK_REQUEST,
1842             WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1843             WEBKIT_TYPE_WEB_POLICY_DECISION);
1844
1845     /**
1846      * WebKitWebView::mime-type-policy-decision-requested:
1847      * @web_view: the object on which the signal is emitted
1848      * @frame: the #WebKitWebFrame that required the policy decision
1849      * @request: a WebKitNetworkRequest
1850      * @mimetype: the MIME type attempted to load
1851      * @policy_decision: a #WebKitWebPolicyDecision
1852      *
1853      * Decide whether or not to display the given MIME type.  If this
1854      * signal is not handled, the default behavior is to show the
1855      * content of the requested URI if WebKit can show this MIME
1856      * type and the content disposition is not a download; if WebKit
1857      * is not able to show the MIME type nothing happens.
1858      *
1859      * Notice that if you return TRUE, meaning that you handled the
1860      * signal, you are expected to be aware of the "Content-Disposition"
1861      * header. A value of "attachment" usually indicates a download
1862      * regardless of the MIME type, see also
1863      * soup_message_headers_get_content_disposition(). And you must call
1864      * webkit_web_policy_decision_ignore(),
1865      * webkit_web_policy_decision_use(), or
1866      * webkit_web_policy_decision_download() on the @policy_decision
1867      * object.
1868      *
1869      * Return value: %TRUE if a decision was made, %FALSE to have the
1870      * default behavior apply
1871      *
1872      * Since: 1.0.3
1873      */
1874     webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
1875             G_TYPE_FROM_CLASS(webViewClass),
1876             (GSignalFlags)G_SIGNAL_RUN_LAST,
1877             0,
1878             g_signal_accumulator_true_handled,
1879             NULL,
1880             webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT,
1881             G_TYPE_BOOLEAN, 4,
1882             WEBKIT_TYPE_WEB_FRAME,
1883             WEBKIT_TYPE_NETWORK_REQUEST,
1884             G_TYPE_STRING,
1885             WEBKIT_TYPE_WEB_POLICY_DECISION);
1886
1887     /**
1888      * WebKitWebView::window-object-cleared:
1889      * @web_view: the object on which the signal is emitted
1890      * @frame: the #WebKitWebFrame to which @window_object belongs
1891      * @context: the #JSGlobalContextRef holding the global object and other
1892      * execution state; equivalent to the return value of
1893      * webkit_web_frame_get_global_context(@frame)
1894      * @window_object: the #JSObjectRef representing the frame's JavaScript
1895      * window object
1896      *
1897      * Emitted when the JavaScript window object in a #WebKitWebFrame has been
1898      * cleared in preparation for a new load. This is the preferred place to
1899      * set custom properties on the window object using the JavaScriptCore API.
1900      */
1901     webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared",
1902             G_TYPE_FROM_CLASS(webViewClass),
1903             (GSignalFlags)G_SIGNAL_RUN_LAST,
1904             G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared),
1905             NULL,
1906             NULL,
1907             webkit_marshal_VOID__OBJECT_POINTER_POINTER,
1908             G_TYPE_NONE, 3,
1909             WEBKIT_TYPE_WEB_FRAME,
1910             G_TYPE_POINTER,
1911             G_TYPE_POINTER);
1912
1913     /**
1914      * WebKitWebView::download-requested:
1915      * @web_view: the object on which the signal is emitted
1916      * @download: a #WebKitDownload object that lets you control the
1917      * download process
1918      *
1919      * A new Download is being requested. By default, if the signal is
1920      * not handled, the download is cancelled. If you handle the download
1921      * and call webkit_download_set_destination_uri(), it will be
1922      * started for you. If you need to set the destination asynchronously
1923      * you are responsible for starting or cancelling it yourself.
1924      *
1925      * If you intend to handle downloads yourself rather than using
1926      * the #WebKitDownload helper object you must handle this signal,
1927      * and return %FALSE.
1928      *
1929      * Also, keep in mind that the default policy for WebKitGTK+ is to
1930      * ignore files with a MIME type that it does not know how to
1931      * handle, which means this signal won't be emitted in the default
1932      * setup. One way to trigger downloads is to connect to
1933      * WebKitWebView::mime-type-policy-decision-requested and call
1934      * webkit_web_policy_decision_download() on the
1935      * #WebKitWebPolicyDecision in the parameter list for the kind of
1936      * files you want your application to download (a common solution
1937      * is to download anything that WebKit can't handle, which you can
1938      * figure out by using webkit_web_view_can_show_mime_type()).
1939      *
1940      * Return value: TRUE if the download should be performed, %FALSE to
1941      * cancel it
1942      *
1943      * Since: 1.1.2
1944      */
1945     webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested",
1946             G_TYPE_FROM_CLASS(webViewClass),
1947             (GSignalFlags)G_SIGNAL_RUN_LAST,
1948             0,
1949             g_signal_accumulator_true_handled,
1950             NULL,
1951             webkit_marshal_BOOLEAN__OBJECT,
1952             G_TYPE_BOOLEAN, 1,
1953             G_TYPE_OBJECT);
1954
1955     /**
1956      * WebKitWebView::load-started:
1957      * @web_view: the object on which the signal is emitted
1958      * @frame: the frame going to do the load
1959      *
1960      * When a #WebKitWebFrame begins to load this signal is emitted.
1961      *
1962      * Deprecated: Use the "load-status" property instead.
1963      */
1964     webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
1965             G_TYPE_FROM_CLASS(webViewClass),
1966             (GSignalFlags)G_SIGNAL_RUN_LAST,
1967             0,
1968             NULL,
1969             NULL,
1970             g_cclosure_marshal_VOID__OBJECT,
1971             G_TYPE_NONE, 1,
1972             WEBKIT_TYPE_WEB_FRAME);
1973
1974     /**
1975      * WebKitWebView::load-committed:
1976      * @web_view: the object on which the signal is emitted
1977      * @frame: the main frame that received the first data
1978      *
1979      * When a #WebKitWebFrame loaded the first data this signal is emitted.
1980      *
1981      * Deprecated: Use the "load-status" property instead.
1982      */
1983     webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
1984             G_TYPE_FROM_CLASS(webViewClass),
1985             (GSignalFlags)G_SIGNAL_RUN_LAST,
1986             0,
1987             NULL,
1988             NULL,
1989             g_cclosure_marshal_VOID__OBJECT,
1990             G_TYPE_NONE, 1,
1991             WEBKIT_TYPE_WEB_FRAME);
1992
1993
1994     /**
1995      * WebKitWebView::load-progress-changed:
1996      * @web_view: the #WebKitWebView
1997      * @progress: the global progress
1998      *
1999      * Deprecated: Use the "progress" property instead.
2000      */
2001     webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
2002             G_TYPE_FROM_CLASS(webViewClass),
2003             (GSignalFlags)G_SIGNAL_RUN_LAST,
2004             0,
2005             NULL,
2006             NULL,
2007             g_cclosure_marshal_VOID__INT,
2008             G_TYPE_NONE, 1,
2009             G_TYPE_INT);
2010
2011     /**
2012      * WebKitWebView::load-error
2013      * @web_view: the object on which the signal is emitted
2014      * @web_frame: the #WebKitWebFrame
2015      * @uri: the URI that triggered the error
2016      * @web_error: the #GError that was triggered
2017      *
2018      * An error occurred while loading. By default, if the signal is not
2019      * handled, the @web_view will display a stock error page. You need to
2020      * handle the signal if you want to provide your own error page.
2021      *
2022      * Since: 1.1.6
2023      *
2024      * Return value: %TRUE to stop other handlers from being invoked for the
2025      * event. %FALSE to propagate the event further.
2026      */
2027     webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error",
2028             G_TYPE_FROM_CLASS(webViewClass),
2029             (GSignalFlags)(G_SIGNAL_RUN_LAST),
2030             0,
2031             g_signal_accumulator_true_handled,
2032             NULL,
2033             webkit_marshal_BOOLEAN__OBJECT_STRING_BOXED,
2034             G_TYPE_BOOLEAN, 3,
2035             WEBKIT_TYPE_WEB_FRAME,
2036             G_TYPE_STRING,
2037             G_TYPE_ERROR);
2038
2039     /**
2040      * WebKitWebView::load-finished:
2041      * @web_view: the #WebKitWebView
2042      * @frame: the #WebKitWebFrame
2043      *
2044      * Deprecated: Use the "load-status" property instead.
2045      */
2046     webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
2047             G_TYPE_FROM_CLASS(webViewClass),
2048             (GSignalFlags)G_SIGNAL_RUN_LAST,
2049             0,
2050             NULL,
2051             NULL,
2052             g_cclosure_marshal_VOID__OBJECT,
2053             G_TYPE_NONE, 1,
2054             WEBKIT_TYPE_WEB_FRAME);
2055
2056     /**
2057      * WebKitWebView::onload-event:
2058      * @web_view: the object on which the signal is emitted
2059      * @frame: the frame
2060      *
2061      * When a #WebKitWebFrame receives an onload event this signal is emitted.
2062      */
2063     webkit_web_view_signals[ONLOAD_EVENT] = g_signal_new("onload-event",
2064             G_TYPE_FROM_CLASS(webViewClass),
2065             (GSignalFlags)G_SIGNAL_RUN_LAST,
2066             0,
2067             NULL,
2068             NULL,
2069             g_cclosure_marshal_VOID__OBJECT,
2070             G_TYPE_NONE, 1,
2071             WEBKIT_TYPE_WEB_FRAME);
2072
2073     /**
2074      * WebKitWebView::title-changed:
2075      * @web_view: the object on which the signal is emitted
2076      * @frame: the main frame
2077      * @title: the new title
2078      *
2079      * When a #WebKitWebFrame changes the document title this signal is emitted.
2080      *
2081      * Deprecated: 1.1.4: Use "notify::title" instead.
2082      */
2083     webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed",
2084             G_TYPE_FROM_CLASS(webViewClass),
2085             (GSignalFlags)G_SIGNAL_RUN_LAST,
2086             0,
2087             NULL,
2088             NULL,
2089             webkit_marshal_VOID__OBJECT_STRING,
2090             G_TYPE_NONE, 2,
2091             WEBKIT_TYPE_WEB_FRAME,
2092             G_TYPE_STRING);
2093
2094     /**
2095      * WebKitWebView::hovering-over-link:
2096      * @web_view: the object on which the signal is emitted
2097      * @title: the link's title
2098      * @uri: the URI the link points to
2099      *
2100      * When the cursor is over a link, this signal is emitted.
2101      */
2102     webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
2103             G_TYPE_FROM_CLASS(webViewClass),
2104             (GSignalFlags)G_SIGNAL_RUN_LAST,
2105             0,
2106             NULL,
2107             NULL,
2108             webkit_marshal_VOID__STRING_STRING,
2109             G_TYPE_NONE, 2,
2110             G_TYPE_STRING,
2111             G_TYPE_STRING);
2112
2113     /**
2114      * WebKitWebView::populate-popup:
2115      * @web_view: the object on which the signal is emitted
2116      * @menu: the context menu
2117      *
2118      * When a context menu is about to be displayed this signal is emitted.
2119      *
2120      * Add menu items to #menu to extend the context menu.
2121      *
2122      * Deprecated: 1.10: Use #WebKitWebView::context-menu signal instead.
2123      */
2124     webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
2125             G_TYPE_FROM_CLASS(webViewClass),
2126             (GSignalFlags)G_SIGNAL_RUN_LAST,
2127             0,
2128             NULL,
2129             NULL,
2130             g_cclosure_marshal_VOID__OBJECT,
2131             G_TYPE_NONE, 1,
2132             GTK_TYPE_MENU);
2133
2134     /**
2135      * WebKitWebView::print-requested
2136      * @web_view: the object in which the signal is emitted
2137      * @web_frame: the frame that is requesting to be printed
2138      *
2139      * Emitted when printing is requested by the frame, usually
2140      * because of a javascript call. When handling this signal you
2141      * should call webkit_web_frame_print_full() or
2142      * webkit_web_frame_print() to do the actual printing.
2143      *
2144      * The default handler will present a print dialog and carry a
2145      * print operation. Notice that this means that if you intend to
2146      * ignore a print request you must connect to this signal, and
2147      * return %TRUE.
2148      *
2149      * Return value: %TRUE if the print request has been handled, %FALSE if
2150      * the default handler should run
2151      *
2152      * Since: 1.1.5
2153      */
2154     webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested",
2155             G_TYPE_FROM_CLASS(webViewClass),
2156             (GSignalFlags)G_SIGNAL_RUN_LAST,
2157             0,
2158             g_signal_accumulator_true_handled,
2159             NULL,
2160             webkit_marshal_BOOLEAN__OBJECT,
2161             G_TYPE_BOOLEAN, 1,
2162             WEBKIT_TYPE_WEB_FRAME);
2163
2164     webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
2165             G_TYPE_FROM_CLASS(webViewClass),
2166             (GSignalFlags)G_SIGNAL_RUN_LAST,
2167             0,
2168             NULL,
2169             NULL,
2170             g_cclosure_marshal_VOID__STRING,
2171             G_TYPE_NONE, 1,
2172             G_TYPE_STRING);
2173
2174     /**
2175      * WebKitWebView::icon-loaded:
2176      * @web_view: the object on which the signal is emitted
2177      * @icon_uri: the URI for the icon
2178      *
2179      * This signal is emitted when the main frame has got a favicon.
2180      * See WebKitIconDatabase::icon-loaded if you want to keep track of
2181      * icons for child frames.
2182      *
2183      * Since: 1.1.18
2184      */
2185     webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded",
2186             G_TYPE_FROM_CLASS(webViewClass),
2187             (GSignalFlags)G_SIGNAL_RUN_LAST,
2188             0,
2189             NULL,
2190             NULL,
2191             g_cclosure_marshal_VOID__STRING,
2192             G_TYPE_NONE, 1,
2193             G_TYPE_STRING);
2194
2195     /**
2196      * WebKitWebView::console-message:
2197      * @web_view: the object on which the signal is emitted
2198      * @message: the message text
2199      * @line: the line where the error occured
2200      * @source_id: the source id
2201      *
2202      * A JavaScript console message was created.
2203      *
2204      * Return value: %TRUE to stop other handlers from being invoked for the
2205      * event. %FALSE to propagate the event further.
2206      */
2207     webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message",
2208             G_TYPE_FROM_CLASS(webViewClass),
2209             (GSignalFlags)G_SIGNAL_RUN_LAST,
2210             G_STRUCT_OFFSET(WebKitWebViewClass, console_message),
2211             g_signal_accumulator_true_handled,
2212             NULL,
2213             webkit_marshal_BOOLEAN__STRING_INT_STRING,
2214             G_TYPE_BOOLEAN, 3,
2215             G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
2216
2217     /**
2218      * WebKitWebView::script-alert:
2219      * @web_view: the object on which the signal is emitted
2220      * @frame: the relevant frame
2221      * @message: the message text
2222      *
2223      * A JavaScript alert dialog was created.
2224      *
2225      * Return value: %TRUE to stop other handlers from being invoked for the
2226      * event. %FALSE to propagate the event further.
2227      */
2228     webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert",
2229             G_TYPE_FROM_CLASS(webViewClass),
2230             (GSignalFlags)G_SIGNAL_RUN_LAST,
2231             G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
2232             g_signal_accumulator_true_handled,
2233             NULL,
2234             webkit_marshal_BOOLEAN__OBJECT_STRING,
2235             G_TYPE_BOOLEAN, 2,
2236             WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING);
2237
2238     /**
2239      * WebKitWebView::script-confirm:
2240      * @web_view: the object on which the signal is emitted
2241      * @frame: the relevant frame
2242      * @message: the message text
2243      * @confirmed: whether the dialog has been confirmed
2244      *
2245      * A JavaScript confirm dialog was created, providing Yes and No buttons.
2246      *
2247      * Return value: %TRUE to stop other handlers from being invoked for the
2248      * event. %FALSE to propagate the event further.
2249      */
2250     webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm",
2251             G_TYPE_FROM_CLASS(webViewClass),
2252             (GSignalFlags)G_SIGNAL_RUN_LAST,
2253             G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
2254             g_signal_accumulator_true_handled,
2255             NULL,
2256             webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
2257             G_TYPE_BOOLEAN, 3,
2258             WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_POINTER);
2259
2260     /**
2261      * WebKitWebView::script-prompt:
2262      * @web_view: the object on which the signal is emitted
2263      * @frame: the relevant frame
2264      * @message: the message text
2265      * @default: the default value
2266      * @text: To be filled with the return value or NULL if the dialog was cancelled.
2267      *
2268      * A JavaScript prompt dialog was created, providing an entry to input text.
2269      *
2270      * Return value: %TRUE to stop other handlers from being invoked for the
2271      * event. %FALSE to propagate the event further.
2272      */
2273     webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt",
2274             G_TYPE_FROM_CLASS(webViewClass),
2275             (GSignalFlags)G_SIGNAL_RUN_LAST,
2276             G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
2277             g_signal_accumulator_true_handled,
2278             NULL,
2279             webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING,
2280             G_TYPE_BOOLEAN, 4,
2281             WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
2282
2283     /**
2284      * WebKitWebView::select-all:
2285      * @web_view: the object which received the signal
2286      *
2287      * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to
2288      * select the complete contents of the text view.
2289      *
2290      * The default bindings for this signal is Ctrl-a.
2291      */
2292     webkit_web_view_signals[::SELECT_ALL] = g_signal_new("select-all",
2293             G_TYPE_FROM_CLASS(webViewClass),
2294             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2295             G_STRUCT_OFFSET(WebKitWebViewClass, select_all),
2296             NULL, NULL,
2297             g_cclosure_marshal_VOID__VOID,
2298             G_TYPE_NONE, 0);
2299
2300     /**
2301      * WebKitWebView::cut-clipboard:
2302      * @web_view: the object which received the signal
2303      *
2304      * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to
2305      * cut the selection to the clipboard.
2306      *
2307      * The default bindings for this signal are Ctrl-x and Shift-Delete.
2308      */
2309     webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut-clipboard",
2310             G_TYPE_FROM_CLASS(webViewClass),
2311             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2312             G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard),
2313             NULL, NULL,
2314             g_cclosure_marshal_VOID__VOID,
2315             G_TYPE_NONE, 0);
2316
2317     /**
2318      * WebKitWebView::copy-clipboard:
2319      * @web_view: the object which received the signal
2320      *
2321      * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to
2322      * copy the selection to the clipboard.
2323      *
2324      * The default bindings for this signal are Ctrl-c and Ctrl-Insert.
2325      */
2326     webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy-clipboard",
2327             G_TYPE_FROM_CLASS(webViewClass),
2328             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2329             G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard),
2330             NULL, NULL,
2331             g_cclosure_marshal_VOID__VOID,
2332             G_TYPE_NONE, 0);
2333
2334     /**
2335      * WebKitWebView::paste-clipboard:
2336      * @web_view: the object which received the signal
2337      *
2338      * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to
2339      * paste the contents of the clipboard into the Web view.
2340      *
2341      * The default bindings for this signal are Ctrl-v and Shift-Insert.
2342      */
2343     webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste-clipboard",
2344             G_TYPE_FROM_CLASS(webViewClass),
2345             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2346             G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard),
2347             NULL, NULL,
2348             g_cclosure_marshal_VOID__VOID,
2349             G_TYPE_NONE, 0);
2350
2351     /**
2352      * WebKitWebView::undo
2353      * @web_view: the object which received the signal
2354      *
2355      * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to
2356      * undo the last editing command.
2357      *
2358      * The default binding for this signal is Ctrl-z
2359      *
2360      * Since: 1.1.14
2361      */
2362     webkit_web_view_signals[UNDO] = g_signal_new("undo",
2363             G_TYPE_FROM_CLASS(webViewClass),
2364             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2365             G_STRUCT_OFFSET(WebKitWebViewClass, undo),
2366             NULL, NULL,
2367             g_cclosure_marshal_VOID__VOID,
2368             G_TYPE_NONE, 0);
2369
2370     /**
2371      * WebKitWebView::redo
2372      * @web_view: the object which received the signal
2373      *
2374      * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to
2375      * redo the last editing command.
2376      *
2377      * The default binding for this signal is Ctrl-Shift-z
2378      *
2379      * Since: 1.1.14
2380      */
2381     webkit_web_view_signals[REDO] = g_signal_new("redo",
2382             G_TYPE_FROM_CLASS(webViewClass),
2383             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2384             G_STRUCT_OFFSET(WebKitWebViewClass, redo),
2385             NULL, NULL,
2386             g_cclosure_marshal_VOID__VOID,
2387             G_TYPE_NONE, 0);
2388
2389     /**
2390      * WebKitWebView::move-cursor:
2391      * @web_view: the object which received the signal
2392      * @step: the type of movement, one of #GtkMovementStep
2393      * @count: an integer indicating the subtype of movement. Currently
2394      *         the permitted values are '1' = forward, '-1' = backwards.
2395      *
2396      * The #WebKitWebView::move-cursor will be emitted to apply the
2397      * cursor movement described by its parameters to the @view.
2398      *
2399      * Return value: %TRUE or %FALSE
2400      * 
2401      * Since: 1.1.4
2402      */
2403     webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor",
2404             G_TYPE_FROM_CLASS(webViewClass),
2405             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2406             G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor),
2407             NULL, NULL,
2408             webkit_marshal_BOOLEAN__ENUM_INT,
2409             G_TYPE_BOOLEAN, 2,
2410             GTK_TYPE_MOVEMENT_STEP,
2411             G_TYPE_INT);
2412
2413     /**
2414      * WebKitWebView::create-plugin-widget:
2415      * @web_view: the object which received the signal
2416      * @mime_type: the mimetype of the requested object
2417      * @uri: the URI to load
2418      * @param: a #GHashTable with additional attributes (strings)
2419      *
2420      * The #WebKitWebView::create-plugin-widget signal will be emitted to
2421      * create a plugin widget for embed or object HTML tags. This
2422      * allows to embed a GtkWidget as a plugin into HTML content. In
2423      * case of a textual selection of the GtkWidget WebCore will attempt
2424      * to set the property value of "webkit-widget-is-selected". This can
2425      * be used to draw a visual indicator of the selection.
2426      *
2427      * Return value: (transfer full): a new #GtkWidget, or %NULL
2428      *
2429      * Since: 1.1.8
2430      */
2431     webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget",
2432             G_TYPE_FROM_CLASS(webViewClass),
2433             (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2434             0,
2435             webkit_signal_accumulator_object_handled,
2436             NULL,
2437             webkit_marshal_OBJECT__STRING_STRING_POINTER,
2438             GTK_TYPE_WIDGET, 3,
2439             G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
2440
2441     /**
2442      * WebKitWebView::database-quota-exceeded
2443      * @web_view: the object which received the signal
2444      * @frame: the relevant frame
2445      * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin
2446      *
2447      * The #WebKitWebView::database-quota-exceeded signal will be emitted when
2448      * a Web Database exceeds the quota of its security origin. This signal
2449      * may be used to increase the size of the quota before the originating
2450      * operation fails.
2451      *
2452      * Since: 1.1.14
2453      */
2454     webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded",
2455             G_TYPE_FROM_CLASS(webViewClass),
2456             (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2457             0,
2458             NULL, NULL,
2459             webkit_marshal_VOID__OBJECT_OBJECT,
2460             G_TYPE_NONE, 2,
2461             G_TYPE_OBJECT, G_TYPE_OBJECT);
2462
2463     /**
2464      * WebKitWebView::resource-request-starting:
2465      * @web_view: the object which received the signal
2466      * @web_frame: the #WebKitWebFrame whose load dispatched this request
2467      * @web_resource: an empty #WebKitWebResource object
2468      * @request: the #WebKitNetworkRequest that will be dispatched
2469      * @response: the #WebKitNetworkResponse representing the redirect
2470      * response, if any
2471      *
2472      * Emitted when a request is about to be sent. You can modify the
2473      * request while handling this signal. You can set the URI in the
2474      * #WebKitNetworkRequest object itself, and add/remove/replace
2475      * headers using the #SoupMessage object it carries, if it is
2476      * present. See webkit_network_request_get_message(). Setting the
2477      * request URI to "about:blank" will effectively cause the request
2478      * to load nothing, and can be used to disable the loading of
2479      * specific resources.
2480      *
2481      * Notice that information about an eventual redirect is available
2482      * in @response's #SoupMessage, not in the #SoupMessage carried by
2483      * the @request. If @response is %NULL, then this is not a
2484      * redirected request.
2485      *
2486      * The #WebKitWebResource object will be the same throughout all
2487      * the lifetime of the resource, but the contents may change from
2488      * inbetween signal emissions.
2489      *
2490      * Since: 1.1.14
2491      */
2492     webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
2493             G_TYPE_FROM_CLASS(webViewClass),
2494             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2495             0,
2496             NULL, NULL,
2497             webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT,
2498             G_TYPE_NONE, 4,
2499             WEBKIT_TYPE_WEB_FRAME,
2500             WEBKIT_TYPE_WEB_RESOURCE,
2501             WEBKIT_TYPE_NETWORK_REQUEST,
2502             WEBKIT_TYPE_NETWORK_RESPONSE);
2503
2504     /**
2505      * WebKitWebView::geolocation-policy-decision-requested:
2506      * @web_view: the object on which the signal is emitted
2507      * @frame: the frame that requests permission
2508      * @policy_decision: a WebKitGeolocationPolicyDecision
2509      *
2510      * This signal is emitted when a @frame wants to obtain the user's
2511      * location. The decision can be made asynchronously, but you must
2512      * call g_object_ref() the @policy_decision, and return %TRUE if
2513      * you are going to handle the request. To actually make the
2514      * decision you need to call webkit_geolocation_policy_allow() or
2515      * webkit_geolocation_policy_deny() on @policy_decision.
2516      *
2517      * Since: 1.1.23
2518      */
2519     webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested",
2520             G_TYPE_FROM_CLASS(webViewClass),
2521             (GSignalFlags)(G_SIGNAL_RUN_LAST),
2522             0,
2523             NULL, NULL,
2524             webkit_marshal_BOOLEAN__OBJECT_OBJECT,
2525             G_TYPE_BOOLEAN, 2,
2526             WEBKIT_TYPE_WEB_FRAME,
2527             WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION);
2528
2529     /**
2530      * WebKitWebView::geolocation-policy-decision-cancelled:
2531      * @web_view: the object on which the signal is emitted
2532      * @frame: the frame that cancels geolocation request.
2533      *
2534      * When a @frame wants to cancel geolocation permission it had requested
2535      * before.
2536      *
2537      * Since: 1.1.23
2538      */
2539     webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled",
2540             G_TYPE_FROM_CLASS(webViewClass),
2541             (GSignalFlags)(G_SIGNAL_RUN_LAST),
2542             0,
2543             NULL, NULL,
2544             g_cclosure_marshal_VOID__OBJECT,
2545             G_TYPE_NONE, 1,
2546             WEBKIT_TYPE_WEB_FRAME);
2547
2548     /*
2549      * DOM-related signals. These signals are experimental, for now,
2550      * and may change API and ABI. Their comments lack one * on
2551      * purpose, to make them not be catched by gtk-doc.
2552      */
2553
2554     /**
2555      * WebKitWebView::document-load-finished:
2556      * @web_view: the object which received the signal
2557      * @web_frame: the #WebKitWebFrame whose load dispatched this request
2558      *
2559      * Emitted when the DOM document object load is finished for the
2560      * given frame.
2561      */
2562     webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished",
2563             G_TYPE_FROM_CLASS(webViewClass),
2564             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2565             0,
2566             NULL, NULL,
2567             g_cclosure_marshal_VOID__OBJECT,
2568             G_TYPE_NONE, 1,
2569             WEBKIT_TYPE_WEB_FRAME);
2570
2571     /**
2572      * WebKitWebView::frame-created:
2573      * @web_view: the object which received the signal
2574      * @web_frame: the #WebKitWebFrame which was just created.
2575      *
2576      * Emitted when a WebKitWebView has created a new frame. This signal will
2577      * be emitted for all sub-frames created during page load. It will not be
2578      * emitted for the main frame, which originates in the WebKitWebView constructor
2579      * and may be accessed at any time using webkit_web_view_get_main_frame.
2580      *
2581      * Since: 1.3.4
2582      */
2583     webkit_web_view_signals[FRAME_CREATED] = g_signal_new("frame-created",
2584             G_TYPE_FROM_CLASS(webViewClass),
2585             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2586             0,
2587             NULL, NULL,
2588             g_cclosure_marshal_VOID__OBJECT,
2589             G_TYPE_NONE, 1,
2590             WEBKIT_TYPE_WEB_FRAME);
2591
2592      /**
2593      * WebKitWebView::run-file-chooser:
2594      * @web_view: the #WebKitWebView on which the signal is emitted
2595      * @request: a #WebKitFileChooserRequest
2596      *
2597      * This signal is emitted when the user interacts with a &lt;input
2598      * type='file' /&gt; HTML element, requesting from WebKit to show
2599      * a dialog to select one or more files to be uploaded. To let the
2600      * application know the details of the file chooser, as well as to
2601      * allow the client application to either cancel the request or
2602      * perform an actual selection of files, the signal will pass an
2603      * instance of the #WebKitFileChooserRequest in the @request
2604      * argument.
2605      *
2606      * The default signal handler will asynchronously run a regular
2607      * #GtkFileChooserDialog for the user to interact with.
2608      *
2609      * If this signal is to be handled asynchronously, you must
2610      * call g_object_ref() on the @request, and return %TRUE to indicate
2611      * that the request is being handled. When you are ready to complete the
2612      * request, call webkit_file_chooser_request_select_files().
2613      *
2614      * Returns: %TRUE to stop other handlers from being invoked for the event.
2615      *   %FALSE to propagate the event further.
2616      *
2617      */
2618     webkit_web_view_signals[RUN_FILE_CHOOSER] =
2619         g_signal_new("run-file-chooser",
2620                      G_TYPE_FROM_CLASS(webViewClass),
2621                      G_SIGNAL_RUN_LAST,
2622                      G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser),
2623                      g_signal_accumulator_true_handled, 0 /* accumulator data */,
2624                      webkit_marshal_BOOLEAN__OBJECT,
2625                      G_TYPE_BOOLEAN, 1, /* number of parameters */
2626                      WEBKIT_TYPE_FILE_CHOOSER_REQUEST);
2627
2628     webkit_web_view_signals[SHOULD_BEGIN_EDITING] = g_signal_new("should-begin-editing",
2629         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2630         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2631         webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2632
2633     webkit_web_view_signals[SHOULD_END_EDITING] = g_signal_new("should-end-editing", G_TYPE_FROM_CLASS(webViewClass),
2634         static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2635         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2636         webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2637
2638     webkit_web_view_signals[SHOULD_INSERT_NODE] = g_signal_new("should-insert-node", G_TYPE_FROM_CLASS(webViewClass), 
2639         static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2640         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2641         webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM, G_TYPE_BOOLEAN,
2642         3, WEBKIT_TYPE_DOM_NODE, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_INSERT_ACTION);
2643
2644     webkit_web_view_signals[SHOULD_INSERT_TEXT] = g_signal_new("should-insert-text", G_TYPE_FROM_CLASS(webViewClass),
2645         static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2646         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2647         webkit_marshal_BOOLEAN__STRING_OBJECT_ENUM, G_TYPE_BOOLEAN,
2648         3, G_TYPE_STRING, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_INSERT_ACTION);
2649
2650     webkit_web_view_signals[SHOULD_DELETE_RANGE] = g_signal_new("should-delete-range", G_TYPE_FROM_CLASS(webViewClass),
2651         static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2652         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2653         webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2654
2655     webkit_web_view_signals[SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT] = g_signal_new("should-show-delete-interface-for-element",
2656         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2657         0, g_signal_accumulator_first_wins, 0,
2658         webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2659
2660     webkit_web_view_signals[SHOULD_CHANGE_SELECTED_RANGE] = g_signal_new("should-change-selected-range",
2661         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2662         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2663         webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM_BOOLEAN, G_TYPE_BOOLEAN,
2664          4, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_SELECTION_AFFINITY, G_TYPE_BOOLEAN);
2665
2666     webkit_web_view_signals[SHOULD_APPLY_STYLE] = g_signal_new("should-apply-style",
2667         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2668         G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2669         webkit_marshal_BOOLEAN__OBJECT_OBJECT, G_TYPE_BOOLEAN,
2670          2, WEBKIT_TYPE_DOM_CSS_STYLE_DECLARATION, WEBKIT_TYPE_DOM_RANGE);
2671
2672     webkit_web_view_signals[EDITING_BEGAN] = g_signal_new("editing-began",
2673         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2674         g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2675
2676     webkit_web_view_signals[USER_CHANGED_CONTENTS] = g_signal_new("user-changed-contents",
2677         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2678         g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2679
2680     webkit_web_view_signals[EDITING_ENDED] = g_signal_new("editing-ended",
2681         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2682         g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2683
2684     webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed",
2685         G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2686         g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2687
2688     /*
2689      * WebKitWebView::viewport-attributes-recompute-requested
2690      * @web_view: the object which received the signal
2691      * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2692      *
2693      * The #WebKitWebView::viewport-attributes-recompute-requested 
2694      * signal will be emitted when a page with a viewport meta tag
2695      * loads and when webkit_viewport_attributes_recompute is called.
2696      *
2697      * The #WebKitViewportAttributes will have device size, available size,
2698      * desktop width, and device DPI pre-filled by values that make sense 
2699      * for the current screen and widget, but you can override those values 
2700      * if you have special requirements (for instance, if you made your
2701      * widget bigger than the available visible area, you should override 
2702      * the available-width and available-height properties to the actual 
2703      * visible area).
2704      *
2705      * Since: 1.3.8
2706      */
2707     webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested",
2708             G_TYPE_FROM_CLASS(webViewClass),
2709             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2710             0,
2711             0, 0,
2712             g_cclosure_marshal_VOID__OBJECT,
2713             G_TYPE_NONE, 1,
2714             WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2715
2716     /*
2717      * WebKitWebView::viewport-attributes-changed
2718      * @web_view: the object which received the signal
2719      * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2720      *
2721      * The #WebKitWebView::viewport-attributes-changed signal will be emitted 
2722      * after the emission of #WebKitWebView::viewport-attributes-recompute-requested 
2723      * and the subsequent viewport attribute recomputation. At this point, 
2724      * if the #WebKitViewportAttributes are valid, the viewport attributes are available.
2725      * 
2726      * Since: 1.3.8
2727      */
2728     webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed",
2729             G_TYPE_FROM_CLASS(webViewClass),
2730             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2731             0,
2732             0, 0,
2733             g_cclosure_marshal_VOID__OBJECT,
2734             G_TYPE_NONE, 1,
2735             WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2736
2737     /**
2738      * WebKitWebView::entering-fullscreen:
2739      * @web_view: the #WebKitWebView on which the signal is emitted.
2740      * @element: the #WebKitDOMHTMLElement which has requested full screen display.
2741      *
2742      * Emitted when JavaScript code calls
2743      * <function>element.webkitRequestFullScreen</function>. If the
2744      * signal is not handled the WebView will proceed to full screen
2745      * its top level window. This signal can be used by client code to
2746      * request permission to the user prior doing the full screen
2747      * transition and eventually prepare the top-level window
2748      * (e.g. hide some widgets that would otherwise be part of the
2749      * full screen window).
2750      *
2751      * Returns: %TRUE to stop other handlers from being invoked for the event.
2752      *    %FALSE to continue emission of the event.
2753      *
2754      * Since: 1.9.0
2755      */
2756     webkit_web_view_signals[ENTERING_FULLSCREEN] =
2757             g_signal_new("entering-fullscreen",
2758                          G_TYPE_FROM_CLASS(webViewClass),
2759                          G_SIGNAL_RUN_LAST,
2760                          G_STRUCT_OFFSET(WebKitWebViewClass, entering_fullscreen),
2761                          g_signal_accumulator_true_handled, 0,
2762                          webkit_marshal_BOOLEAN__OBJECT,
2763                          G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2764
2765
2766     /**
2767      * WebKitWebView::leaving-fullscreen:
2768      * @web_view: the #WebKitWebView on which the signal is emitted.
2769      * @element: the #WebKitDOMHTMLElement which is currently displayed full screen.
2770      *
2771      * Emitted when the WebView is about to restore its top level
2772      * window out of its full screen state. This signal can be used by
2773      * client code to restore widgets hidden during the
2774      * entering-fullscreen stage for instance.
2775      *
2776      * Returns: %TRUE to stop other handlers from being invoked for the event.
2777      *    %FALSE to continue emission of the event.
2778      *
2779      * Since: 1.9.0
2780      */
2781     webkit_web_view_signals[LEAVING_FULLSCREEN] =
2782             g_signal_new("leaving-fullscreen",
2783                          G_TYPE_FROM_CLASS(webViewClass),
2784                          G_SIGNAL_RUN_LAST,
2785                          G_STRUCT_OFFSET(WebKitWebViewClass, leaving_fullscreen),
2786                          g_signal_accumulator_true_handled, 0,
2787                          webkit_marshal_BOOLEAN__OBJECT,
2788                          G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2789
2790     /**
2791      * WebKitWebView::resource-response-received:
2792      * @web_view: the object which received the signal
2793      * @web_frame: the #WebKitWebFrame the response was received for
2794      * @web_resource: the #WebKitWebResource being loaded
2795      * @response: the #WebKitNetworkResponse that was received
2796      *
2797      * Emitted when the first byte of data arrives
2798      *
2799      * Since: 1.7.5
2800      */
2801     webkit_web_view_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received",
2802             G_TYPE_FROM_CLASS(webViewClass),
2803             G_SIGNAL_RUN_LAST,
2804             0,
2805             0, 0,
2806             webkit_marshal_VOID__OBJECT_OBJECT_OBJECT,
2807             G_TYPE_NONE, 3,
2808             WEBKIT_TYPE_WEB_FRAME,
2809             WEBKIT_TYPE_WEB_RESOURCE,
2810             WEBKIT_TYPE_NETWORK_RESPONSE);
2811
2812     /**
2813      * WebKitWebView::resource-load-finished:
2814      * @web_view: the object which received the signal
2815      * @web_frame: the #WebKitWebFrame the response was received for
2816      * @web_resource: the #WebKitWebResource that was loaded
2817      *
2818      * Emitted when all the data for the resource was loaded
2819      *
2820      * Since: 1.7.5
2821      */
2822     webkit_web_view_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished",
2823             G_TYPE_FROM_CLASS(webViewClass),
2824             G_SIGNAL_RUN_LAST,
2825             0,
2826             0, 0,
2827             webkit_marshal_VOID__OBJECT_OBJECT,
2828             G_TYPE_NONE, 2,
2829             WEBKIT_TYPE_WEB_FRAME,
2830             WEBKIT_TYPE_WEB_RESOURCE);
2831
2832     /**
2833      * WebKitWebView::resource-content-length-received:
2834      * @web_view: the object which received the signal
2835      * @web_frame: the #WebKitWebFrame the response was received for
2836      * @web_resource: the #WebKitWebResource that was loaded
2837      * @length_received: the amount of data received since the last signal emission
2838      *
2839      * Emitted when new resource data has been received. The
2840      * @length_received variable stores the amount of bytes received
2841      * since the last time this signal was emitted. This is useful to
2842      * provide progress information about the resource load operation.
2843      *
2844      * Since: 1.7.5
2845      */
2846     webkit_web_view_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received",
2847             G_TYPE_FROM_CLASS(webViewClass),
2848             G_SIGNAL_RUN_LAST,
2849             0,
2850             0, 0,
2851             webkit_marshal_VOID__OBJECT_OBJECT_INT,
2852             G_TYPE_NONE, 3,
2853             WEBKIT_TYPE_WEB_FRAME,
2854             WEBKIT_TYPE_WEB_RESOURCE,
2855             G_TYPE_INT);
2856
2857     /**
2858      * WebKitWebView::resource-load-failed:
2859      * @web_view: the object which received the signal
2860      * @web_frame: the #WebKitWebFrame the response was received for
2861      * @web_resource: the #WebKitWebResource that was loaded
2862      * @error: the #GError that was triggered
2863      *
2864      * Invoked when a resource failed to load
2865      *
2866      * Since: 1.7.5
2867      */
2868     webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed",
2869             G_TYPE_FROM_CLASS(webViewClass),
2870             G_SIGNAL_RUN_LAST,
2871             0,
2872             0, 0,
2873             webkit_marshal_VOID__OBJECT_OBJECT_BOXED,
2874             G_TYPE_NONE, 3,
2875             WEBKIT_TYPE_WEB_FRAME,
2876             WEBKIT_TYPE_WEB_RESOURCE,
2877             G_TYPE_ERROR);
2878
2879     /**
2880      * WebKitWebView::context-menu:
2881      * @web_view: the object which received the signal
2882      * @default_menu: the default context menu
2883      * @hit_test_result: a #WebKitHitTestResult with the context of the current position.
2884      * @triggered_with_keyboard: %TRUE if the context menu was triggered using the keyboard
2885      *
2886      * Emmited when a context menu is about to be displayed to give the application
2887      * a chance to create and handle its own context menu. If you only want to add custom
2888      * options to the default context menu you can simply modify the given @default_menu.
2889      *
2890      * When @triggered_with_keyboard is %TRUE the coordinates of the given @hit_test_result should be
2891      * used to position the popup menu. When the context menu has been triggered by a
2892      * mouse event you could either use the @hit_test_result coordinates or pass %NULL
2893      * to the #GtkMenuPositionFunc parameter of gtk_menu_popup() function.
2894      * Note that coordinates of @hit_test_result are relative to @web_view window.
2895      *
2896      * If your application will create and display its own popup menu, %TRUE should be returned.
2897      * Note that when the context menu is handled by the application, the #WebKitWebSettings:enable-default-context-menu
2898      * setting will be ignored and the #WebKitWebView::populate-popup signal won't be emitted.
2899      * If you don't want any context menu to be shown, you can simply connect to this signal
2900      * and return %TRUE without doing anything else.
2901      *
2902      * Since: 1.10
2903      */
2904     webkit_web_view_signals[CONTEXT_MENU] = g_signal_new("context-menu",
2905             G_TYPE_FROM_CLASS(webViewClass),
2906             G_SIGNAL_RUN_LAST,
2907             0, 0, 0,
2908             webkit_marshal_BOOLEAN__OBJECT_OBJECT_BOOLEAN,
2909             G_TYPE_BOOLEAN, 3,
2910             GTK_TYPE_WIDGET,
2911             WEBKIT_TYPE_HIT_TEST_RESULT,
2912             G_TYPE_BOOLEAN);
2913
2914     /*
2915      * implementations of virtual methods
2916      */
2917     webViewClass->create_web_view = webkit_web_view_real_create_web_view;
2918     webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
2919     webViewClass->close_web_view = webkit_web_view_real_close_web_view;
2920     webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
2921     webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
2922     webViewClass->choose_file = webkit_web_view_real_choose_file;
2923     webViewClass->script_alert = webkit_web_view_real_script_alert;
2924     webViewClass->script_confirm = webkit_web_view_real_script_confirm;
2925     webViewClass->script_prompt = webkit_web_view_real_script_prompt;
2926     webViewClass->console_message = webkit_web_view_real_console_message;
2927     webViewClass->select_all = webkit_web_view_real_select_all;
2928     webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
2929     webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
2930     webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
2931     webViewClass->undo = webkit_web_view_real_undo;
2932     webViewClass->redo = webkit_web_view_real_redo;
2933     webViewClass->move_cursor = webkit_web_view_real_move_cursor;
2934     webViewClass->should_allow_editing_action = webkit_web_view_real_should_allow_editing_action;
2935     webViewClass->entering_fullscreen = webkit_web_view_real_entering_fullscreen;
2936     webViewClass->leaving_fullscreen = webkit_web_view_real_leaving_fullscreen;
2937     webViewClass->run_file_chooser = webkitWebViewRealRunFileChooser;
2938
2939     GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
2940     objectClass->dispose = webkit_web_view_dispose;
2941     objectClass->finalize = webkit_web_view_finalize;
2942     objectClass->get_property = webkit_web_view_get_property;
2943     objectClass->set_property = webkit_web_view_set_property;
2944
2945     GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass);
2946     widgetClass->realize = webkit_web_view_realize;
2947 #ifdef GTK_API_VERSION_2
2948     widgetClass->expose_event = webkit_web_view_expose_event;
2949 #else
2950     widgetClass->draw = webkit_web_view_draw;
2951 #endif
2952     widgetClass->key_press_event = webkit_web_view_key_press_event;
2953     widgetClass->key_release_event = webkit_web_view_key_release_event;
2954     widgetClass->button_press_event = webkit_web_view_button_press_event;
2955     widgetClass->button_release_event = webkit_web_view_button_release_event;
2956     widgetClass->motion_notify_event = webkit_web_view_motion_event;
2957     widgetClass->scroll_event = webkit_web_view_scroll_event;
2958     widgetClass->size_allocate = webkit_web_view_size_allocate;
2959 #ifdef GTK_API_VERSION_2
2960     widgetClass->size_request = webkit_web_view_size_request;
2961 #else
2962     widgetClass->get_preferred_width = webkit_web_view_get_preferred_width;
2963     widgetClass->get_preferred_height = webkit_web_view_get_preferred_height;
2964 #endif
2965 #if ENABLE(CONTEXT_MENUS)
2966     widgetClass->popup_menu = webkit_web_view_popup_menu_handler;
2967 #else
2968     widgetClass->popup_menu = NULL;
2969 #endif
2970     widgetClass->grab_focus = webkit_web_view_grab_focus;
2971     widgetClass->focus_in_event = webkit_web_view_focus_in_event;
2972     widgetClass->focus_out_event = webkit_web_view_focus_out_event;
2973     widgetClass->get_accessible = webkit_web_view_get_accessible;
2974     widgetClass->screen_changed = webkit_web_view_screen_changed;
2975     widgetClass->drag_end = webkit_web_view_drag_end;
2976     widgetClass->drag_data_get = webkit_web_view_drag_data_get;
2977     widgetClass->drag_motion = webkit_web_view_drag_motion;
2978     widgetClass->drag_leave = webkit_web_view_drag_leave;
2979     widgetClass->drag_drop = webkit_web_view_drag_drop;
2980     widgetClass->drag_data_received = webkit_web_view_drag_data_received;
2981 #if GTK_CHECK_VERSION(2, 12, 0)
2982     widgetClass->query_tooltip = webkit_web_view_query_tooltip;
2983     widgetClass->show_help = webkit_web_view_show_help;
2984 #endif
2985     widgetClass->map = webkitWebViewMap;
2986
2987     GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
2988     containerClass->add = webkit_web_view_container_add;
2989     containerClass->remove = webkit_web_view_container_remove;
2990     containerClass->forall = webkit_web_view_container_forall;
2991
2992     /*
2993      * make us scrollable (e.g. addable to a GtkScrolledWindow)
2994      */
2995 #ifdef GTK_API_VERSION_2
2996     webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments;
2997     GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments",
2998             G_TYPE_FROM_CLASS(webViewClass),
2999             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
3000             G_STRUCT_OFFSET(WebKitWebViewClass, set_scroll_adjustments),
3001             NULL, NULL,
3002             webkit_marshal_VOID__OBJECT_OBJECT,
3003             G_TYPE_NONE, 2,
3004             GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
3005 #else
3006     g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment");
3007     g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment");
3008     g_object_class_override_property(objectClass, PROP_HSCROLL_POLICY, "hscroll-policy");
3009     g_object_class_override_property(objectClass, PROP_VSCROLL_POLICY, "vscroll-policy");
3010 #endif
3011
3012     /*
3013      * Key bindings
3014      */
3015
3016     binding_set = gtk_binding_set_by_class(webViewClass);
3017
3018     gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK,
3019                                  "select_all", 0);
3020
3021     /* Cut/copy/paste */
3022
3023     gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK,
3024                                  "cut_clipboard", 0);
3025     gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK,
3026                                  "copy_clipboard", 0);
3027     gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK,
3028                                  "paste_clipboard", 0);
3029     gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK,
3030                                  "undo", 0);
3031     gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
3032                                  "redo", 0);
3033
3034     gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK,
3035                                  "cut_clipboard", 0);
3036     gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK,
3037                                  "copy_clipboard", 0);
3038     gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
3039                                  "paste_clipboard", 0);
3040
3041     /* Movement */
3042     
3043     gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0),
3044                                  "move-cursor", 2,
3045                                  G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
3046                                  G_TYPE_INT, 1);
3047     gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0),
3048                                  "move-cursor", 2,
3049                                  G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
3050                                  G_TYPE_INT, -1);
3051     gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0),
3052                                  "move-cursor", 2,
3053                                  G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
3054                                  G_TYPE_INT, 1);
3055     gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0),
3056                                  "move-cursor", 2,
3057                                  G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
3058                                  G_TYPE_INT, -1);
3059     gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0),
3060                                  "move-cursor", 2,
3061                                  G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3062                                  G_TYPE_INT, 1);
3063     gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK,
3064                                  "move-cursor", 2,
3065                                  G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3066                                  G_TYPE_INT, -1);
3067     gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0),
3068                                  "move-cursor", 2,
3069                                  G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3070                                  G_TYPE_INT, 1);
3071     gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0),
3072                                  "move-cursor", 2,
3073                                  G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3074                                  G_TYPE_INT, -1);
3075     gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0),
3076                                  "move-cursor", 2,
3077                                  G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
3078                                  G_TYPE_INT, 1);
3079     gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0),
3080                                  "move-cursor", 2,
3081                                  G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
3082                                  G_TYPE_INT, -1);
3083
3084     /*
3085      * properties
3086      */
3087
3088     /**
3089     * WebKitWebView:title:
3090     *
3091     * Returns: the @web_view's document title.
3092     *
3093     * Since: 1.1.4
3094     */
3095     g_object_class_install_property(objectClass, PROP_TITLE,
3096                                     g_param_spec_string("title",
3097                                                         _("Title"),
3098                                                         _("Returns the @web_view's document title"),
3099                                                         NULL,
3100                                                         WEBKIT_PARAM_READABLE));
3101
3102     /**
3103     * WebKitWebView:uri:
3104     *
3105     * Returns: the current URI of the contents displayed by the @web_view.
3106     *
3107     * Since: 1.1.4
3108     */
3109     g_object_class_install_property(objectClass, PROP_URI,
3110                                     g_param_spec_string("uri",
3111                                                         _("URI"),
3112                                                         _("Returns the current URI of the contents displayed by the @web_view"),
3113                                                         NULL,
3114                                                         WEBKIT_PARAM_READABLE));
3115
3116     /**
3117     * WebKitWebView:copy-target-list:
3118     *
3119     * The list of targets this web view supports for clipboard copying.
3120     *
3121     * Since: 1.0.2
3122     */
3123     g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
3124                                     g_param_spec_boxed("copy-target-list",
3125                                                        _("Copy target list"),
3126                                                        _("The list of targets this web view supports for clipboard copying"),
3127                                                        GTK_TYPE_TARGET_LIST,
3128                                                        WEBKIT_PARAM_READABLE));
3129
3130     /**
3131     * WebKitWebView:paste-target-list:
3132     *
3133     * The list of targets this web view supports for clipboard pasting.
3134     *
3135     * Since: 1.0.2
3136     */
3137     g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
3138                                     g_param_spec_boxed("paste-target-list",
3139                                                        _("Paste target list"),
3140                                                        _("The list of targets this web view supports for clipboard pasting"),
3141                                                        GTK_TYPE_TARGET_LIST,
3142                                                        WEBKIT_PARAM_READABLE));
3143
3144     g_object_class_install_property(objectClass, PROP_SETTINGS,
3145                                     g_param_spec_object("settings",
3146                                                         _("Settings"),
3147                                                         _("An associated WebKitWebSettings instance"),
3148                                                         WEBKIT_TYPE_WEB_SETTINGS,
3149                                                         WEBKIT_PARAM_READWRITE));
3150
3151     /**
3152     * WebKitWebView:web-inspector:
3153     *
3154     * The associated WebKitWebInspector instance.
3155     *
3156     * Since: 1.0.3
3157     */
3158     g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
3159                                     g_param_spec_object("web-inspector",
3160                                                         _("Web Inspector"),
3161                                                         _("The associated WebKitWebInspector instance"),
3162                                                         WEBKIT_TYPE_WEB_INSPECTOR,
3163                                                         WEBKIT_PARAM_READABLE));
3164
3165     /**
3166     * WebKitWebView:viewport-attributes:
3167     *
3168     * The associated #WebKitViewportAttributes instance.
3169     *
3170     * Since: 1.3.8
3171     */
3172     g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES,
3173                                     g_param_spec_object("viewport-attributes",
3174                                                         _("Viewport Attributes"),
3175                                                         _("The associated WebKitViewportAttributes instance"),
3176                                                         WEBKIT_TYPE_VIEWPORT_ATTRIBUTES,
3177                                                         WEBKIT_PARAM_READABLE));
3178
3179     /**
3180     * WebKitWebView:window-features:
3181     *
3182     * An associated WebKitWebWindowFeatures instance.
3183     *
3184     * Since: 1.0.3
3185     */
3186     g_object_class_install_property(objectClass, PROP_WINDOW_FEATURES,
3187                                     g_param_spec_object("window-features",
3188                                                         "Window Features",
3189                                                         "An associated WebKitWebWindowFeatures instance",
3190                                                         WEBKIT_TYPE_WEB_WINDOW_FEATURES,
3191                                                         WEBKIT_PARAM_READWRITE));
3192
3193     g_object_class_install_property(objectClass, PROP_EDITABLE,
3194                                     g_param_spec_boolean("editable",
3195                                                          _("Editable"),
3196                                                          _("Whether content can be modified by the user"),
3197                                                          FALSE,
3198                                                          WEBKIT_PARAM_READWRITE));
3199
3200     g_object_class_install_property(objectClass, PROP_TRANSPARENT,
3201                                     g_param_spec_boolean("transparent",
3202                                                          _("Transparent"),
3203                                                          _("Whether content has a transparent background"),
3204                                                          FALSE,
3205                                                          WEBKIT_PARAM_READWRITE));
3206
3207     /**
3208     * WebKitWebView:zoom-level:
3209     *
3210     * The level of zoom of the content.
3211     *
3212     * Since: 1.0.1
3213     */
3214     g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
3215                                     g_param_spec_float("zoom-level",
3216                                                        _("Zoom level"),
3217                                                        _("The level of zoom of the content"),
3218                                                        G_MINFLOAT,
3219                                                        G_MAXFLOAT,
3220                                                        1.0f,
3221                                                        WEBKIT_PARAM_READWRITE));
3222
3223     /**
3224     * WebKitWebView:full-content-zoom:
3225     *
3226     * Whether the full content is scaled when zooming.
3227     *
3228     * Since: 1.0.1
3229     */
3230     g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM,
3231                                     g_param_spec_boolean("full-content-zoom",
3232                                                          _("Full content zoom"),
3233                                                          _("Whether the full content is scaled when zooming"),
3234                                                          FALSE,
3235                                                          WEBKIT_PARAM_READWRITE));
3236
3237     /**
3238      * WebKitWebView:encoding:
3239      *
3240      * The default encoding of the web view.
3241      *
3242      * Since: 1.1.2
3243      */
3244     g_object_class_install_property(objectClass, PROP_ENCODING,
3245                                     g_param_spec_string("encoding",
3246                                                         _("Encoding"),
3247                                                         _("The default encoding of the web view"),
3248                                                         NULL,
3249                                                         WEBKIT_PARAM_READABLE));
3250
3251     /**
3252      * WebKitWebView:custom-encoding:
3253      *
3254      * The custom encoding of the web view.
3255      *
3256      * Since: 1.1.2
3257      */
3258     g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING,
3259                                     g_param_spec_string("custom-encoding",
3260                                                         _("Custom Encoding"),
3261                                                         _("The custom encoding of the web view"),
3262                                                         NULL,
3263                                                         WEBKIT_PARAM_READWRITE));
3264
3265     /**
3266     * WebKitWebView:load-status:
3267     *
3268     * Determines the current status of the load.
3269     *
3270     * Connect to "notify::load-status" to monitor loading.
3271     *
3272     * Some versions of WebKitGTK+ emitted this signal for the default
3273     * error page, while loading it. This behavior was considered bad,
3274     * because it was essentially exposing an implementation
3275     * detail. From 1.1.19 onwards this signal is no longer emitted for
3276     * the default error pages, but keep in mind that if you override
3277     * the error pages by using webkit_web_frame_load_alternate_string()
3278     * the signals will be emitted.
3279     *
3280     * Since: 1.1.7
3281     */
3282     g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
3283                                     g_param_spec_enum("load-status",
3284                                                       "Load Status",
3285                                                       "Determines the current status of the load",
3286                                                       WEBKIT_TYPE_LOAD_STATUS,
3287                                                     &