2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
3 * Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com>
4 * Copyright (C) 2007 Xan Lopez <xan@gnome.org>
5 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
7 * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
8 * Copyright (C) 2008 Nuanti Ltd.
9 * Copyright (C) 2008, 2009, 2010 Collabora Ltd.
10 * Copyright (C) 2009, 2010, 2012 Igalia S.L.
11 * Copyright (C) 2009 Movial Creative Technologies Inc.
12 * Copyright (C) 2009 Bobby Powers
13 * Copyright (C) 2010 Joone Hur <joone@kldp.org>
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include "webkitwebview.h"
33 #include "AXObjectCache.h"
34 #include "AbstractDatabase.h"
35 #include "BackForwardListImpl.h"
36 #include "CairoUtilities.h"
38 #include "ChromeClientGtk.h"
39 #include "ClipboardUtilitiesGtk.h"
40 #include "ContextMenu.h"
41 #include "ContextMenuClientGtk.h"
42 #include "ContextMenuController.h"
45 #include "DocumentLoader.h"
46 #include "DragActions.h"
47 #include "DragClientGtk.h"
48 #include "DragController.h"
50 #include "DragSession.h"
51 #include "DumpRenderTreeSupportGtk.h"
53 #include "EditorClientGtk.h"
54 #include "EventHandler.h"
55 #include "FloatQuad.h"
56 #include "FocusController.h"
57 #include "FrameLoader.h"
58 #include "FrameLoaderClient.h"
59 #include "FrameLoaderTypes.h"
60 #include "FrameView.h"
61 #include "GeolocationClientGtk.h"
62 #include "GeolocationClientMock.h"
63 #include "GOwnPtrGtk.h"
64 #include "GraphicsContext.h"
65 #include "GtkUtilities.h"
66 #include "GtkVersioning.h"
67 #include "HTMLNames.h"
68 #include "HitTestRequest.h"
69 #include "HitTestResult.h"
70 #include "IconDatabase.h"
71 #include "InspectorClientGtk.h"
72 #include "MemoryCache.h"
73 #include "MouseEventWithHitTestResults.h"
74 #include "NotImplemented.h"
75 #include "PageCache.h"
76 #include "Pasteboard.h"
77 #include "PasteboardHelper.h"
78 #include "PlatformKeyboardEvent.h"
79 #include "PlatformWheelEvent.h"
80 #include "ProgressTracker.h"
81 #include "RenderView.h"
82 #include "ResourceHandle.h"
83 #include "ScriptValue.h"
85 #include "webkit/WebKitDOMDocumentPrivate.h"
86 #include "webkitdownload.h"
87 #include "webkitdownloadprivate.h"
88 #include "webkitenumtypes.h"
89 #include "webkitgeolocationpolicydecision.h"
90 #include "webkitglobalsprivate.h"
91 #include "webkithittestresultprivate.h"
92 #include "webkiticondatabase.h"
93 #include "webkitmarshal.h"
94 #include "webkitnetworkrequest.h"
95 #include "webkitnetworkresponse.h"
96 #include "webkitviewportattributes.h"
97 #include "webkitviewportattributesprivate.h"
98 #include "webkitwebbackforwardlist.h"
99 #include "webkitwebframeprivate.h"
100 #include "webkitwebhistoryitem.h"
101 #include "webkitwebhistoryitemprivate.h"
102 #include "webkitwebinspector.h"
103 #include "webkitwebinspectorprivate.h"
104 #include "webkitwebpolicydecision.h"
105 #include "webkitwebresource.h"
106 #include "webkitwebsettingsprivate.h"
107 #include "webkitwebplugindatabaseprivate.h"
108 #include "webkitwebwindowfeatures.h"
109 #include "webkitwebviewprivate.h"
110 #include <gdk/gdkkeysyms.h>
111 #include <glib/gi18n-lib.h>
112 #include <wtf/gobject/GOwnPtr.h>
113 #include <wtf/text/CString.h>
115 #if ENABLE(DEVICE_ORIENTATION)
116 #include "DeviceMotionClientGtk.h"
117 #include "DeviceOrientationClientGtk.h"
121 * SECTION:webkitwebview
122 * @short_description: The central class of the WebKitGTK+ API
123 * @see_also: #WebKitWebSettings, #WebKitWebFrame
125 * #WebKitWebView is the central class of the WebKitGTK+ API. It is a
126 * #GtkWidget implementing the scrolling interface which means you can
127 * embed in a #GtkScrolledWindow. It is responsible for managing the
128 * drawing of the content, forwarding of events. You can load any URI
129 * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings
130 * you can control various aspects of the rendering and loading of the content.
131 * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A
132 * #WebKitWebFrame can have n children.
135 * /<!-- -->* Create the widgets *<!-- -->/
136 * GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
137 * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
138 * GtkWidget *web_view = webkit_web_view_new ();
140 * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/
141 * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
142 * gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
144 * /<!-- -->* Open a webpage *<!-- -->/
145 * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
147 * /<!-- -->* Show the result *<!-- -->/
148 * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
149 * gtk_widget_show_all (main_window);
153 using namespace WebKit;
154 using namespace WebCore;
158 NAVIGATION_REQUESTED,
159 NEW_WINDOW_POLICY_DECISION_REQUESTED,
160 NAVIGATION_POLICY_DECISION_REQUESTED,
161 MIME_TYPE_POLICY_DECISION_REQUESTED,
164 WINDOW_OBJECT_CLEARED,
167 LOAD_PROGRESS_CHANGED,
173 STATUS_BAR_TEXT_CHANGED,
191 DATABASE_QUOTA_EXCEEDED,
192 RESOURCE_REQUEST_STARTING,
193 DOCUMENT_LOAD_FINISHED,
194 GEOLOCATION_POLICY_DECISION_REQUESTED,
195 GEOLOCATION_POLICY_DECISION_CANCELLED,
198 SHOULD_BEGIN_EDITING,
203 SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT,
204 SHOULD_CHANGE_SELECTED_RANGE,
207 USER_CHANGED_CONTENTS,
209 VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED,
210 VIEWPORT_ATTRIBUTES_CHANGED,
211 RESOURCE_RESPONSE_RECEIVED,
212 RESOURCE_LOAD_FINISHED,
213 RESOURCE_CONTENT_LENGTH_RECEIVED,
214 RESOURCE_LOAD_FAILED,
224 PROP_COPY_TARGET_LIST,
225 PROP_PASTE_TARGET_LIST,
229 PROP_VIEWPORT_ATTRIBUTES,
230 PROP_WINDOW_FEATURES,
233 PROP_FULL_CONTENT_ZOOM,
237 PROP_CUSTOM_ENCODING,
240 #ifdef GTK_API_VERSION_2
250 // Undocumented. Leave these properties at the end of the list
251 // so that we can remove them without breaking ABI compatibility.
255 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
257 #ifdef GTK_API_VERSION_2
258 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
260 G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
261 G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0))
264 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
265 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
267 static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView*);
269 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
271 WebKitWebView* view = WEBKIT_WEB_VIEW(userData);
272 WebKitWebViewPrivate* priv = view->priv;
273 GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view));
274 GtkRequisition menuSize;
276 #ifdef GTK_API_VERSION_2
277 gtk_widget_size_request(GTK_WIDGET(menu), &menuSize);
279 gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, NULL);
282 *x = priv->lastPopupXPosition;
283 if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
284 *x -= menuSize.width;
286 *y = priv->lastPopupYPosition;
287 if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
288 *y -= menuSize.height;
293 static Node* getFocusedNode(Frame* frame)
295 if (Document* doc = frame->document())
296 return doc->focusedNode();
300 static void contextMenuItemActivated(GtkMenuItem* item, ContextMenuController* controller)
302 ContextMenuItem contextItem(item);
303 controller->contextMenuItemSelected(&contextItem);
306 static void contextMenuConnectActivate(GtkMenuItem* item, ContextMenuController* controller)
308 if (GTK_IS_SEPARATOR_MENU_ITEM(item))
311 if (GtkWidget* menu = gtk_menu_item_get_submenu(item)) {
312 gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller);
316 g_signal_connect(item, "activate", G_CALLBACK(contextMenuItemActivated), controller);
319 static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
321 Page* page = core(webView);
322 page->contextMenuController()->clearContextMenu();
324 Frame* mainFrame = page->mainFrame();
325 gboolean mousePressEventResult = FALSE;
327 if (!mainFrame->view())
330 mainFrame->view()->setCursor(pointerCursor());
331 if (page->frameCount()) {
332 HitTestRequest request(HitTestRequest::Active);
333 IntPoint point = mainFrame->view()->windowToContents(event.position());
334 MouseEventWithHitTestResults mev = mainFrame->document()->prepareMouseEvent(request, point, event);
336 Frame* targetFrame = EventHandler::subframeForHitTestResult(mev);
338 targetFrame = mainFrame;
340 focusedFrame = page->focusController()->focusedOrMainFrame();
341 if (targetFrame != focusedFrame) {
342 page->focusController()->setFocusedFrame(targetFrame);
343 focusedFrame = targetFrame;
346 focusedFrame = mainFrame;
348 if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event))
349 mousePressEventResult = TRUE;
352 bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event);
356 // If coreMenu is NULL, this means WebCore decided to not create
357 // the default context menu; this may happen when the page is
358 // handling the right-click for reasons other than the context menu.
359 ContextMenuController* controller = page->contextMenuController();
360 ContextMenu* coreMenu = controller->contextMenu();
362 return mousePressEventResult;
364 // If we reach here, it's because WebCore is going to show the
365 // default context menu. We check our setting to figure out
366 // whether we want it or not.
367 WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
368 gboolean enableDefaultContextMenu;
369 g_object_get(settings, "enable-default-context-menu", &enableDefaultContextMenu, NULL);
371 if (!enableDefaultContextMenu)
374 GtkMenu* menu = GTK_MENU(coreMenu->platformDescription());
378 // We connect the "activate" signal here rather than in ContextMenuGtk to avoid
379 // a layering violation. ContextMenuGtk should not know about the ContextMenuController.
380 gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller);
382 g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, menu);
384 // If the context menu is now empty, don't show it.
385 GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(menu)));
389 WebKitWebViewPrivate* priv = webView->priv;
390 priv->currentMenu = menu;
391 priv->lastPopupXPosition = event.globalPosition().x();
392 priv->lastPopupYPosition = event.globalPosition().y();
394 gtk_menu_popup(menu, 0, 0, &PopupMenuPositionFunc, webView, event.button() + 1, gtk_get_current_event_time());
398 static const int gContextMenuMargin = 1;
399 static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame)
401 FrameSelection* selection = frame->selection();
402 if (!selection->selection().isNonOrphanedCaretOrRange()
403 || (selection->selection().isCaret() && !selection->selection().isContentEditable())) {
404 if (Node* focusedNode = getFocusedNode(frame))
405 return focusedNode->getRect().location();
407 // There was no selection and no focused node, so just put the context
408 // menu into the corner of the view, offset slightly.
409 return IntPoint(gContextMenuMargin, gContextMenuMargin);
412 // selection->selection().firstRange can return 0 here, but if that was the case
413 // selection->selection().isNonOrphanedCaretOrRange() would have returned false
414 // above, so we do not have to check it.
415 IntRect firstRect = frame->editor()->firstRectForRange(selection->selection().firstRange().get());
416 return IntPoint(firstRect.x(), firstRect.maxY());
419 static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
421 Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController()->focusedOrMainFrame();
422 IntPoint location = getLocationForKeyboardGeneratedContextMenu(frame);
424 FrameView* view = frame->view();
428 // Never let the context menu touch the very edge of the view.
429 location = view->contentsToWindow(location);
430 location.expandedTo(IntPoint(gContextMenuMargin, gContextMenuMargin));
431 location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin));
433 IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location));
434 PlatformMouseEvent event(location, globalPoint, RightButton, PlatformEvent::MousePressed, 0, false, false, false, false, gtk_get_current_event_time());
435 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
438 static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
440 // This may be called after the page has been destroyed, in which case we do nothing.
441 Page* page = core(webView);
443 static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setHorizontalAdjustment(adjustment);
446 static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
448 // This may be called after the page has been destroyed, in which case we do nothing.
449 Page* page = core(webView);
451 static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->setVerticalAdjustment(adjustment);
454 #ifndef GTK_API_VERSION_2
455 static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
457 Page* page = core(webView);
459 return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->horizontalAdjustment();
463 static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
465 Page* page = core(webView);
467 return static_cast<WebKit::ChromeClient*>(page->chrome()->client())->adjustmentWatcher()->verticalAdjustment();
471 static void setHorizontalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
473 webView->priv->horizontalScrollingPolicy = policy;
474 gtk_widget_queue_resize(GTK_WIDGET(webView));
477 static void setVerticalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
479 webView->priv->verticalScrollingPolicy = policy;
480 gtk_widget_queue_resize(GTK_WIDGET(webView));
483 static GtkScrollablePolicy getHorizontalScrollPolicy(WebKitWebView* webView)
485 return webView->priv->horizontalScrollingPolicy;
488 static GtkScrollablePolicy getVerticalScrollPolicy(WebKitWebView* webView)
490 return webView->priv->verticalScrollingPolicy;
495 static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
497 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
501 g_value_set_string(value, webkit_web_view_get_title(webView));
504 g_value_set_string(value, webkit_web_view_get_uri(webView));
506 case PROP_COPY_TARGET_LIST:
507 g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView));
509 case PROP_PASTE_TARGET_LIST:
510 g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
513 g_value_set_boolean(value, webkit_web_view_get_editable(webView));
516 g_value_set_object(value, webkit_web_view_get_settings(webView));
518 case PROP_WEB_INSPECTOR:
519 g_value_set_object(value, webkit_web_view_get_inspector(webView));
521 case PROP_VIEWPORT_ATTRIBUTES:
522 g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView));
524 case PROP_WINDOW_FEATURES:
525 g_value_set_object(value, webkit_web_view_get_window_features(webView));
527 case PROP_TRANSPARENT:
528 g_value_set_boolean(value, webkit_web_view_get_transparent(webView));
530 case PROP_ZOOM_LEVEL:
531 g_value_set_float(value, webkit_web_view_get_zoom_level(webView));
533 case PROP_FULL_CONTENT_ZOOM:
534 g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView));
537 g_value_set_string(value, webkit_web_view_get_encoding(webView));
539 case PROP_CUSTOM_ENCODING:
540 g_value_set_string(value, webkit_web_view_get_custom_encoding(webView));
542 case PROP_LOAD_STATUS:
543 g_value_set_enum(value, webkit_web_view_get_load_status(webView));
546 g_value_set_double(value, webkit_web_view_get_progress(webView));
549 g_value_set_string(value, webkit_web_view_get_icon_uri(webView));
551 case PROP_IM_CONTEXT:
552 g_value_set_object(value, webkit_web_view_get_im_context(webView));
555 g_value_set_enum(value, webkit_web_view_get_view_mode(webView));
557 #ifndef GTK_API_VERSION_2
558 case PROP_HADJUSTMENT:
559 g_value_set_object(value, getHorizontalAdjustment(webView));
561 case PROP_VADJUSTMENT:
562 g_value_set_object(value, getVerticalAdjustment(webView));
564 case PROP_HSCROLL_POLICY:
565 g_value_set_enum(value, getHorizontalScrollPolicy(webView));
567 case PROP_VSCROLL_POLICY:
568 g_value_set_enum(value, getVerticalScrollPolicy(webView));
571 case PROP_SELF_SCROLLING:
572 g_value_set_boolean(value, webView->priv->selfScrolling);
575 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
579 static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec)
581 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
585 webkit_web_view_set_editable(webView, g_value_get_boolean(value));
588 webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value)));
590 case PROP_WINDOW_FEATURES:
591 webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value)));
593 case PROP_TRANSPARENT:
594 webkit_web_view_set_transparent(webView, g_value_get_boolean(value));
596 case PROP_ZOOM_LEVEL:
597 webkit_web_view_set_zoom_level(webView, g_value_get_float(value));
599 case PROP_FULL_CONTENT_ZOOM:
600 webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value));
602 case PROP_CUSTOM_ENCODING:
603 webkit_web_view_set_custom_encoding(webView, g_value_get_string(value));
606 webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value)));
608 #ifndef GTK_API_VERSION_2
609 case PROP_HADJUSTMENT:
610 setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
612 case PROP_VADJUSTMENT:
613 setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
615 case PROP_HSCROLL_POLICY:
616 setHorizontalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
618 case PROP_VSCROLL_POLICY:
619 setVerticalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
622 case PROP_SELF_SCROLLING:
623 webView->priv->selfScrolling = g_value_get_boolean(value);
626 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
630 #ifdef GTK_API_VERSION_2
631 static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
634 GOwnPtr<GdkRectangle> rects;
635 gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
637 RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window));
638 for (int i = 0; i < rectCount; i++) {
639 copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(),
640 cr.get(), IntSize(), IntRect(rects.get()[i]));
643 // Chaining up to the parent forces child widgets to be drawn.
644 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->expose_event(widget, event);
648 static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
650 GdkRectangle clipRect;
651 if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
654 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
655 #if USE(TEXTURE_MAPPER_GL)
656 if (priv->acceleratedCompositingContext->renderLayersToWindow(clipRect))
660 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
661 if (rectList->status || !rectList->num_rectangles) {
662 cairo_rectangle_list_destroy(rectList);
666 Vector<IntRect> rects;
667 for (int i = 0; i < rectList->num_rectangles; i++) {
668 copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(),
669 enclosingIntRect(FloatRect(rectList->rectangles[i])));
671 cairo_rectangle_list_destroy(rectList);
673 // Chaining up to the parent forces child widgets to be drawn.
674 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr);
677 #endif // GTK_API_VERSION_2
679 static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event)
681 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
683 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
684 PlatformKeyboardEvent keyboardEvent(event);
689 if (frame->eventHandler()->keyEvent(keyboardEvent))
692 /* Chain up to our parent class for binding activation */
693 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event);
696 static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event)
698 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
700 // GTK+ IM contexts often require us to filter key release events, which
701 // WebCore does not do by default, so we filter the event here. We only block
702 // the event if we don't have a pending composition, because that means we
703 // are using a context like 'simple' which marks every keystroke as filtered.
704 WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient());
705 if (gtk_im_context_filter_keypress(webView->priv->imContext.get(), event) && !client->hasPendingComposition())
708 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
712 PlatformKeyboardEvent keyboardEvent(event);
713 if (frame->eventHandler()->keyEvent(keyboardEvent))
716 /* Chain up to our parent class for binding activation */
717 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event);
720 static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
722 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
723 WebKitWebViewPrivate* priv = webView->priv;
725 // FIXME: need to keep track of subframe focus for key events
726 gtk_widget_grab_focus(widget);
728 if (!priv->clickCounter.shouldProcessButtonEvent(event))
731 PlatformMouseEvent platformEvent(event);
732 int count = priv->clickCounter.clickCountForGdkButtonEvent(widget, event);
733 platformEvent.setClickCount(count);
735 if (event->button == 3)
736 return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event));
738 Frame* frame = core(webView)->mainFrame();
742 gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent);
743 // Handle the IM context when a mouse press fires
744 static_cast<WebKit::EditorClient*>(core(webView)->editorClient())->handleInputMethodMousePress();
747 /* Copy selection to the X11 selection clipboard */
748 if (event->button == 2) {
749 PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper();
750 bool wasUsingPrimary = helper->usePrimarySelectionClipboard();
751 helper->setUsePrimarySelectionClipboard(true);
753 Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
754 result = result || editor->canPaste() || editor->canDHTMLPaste();
757 helper->setUsePrimarySelectionClipboard(wasUsingPrimary);
764 static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
766 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
768 Frame* focusedFrame = core(webView)->focusController()->focusedFrame();
770 if (focusedFrame && focusedFrame->editor()->canEdit()) {
772 WebKitWebViewPrivate* priv = webView->priv;
773 hildon_gtk_im_context_filter_event(priv->imContext.get(), (GdkEvent*)event);
777 Frame* mainFrame = core(webView)->mainFrame();
778 if (mainFrame->view())
779 mainFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
781 /* We always return FALSE here because WebKit can, for the same click, decide
782 * to not handle press-event but handle release-event, which can totally confuse
783 * some GTK+ containers when there are no other events in between. This way we
784 * guarantee that this case never happens, and that if press-event goes through
785 * release-event also goes through.
791 static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event)
793 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
795 Frame* frame = core(webView)->mainFrame();
799 return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event));
802 static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event)
804 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
806 Frame* frame = core(webView)->mainFrame();
810 PlatformWheelEvent wheelEvent(event);
811 return frame->eventHandler()->handleWheelEvent(wheelEvent);
814 #ifdef GTK_API_VERSION_2
815 static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)
817 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
818 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
822 FrameView* view = coreFrame->view();
826 requisition->width = view->contentsWidth();
827 requisition->height = view->contentsHeight();
830 static void webkit_web_view_get_preferred_width(GtkWidget* widget, gint* minimum, gint* natural)
832 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
833 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
837 FrameView* view = coreFrame->view();
841 *minimum = *natural = view->contentsWidth();
844 static void webkit_web_view_get_preferred_height(GtkWidget* widget, gint* minimum, gint* natural)
846 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
847 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
851 FrameView* view = coreFrame->view();
855 *minimum = *natural = view->contentsHeight();
859 static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
861 if (!gtk_widget_get_visible(child))
864 GtkAllocation* allocation = static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(child), "delayed-allocation"));
868 g_object_set_data(G_OBJECT(child), "delayed-allocation", 0);
869 gtk_widget_size_allocate(child, allocation);
870 *allocation = IntRect();
873 static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation)
875 Page* page = core(webView);
877 if (FrameView* frameView = page->mainFrame()->view()) {
878 oldSize = frameView->size();
879 frameView->resize(allocation->width, allocation->height);
882 gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0);
884 WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome()->client());
885 chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
886 chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars();
888 #if USE(ACCELERATED_COMPOSITING)
889 webView->priv->acceleratedCompositingContext->resizeRootLayer(IntSize(allocation->width, allocation->height));
893 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
895 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
897 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
898 if (!gtk_widget_get_mapped(widget)) {
899 webView->priv->needsResizeOnMap = true;
902 resizeWebViewFromAllocation(webView, allocation);
905 static void webkitWebViewMap(GtkWidget* widget)
907 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget);
909 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
910 if (!webView->priv->needsResizeOnMap)
913 GtkAllocation allocation;
914 gtk_widget_get_allocation(widget, &allocation);
915 resizeWebViewFromAllocation(webView, &allocation);
916 webView->priv->needsResizeOnMap = false;
919 static void webkit_web_view_grab_focus(GtkWidget* widget)
922 if (gtk_widget_is_sensitive(widget)) {
923 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
924 FocusController* focusController = core(webView)->focusController();
926 focusController->setActive(true);
928 if (focusController->focusedFrame())
929 focusController->setFocused(true);
931 focusController->setFocusedFrame(core(webView)->mainFrame());
934 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget);
937 static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event)
939 // TODO: Improve focus handling as suggested in
940 // http://bugs.webkit.org/show_bug.cgi?id=16910
941 GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
942 if (widgetIsOnscreenToplevelWindow(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
943 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
944 FocusController* focusController = core(webView)->focusController();
946 focusController->setActive(true);
948 if (focusController->focusedFrame())
949 focusController->setFocused(true);
951 focusController->setFocusedFrame(core(webView)->mainFrame());
953 if (focusController->focusedFrame()->editor()->canEdit())
954 gtk_im_context_focus_in(webView->priv->imContext.get());
956 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
959 static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event)
961 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
963 // We may hit this code while destroying the widget, and we might
964 // no longer have a page, then.
965 Page* page = core(webView);
967 page->focusController()->setActive(false);
968 page->focusController()->setFocused(false);
971 if (webView->priv->imContext)
972 gtk_im_context_focus_out(webView->priv->imContext.get());
974 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
977 static void webkit_web_view_realize(GtkWidget* widget)
979 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
981 gtk_widget_set_realized(widget, TRUE);
983 GtkAllocation allocation;
984 #if GTK_CHECK_VERSION(2, 18, 0)
985 gtk_widget_get_allocation(widget, &allocation);
987 allocation = widget->allocation;
990 GdkWindowAttr attributes;
991 attributes.window_type = GDK_WINDOW_CHILD;
992 attributes.x = allocation.x;
993 attributes.y = allocation.y;
994 attributes.width = allocation.width;
995 attributes.height = allocation.height;
996 attributes.wclass = GDK_INPUT_OUTPUT;
997 attributes.visual = gtk_widget_get_visual(widget);
998 #ifdef GTK_API_VERSION_2
999 attributes.colormap = gtk_widget_get_colormap(widget);
1001 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
1003 | GDK_BUTTON_PRESS_MASK
1004 | GDK_BUTTON_RELEASE_MASK
1006 | GDK_POINTER_MOTION_MASK
1007 | GDK_KEY_PRESS_MASK
1008 | GDK_KEY_RELEASE_MASK
1009 | GDK_BUTTON_MOTION_MASK
1010 | GDK_BUTTON1_MOTION_MASK
1011 | GDK_BUTTON2_MOTION_MASK
1012 | GDK_BUTTON3_MOTION_MASK;
1014 gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
1015 #ifdef GTK_API_VERSION_2
1016 attributes_mask |= GDK_WA_COLORMAP;
1018 GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
1020 #if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER_GL)
1021 priv->hasNativeWindow = gdk_window_ensure_native(window);
1023 gtk_widget_set_window(widget, window);
1024 gdk_window_set_user_data(window, widget);
1026 #ifdef GTK_API_VERSION_2
1027 #if GTK_CHECK_VERSION(2, 20, 0)
1028 gtk_widget_style_attach(widget);
1030 widget->style = gtk_style_attach(gtk_widget_get_style(widget), window);
1032 gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL);
1034 gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
1037 gtk_im_context_set_client_window(priv->imContext.get(), window);
1040 #ifdef GTK_API_VERSION_2
1041 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* horizontalAdjustment, GtkAdjustment* verticalAdjustment)
1043 setHorizontalAdjustment(webView, horizontalAdjustment);
1044 setVerticalAdjustment(webView, verticalAdjustment);
1048 static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget)
1050 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1051 WebKitWebViewPrivate* priv = webView->priv;
1053 priv->children.add(widget);
1054 gtk_widget_set_parent(widget, GTK_WIDGET(container));
1057 static void webkit_web_view_container_remove(GtkContainer* container, GtkWidget* widget)
1059 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1060 WebKitWebViewPrivate* priv = webView->priv;
1062 if (priv->children.contains(widget)) {
1063 gtk_widget_unparent(widget);
1064 priv->children.remove(widget);
1068 static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData)
1070 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1071 WebKitWebViewPrivate* priv = webView->priv;
1073 HashSet<GtkWidget*> children = priv->children;
1074 HashSet<GtkWidget*>::const_iterator end = children.end();
1075 for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current)
1076 (*callback)(*current, callbackData);
1079 static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*)
1084 static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*)
1089 static gboolean webkit_web_view_real_close_web_view(WebKitWebView*)
1094 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*)
1096 return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
1099 static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
1104 static gchar* webkit_web_view_real_choose_file(WebKitWebView*, WebKitWebFrame*, const gchar* old_name)
1107 return g_strdup(old_name);
1111 WEBKIT_SCRIPT_DIALOG_ALERT,
1112 WEBKIT_SCRIPT_DIALOG_CONFIRM,
1113 WEBKIT_SCRIPT_DIALOG_PROMPT
1114 } WebKitScriptDialogType;
1116 static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, WebKitScriptDialogType type, const gchar* defaultValue, gchar** value)
1118 GtkMessageType messageType;
1119 GtkButtonsType buttons;
1120 gint defaultResponse;
1123 GtkWidget* entry = 0;
1124 gboolean didConfirm = FALSE;
1127 case WEBKIT_SCRIPT_DIALOG_ALERT:
1128 messageType = GTK_MESSAGE_WARNING;
1129 buttons = GTK_BUTTONS_CLOSE;
1130 defaultResponse = GTK_RESPONSE_CLOSE;
1132 case WEBKIT_SCRIPT_DIALOG_CONFIRM:
1133 messageType = GTK_MESSAGE_QUESTION;
1134 buttons = GTK_BUTTONS_OK_CANCEL;
1135 defaultResponse = GTK_RESPONSE_OK;
1137 case WEBKIT_SCRIPT_DIALOG_PROMPT:
1138 messageType = GTK_MESSAGE_QUESTION;
1139 buttons = GTK_BUTTONS_OK_CANCEL;
1140 defaultResponse = GTK_RESPONSE_OK;
1143 g_warning("Unknown value for WebKitScriptDialogType.");
1147 window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
1148 dialog = gtk_message_dialog_new(widgetIsOnscreenToplevelWindow(window) ? GTK_WINDOW(window) : 0,
1149 GTK_DIALOG_DESTROY_WITH_PARENT,
1154 gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL);
1155 gtk_window_set_title(GTK_WINDOW(dialog), title);
1158 if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) {
1159 entry = gtk_entry_new();
1160 gtk_entry_set_text(GTK_ENTRY(entry), defaultValue);
1161 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
1162 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
1163 gtk_widget_show(entry);
1166 gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
1167 gint response = gtk_dialog_run(GTK_DIALOG(dialog));
1170 case GTK_RESPONSE_OK:
1173 *value = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
1175 case GTK_RESPONSE_CANCEL:
1180 gtk_widget_destroy(GTK_WIDGET(dialog));
1184 static gboolean webkit_web_view_real_script_alert(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message)
1186 webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_ALERT, 0, 0);
1190 static gboolean webkit_web_view_real_script_confirm(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm)
1192 *didConfirm = webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_CONFIRM, 0, 0);
1196 static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value)
1198 if (!webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_PROMPT, defaultValue, value))
1203 static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId)
1205 g_message("console message: %s @%d: %s\n", sourceId, line, message);
1209 static void webkit_web_view_real_select_all(WebKitWebView* webView)
1211 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1212 frame->editor()->command("SelectAll").execute();
1215 static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView)
1217 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1218 frame->editor()->command("Cut").execute();
1221 static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
1223 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1224 frame->editor()->command("Copy").execute();
1227 static void webkit_web_view_real_undo(WebKitWebView* webView)
1229 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1230 frame->editor()->command("Undo").execute();
1233 static void webkit_web_view_real_redo(WebKitWebView* webView)
1235 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1236 frame->editor()->command("Redo").execute();
1239 static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
1241 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
1242 g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
1243 step == GTK_MOVEMENT_DISPLAY_LINES ||
1244 step == GTK_MOVEMENT_PAGES ||
1245 step == GTK_MOVEMENT_BUFFER_ENDS, FALSE);
1246 g_return_val_if_fail(count == 1 || count == -1, FALSE);
1248 ScrollDirection direction;
1249 ScrollGranularity granularity;
1252 case GTK_MOVEMENT_DISPLAY_LINES:
1253 granularity = ScrollByLine;
1255 direction = ScrollDown;
1257 direction = ScrollUp;
1259 case GTK_MOVEMENT_VISUAL_POSITIONS:
1260 granularity = ScrollByLine;
1262 direction = ScrollRight;
1264 direction = ScrollLeft;
1266 case GTK_MOVEMENT_PAGES:
1267 granularity = ScrollByPage;
1269 direction = ScrollDown;
1271 direction = ScrollUp;
1273 case GTK_MOVEMENT_BUFFER_ENDS:
1274 granularity = ScrollByDocument;
1276 direction = ScrollDown;
1278 direction = ScrollUp;
1281 g_assert_not_reached();
1285 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1286 if (!frame->eventHandler()->scrollOverflow(direction, granularity))
1287 frame->view()->scroll(direction, granularity);
1292 static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
1294 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1295 frame->editor()->command("Paste").execute();
1298 static gboolean webkit_web_view_real_should_allow_editing_action(WebKitWebView*)
1303 static void webkit_web_view_dispose(GObject* object)
1305 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
1306 WebKitWebViewPrivate* priv = webView->priv;
1308 priv->disposing = TRUE;
1310 // Make sure GtkAdjustmentWatcher won't be reacting to adjustment changes after the
1311 // WebView is destroyed.
1312 setHorizontalAdjustment(webView, 0);
1313 setVerticalAdjustment(webView, 0);
1315 // These smart pointers are cleared manually, because some cleanup operations are
1316 // very sensitive to their value. We may crash if these are done in the wrong order.
1317 priv->backForwardList.clear();
1319 if (priv->corePage) {
1320 webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
1321 core(priv->mainFrame)->loader()->detachFromParent();
1322 delete priv->corePage;
1326 if (priv->webSettings) {
1327 g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView);
1328 priv->webSettings.clear();
1331 if (priv->currentMenu) {
1332 gtk_widget_destroy(GTK_WIDGET(priv->currentMenu));
1333 priv->currentMenu = 0;
1336 priv->webInspector.clear();
1337 priv->viewportAttributes.clear();
1338 priv->webWindowFeatures.clear();
1339 priv->mainResource.clear();
1340 priv->subResources.clear();
1342 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
1345 static void webkit_web_view_finalize(GObject* object)
1347 // We need to manually call the destructor here, since this object's memory is managed
1348 // by GLib. This calls all C++ members' destructors and prevents memory leaks.
1349 WEBKIT_WEB_VIEW(object)->priv->~WebKitWebViewPrivate();
1350 G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
1353 static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1355 gpointer newWebView = g_value_get_object(handlerReturn);
1356 g_value_set_object(returnAccu, newWebView);
1358 // Continue if we don't have a newWebView
1362 static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1364 WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn);
1365 g_value_set_enum(returnAccu, navigationResponse);
1367 if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)
1373 static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
1375 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1379 if (!AXObjectCache::accessibilityEnabled())
1380 AXObjectCache::enableAccessibility();
1382 Frame* coreFrame = core(webView)->mainFrame();
1386 Document* doc = coreFrame->document();
1390 AccessibilityObject* rootAccessible = doc->axObjectCache()->rootObject();
1391 if (!rootAccessible)
1394 AtkObject* axRoot = rootAccessible->wrapper();
1395 if (!axRoot || !ATK_IS_OBJECT(axRoot))
1398 // Ensure the parent is set to make top-down and bottom-up navigation work.
1399 GtkWidget* parentWidget = gtk_widget_get_parent(widget);
1400 AtkObject* axParent = parentWidget ? gtk_widget_get_accessible(parentWidget) : 0;
1402 atk_object_set_parent(axRoot, axParent);
1407 static gdouble webViewGetDPI(WebKitWebView* webView)
1409 if (webView->priv->webSettings->priv->enforce96DPI)
1412 static const double defaultDPI = 96;
1413 GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
1417 // gdk_screen_get_resolution() returns -1 when no DPI is set.
1418 gdouble DPI = gdk_screen_get_resolution(screen);
1419 return DPI != -1 ? DPI : defaultDPI;
1422 static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen)
1424 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1425 WebKitWebViewPrivate* priv = webView->priv;
1427 if (priv->disposing)
1430 WebKitWebSettings* webSettings = priv->webSettings.get();
1431 Settings* settings = core(webView)->settings();
1432 gdouble DPI = webViewGetDPI(webView);
1434 guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
1436 g_object_get(webSettings,
1437 "default-font-size", &defaultFontSize,
1438 "default-monospace-font-size", &defaultMonospaceFontSize,
1439 "minimum-font-size", &minimumFontSize,
1440 "minimum-logical-font-size", &minimumLogicalFontSize,
1443 settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI);
1444 settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI);
1445 settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI);
1446 settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
1449 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
1451 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1452 if (!webView->priv->dragAndDropHelper.handleDragEnd(context))
1455 Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
1459 // Synthesize a button release event to send with the drag end action.
1460 GOwnPtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_RELEASE));
1461 int x, y, xRoot, yRoot;
1462 GdkModifierType modifiers = static_cast<GdkModifierType>(0);
1463 #ifdef GTK_API_VERSION_2
1464 GdkDisplay* display = gdk_display_get_default();
1465 gdk_display_get_pointer(display, 0, &xRoot, &yRoot, &modifiers);
1466 event->button.window = gdk_display_get_window_at_pointer(display, &x, &y);
1468 GdkDevice* device = gdk_drag_context_get_device(context);
1469 event->button.window = gdk_device_get_window_at_position(device, &x, &y);
1470 gdk_device_get_position(device, 0, &xRoot, &yRoot);
1473 if (event->button.window)
1474 g_object_ref(event->button.window);
1475 event->button.x = x;
1476 event->button.y = y;
1477 event->button.x_root = xRoot;
1478 event->button.y_root = yRoot;
1479 event->button.state = modifiers;
1481 PlatformMouseEvent platformEvent(&event->button);
1482 frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
1485 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint)
1487 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
1490 static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened)
1492 // Don't call dragExited if we have just received a drag-drop signal. This
1493 // happens in the case of a successful drop onto the view.
1495 core(WEBKIT_WEB_VIEW(widget))->dragController()->dragExited(dragData);
1496 core(WEBKIT_WEB_VIEW(widget))->dragController()->dragEnded();
1499 static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time)
1501 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback);
1504 static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1506 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1507 OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragMotion(context, IntPoint(x, y), time));
1511 DragOperation operation = core(webView)->dragController()->dragUpdated(dragData.get()).operation;
1512 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1516 static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time)
1518 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1519 OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info));
1523 DragOperation operation = core(webView)->dragController()->dragEntered(dragData.get()).operation;
1524 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1527 static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1529 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1530 OwnPtr<DragData> dragData(webView->priv->dragAndDropHelper.handleDragDrop(context, IntPoint(x, y)));
1534 core(webView)->dragController()->performDrag(dragData.get());
1535 gtk_drag_finish(context, TRUE, FALSE, time);
1539 #if GTK_CHECK_VERSION(2, 12, 0)
1540 static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip)
1542 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
1544 if (keyboard_mode) {
1545 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1547 // Get the title of the current focused element.
1548 Frame* coreFrame = core(webView)->focusController()->focusedOrMainFrame();
1552 Node* node = getFocusedNode(coreFrame);
1556 for (Node* titleNode = node; titleNode; titleNode = titleNode->parentNode()) {
1557 if (titleNode->isElementNode()) {
1558 String title = static_cast<Element*>(titleNode)->title();
1559 if (!title.isEmpty()) {
1560 if (FrameView* view = coreFrame->view()) {
1561 GdkRectangle area = view->contentsToWindow(node->getRect());
1562 gtk_tooltip_set_tip_area(tooltip, &area);
1564 gtk_tooltip_set_text(tooltip, title.utf8().data());
1574 if (priv->tooltipText.length() > 0) {
1575 if (!keyboard_mode) {
1576 if (!priv->tooltipArea.isEmpty()) {
1577 GdkRectangle area = priv->tooltipArea;
1578 gtk_tooltip_set_tip_area(tooltip, &area);
1580 gtk_tooltip_set_tip_area(tooltip, 0);
1582 gtk_tooltip_set_text(tooltip, priv->tooltipText.data());
1589 static gboolean webkit_web_view_show_help(GtkWidget* widget, GtkWidgetHelpType help_type)
1591 if (help_type == GTK_WIDGET_HELP_TOOLTIP)
1592 gtk_widget_set_has_tooltip(widget, TRUE);
1594 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->show_help(widget, help_type);
1598 static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView* webView)
1600 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
1601 return GTK_IM_CONTEXT(webView->priv->imContext.get());
1604 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
1606 GtkBindingSet* binding_set;
1615 * WebKitWebView::create-web-view:
1616 * @web_view: the object on which the signal is emitted
1617 * @frame: the #WebKitWebFrame
1619 * Emitted when the creation of a new window is requested.
1620 * If this signal is handled the signal handler should return the
1621 * newly created #WebKitWebView.
1623 * The new #WebKitWebView should not be displayed to the user
1624 * until the #WebKitWebView::web-view-ready signal is emitted.
1626 * The signal handlers should not try to deal with the reference count for
1627 * the new #WebKitWebView. The widget to which the widget is added will
1630 * Return value: (transfer full): a newly allocated #WebKitWebView, or %NULL
1634 webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
1635 G_TYPE_FROM_CLASS(webViewClass),
1636 (GSignalFlags)G_SIGNAL_RUN_LAST,
1637 G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view),
1638 webkit_signal_accumulator_object_handled,
1640 webkit_marshal_OBJECT__OBJECT,
1641 WEBKIT_TYPE_WEB_VIEW , 1,
1642 WEBKIT_TYPE_WEB_FRAME);
1645 * WebKitWebView::web-view-ready:
1646 * @web_view: the object on which the signal is emitted
1648 * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView
1649 * should be displayed to the user. When this signal is emitted
1650 * all the information about how the window should look, including
1651 * size, position, whether the location, status and scroll bars
1652 * should be displayed, is already set on the
1653 * #WebKitWebWindowFeatures object contained by the #WebKitWebView.
1655 * Notice that some of that information may change during the life
1656 * time of the window, so you may want to connect to the ::notify
1657 * signal of the #WebKitWebWindowFeatures object to handle those.
1659 * Return value: %TRUE to stop handlers from being invoked for the event or
1660 * %FALSE to propagate the event furter
1664 webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
1665 G_TYPE_FROM_CLASS(webViewClass),
1666 (GSignalFlags)G_SIGNAL_RUN_LAST,
1667 G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready),
1668 g_signal_accumulator_true_handled,
1670 webkit_marshal_BOOLEAN__VOID,
1674 * WebKitWebView::close-web-view:
1675 * @web_view: the object on which the signal is emitted
1677 * Emitted when closing a #WebKitWebView is requested. This occurs when a
1678 * call is made from JavaScript's window.close function. The default
1679 * signal handler does not do anything. It is the owner's responsibility
1680 * to hide or delete the web view, if necessary.
1682 * Return value: %TRUE to stop handlers from being invoked for the event or
1683 * %FALSE to propagate the event furter
1687 webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
1688 G_TYPE_FROM_CLASS(webViewClass),
1689 (GSignalFlags)G_SIGNAL_RUN_LAST,
1690 G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view),
1691 g_signal_accumulator_true_handled,
1693 webkit_marshal_BOOLEAN__VOID,
1697 * WebKitWebView::navigation-requested:
1698 * @web_view: the object on which the signal is emitted
1699 * @frame: the #WebKitWebFrame that required the navigation
1700 * @request: a #WebKitNetworkRequest
1702 * Emitted when @frame requests a navigation to another page.
1704 * Return value: a #WebKitNavigationResponse
1706 * Deprecated: Use WebKitWebView::navigation-policy-decision-requested
1709 webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
1710 G_TYPE_FROM_CLASS(webViewClass),
1711 (GSignalFlags)G_SIGNAL_RUN_LAST,
1712 G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
1713 webkit_navigation_request_handled,
1715 webkit_marshal_ENUM__OBJECT_OBJECT,
1716 WEBKIT_TYPE_NAVIGATION_RESPONSE, 2,
1717 WEBKIT_TYPE_WEB_FRAME,
1718 WEBKIT_TYPE_NETWORK_REQUEST);
1721 * WebKitWebView::new-window-policy-decision-requested:
1722 * @web_view: the object on which the signal is emitted
1723 * @frame: the #WebKitWebFrame that required the navigation
1724 * @request: a #WebKitNetworkRequest
1725 * @navigation_action: a #WebKitWebNavigationAction
1726 * @policy_decision: a #WebKitWebPolicyDecision
1728 * Emitted when @frame requests opening a new window. With this
1729 * signal the browser can use the context of the request to decide
1730 * about the new window. If the request is not handled the default
1731 * behavior is to allow opening the new window to load the URI,
1732 * which will cause a create-web-view signal emission where the
1733 * browser handles the new window action but without information
1734 * of the context that caused the navigation. The following
1735 * navigation-policy-decision-requested emissions will load the
1736 * page after the creation of the new window just with the
1737 * information of this new navigation context, without any
1738 * information about the action that made this new window to be
1741 * Notice that if you return TRUE, meaning that you handled the
1742 * signal, you are expected to have decided what to do, by calling
1743 * webkit_web_policy_decision_ignore(),
1744 * webkit_web_policy_decision_use(), or
1745 * webkit_web_policy_decision_download() on the @policy_decision
1748 * Return value: %TRUE if a decision was made, %FALSE to have the
1749 * default behavior apply
1753 webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] =
1754 g_signal_new("new-window-policy-decision-requested",
1755 G_TYPE_FROM_CLASS(webViewClass),
1756 (GSignalFlags)G_SIGNAL_RUN_LAST,
1758 g_signal_accumulator_true_handled,
1760 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1762 WEBKIT_TYPE_WEB_FRAME,
1763 WEBKIT_TYPE_NETWORK_REQUEST,
1764 WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1765 WEBKIT_TYPE_WEB_POLICY_DECISION);
1768 * WebKitWebView::navigation-policy-decision-requested:
1769 * @web_view: the object on which the signal is emitted
1770 * @frame: the #WebKitWebFrame that required the navigation
1771 * @request: a #WebKitNetworkRequest
1772 * @navigation_action: a #WebKitWebNavigationAction
1773 * @policy_decision: a #WebKitWebPolicyDecision
1775 * Emitted when @frame requests a navigation to another page.
1776 * If this signal is not handled, the default behavior is to allow the
1779 * Notice that if you return TRUE, meaning that you handled the
1780 * signal, you are expected to have decided what to do, by calling
1781 * webkit_web_policy_decision_ignore(),
1782 * webkit_web_policy_decision_use(), or
1783 * webkit_web_policy_decision_download() on the @policy_decision
1786 * Return value: %TRUE if a decision was made, %FALSE to have the
1787 * default behavior apply
1791 webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested",
1792 G_TYPE_FROM_CLASS(webViewClass),
1793 (GSignalFlags)G_SIGNAL_RUN_LAST,
1795 g_signal_accumulator_true_handled,
1797 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1799 WEBKIT_TYPE_WEB_FRAME,
1800 WEBKIT_TYPE_NETWORK_REQUEST,
1801 WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1802 WEBKIT_TYPE_WEB_POLICY_DECISION);
1805 * WebKitWebView::mime-type-policy-decision-requested:
1806 * @web_view: the object on which the signal is emitted
1807 * @frame: the #WebKitWebFrame that required the policy decision
1808 * @request: a WebKitNetworkRequest
1809 * @mimetype: the MIME type attempted to load
1810 * @policy_decision: a #WebKitWebPolicyDecision
1812 * Decide whether or not to display the given MIME type. If this
1813 * signal is not handled, the default behavior is to show the
1814 * content of the requested URI if WebKit can show this MIME
1815 * type and the content disposition is not a download; if WebKit
1816 * is not able to show the MIME type nothing happens.
1818 * Notice that if you return TRUE, meaning that you handled the
1819 * signal, you are expected to be aware of the "Content-Disposition"
1820 * header. A value of "attachment" usually indicates a download
1821 * regardless of the MIME type, see also
1822 * soup_message_headers_get_content_disposition(). And you must call
1823 * webkit_web_policy_decision_ignore(),
1824 * webkit_web_policy_decision_use(), or
1825 * webkit_web_policy_decision_download() on the @policy_decision
1828 * Return value: %TRUE if a decision was made, %FALSE to have the
1829 * default behavior apply
1833 webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
1834 G_TYPE_FROM_CLASS(webViewClass),
1835 (GSignalFlags)G_SIGNAL_RUN_LAST,
1837 g_signal_accumulator_true_handled,
1839 webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT,
1841 WEBKIT_TYPE_WEB_FRAME,
1842 WEBKIT_TYPE_NETWORK_REQUEST,
1844 WEBKIT_TYPE_WEB_POLICY_DECISION);
1847 * WebKitWebView::window-object-cleared:
1848 * @web_view: the object on which the signal is emitted
1849 * @frame: the #WebKitWebFrame to which @window_object belongs
1850 * @context: the #JSGlobalContextRef holding the global object and other
1851 * execution state; equivalent to the return value of
1852 * webkit_web_frame_get_global_context(@frame)
1853 * @window_object: the #JSObjectRef representing the frame's JavaScript
1856 * Emitted when the JavaScript window object in a #WebKitWebFrame has been
1857 * cleared in preparation for a new load. This is the preferred place to
1858 * set custom properties on the window object using the JavaScriptCore API.
1860 webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared",
1861 G_TYPE_FROM_CLASS(webViewClass),
1862 (GSignalFlags)G_SIGNAL_RUN_LAST,
1863 G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared),
1866 webkit_marshal_VOID__OBJECT_POINTER_POINTER,
1868 WEBKIT_TYPE_WEB_FRAME,
1873 * WebKitWebView::download-requested:
1874 * @web_view: the object on which the signal is emitted
1875 * @download: a #WebKitDownload object that lets you control the
1878 * A new Download is being requested. By default, if the signal is
1879 * not handled, the download is cancelled. If you handle the download
1880 * and call webkit_download_set_destination_uri(), it will be
1881 * started for you. If you need to set the destination asynchronously
1882 * you are responsible for starting or cancelling it yourself.
1884 * If you intend to handle downloads yourself rather than using
1885 * the #WebKitDownload helper object you must handle this signal,
1886 * and return %FALSE.
1888 * Also, keep in mind that the default policy for WebKitGTK+ is to
1889 * ignore files with a MIME type that it does not know how to
1890 * handle, which means this signal won't be emitted in the default
1891 * setup. One way to trigger downloads is to connect to
1892 * WebKitWebView::mime-type-policy-decision-requested and call
1893 * webkit_web_policy_decision_download() on the
1894 * #WebKitWebPolicyDecision in the parameter list for the kind of
1895 * files you want your application to download (a common solution
1896 * is to download anything that WebKit can't handle, which you can
1897 * figure out by using webkit_web_view_can_show_mime_type()).
1899 * Return value: TRUE if the download should be performed, %FALSE to
1904 webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested",
1905 G_TYPE_FROM_CLASS(webViewClass),
1906 (GSignalFlags)G_SIGNAL_RUN_LAST,
1908 g_signal_accumulator_true_handled,
1910 webkit_marshal_BOOLEAN__OBJECT,
1915 * WebKitWebView::load-started:
1916 * @web_view: the object on which the signal is emitted
1917 * @frame: the frame going to do the load
1919 * When a #WebKitWebFrame begins to load this signal is emitted.
1921 * Deprecated: Use the "load-status" property instead.
1923 webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
1924 G_TYPE_FROM_CLASS(webViewClass),
1925 (GSignalFlags)G_SIGNAL_RUN_LAST,
1929 g_cclosure_marshal_VOID__OBJECT,
1931 WEBKIT_TYPE_WEB_FRAME);
1934 * WebKitWebView::load-committed:
1935 * @web_view: the object on which the signal is emitted
1936 * @frame: the main frame that received the first data
1938 * When a #WebKitWebFrame loaded the first data this signal is emitted.
1940 * Deprecated: Use the "load-status" property instead.
1942 webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
1943 G_TYPE_FROM_CLASS(webViewClass),
1944 (GSignalFlags)G_SIGNAL_RUN_LAST,
1948 g_cclosure_marshal_VOID__OBJECT,
1950 WEBKIT_TYPE_WEB_FRAME);
1954 * WebKitWebView::load-progress-changed:
1955 * @web_view: the #WebKitWebView
1956 * @progress: the global progress
1958 * Deprecated: Use the "progress" property instead.
1960 webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
1961 G_TYPE_FROM_CLASS(webViewClass),
1962 (GSignalFlags)G_SIGNAL_RUN_LAST,
1966 g_cclosure_marshal_VOID__INT,
1971 * WebKitWebView::load-error
1972 * @web_view: the object on which the signal is emitted
1973 * @web_frame: the #WebKitWebFrame
1974 * @uri: the URI that triggered the error
1975 * @web_error: the #GError that was triggered
1977 * An error occurred while loading. By default, if the signal is not
1978 * handled, the @web_view will display a stock error page. You need to
1979 * handle the signal if you want to provide your own error page.
1983 * Return value: %TRUE to stop other handlers from being invoked for the
1984 * event. %FALSE to propagate the event further.
1986 webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error",
1987 G_TYPE_FROM_CLASS(webViewClass),
1988 (GSignalFlags)(G_SIGNAL_RUN_LAST),
1990 g_signal_accumulator_true_handled,
1992 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
1994 WEBKIT_TYPE_WEB_FRAME,
1999 * WebKitWebView::load-finished:
2000 * @web_view: the #WebKitWebView
2001 * @frame: the #WebKitWebFrame
2003 * Deprecated: Use the "load-status" property instead.
2005 webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
2006 G_TYPE_FROM_CLASS(webViewClass),
2007 (GSignalFlags)G_SIGNAL_RUN_LAST,
2011 g_cclosure_marshal_VOID__OBJECT,
2013 WEBKIT_TYPE_WEB_FRAME);
2016 * WebKitWebView::onload-event:
2017 * @web_view: the object on which the signal is emitted
2020 * When a #WebKitWebFrame receives an onload event this signal is emitted.
2022 webkit_web_view_signals[ONLOAD_EVENT] = g_signal_new("onload-event",
2023 G_TYPE_FROM_CLASS(webViewClass),
2024 (GSignalFlags)G_SIGNAL_RUN_LAST,
2028 g_cclosure_marshal_VOID__OBJECT,
2030 WEBKIT_TYPE_WEB_FRAME);
2033 * WebKitWebView::title-changed:
2034 * @web_view: the object on which the signal is emitted
2035 * @frame: the main frame
2036 * @title: the new title
2038 * When a #WebKitWebFrame changes the document title this signal is emitted.
2040 * Deprecated: 1.1.4: Use "notify::title" instead.
2042 webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed",
2043 G_TYPE_FROM_CLASS(webViewClass),
2044 (GSignalFlags)G_SIGNAL_RUN_LAST,
2048 webkit_marshal_VOID__OBJECT_STRING,
2050 WEBKIT_TYPE_WEB_FRAME,
2054 * WebKitWebView::hovering-over-link:
2055 * @web_view: the object on which the signal is emitted
2056 * @title: the link's title
2057 * @uri: the URI the link points to
2059 * When the cursor is over a link, this signal is emitted.
2061 webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
2062 G_TYPE_FROM_CLASS(webViewClass),
2063 (GSignalFlags)G_SIGNAL_RUN_LAST,
2067 webkit_marshal_VOID__STRING_STRING,
2073 * WebKitWebView::populate-popup:
2074 * @web_view: the object on which the signal is emitted
2075 * @menu: the context menu
2077 * When a context menu is about to be displayed this signal is emitted.
2079 * Add menu items to #menu to extend the context menu.
2081 webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
2082 G_TYPE_FROM_CLASS(webViewClass),
2083 (GSignalFlags)G_SIGNAL_RUN_LAST,
2087 g_cclosure_marshal_VOID__OBJECT,
2092 * WebKitWebView::print-requested
2093 * @web_view: the object in which the signal is emitted
2094 * @web_frame: the frame that is requesting to be printed
2096 * Emitted when printing is requested by the frame, usually
2097 * because of a javascript call. When handling this signal you
2098 * should call webkit_web_frame_print_full() or
2099 * webkit_web_frame_print() to do the actual printing.
2101 * The default handler will present a print dialog and carry a
2102 * print operation. Notice that this means that if you intend to
2103 * ignore a print request you must connect to this signal, and
2106 * Return value: %TRUE if the print request has been handled, %FALSE if
2107 * the default handler should run
2111 webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested",
2112 G_TYPE_FROM_CLASS(webViewClass),
2113 (GSignalFlags)G_SIGNAL_RUN_LAST,
2115 g_signal_accumulator_true_handled,
2117 webkit_marshal_BOOLEAN__OBJECT,
2119 WEBKIT_TYPE_WEB_FRAME);
2121 webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
2122 G_TYPE_FROM_CLASS(webViewClass),
2123 (GSignalFlags)G_SIGNAL_RUN_LAST,
2127 g_cclosure_marshal_VOID__STRING,
2132 * WebKitWebView::icon-loaded:
2133 * @web_view: the object on which the signal is emitted
2134 * @icon_uri: the URI for the icon
2136 * This signal is emitted when the main frame has got a favicon.
2137 * See WebKitIconDatabase::icon-loaded if you want to keep track of
2138 * icons for child frames.
2142 webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded",
2143 G_TYPE_FROM_CLASS(webViewClass),
2144 (GSignalFlags)G_SIGNAL_RUN_LAST,
2148 g_cclosure_marshal_VOID__STRING,
2153 * WebKitWebView::console-message:
2154 * @web_view: the object on which the signal is emitted
2155 * @message: the message text
2156 * @line: the line where the error occured
2157 * @source_id: the source id
2159 * A JavaScript console message was created.
2161 * Return value: %TRUE to stop other handlers from being invoked for the
2162 * event. %FALSE to propagate the event further.
2164 webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message",
2165 G_TYPE_FROM_CLASS(webViewClass),
2166 (GSignalFlags)G_SIGNAL_RUN_LAST,
2167 G_STRUCT_OFFSET(WebKitWebViewClass, console_message),
2168 g_signal_accumulator_true_handled,
2170 webkit_marshal_BOOLEAN__STRING_INT_STRING,
2172 G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
2175 * WebKitWebView::script-alert:
2176 * @web_view: the object on which the signal is emitted
2177 * @frame: the relevant frame
2178 * @message: the message text
2180 * A JavaScript alert dialog was created.
2182 * Return value: %TRUE to stop other handlers from being invoked for the
2183 * event. %FALSE to propagate the event further.
2185 webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert",
2186 G_TYPE_FROM_CLASS(webViewClass),
2187 (GSignalFlags)G_SIGNAL_RUN_LAST,
2188 G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
2189 g_signal_accumulator_true_handled,
2191 webkit_marshal_BOOLEAN__OBJECT_STRING,
2193 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING);
2196 * WebKitWebView::script-confirm:
2197 * @web_view: the object on which the signal is emitted
2198 * @frame: the relevant frame
2199 * @message: the message text
2200 * @confirmed: whether the dialog has been confirmed
2202 * A JavaScript confirm dialog was created, providing Yes and No buttons.
2204 * Return value: %TRUE to stop other handlers from being invoked for the
2205 * event. %FALSE to propagate the event further.
2207 webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm",
2208 G_TYPE_FROM_CLASS(webViewClass),
2209 (GSignalFlags)G_SIGNAL_RUN_LAST,
2210 G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
2211 g_signal_accumulator_true_handled,
2213 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
2215 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_POINTER);
2218 * WebKitWebView::script-prompt:
2219 * @web_view: the object on which the signal is emitted
2220 * @frame: the relevant frame
2221 * @message: the message text
2222 * @default: the default value
2223 * @text: To be filled with the return value or NULL if the dialog was cancelled.
2225 * A JavaScript prompt dialog was created, providing an entry to input text.
2227 * Return value: %TRUE to stop other handlers from being invoked for the
2228 * event. %FALSE to propagate the event further.
2230 webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt",
2231 G_TYPE_FROM_CLASS(webViewClass),
2232 (GSignalFlags)G_SIGNAL_RUN_LAST,
2233 G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
2234 g_signal_accumulator_true_handled,
2236 webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING,
2238 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
2241 * WebKitWebView::select-all:
2242 * @web_view: the object which received the signal
2244 * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to
2245 * select the complete contents of the text view.
2247 * The default bindings for this signal is Ctrl-a.
2249 webkit_web_view_signals[SELECT_ALL] = g_signal_new("select-all",
2250 G_TYPE_FROM_CLASS(webViewClass),
2251 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2252 G_STRUCT_OFFSET(WebKitWebViewClass, select_all),
2254 g_cclosure_marshal_VOID__VOID,
2258 * WebKitWebView::cut-clipboard:
2259 * @web_view: the object which received the signal
2261 * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to
2262 * cut the selection to the clipboard.
2264 * The default bindings for this signal are Ctrl-x and Shift-Delete.
2266 webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut-clipboard",
2267 G_TYPE_FROM_CLASS(webViewClass),
2268 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2269 G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard),
2271 g_cclosure_marshal_VOID__VOID,
2275 * WebKitWebView::copy-clipboard:
2276 * @web_view: the object which received the signal
2278 * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to
2279 * copy the selection to the clipboard.
2281 * The default bindings for this signal are Ctrl-c and Ctrl-Insert.
2283 webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy-clipboard",
2284 G_TYPE_FROM_CLASS(webViewClass),
2285 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2286 G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard),
2288 g_cclosure_marshal_VOID__VOID,
2292 * WebKitWebView::paste-clipboard:
2293 * @web_view: the object which received the signal
2295 * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to
2296 * paste the contents of the clipboard into the Web view.
2298 * The default bindings for this signal are Ctrl-v and Shift-Insert.
2300 webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste-clipboard",
2301 G_TYPE_FROM_CLASS(webViewClass),
2302 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2303 G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard),
2305 g_cclosure_marshal_VOID__VOID,
2309 * WebKitWebView::undo
2310 * @web_view: the object which received the signal
2312 * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to
2313 * undo the last editing command.
2315 * The default binding for this signal is Ctrl-z
2319 webkit_web_view_signals[UNDO] = g_signal_new("undo",
2320 G_TYPE_FROM_CLASS(webViewClass),
2321 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2322 G_STRUCT_OFFSET(WebKitWebViewClass, undo),
2324 g_cclosure_marshal_VOID__VOID,
2328 * WebKitWebView::redo
2329 * @web_view: the object which received the signal
2331 * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to
2332 * redo the last editing command.
2334 * The default binding for this signal is Ctrl-Shift-z
2338 webkit_web_view_signals[REDO] = g_signal_new("redo",
2339 G_TYPE_FROM_CLASS(webViewClass),
2340 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2341 G_STRUCT_OFFSET(WebKitWebViewClass, redo),
2343 g_cclosure_marshal_VOID__VOID,
2347 * WebKitWebView::move-cursor:
2348 * @web_view: the object which received the signal
2349 * @step: the type of movement, one of #GtkMovementStep
2350 * @count: an integer indicating the subtype of movement. Currently
2351 * the permitted values are '1' = forward, '-1' = backwards.
2353 * The #WebKitWebView::move-cursor will be emitted to apply the
2354 * cursor movement described by its parameters to the @view.
2356 * Return value: %TRUE or %FALSE
2360 webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor",
2361 G_TYPE_FROM_CLASS(webViewClass),
2362 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2363 G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor),
2365 webkit_marshal_BOOLEAN__ENUM_INT,
2367 GTK_TYPE_MOVEMENT_STEP,
2371 * WebKitWebView::create-plugin-widget:
2372 * @web_view: the object which received the signal
2373 * @mime_type: the mimetype of the requested object
2374 * @uri: the URI to load
2375 * @param: a #GHashTable with additional attributes (strings)
2377 * The #WebKitWebView::create-plugin-widget signal will be emitted to
2378 * create a plugin widget for embed or object HTML tags. This
2379 * allows to embed a GtkWidget as a plugin into HTML content. In
2380 * case of a textual selection of the GtkWidget WebCore will attempt
2381 * to set the property value of "webkit-widget-is-selected". This can
2382 * be used to draw a visual indicator of the selection.
2384 * Return value: (transfer full): a new #GtkWidget, or %NULL
2388 webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget",
2389 G_TYPE_FROM_CLASS(webViewClass),
2390 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2392 webkit_signal_accumulator_object_handled,
2394 webkit_marshal_OBJECT__STRING_STRING_POINTER,
2396 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
2399 * WebKitWebView::database-quota-exceeded
2400 * @web_view: the object which received the signal
2401 * @frame: the relevant frame
2402 * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin
2404 * The #WebKitWebView::database-quota-exceeded signal will be emitted when
2405 * a Web Database exceeds the quota of its security origin. This signal
2406 * may be used to increase the size of the quota before the originating
2411 webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded",
2412 G_TYPE_FROM_CLASS(webViewClass),
2413 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2416 webkit_marshal_VOID__OBJECT_OBJECT,
2418 G_TYPE_OBJECT, G_TYPE_OBJECT);
2421 * WebKitWebView::resource-request-starting:
2422 * @web_view: the object which received the signal
2423 * @web_frame: the #WebKitWebFrame whose load dispatched this request
2424 * @web_resource: an empty #WebKitWebResource object
2425 * @request: the #WebKitNetworkRequest that will be dispatched
2426 * @response: the #WebKitNetworkResponse representing the redirect
2429 * Emitted when a request is about to be sent. You can modify the
2430 * request while handling this signal. You can set the URI in the
2431 * #WebKitNetworkRequest object itself, and add/remove/replace
2432 * headers using the #SoupMessage object it carries, if it is
2433 * present. See webkit_network_request_get_message(). Setting the
2434 * request URI to "about:blank" will effectively cause the request
2435 * to load nothing, and can be used to disable the loading of
2436 * specific resources.
2438 * Notice that information about an eventual redirect is available
2439 * in @response's #SoupMessage, not in the #SoupMessage carried by
2440 * the @request. If @response is %NULL, then this is not a
2441 * redirected request.
2443 * The #WebKitWebResource object will be the same throughout all
2444 * the lifetime of the resource, but the contents may change from
2445 * inbetween signal emissions.
2449 webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
2450 G_TYPE_FROM_CLASS(webViewClass),
2451 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2454 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT,
2456 WEBKIT_TYPE_WEB_FRAME,
2457 WEBKIT_TYPE_WEB_RESOURCE,
2458 WEBKIT_TYPE_NETWORK_REQUEST,
2459 WEBKIT_TYPE_NETWORK_RESPONSE);
2462 * WebKitWebView::geolocation-policy-decision-requested:
2463 * @web_view: the object on which the signal is emitted
2464 * @frame: the frame that requests permission
2465 * @policy_decision: a WebKitGeolocationPolicyDecision
2467 * This signal is emitted when a @frame wants to obtain the user's
2468 * location. The decision can be made asynchronously, but you must
2469 * call g_object_ref() the @policy_decision, and return %TRUE if
2470 * you are going to handle the request. To actually make the
2471 * decision you need to call webkit_geolocation_policy_allow() or
2472 * webkit_geolocation_policy_deny() on @policy_decision.
2476 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested",
2477 G_TYPE_FROM_CLASS(webViewClass),
2478 (GSignalFlags)(G_SIGNAL_RUN_LAST),
2481 webkit_marshal_BOOLEAN__OBJECT_OBJECT,
2483 WEBKIT_TYPE_WEB_FRAME,
2484 WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION);
2487 * WebKitWebView::geolocation-policy-decision-cancelled:
2488 * @web_view: the object on which the signal is emitted
2489 * @frame: the frame that cancels geolocation request.
2491 * When a @frame wants to cancel geolocation permission it had requested
2496 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled",
2497 G_TYPE_FROM_CLASS(webViewClass),
2498 (GSignalFlags)(G_SIGNAL_RUN_LAST),
2501 g_cclosure_marshal_VOID__OBJECT,
2503 WEBKIT_TYPE_WEB_FRAME);
2506 * DOM-related signals. These signals are experimental, for now,
2507 * and may change API and ABI. Their comments lack one * on
2508 * purpose, to make them not be catched by gtk-doc.
2512 * WebKitWebView::document-load-finished
2513 * @web_view: the object which received the signal
2514 * @web_frame: the #WebKitWebFrame whose load dispatched this request
2516 * Emitted when the DOM document object load is finished for the
2519 webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished",
2520 G_TYPE_FROM_CLASS(webViewClass),
2521 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2524 g_cclosure_marshal_VOID__OBJECT,
2526 WEBKIT_TYPE_WEB_FRAME);
2529 * WebKitWebView::frame-created
2530 * @web_view: the object which received the signal
2531 * @web_frame: the #WebKitWebFrame which was just created.
2533 * Emitted when a WebKitWebView has created a new frame. This signal will
2534 * be emitted for all sub-frames created during page load. It will not be
2535 * emitted for the main frame, which originates in the WebKitWebView constructor
2536 * and may be accessed at any time using webkit_web_view_get_main_frame.
2540 webkit_web_view_signals[FRAME_CREATED] = g_signal_new("frame-created",
2541 G_TYPE_FROM_CLASS(webViewClass),
2542 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2545 g_cclosure_marshal_VOID__OBJECT,
2547 WEBKIT_TYPE_WEB_FRAME);
2549 webkit_web_view_signals[SHOULD_BEGIN_EDITING] = g_signal_new("should-begin-editing",
2550 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2551 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2552 webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2554 webkit_web_view_signals[SHOULD_END_EDITING] = g_signal_new("should-end-editing", G_TYPE_FROM_CLASS(webViewClass),
2555 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2556 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2557 webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2559 webkit_web_view_signals[SHOULD_INSERT_NODE] = g_signal_new("should-insert-node", G_TYPE_FROM_CLASS(webViewClass),
2560 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2561 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2562 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM, G_TYPE_BOOLEAN,
2563 3, WEBKIT_TYPE_DOM_NODE, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_INSERT_ACTION);
2565 webkit_web_view_signals[SHOULD_INSERT_TEXT] = g_signal_new("should-insert-text", G_TYPE_FROM_CLASS(webViewClass),
2566 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2567 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2568 webkit_marshal_BOOLEAN__STRING_OBJECT_ENUM, G_TYPE_BOOLEAN,
2569 3, G_TYPE_STRING, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_INSERT_ACTION);
2571 webkit_web_view_signals[SHOULD_DELETE_RANGE] = g_signal_new("should-delete-range", G_TYPE_FROM_CLASS(webViewClass),
2572 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2573 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2574 webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_RANGE);
2576 webkit_web_view_signals[SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT] = g_signal_new("should-show-delete-interface-for-element",
2577 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2578 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2579 webkit_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2581 webkit_web_view_signals[SHOULD_CHANGE_SELECTED_RANGE] = g_signal_new("should-change-selected-range",
2582 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2583 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2584 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM_BOOLEAN, G_TYPE_BOOLEAN,
2585 4, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_DOM_RANGE, WEBKIT_TYPE_SELECTION_AFFINITY, G_TYPE_BOOLEAN);
2587 webkit_web_view_signals[SHOULD_APPLY_STYLE] = g_signal_new("should-apply-style",
2588 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2589 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), g_signal_accumulator_first_wins, 0,
2590 webkit_marshal_BOOLEAN__OBJECT_OBJECT, G_TYPE_BOOLEAN,
2591 2, WEBKIT_TYPE_DOM_CSS_STYLE_DECLARATION, WEBKIT_TYPE_DOM_RANGE);
2593 webkit_web_view_signals[EDITING_BEGAN] = g_signal_new("editing-began",
2594 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2595 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2597 webkit_web_view_signals[USER_CHANGED_CONTENTS] = g_signal_new("user-changed-contents",
2598 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2599 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2601 webkit_web_view_signals[EDITING_ENDED] = g_signal_new("editing-ended",
2602 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2603 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2605 webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed",
2606 G_TYPE_FROM_CLASS(webViewClass), static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 0, 0, 0,
2607 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
2610 * WebKitWebView::viewport-attributes-recompute-requested
2611 * @web_view: the object which received the signal
2612 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2614 * The #WebKitWebView::viewport-attributes-recompute-requested
2615 * signal will be emitted when a page with a viewport meta tag
2616 * loads and when webkit_viewport_attributes_recompute is called.
2618 * The #WebKitViewportAttributes will have device size, available size,
2619 * desktop width, and device DPI pre-filled by values that make sense
2620 * for the current screen and widget, but you can override those values
2621 * if you have special requirements (for instance, if you made your
2622 * widget bigger than the available visible area, you should override
2623 * the available-width and available-height properties to the actual
2628 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested",
2629 G_TYPE_FROM_CLASS(webViewClass),
2630 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2633 g_cclosure_marshal_VOID__OBJECT,
2635 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2638 * WebKitWebView::viewport-attributes-changed
2639 * @web_view: the object which received the signal
2640 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2642 * The #WebKitWebView::viewport-attributes-changed signal will be emitted
2643 * after the emission of #WebKitWebView::viewport-attributes-recompute-requested
2644 * and the subsequent viewport attribute recomputation. At this point,
2645 * if the #WebKitViewportAttributes are valid, the viewport attributes are available.
2649 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed",
2650 G_TYPE_FROM_CLASS(webViewClass),
2651 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2654 g_cclosure_marshal_VOID__OBJECT,
2656 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2659 * WebKitWebView::resource-response-received
2660 * @webView: the object which received the signal
2661 * @webFrame: the #WebKitWebFrame the response was received for
2662 * @webResource: the #WebKitWebResource being loaded
2663 * @response: the #WebKitNetworkResponse that was received
2665 * Emitted when the first byte of data arrives
2669 webkit_web_view_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received",
2670 G_TYPE_FROM_CLASS(webViewClass),
2674 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT,
2676 WEBKIT_TYPE_WEB_FRAME,
2677 WEBKIT_TYPE_WEB_RESOURCE,
2678 WEBKIT_TYPE_NETWORK_RESPONSE);
2681 * WebKitWebView::resource-load-finished
2682 * @webView: the object which received the signal
2683 * @webFrame: the #WebKitWebFrame the response was received for
2684 * @webResource: the #WebKitWebResource that was loaded
2686 * Emitted when all the data for the resource was loaded
2690 webkit_web_view_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished",
2691 G_TYPE_FROM_CLASS(webViewClass),
2695 webkit_marshal_VOID__OBJECT_OBJECT,
2697 WEBKIT_TYPE_WEB_FRAME,
2698 WEBKIT_TYPE_WEB_RESOURCE);
2701 * WebKitWebView::resource-content-length-received
2702 * @webView: the object which received the signal
2703 * @webFrame: the #WebKitWebFrame the response was received for
2704 * @webResource: the #WebKitWebResource that was loaded
2705 * @lengthReceived: the resource data length in bytes
2707 * Emitted when the HTTP Content-Length response header has been
2708 * received and parsed successfully.
2712 webkit_web_view_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received",
2713 G_TYPE_FROM_CLASS(webViewClass),
2717 webkit_marshal_VOID__OBJECT_OBJECT_INT,
2719 WEBKIT_TYPE_WEB_FRAME,
2720 WEBKIT_TYPE_WEB_RESOURCE,
2724 * WebKitWebView::resource-load-failed
2725 * @webView: the object which received the signal
2726 * @webFrame: the #WebKitWebFrame the response was received for
2727 * @webResource: the #WebKitWebResource that was loaded
2728 * @webError: the #GError that was triggered
2730 * Invoked when a resource failed to load
2734 webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed",
2735 G_TYPE_FROM_CLASS(webViewClass),
2739 webkit_marshal_VOID__OBJECT_OBJECT_POINTER,
2741 WEBKIT_TYPE_WEB_FRAME,
2742 WEBKIT_TYPE_WEB_RESOURCE,
2746 * implementations of virtual methods
2748 webViewClass->create_web_view = webkit_web_view_real_create_web_view;
2749 webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
2750 webViewClass->close_web_view = webkit_web_view_real_close_web_view;
2751 webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
2752 webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
2753 webViewClass->choose_file = webkit_web_view_real_choose_file;
2754 webViewClass->script_alert = webkit_web_view_real_script_alert;
2755 webViewClass->script_confirm = webkit_web_view_real_script_confirm;
2756 webViewClass->script_prompt = webkit_web_view_real_script_prompt;
2757 webViewClass->console_message = webkit_web_view_real_console_message;
2758 webViewClass->select_all = webkit_web_view_real_select_all;
2759 webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
2760 webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
2761 webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
2762 webViewClass->undo = webkit_web_view_real_undo;
2763 webViewClass->redo = webkit_web_view_real_redo;
2764 webViewClass->move_cursor = webkit_web_view_real_move_cursor;
2765 webViewClass->should_allow_editing_action = webkit_web_view_real_should_allow_editing_action;
2767 GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
2768 objectClass->dispose = webkit_web_view_dispose;
2769 objectClass->finalize = webkit_web_view_finalize;
2770 objectClass->get_property = webkit_web_view_get_property;
2771 objectClass->set_property = webkit_web_view_set_property;
2773 GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass);
2774 widgetClass->realize = webkit_web_view_realize;
2775 #ifdef GTK_API_VERSION_2
2776 widgetClass->expose_event = webkit_web_view_expose_event;
2778 widgetClass->draw = webkit_web_view_draw;
2780 widgetClass->key_press_event = webkit_web_view_key_press_event;
2781 widgetClass->key_release_event = webkit_web_view_key_release_event;
2782 widgetClass->button_press_event = webkit_web_view_button_press_event;
2783 widgetClass->button_release_event = webkit_web_view_button_release_event;
2784 widgetClass->motion_notify_event = webkit_web_view_motion_event;
2785 widgetClass->scroll_event = webkit_web_view_scroll_event;
2786 widgetClass->size_allocate = webkit_web_view_size_allocate;
2787 #ifdef GTK_API_VERSION_2
2788 widgetClass->size_request = webkit_web_view_size_request;
2790 widgetClass->get_preferred_width = webkit_web_view_get_preferred_width;
2791 widgetClass->get_preferred_height = webkit_web_view_get_preferred_height;
2793 widgetClass->popup_menu = webkit_web_view_popup_menu_handler;
2794 widgetClass->grab_focus = webkit_web_view_grab_focus;
2795 widgetClass->focus_in_event = webkit_web_view_focus_in_event;
2796 widgetClass->focus_out_event = webkit_web_view_focus_out_event;
2797 widgetClass->get_accessible = webkit_web_view_get_accessible;
2798 widgetClass->screen_changed = webkit_web_view_screen_changed;
2799 widgetClass->drag_end = webkit_web_view_drag_end;
2800 widgetClass->drag_data_get = webkit_web_view_drag_data_get;
2801 widgetClass->drag_motion = webkit_web_view_drag_motion;
2802 widgetClass->drag_leave = webkit_web_view_drag_leave;
2803 widgetClass->drag_drop = webkit_web_view_drag_drop;
2804 widgetClass->drag_data_received = webkit_web_view_drag_data_received;
2805 #if GTK_CHECK_VERSION(2, 12, 0)
2806 widgetClass->query_tooltip = webkit_web_view_query_tooltip;
2807 widgetClass->show_help = webkit_web_view_show_help;
2809 widgetClass->map = webkitWebViewMap;
2811 GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
2812 containerClass->add = webkit_web_view_container_add;
2813 containerClass->remove = webkit_web_view_container_remove;
2814 containerClass->forall = webkit_web_view_container_forall;
2817 * make us scrollable (e.g. addable to a GtkScrolledWindow)
2819 #ifdef GTK_API_VERSION_2
2820 webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments;
2821 GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments",
2822 G_TYPE_FROM_CLASS(webViewClass),
2823 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2824 G_STRUCT_OFFSET(WebKitWebViewClass, set_scroll_adjustments),
2826 webkit_marshal_VOID__OBJECT_OBJECT,
2828 GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
2830 g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment");
2831 g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment");
2832 g_object_class_override_property(objectClass, PROP_HSCROLL_POLICY, "hscroll-policy");
2833 g_object_class_override_property(objectClass, PROP_VSCROLL_POLICY, "vscroll-policy");
2840 binding_set = gtk_binding_set_by_class(webViewClass);
2842 gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK,
2845 /* Cut/copy/paste */
2847 gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK,
2848 "cut_clipboard", 0);
2849 gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK,
2850 "copy_clipboard", 0);
2851 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK,
2852 "paste_clipboard", 0);
2853 gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK,
2855 gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
2858 gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK,
2859 "cut_clipboard", 0);
2860 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK,
2861 "copy_clipboard", 0);
2862 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
2863 "paste_clipboard", 0);
2867 gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0),
2869 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
2871 gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0),
2873 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
2875 gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0),
2877 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
2879 gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0),
2881 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
2883 gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0),
2885 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
2887 gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK,
2889 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
2891 gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0),
2893 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
2895 gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0),
2897 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
2899 gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0),
2901 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
2903 gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0),
2905 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
2913 * WebKitWebView:title:
2915 * Returns: the @web_view's document title.
2919 g_object_class_install_property(objectClass, PROP_TITLE,
2920 g_param_spec_string("title",
2922 _("Returns the @web_view's document title"),
2924 WEBKIT_PARAM_READABLE));
2927 * WebKitWebView:uri:
2929 * Returns: the current URI of the contents displayed by the @web_view.
2933 g_object_class_install_property(objectClass, PROP_URI,
2934 g_param_spec_string("uri",
2936 _("Returns the current URI of the contents displayed by the @web_view"),
2938 WEBKIT_PARAM_READABLE));
2941 * WebKitWebView:copy-target-list:
2943 * The list of targets this web view supports for clipboard copying.
2947 g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
2948 g_param_spec_boxed("copy-target-list",
2949 _("Copy target list"),
2950 _("The list of targets this web view supports for clipboard copying"),
2951 GTK_TYPE_TARGET_LIST,
2952 WEBKIT_PARAM_READABLE));
2955 * WebKitWebView:paste-target-list:
2957 * The list of targets this web view supports for clipboard pasting.
2961 g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
2962 g_param_spec_boxed("paste-target-list",
2963 _("Paste target list"),
2964 _("The list of targets this web view supports for clipboard pasting"),
2965 GTK_TYPE_TARGET_LIST,
2966 WEBKIT_PARAM_READABLE));
2968 g_object_class_install_property(objectClass, PROP_SETTINGS,
2969 g_param_spec_object("settings",
2971 _("An associated WebKitWebSettings instance"),
2972 WEBKIT_TYPE_WEB_SETTINGS,
2973 WEBKIT_PARAM_READWRITE));
2976 * WebKitWebView:web-inspector:
2978 * The associated WebKitWebInspector instance.
2982 g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
2983 g_param_spec_object("web-inspector",
2985 _("The associated WebKitWebInspector instance"),
2986 WEBKIT_TYPE_WEB_INSPECTOR,
2987 WEBKIT_PARAM_READABLE));
2990 * WebKitWebView:viewport-attributes:
2992 * The associated #WebKitViewportAttributes instance.
2996 g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES,
2997 g_param_spec_object("viewport-attributes",
2998 _("Viewport Attributes"),
2999 _("The associated WebKitViewportAttributes instance"),
3000 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES,
3001 WEBKIT_PARAM_READABLE));
3004 * WebKitWebView:window-features:
3006 * An associated WebKitWebWindowFeatures instance.
3010 g_object_class_install_property(objectClass, PROP_WINDOW_FEATURES,
3011 g_param_spec_object("window-features",
3013 "An associated WebKitWebWindowFeatures instance",
3014 WEBKIT_TYPE_WEB_WINDOW_FEATURES,
3015 WEBKIT_PARAM_READWRITE));
3017 g_object_class_install_property(objectClass, PROP_EDITABLE,
3018 g_param_spec_boolean("editable",
3020 _("Whether content can be modified by the user"),
3022 WEBKIT_PARAM_READWRITE));
3024 g_object_class_install_property(objectClass, PROP_TRANSPARENT,
3025 g_param_spec_boolean("transparent",
3027 _("Whether content has a transparent background"),
3029 WEBKIT_PARAM_READWRITE));
3032 * WebKitWebView:zoom-level:
3034 * The level of zoom of the content.
3038 g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
3039 g_param_spec_float("zoom-level",
3041 _("The level of zoom of the content"),
3045 WEBKIT_PARAM_READWRITE));
3048 * WebKitWebView:full-content-zoom:
3050 * Whether the full content is scaled when zooming.
3054 g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM,
3055 g_param_spec_boolean("full-content-zoom",
3056 _("Full content zoom"),
3057 _("Whether the full content is scaled when zooming"),
3059 WEBKIT_PARAM_READWRITE));
3062 * WebKitWebView:encoding:
3064 * The default encoding of the web view.
3068 g_object_class_install_property(objectClass, PROP_ENCODING,
3069 g_param_spec_string("encoding",
3071 _("The default encoding of the web view"),
3073 WEBKIT_PARAM_READABLE));
3076 * WebKitWebView:custom-encoding:
3078 * The custom encoding of the web view.
3082 g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING,
3083 g_param_spec_string("custom-encoding",
3084 _("Custom Encoding"),
3085 _("The custom encoding of the web view"),
3087 WEBKIT_PARAM_READWRITE));
3090 * WebKitWebView:load-status:
3092 * Determines the current status of the load.
3094 * Connect to "notify::load-status" to monitor loading.
3096 * Some versions of WebKitGTK+ emitted this signal for the default
3097 * error page, while loading it. This behavior was considered bad,
3098 * because it was essentially exposing an implementation
3099 * detail. From 1.1.19 onwards this signal is no longer emitted for
3100 * the default error pages, but keep in mind that if you override
3101 * the error pages by using webkit_web_frame_load_alternate_string()
3102 * the signals will be emitted.
3106 g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
3107 g_param_spec_enum("load-status",
3109 "Determines the current status of the load",
3110 WEBKIT_TYPE_LOAD_STATUS,
3111 WEBKIT_LOAD_FINISHED,
3112 WEBKIT_PARAM_READABLE));
3115 * WebKitWebView:progress:
3117 * Determines the current progress of the load.
3121 g_object_class_install_property(objectClass, PROP_PROGRESS,
3122 g_param_spec_double("progress",
3124 "Determines the current progress of the load",
3126 WEBKIT_PARAM_READABLE));
3129 * WebKitWebView:icon-uri:
3131 * The URI for the favicon for the #WebKitWebView.
3135 g_object_class_install_property(objectClass, PROP_ICON_URI,
3136 g_param_spec_string("icon-uri",
3138 _("The URI for the favicon for the #WebKitWebView."),
3140 WEBKIT_PARAM_READABLE));
3142 * WebKitWebView:im-context:
3144 * The GtkIMMulticontext for the #WebKitWebView.
3146 * This is the input method context used for all text entry widgets inside
3147 * the #WebKitWebView. It can be used to generate context menu items for
3148 * controlling the active input method.
3152 g_object_class_install_property(objectClass, PROP_IM_CONTEXT,
3153 g_param_spec_object("im-context",
3155 "The GtkIMMultiContext for the #WebKitWebView.",
3156 GTK_TYPE_IM_CONTEXT,
3157 WEBKIT_PARAM_READABLE));
3160 * WebKitWebView:view-mode:
3162 * The "view-mode" media feature for the #WebKitWebView.
3164 * The "view-mode" media feature is additional information for web
3165 * applications about how the application is running, when it comes
3166 * to user experience. Whether the application is running inside a
3167 * regular browser window, in a dedicated window, fullscreen, for
3170 * This property stores a %WebKitWebViewViewMode value that matches
3171 * the "view-mode" media feature the web application will see.
3173 * See http://www.w3.org/TR/view-mode/ for more information.
3177 g_object_class_install_property(objectClass, PROP_VIEW_MODE,
3178 g_param_spec_enum("view-mode",
3180 "The view-mode media feature for the #WebKitWebView.",
3181 WEBKIT_TYPE_WEB_VIEW_VIEW_MODE,
3182 WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED,
3183 WEBKIT_PARAM_READWRITE));
3185 // This property should be undocumented for now. It's only used by DRT.
3186 g_object_class_install_property(objectClass, PROP_SELF_SCROLLING,
3187 g_param_spec_boolean("self-scrolling", "Self-scrolling",
3188 "Whether or not this WebView draws its own scrollbars.",
3190 static_cast<GParamFlags>(G_PARAM_CONSTRUCT_ONLY | WEBKIT_PARAM_READWRITE)));
3192 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
3195 static void webkit_web_view_update_settings(WebKitWebView* webView)
3197 WebKitWebSettingsPrivate* settingsPrivate = webView->priv->webSettings->priv;
3198 Settings* coreSettings = core(webView)->settings();
3200 coreSettings->setDefaultTextEncodingName(settingsPrivate->defaultEncoding.data());
3201 coreSettings->setCursiveFontFamily(settingsPrivate->cursiveFontFamily.data());
3202 coreSettings->setStandardFontFamily(settingsPrivate->defaultFontFamily.data());
3203 coreSettings->setFantasyFontFamily(settingsPrivate->fantasyFontFamily.data());
3204 coreSettings->setFixedFontFamily(settingsPrivate->monospaceFontFamily.data());
3205 coreSettings->setSansSerifFontFamily(settingsPrivate->sansSerifFontFamily.data());
3206 coreSettings->setSerifFontFamily(settingsPrivate->serifFontFamily.data());
3207 coreSettings->setLoadsImagesAutomatically(settingsPrivate->autoLoadImages);
3208 coreSettings->setShrinksStandaloneImagesToFit(settingsPrivate->autoShrinkImages);
3209 coreSettings->setShouldPrintBackgrounds(settingsPrivate->printBackgrounds);
3210 coreSettings->setScriptEnabled(settingsPrivate->enableScripts);
3211 coreSettings->setPluginsEnabled(settingsPrivate->enablePlugins);
3212 coreSettings->setTextAreasAreResizable(settingsPrivate->resizableTextAreas);
3213 coreSettings->setUserStyleSheetLocation(KURL(KURL(), settingsPrivate->userStylesheetURI.data()));
3214 coreSettings->setDeveloperExtrasEnabled(settingsPrivate->enableDeveloperExtras);
3215 coreSettings->setPrivateBrowsingEnabled(settingsPrivate->enablePrivateBrowsing);
3216 coreSettings->setCaretBrowsingEnabled(settingsPrivate->enableCaretBrowsing);
3217 coreSettings->setLocalStorageEnabled(settingsPrivate->enableHTML5LocalStorage);
3218 coreSettings->setLocalStorageDatabasePath(settingsPrivate->html5LocalStorageDatabasePath.data());
3219 coreSettings->setXSSAuditorEnabled(settingsPrivate->enableXSSAuditor);
3220 coreSettings->setSpatialNavigationEnabled(settingsPrivate->enableSpatialNavigation);
3221 coreSettings->setFrameFlatteningEnabled(settingsPrivate->enableFrameFlattening);
3222 coreSettings->setJavaScriptCanOpenWindowsAutomatically(settingsPrivate->javascriptCanOpenWindowsAutomatically);
3223 coreSettings->setJavaScriptCanAccessClipboard(settingsPrivate->javascriptCanAccessClipboard);
3224 coreSettings->setOfflineWebApplicationCacheEnabled(settingsPrivate->enableOfflineWebApplicationCache);
3225 coreSettings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(settingsPrivate->editingBehavior));
3226 coreSettings->setAllowUniversalAccessFromFileURLs(settingsPrivate->enableUniversalAccessFromFileURIs);
3227 coreSettings->setAllowFileAccessFromFileURLs(settingsPrivate->enableFileAccessFromFileURIs);
3228 coreSettings->setDOMPasteAllowed(settingsPrivate->enableDOMPaste);
3229 coreSettings->setNeedsSiteSpecificQuirks(settingsPrivate->enableSiteSpecificQuirks);
3230 coreSettings->setUsesPageCache(settingsPrivate->enablePageCache);
3231 coreSettings->setJavaEnabled(settingsPrivate->enableJavaApplet);
3232 coreSettings->setHyperlinkAuditingEnabled(settingsPrivate->enableHyperlinkAuditing);
3233 coreSettings->setDNSPrefetchingEnabled(settingsPrivate->enableDNSPrefetching);
3235 #if ENABLE(SQL_DATABASE)
3236 AbstractDatabase::setIsAvailable(settingsPrivate->enableHTML5Database);
3239 #if ENABLE(FULLSCREEN_API)
3240 coreSettings->setFullScreenEnabled(settingsPrivate->enableFullscreen);
3243 #if ENABLE(SPELLCHECK)
3244 if (settingsPrivate->enableSpellChecking) {
3245 WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient());
3246 static_cast<WebKit::TextCheckerClientGtk*>(client->textChecker())->updateSpellCheckingLanguage(settingsPrivate->spellCheckingLanguages.data());
3251 coreSettings->setWebGLEnabled(settingsPrivate->enableWebgl);
3254 #if USE(ACCELERATED_COMPOSITING)
3255 coreSettings->setAcceleratedCompositingEnabled(settingsPrivate->enableAcceleratedCompositing);
3258 #if ENABLE(WEB_AUDIO)
3259 coreSettings->setWebAudioEnabled(settingsPrivate->enableWebAudio);
3262 #if ENABLE(WEB_SOCKETS)
3263 coreSettings->setUseHixie76WebSocketProtocol(false);
3266 if (Page* page = core(webView))
3267 page->setTabKeyCyclesThroughElements(settingsPrivate->tabKeyCyclesThroughElements);
3269 webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL);
3272 static inline gint pixelsFromSize(WebKitWebView* webView, gint size)
3274 return size / 72.0 * webViewGetDPI(webView);
3277 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView)
3279 Settings* settings = core(webView)->settings();
3281 const gchar* name = g_intern_string(pspec->name);
3282 GValue value = { 0, { { 0 } } };
3283 g_value_init(&value, pspec->value_type);
3284 g_object_get_property(G_OBJECT(webSettings), name, &value);
3286 if (name == g_intern_string("default-encoding"))
3287 settings->setDefaultTextEncodingName(g_value_get_string(&value));
3288 else if (name == g_intern_string("cursive-font-family"))