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