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