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