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