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