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