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