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