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