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