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