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