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