2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
3 * Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com>
4 * Copyright (C) 2007 Xan Lopez <xan@gnome.org>
5 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
7 * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
8 * Copyright (C) 2008 Nuanti Ltd.
9 * Copyright (C) 2008, 2009, 2010 Collabora Ltd.
10 * Copyright (C) 2009, 2010, 2012 Igalia S.L.
11 * Copyright (C) 2009 Movial Creative Technologies Inc.
12 * Copyright (C) 2009 Bobby Powers
13 * Copyright (C) 2010 Joone Hur <joone@kldp.org>
14 * Copyright (C) 2012 Igalia S.L.
15 * Copyright (C) 2013 Apple Inc. All rights reserved.
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 #include "webkitwebview.h"
35 #include "AXObjectCache.h"
36 #include "ArchiveResource.h"
37 #include "BackForwardController.h"
38 #include "BackForwardList.h"
39 #include "BatteryClientGtk.h"
40 #include "CairoUtilities.h"
42 #include "ChromeClientGtk.h"
43 #include "ClipboardUtilitiesGtk.h"
44 #include "ContextMenu.h"
45 #include "ContextMenuClientGtk.h"
46 #include "ContextMenuController.h"
48 #include "DatabaseManager.h"
50 #include "DocumentLoader.h"
51 #include "DragActions.h"
52 #include "DragClientGtk.h"
53 #include "DragController.h"
55 #include "DragSession.h"
56 #include "DumpRenderTreeSupportGtk.h"
58 #include "EditorClientGtk.h"
59 #include "EventHandler.h"
60 #include "FloatQuad.h"
61 #include "FocusController.h"
62 #include "FrameLoader.h"
63 #include "FrameLoaderClientGtk.h"
64 #include "FrameLoaderTypes.h"
65 #include "FrameView.h"
66 #include "GUniquePtrGtk.h"
67 #include "GeolocationClientGtk.h"
68 #include "GeolocationController.h"
69 #include "GraphicsContext.h"
70 #include "GtkUtilities.h"
71 #include "GtkVersioning.h"
72 #include "HTMLNames.h"
73 #include "HitTestRequest.h"
74 #include "HitTestResult.h"
75 #include "InspectorClientGtk.h"
76 #include "MainFrame.h"
77 #include "MemoryCache.h"
78 #include "MouseEventWithHitTestResults.h"
79 #include "NotImplemented.h"
80 #include "PageCache.h"
81 #include "Pasteboard.h"
82 #include "PasteboardHelper.h"
83 #include "PlatformKeyboardEvent.h"
84 #include "PlatformWheelEvent.h"
85 #include "ProgressTracker.h"
86 #include "ProgressTrackerClientGtk.h"
87 #include "RenderView.h"
88 #include "ResourceHandle.h"
89 #include "RuntimeEnabledFeatures.h"
90 #include "ScriptController.h"
92 #include "WebKitDOMDocumentPrivate.h"
93 #include "webkitdownload.h"
94 #include "webkitdownloadprivate.h"
95 #include "webkitenumtypes.h"
96 #include "webkitfavicondatabase.h"
97 #include "webkitgeolocationpolicydecision.h"
98 #include "webkitglobalsprivate.h"
99 #include "webkithittestresultprivate.h"
100 #include "webkiticondatabase.h"
101 #include "webkitmarshal.h"
102 #include "webkitnetworkrequest.h"
103 #include "webkitnetworkresponse.h"
104 #include "webkitviewportattributes.h"
105 #include "webkitviewportattributesprivate.h"
106 #include "webkitwebbackforwardlist.h"
107 #include "webkitwebframeprivate.h"
108 #include "webkitwebhistoryitem.h"
109 #include "webkitwebhistoryitemprivate.h"
110 #include "webkitwebinspector.h"
111 #include "webkitwebinspectorprivate.h"
112 #include "webkitwebpolicydecision.h"
113 #include "webkitwebresource.h"
114 #include "webkitwebresourceprivate.h"
115 #include "webkitwebsettingsprivate.h"
116 #include "webkitwebplugindatabaseprivate.h"
117 #include "webkitwebwindowfeatures.h"
118 #include "webkitwebviewprivate.h"
119 #include <bindings/ScriptValue.h>
120 #include <gdk/gdkkeysyms.h>
121 #include <glib/gi18n-lib.h>
123 #include <wtf/text/CString.h>
125 #if ENABLE(DEVICE_ORIENTATION)
126 #include "DeviceMotionClientGtk.h"
127 #include "DeviceOrientationClientGtk.h"
130 #if PLATFORM(WAYLAND) && defined(GDK_WINDOWING_WAYLAND)
131 #include <gdk/gdkwayland.h>
135 * SECTION:webkitwebview
136 * @short_description: The central class of the WebKitGTK+ API
137 * @see_also: #WebKitWebSettings, #WebKitWebFrame
139 * #WebKitWebView is the central class of the WebKitGTK+ API. It is a
140 * #GtkWidget implementing the scrolling interface which means you can
141 * embed in a #GtkScrolledWindow. It is responsible for managing the
142 * drawing of the content, forwarding of events. You can load any URI
143 * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings
144 * you can control various aspects of the rendering and loading of the content.
145 * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A
146 * #WebKitWebFrame can have n children.
149 * /<!-- -->* Create the widgets *<!-- -->/
150 * GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
151 * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
152 * GtkWidget *web_view = webkit_web_view_new ();
154 * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/
155 * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view);
156 * gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
158 * /<!-- -->* Open a webpage *<!-- -->/
159 * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
161 * /<!-- -->* Show the result *<!-- -->/
162 * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
163 * gtk_widget_show_all (main_window);
167 using namespace WebKit;
168 using namespace WebCore;
172 NAVIGATION_REQUESTED,
173 NEW_WINDOW_POLICY_DECISION_REQUESTED,
174 NAVIGATION_POLICY_DECISION_REQUESTED,
175 MIME_TYPE_POLICY_DECISION_REQUESTED,
178 WINDOW_OBJECT_CLEARED,
181 LOAD_PROGRESS_CHANGED,
187 STATUS_BAR_TEXT_CHANGED,
205 DATABASE_QUOTA_EXCEEDED,
206 RESOURCE_REQUEST_STARTING,
207 DOCUMENT_LOAD_FINISHED,
208 GEOLOCATION_POLICY_DECISION_REQUESTED,
209 GEOLOCATION_POLICY_DECISION_CANCELLED,
212 SHOULD_BEGIN_EDITING,
217 SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT,
218 SHOULD_CHANGE_SELECTED_RANGE,
221 USER_CHANGED_CONTENTS,
223 VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED,
224 VIEWPORT_ATTRIBUTES_CHANGED,
225 RESOURCE_RESPONSE_RECEIVED,
226 RESOURCE_LOAD_FINISHED,
227 RESOURCE_CONTENT_LENGTH_RECEIVED,
228 RESOURCE_LOAD_FAILED,
242 PROP_COPY_TARGET_LIST,
243 PROP_PASTE_TARGET_LIST,
247 PROP_VIEWPORT_ATTRIBUTES,
248 PROP_WINDOW_FEATURES,
251 PROP_FULL_CONTENT_ZOOM,
255 PROP_CUSTOM_ENCODING,
258 #ifdef GTK_API_VERSION_2
268 // Undocumented. Leave these properties at the end of the list
269 // so that we can remove them without breaking ABI compatibility.
273 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
275 #ifdef GTK_API_VERSION_2
276 G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
278 G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER,
279 G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0))
282 static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
283 static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
284 static void webkitWebViewDirectionChanged(WebKitWebView*, GtkTextDirection previousDirection, gpointer);
286 static inline WebKitWebViewTargetInfo toWebKitWebViewTargetInfo(PasteboardHelper::PasteboardTargetType flags)
289 case PasteboardHelper::TargetTypeMarkup:
290 return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
292 case PasteboardHelper::TargetTypeText:
293 return WEBKIT_WEB_VIEW_TARGET_INFO_TEXT;
295 case PasteboardHelper::TargetTypeImage:
296 return WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE;
298 case PasteboardHelper::TargetTypeURIList:
299 return WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST;
301 case PasteboardHelper::TargetTypeNetscapeURL:
302 return WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL;
305 ASSERT_NOT_REACHED();
306 return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
310 static GtkTargetList* copyGtkTargetListConvertingWebCoreEnumValuesToWebKitEnumValues(GtkTargetList* coreGtkTargetList)
312 g_return_val_if_fail(coreGtkTargetList, nullptr);
314 GtkTargetList* targetListWithWebKitEnumValues = nullptr;
316 GtkTargetEntry* table(gtk_target_table_new_from_list(coreGtkTargetList, &tableSize));
318 for (int i = 0; i < tableSize; i++)
319 table[i].flags = toWebKitWebViewTargetInfo(static_cast<PasteboardHelper::PasteboardTargetType>(table[i].flags));
321 targetListWithWebKitEnumValues = gtk_target_list_new(table, tableSize);
322 gtk_target_table_free(table, tableSize);
324 return targetListWithWebKitEnumValues;
327 #if ENABLE(CONTEXT_MENUS)
328 static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData)
330 WebKitWebView* view = WEBKIT_WEB_VIEW(userData);
331 WebKitWebViewPrivate* priv = view->priv;
332 GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view));
333 GtkRequisition menuSize;
335 #ifdef GTK_API_VERSION_2
336 gtk_widget_size_request(GTK_WIDGET(menu), &menuSize);
338 gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, NULL);
341 *x = priv->lastPopupXPosition;
342 if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
343 *x -= menuSize.width;
345 *y = priv->lastPopupYPosition;
346 if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
347 *y -= menuSize.height;
353 static Node* getFocusedNode(Frame* frame)
355 if (Document* doc = frame->document())
356 return doc->focusedElement();
360 #if ENABLE(CONTEXT_MENUS)
361 static void contextMenuItemActivated(GtkMenuItem* item, ContextMenuController* controller)
363 ContextMenuItem contextItem(item);
364 controller->contextMenuItemSelected(&contextItem);
367 static void contextMenuConnectActivate(GtkMenuItem* item, ContextMenuController* controller)
369 if (GTK_IS_SEPARATOR_MENU_ITEM(item))
372 if (GtkWidget* menu = gtk_menu_item_get_submenu(item)) {
373 gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller);
377 g_signal_connect(item, "activate", G_CALLBACK(contextMenuItemActivated), controller);
380 static MouseEventWithHitTestResults prepareMouseEventForFrame(Frame* frame, const PlatformMouseEvent& event)
382 HitTestRequest request(HitTestRequest::Active| HitTestRequest::DisallowShadowContent);
383 IntPoint point = frame->view()->windowToContents(event.position());
384 return frame->document()->prepareMouseEvent(request, point, event);
387 // Check enable-default-context-menu setting for compatibility.
388 static bool defaultContextMenuEnabled(WebKitWebView* webView)
390 gboolean enableDefaultContextMenu;
391 g_object_get(webkit_web_view_get_settings(webView), "enable-default-context-menu", &enableDefaultContextMenu, NULL);
392 return enableDefaultContextMenu;
395 static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event, bool triggeredWithKeyboard)
397 Page* page = core(webView);
398 page->contextMenuController().clearContextMenu();
400 Frame* mainFrame = &page->mainFrame();
401 gboolean mousePressEventResult = FALSE;
402 GRefPtr<WebKitHitTestResult> hitTestResult;
404 if (!mainFrame->view())
407 mainFrame->view()->setCursor(pointerCursor());
408 if (page->subframeCount()) {
409 MouseEventWithHitTestResults mev = prepareMouseEventForFrame(mainFrame, event);
410 Frame* targetFrame = EventHandler::subframeForHitTestResult(mev);
412 targetFrame = mainFrame;
414 focusedFrame = &page->focusController().focusedOrMainFrame();
415 if (targetFrame != focusedFrame) {
416 page->focusController().setFocusedFrame(targetFrame);
417 focusedFrame = targetFrame;
419 if (focusedFrame == mainFrame)
420 hitTestResult = adoptGRef(kit(mev.hitTestResult()));
422 focusedFrame = mainFrame;
424 if (focusedFrame->view() && focusedFrame->eventHandler().handleMousePressEvent(event))
425 mousePressEventResult = TRUE;
427 bool handledEvent = focusedFrame->eventHandler().sendContextMenuEvent(event);
431 // If coreMenu is NULL, this means WebCore decided to not create
432 // the default context menu; this may happen when the page is
433 // handling the right-click for reasons other than the context menu.
434 ContextMenu* coreMenu = page->contextMenuController().contextMenu();
436 return mousePressEventResult;
438 GtkMenu* defaultMenu = coreMenu->platformDescription();
441 // We connect the "activate" signal here rather than in ContextMenuGtk to avoid
442 // a layering violation. ContextMenuGtk should not know about the ContextMenuController.
443 gtk_container_foreach(GTK_CONTAINER(defaultMenu), reinterpret_cast<GtkCallback>(contextMenuConnectActivate), &page->contextMenuController());
445 if (!hitTestResult) {
446 MouseEventWithHitTestResults mev = prepareMouseEventForFrame(focusedFrame, event);
447 hitTestResult = adoptGRef(kit(mev.hitTestResult()));
451 g_signal_emit(webView, webkit_web_view_signals[CONTEXT_MENU], 0, defaultMenu, hitTestResult.get(), triggeredWithKeyboard, &handled);
455 // Return now if default context menu is disabled by enable-default-context-menu setting.
456 // Check enable-default-context-menu setting for compatibility.
457 if (!defaultContextMenuEnabled(webView))
460 // Emit populate-popup signal for compatibility.
461 g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, defaultMenu);
463 // If the context menu is now empty, don't show it.
464 GUniquePtr<GList> items(gtk_container_get_children(GTK_CONTAINER(defaultMenu)));
468 WebKitWebViewPrivate* priv = webView->priv;
469 priv->currentMenu = defaultMenu;
470 priv->lastPopupXPosition = event.globalPosition().x();
471 priv->lastPopupYPosition = event.globalPosition().y();
473 gtk_menu_popup(defaultMenu, 0, 0, &PopupMenuPositionFunc, webView, event.button() + 1, gtk_get_current_event_time());
477 static const int gContextMenuMargin = 1;
478 static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame)
480 FrameSelection& selection = frame->selection();
481 if (!selection.selection().isNonOrphanedCaretOrRange()
482 || (selection.selection().isCaret() && !selection.selection().isContentEditable())) {
483 if (Node* focusedNode = getFocusedNode(frame))
484 return focusedNode->pixelSnappedBoundingBox().location();
486 // There was no selection and no focused node, so just put the context
487 // menu into the corner of the view, offset slightly.
488 return IntPoint(gContextMenuMargin, gContextMenuMargin);
491 // selection->selection().firstRange can return 0 here, but if that was the case
492 // selection->selection().isNonOrphanedCaretOrRange() would have returned false
493 // above, so we do not have to check it.
494 IntRect firstRect = frame->editor().firstRectForRange(selection.selection().firstRange().get());
495 return IntPoint(firstRect.x(), firstRect.maxY());
498 static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
500 Frame& frame = core(WEBKIT_WEB_VIEW(widget))->focusController().focusedOrMainFrame();
501 IntPoint location = getLocationForKeyboardGeneratedContextMenu(&frame);
503 FrameView* view = frame.view();
507 // Never let the context menu touch the very edge of the view.
508 location = view->contentsToWindow(location);
509 location.expandedTo(IntPoint(gContextMenuMargin, gContextMenuMargin));
510 location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin));
512 IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location));
513 PlatformMouseEvent event(location, globalPoint, RightButton, PlatformEvent::MousePressed, 0, false, false, false, false, gtk_get_current_event_time());
514 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event, true);
516 #endif // ENABLE(CONTEXT_MENUS)
518 static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
520 // This may be called after the page has been destroyed, in which case we do nothing.
521 Page* page = core(webView);
523 static_cast<WebKit::ChromeClient&>(page->chrome().client()).adjustmentWatcher()->setHorizontalAdjustment(adjustment);
526 static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment)
528 // This may be called after the page has been destroyed, in which case we do nothing.
529 Page* page = core(webView);
531 static_cast<WebKit::ChromeClient&>(page->chrome().client()).adjustmentWatcher()->setVerticalAdjustment(adjustment);
534 #ifndef GTK_API_VERSION_2
535 static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView)
537 Page* page = core(webView);
539 return static_cast<WebKit::ChromeClient&>(page->chrome().client()).adjustmentWatcher()->horizontalAdjustment();
543 static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView)
545 Page* page = core(webView);
547 return static_cast<WebKit::ChromeClient&>(page->chrome().client()).adjustmentWatcher()->verticalAdjustment();
551 static void setHorizontalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
553 webView->priv->horizontalScrollingPolicy = policy;
554 gtk_widget_queue_resize(GTK_WIDGET(webView));
557 static void setVerticalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy)
559 webView->priv->verticalScrollingPolicy = policy;
560 gtk_widget_queue_resize(GTK_WIDGET(webView));
563 static GtkScrollablePolicy getHorizontalScrollPolicy(WebKitWebView* webView)
565 return webView->priv->horizontalScrollingPolicy;
568 static GtkScrollablePolicy getVerticalScrollPolicy(WebKitWebView* webView)
570 return webView->priv->verticalScrollingPolicy;
575 static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
577 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
581 g_value_set_string(value, webkit_web_view_get_title(webView));
584 g_value_set_string(value, webkit_web_view_get_uri(webView));
586 case PROP_COPY_TARGET_LIST:
587 g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView));
589 case PROP_PASTE_TARGET_LIST:
590 g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
593 g_value_set_boolean(value, webkit_web_view_get_editable(webView));
596 g_value_set_object(value, webkit_web_view_get_settings(webView));
598 case PROP_WEB_INSPECTOR:
599 g_value_set_object(value, webkit_web_view_get_inspector(webView));
601 case PROP_VIEWPORT_ATTRIBUTES:
602 g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView));
604 case PROP_WINDOW_FEATURES:
605 g_value_set_object(value, webkit_web_view_get_window_features(webView));
607 case PROP_TRANSPARENT:
608 g_value_set_boolean(value, webkit_web_view_get_transparent(webView));
610 case PROP_ZOOM_LEVEL:
611 g_value_set_float(value, webkit_web_view_get_zoom_level(webView));
613 case PROP_FULL_CONTENT_ZOOM:
614 g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView));
617 g_value_set_string(value, webkit_web_view_get_encoding(webView));
619 case PROP_CUSTOM_ENCODING:
620 g_value_set_string(value, webkit_web_view_get_custom_encoding(webView));
622 case PROP_LOAD_STATUS:
623 g_value_set_enum(value, webkit_web_view_get_load_status(webView));
626 g_value_set_double(value, webkit_web_view_get_progress(webView));
629 g_value_set_string(value, webkit_web_view_get_icon_uri(webView));
631 case PROP_IM_CONTEXT:
632 g_value_set_object(value, webView->priv->imFilter.context());
635 g_value_set_enum(value, webkit_web_view_get_view_mode(webView));
637 #ifndef GTK_API_VERSION_2
638 case PROP_HADJUSTMENT:
639 g_value_set_object(value, getHorizontalAdjustment(webView));
641 case PROP_VADJUSTMENT:
642 g_value_set_object(value, getVerticalAdjustment(webView));
644 case PROP_HSCROLL_POLICY:
645 g_value_set_enum(value, getHorizontalScrollPolicy(webView));
647 case PROP_VSCROLL_POLICY:
648 g_value_set_enum(value, getVerticalScrollPolicy(webView));
651 case PROP_SELF_SCROLLING:
652 g_value_set_boolean(value, webView->priv->selfScrolling);
655 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
659 static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec)
661 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
665 webkit_web_view_set_editable(webView, g_value_get_boolean(value));
668 webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value)));
670 case PROP_WINDOW_FEATURES:
671 webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value)));
673 case PROP_TRANSPARENT:
674 webkit_web_view_set_transparent(webView, g_value_get_boolean(value));
676 case PROP_ZOOM_LEVEL:
677 webkit_web_view_set_zoom_level(webView, g_value_get_float(value));
679 case PROP_FULL_CONTENT_ZOOM:
680 webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value));
682 case PROP_CUSTOM_ENCODING:
683 webkit_web_view_set_custom_encoding(webView, g_value_get_string(value));
686 webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value)));
688 #ifndef GTK_API_VERSION_2
689 case PROP_HADJUSTMENT:
690 setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
692 case PROP_VADJUSTMENT:
693 setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value)));
695 case PROP_HSCROLL_POLICY:
696 setHorizontalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
698 case PROP_VSCROLL_POLICY:
699 setVerticalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value)));
702 case PROP_SELF_SCROLLING:
703 webView->priv->selfScrolling = g_value_get_boolean(value);
706 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
710 #ifdef GTK_API_VERSION_2
711 static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
714 GUniqueOutPtr<GdkRectangle> rects;
715 gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
717 RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window));
719 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
720 #if USE(TEXTURE_MAPPER)
721 GdkRectangle clipRect;
722 gdk_region_get_clipbox(event->region, &clipRect);
723 if (priv->acceleratedCompositingContext->renderLayersToWindow(cr.get(), clipRect)) {
724 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->expose_event(widget, event);
729 for (int i = 0; i < rectCount; i++) {
730 copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(),
731 cr.get(), IntSize(), IntRect(rects.get()[i]));
734 // Chaining up to the parent forces child widgets to be drawn.
735 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->expose_event(widget, event);
739 static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
741 GdkRectangle clipRect;
742 if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
745 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
746 #if USE(TEXTURE_MAPPER)
747 if (priv->acceleratedCompositingContext->renderLayersToWindow(cr, clipRect)) {
748 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr);
753 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
754 if (rectList->status || !rectList->num_rectangles) {
755 cairo_rectangle_list_destroy(rectList);
759 Vector<IntRect> rects;
760 for (int i = 0; i < rectList->num_rectangles; i++) {
761 copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(),
762 enclosingIntRect(FloatRect(rectList->rectangles[i])));
764 cairo_rectangle_list_destroy(rectList);
766 // Chaining up to the parent forces child widgets to be drawn.
767 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr);
770 #endif // GTK_API_VERSION_2
772 static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event)
774 if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event))
776 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event);
779 static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event)
781 if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event))
783 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event);
786 static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event)
788 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
789 WebKitWebViewPrivate* priv = webView->priv;
791 // FIXME: need to keep track of subframe focus for key events
792 gtk_widget_grab_focus(widget);
794 if (!priv->clickCounter.shouldProcessButtonEvent(event))
797 PlatformMouseEvent platformEvent(event);
798 int count = priv->clickCounter.clickCountForGdkButtonEvent(widget, event);
799 platformEvent.setClickCount(count);
801 #if ENABLE(CONTEXT_MENUS)
802 if (event->button == 3)
803 return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event), false);
806 Frame& frame = core(webView)->mainFrame();
810 priv->imFilter.notifyMouseButtonPress();
811 gboolean result = frame.eventHandler().handleMousePressEvent(platformEvent);
816 static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
818 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
820 Frame& mainFrame = core(webView)->mainFrame();
821 if (mainFrame.view())
822 mainFrame.eventHandler().handleMouseReleaseEvent(PlatformMouseEvent(event));
824 /* We always return FALSE here because WebKit can, for the same click, decide
825 * to not handle press-event but handle release-event, which can totally confuse
826 * some GTK+ containers when there are no other events in between. This way we
827 * guarantee that this case never happens, and that if press-event goes through
828 * release-event also goes through.
834 static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event)
836 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
838 Frame& frame = core(webView)->mainFrame();
842 return frame.eventHandler().mouseMoved(PlatformMouseEvent(event));
845 static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event)
847 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
849 Frame& frame = core(webView)->mainFrame();
853 PlatformWheelEvent wheelEvent(event);
854 return frame.eventHandler().handleWheelEvent(wheelEvent);
857 #ifdef GTK_API_VERSION_2
858 static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)
860 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
861 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
865 FrameView* view = coreFrame->view();
869 requisition->width = view->contentsWidth();
870 requisition->height = view->contentsHeight();
873 static void webkit_web_view_get_preferred_width(GtkWidget* widget, gint* minimum, gint* natural)
875 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
876 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
880 FrameView* view = coreFrame->view();
884 *minimum = *natural = view->contentsWidth();
887 static void webkit_web_view_get_preferred_height(GtkWidget* widget, gint* minimum, gint* natural)
889 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
890 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
894 FrameView* view = coreFrame->view();
898 *minimum = *natural = view->contentsHeight();
902 static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*)
904 if (!gtk_widget_get_visible(child))
907 GtkAllocation* allocation = static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(child), "delayed-allocation"));
911 g_object_set_data(G_OBJECT(child), "delayed-allocation", 0);
912 gtk_widget_size_allocate(child, allocation);
913 *allocation = IntRect();
916 static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation, bool sizeChanged)
918 Page* page = core(webView);
920 FrameView* frameView = page->mainFrame().view();
921 if (sizeChanged && frameView) {
922 oldSize = frameView->size();
923 frameView->resize(allocation->width, allocation->height);
926 gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0);
931 WebKit::ChromeClient& chromeClient = static_cast<WebKit::ChromeClient&>(page->chrome().client());
932 chromeClient.widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height));
933 chromeClient.adjustmentWatcher()->updateAdjustmentsFromScrollbars();
936 static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
938 GtkAllocation oldAllocation;
939 gtk_widget_get_allocation(widget, &oldAllocation);
940 bool sizeChanged = allocation->width != oldAllocation.width || allocation->height != oldAllocation.height;
942 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation);
944 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
945 if (sizeChanged && !gtk_widget_get_mapped(widget)) {
946 webView->priv->needsResizeOnMap = true;
949 resizeWebViewFromAllocation(webView, allocation, sizeChanged);
952 static void webkitWebViewMap(GtkWidget* widget)
954 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget);
956 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
957 if (!webView->priv->needsResizeOnMap)
960 GtkAllocation allocation;
961 gtk_widget_get_allocation(widget, &allocation);
962 resizeWebViewFromAllocation(webView, &allocation, true);
963 webView->priv->needsResizeOnMap = false;
966 static void webkit_web_view_grab_focus(GtkWidget* widget)
969 if (gtk_widget_is_sensitive(widget)) {
970 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
971 FocusController& focusController = core(webView)->focusController();
973 focusController.setActive(true);
975 if (focusController.focusedFrame())
976 focusController.setFocused(true);
978 focusController.setFocusedFrame(&core(webView)->mainFrame());
981 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget);
984 static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event)
986 // TODO: Improve focus handling as suggested in
987 // http://bugs.webkit.org/show_bug.cgi?id=16910
988 GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
989 if (!widgetIsOnscreenToplevelWindow(toplevel) || !gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel)))
990 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
992 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
993 FocusController& focusController = core(webView)->focusController();
995 focusController.setActive(true);
996 if (focusController.focusedFrame())
997 focusController.setFocused(true);
999 focusController.setFocusedFrame(&core(webView)->mainFrame());
1001 if (focusController.focusedFrame()->editor().canEdit())
1002 webView->priv->imFilter.notifyFocusedIn();
1003 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
1006 static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event)
1008 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1010 // We may hit this code while destroying the widget, and we might
1011 // no longer have a page, then.
1012 if (Page* page = core(webView)) {
1013 page->focusController().setActive(false);
1014 page->focusController().setFocused(false);
1017 webView->priv->imFilter.notifyFocusedOut();
1018 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
1021 static void webkit_web_view_realize(GtkWidget* widget)
1023 gtk_widget_set_realized(widget, TRUE);
1025 GtkAllocation allocation;
1026 gtk_widget_get_allocation(widget, &allocation);
1028 GdkWindowAttr attributes;
1029 attributes.window_type = GDK_WINDOW_CHILD;
1030 attributes.x = allocation.x;
1031 attributes.y = allocation.y;
1032 attributes.width = allocation.width;
1033 attributes.height = allocation.height;
1034 attributes.wclass = GDK_INPUT_OUTPUT;
1035 attributes.visual = gtk_widget_get_visual(widget);
1036 #ifdef GTK_API_VERSION_2
1037 attributes.colormap = gtk_widget_get_colormap(widget);
1039 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
1041 | GDK_BUTTON_PRESS_MASK
1042 | GDK_BUTTON_RELEASE_MASK
1044 #if GTK_CHECK_VERSION(3, 3, 18)
1045 | GDK_SMOOTH_SCROLL_MASK
1047 | GDK_POINTER_MOTION_MASK
1048 | GDK_KEY_PRESS_MASK
1049 | GDK_KEY_RELEASE_MASK
1050 | GDK_BUTTON_MOTION_MASK
1051 | GDK_BUTTON1_MOTION_MASK
1052 | GDK_BUTTON2_MOTION_MASK
1053 | GDK_BUTTON3_MOTION_MASK;
1055 gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
1056 #ifdef GTK_API_VERSION_2
1057 attributes_mask |= GDK_WA_COLORMAP;
1059 GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask);
1061 gtk_widget_set_window(widget, window);
1062 gdk_window_set_user_data(window, widget);
1064 #ifdef GTK_API_VERSION_2
1065 gtk_widget_style_attach(widget);
1066 gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL);
1068 gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
1072 #ifdef GTK_API_VERSION_2
1073 static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* horizontalAdjustment, GtkAdjustment* verticalAdjustment)
1075 setHorizontalAdjustment(webView, horizontalAdjustment);
1076 setVerticalAdjustment(webView, verticalAdjustment);
1080 static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget)
1082 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1083 WebKitWebViewPrivate* priv = webView->priv;
1085 priv->children.add(widget);
1086 gtk_widget_set_parent(widget, GTK_WIDGET(container));
1089 static void webkit_web_view_container_remove(GtkContainer* container, GtkWidget* widget)
1091 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1092 WebKitWebViewPrivate* priv = webView->priv;
1094 if (priv->children.contains(widget)) {
1095 gtk_widget_unparent(widget);
1096 priv->children.remove(widget);
1100 static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData)
1102 WebKitWebView* webView = WEBKIT_WEB_VIEW(container);
1103 WebKitWebViewPrivate* priv = webView->priv;
1105 HashSet<GtkWidget*> children = priv->children;
1106 HashSet<GtkWidget*>::const_iterator end = children.end();
1107 for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current)
1108 (*callback)(*current, callbackData);
1111 static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*)
1116 static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*)
1121 static gboolean webkit_web_view_real_close_web_view(WebKitWebView*)
1126 static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*)
1128 return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
1131 static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object)
1136 static gchar* webkit_web_view_real_choose_file(WebKitWebView*, WebKitWebFrame*, const gchar* old_name)
1139 return g_strdup(old_name);
1143 WEBKIT_SCRIPT_DIALOG_ALERT,
1144 WEBKIT_SCRIPT_DIALOG_CONFIRM,
1145 WEBKIT_SCRIPT_DIALOG_PROMPT
1146 } WebKitScriptDialogType;
1148 static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, WebKitScriptDialogType type, const gchar* defaultValue, gchar** value)
1150 GtkMessageType messageType;
1151 GtkButtonsType buttons;
1152 gint defaultResponse;
1155 GtkWidget* entry = 0;
1156 gboolean didConfirm = FALSE;
1159 case WEBKIT_SCRIPT_DIALOG_ALERT:
1160 messageType = GTK_MESSAGE_WARNING;
1161 buttons = GTK_BUTTONS_CLOSE;
1162 defaultResponse = GTK_RESPONSE_CLOSE;
1164 case WEBKIT_SCRIPT_DIALOG_CONFIRM:
1165 messageType = GTK_MESSAGE_QUESTION;
1166 buttons = GTK_BUTTONS_OK_CANCEL;
1167 defaultResponse = GTK_RESPONSE_OK;
1169 case WEBKIT_SCRIPT_DIALOG_PROMPT:
1170 messageType = GTK_MESSAGE_QUESTION;
1171 buttons = GTK_BUTTONS_OK_CANCEL;
1172 defaultResponse = GTK_RESPONSE_OK;
1175 g_warning("Unknown value for WebKitScriptDialogType.");
1179 window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
1180 dialog = gtk_message_dialog_new(widgetIsOnscreenToplevelWindow(window) ? GTK_WINDOW(window) : 0,
1181 GTK_DIALOG_DESTROY_WITH_PARENT,
1186 gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL);
1187 gtk_window_set_title(GTK_WINDOW(dialog), title);
1190 if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) {
1191 entry = gtk_entry_new();
1192 gtk_entry_set_text(GTK_ENTRY(entry), defaultValue);
1193 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
1194 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
1195 gtk_widget_show(entry);
1198 gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
1199 gint response = gtk_dialog_run(GTK_DIALOG(dialog));
1202 case GTK_RESPONSE_OK:
1205 *value = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
1207 case GTK_RESPONSE_CANCEL:
1212 gtk_widget_destroy(GTK_WIDGET(dialog));
1216 static gboolean webkit_web_view_real_script_alert(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message)
1218 webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_ALERT, 0, 0);
1222 static gboolean webkit_web_view_real_script_confirm(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm)
1224 *didConfirm = webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_CONFIRM, 0, 0);
1228 static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value)
1230 if (!webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_PROMPT, defaultValue, value))
1235 static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId)
1237 g_message("console message: %s @%d: %s\n", sourceId, line, message);
1241 static void webkit_web_view_real_select_all(WebKitWebView* webView)
1243 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1244 frame.editor().command("SelectAll").execute();
1247 static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView)
1249 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1250 frame.editor().command("Cut").execute();
1253 static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
1255 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1256 frame.editor().command("Copy").execute();
1259 static void webkit_web_view_real_undo(WebKitWebView* webView)
1261 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1262 frame.editor().command("Undo").execute();
1265 static void webkit_web_view_real_redo(WebKitWebView* webView)
1267 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1268 frame.editor().command("Redo").execute();
1271 static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
1273 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
1274 g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
1275 step == GTK_MOVEMENT_DISPLAY_LINES ||
1276 step == GTK_MOVEMENT_PAGES ||
1277 step == GTK_MOVEMENT_BUFFER_ENDS, FALSE);
1278 g_return_val_if_fail(count == 1 || count == -1, FALSE);
1280 ScrollDirection direction;
1281 ScrollGranularity granularity;
1284 case GTK_MOVEMENT_DISPLAY_LINES:
1285 granularity = ScrollByLine;
1287 direction = ScrollDown;
1289 direction = ScrollUp;
1291 case GTK_MOVEMENT_VISUAL_POSITIONS:
1292 granularity = ScrollByLine;
1294 direction = ScrollRight;
1296 direction = ScrollLeft;
1298 case GTK_MOVEMENT_PAGES:
1299 granularity = ScrollByPage;
1301 direction = ScrollDown;
1303 direction = ScrollUp;
1305 case GTK_MOVEMENT_BUFFER_ENDS:
1306 granularity = ScrollByDocument;
1308 direction = ScrollDown;
1310 direction = ScrollUp;
1313 g_assert_not_reached();
1317 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1318 if (!frame.eventHandler().scrollOverflow(direction, granularity))
1319 frame.view()->scroll(direction, granularity);
1324 static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
1326 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1327 frame.editor().command("Paste").execute();
1330 static gboolean webkit_web_view_real_should_allow_editing_action(WebKitWebView*)
1335 static gboolean webkit_web_view_real_entering_fullscreen(WebKitWebView* webView)
1340 static gboolean webkit_web_view_real_leaving_fullscreen(WebKitWebView* webView)
1345 static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request)
1347 GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request);
1348 if (responseID == GTK_RESPONSE_ACCEPT) {
1349 GUniquePtr<GSList> filesList(gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)));
1350 GRefPtr<GPtrArray> filesArray = adoptGRef(g_ptr_array_new());
1351 for (GSList* file = filesList.get(); file; file = g_slist_next(file))
1352 g_ptr_array_add(filesArray.get(), file->data);
1353 g_ptr_array_add(filesArray.get(), 0);
1354 webkit_file_chooser_request_select_files(adoptedRequest.get(), reinterpret_cast<const gchar* const*>(filesArray->pdata));
1357 gtk_widget_destroy(GTK_WIDGET(dialog));
1360 static gboolean webkitWebViewRealRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request)
1362 GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView));
1363 if (!widgetIsOnscreenToplevelWindow(toplevel))
1366 gboolean allowsMultipleSelection = webkit_file_chooser_request_get_select_multiple(request);
1367 GtkWidget* dialog = gtk_file_chooser_dialog_new(allowsMultipleSelection ? _("Select Files") : _("Select File"),
1368 toplevel ? GTK_WINDOW(toplevel) : 0,
1369 GTK_FILE_CHOOSER_ACTION_OPEN,
1370 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
1371 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
1374 if (GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(request))
1375 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
1376 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), allowsMultipleSelection);
1378 if (const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(request))
1379 gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), selectedFiles[0]);
1381 g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request));
1382 gtk_widget_show(dialog);
1387 static void webkit_web_view_dispose(GObject* object)
1389 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
1390 WebKitWebViewPrivate* priv = webView->priv;
1391 WebCore::Page* corePagePtr = priv->corePage;
1393 priv->disposing = TRUE;
1395 // Make sure GtkAdjustmentWatcher won't be reacting to adjustment changes after the
1396 // WebView is destroyed.
1397 setHorizontalAdjustment(webView, 0);
1398 setVerticalAdjustment(webView, 0);
1400 // These smart pointers are cleared manually, because some cleanup operations are
1401 // very sensitive to their value. We may crash if these are done in the wrong order.
1402 priv->backForwardList.clear();
1404 if (priv->corePage) {
1405 webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
1406 core(priv->mainFrame)->loader().detachFromParent();
1410 if (priv->webSettings) {
1411 g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView);
1412 priv->webSettings.clear();
1415 if (priv->currentMenu) {
1416 gtk_widget_destroy(GTK_WIDGET(priv->currentMenu));
1417 priv->currentMenu = 0;
1420 priv->webInspector.clear();
1421 priv->viewportAttributes.clear();
1422 priv->webWindowFeatures.clear();
1423 priv->mainResource.clear();
1424 priv->subResources.clear();
1425 priv->targetList.clear();
1427 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
1429 // We need to run the parent's dispose before destroying the Page
1430 // pointer. Otherwise we're triggering the deletion of
1431 // InspectorFrontendClient before it can clean up itself.
1435 static void webkit_web_view_finalize(GObject* object)
1437 // We need to manually call the destructor here, since this object's memory is managed
1438 // by GLib. This calls all C++ members' destructors and prevents memory leaks.
1439 WEBKIT_WEB_VIEW(object)->priv->~WebKitWebViewPrivate();
1440 G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
1443 static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1445 gpointer newWebView = g_value_get_object(handlerReturn);
1446 g_value_set_object(returnAccu, newWebView);
1448 // Continue if we don't have a newWebView
1452 static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
1454 WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn);
1455 g_value_set_enum(returnAccu, navigationResponse);
1457 if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT)
1463 #if HAVE(ACCESSIBILITY)
1464 static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
1466 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1470 if (!AXObjectCache::accessibilityEnabled())
1471 AXObjectCache::enableAccessibility();
1473 Frame& coreFrame = core(webView)->mainFrame();
1475 Document* doc = coreFrame.document();
1479 AccessibilityObject* rootAccessible = doc->axObjectCache()->rootObject();
1480 if (!rootAccessible)
1483 AtkObject* axRoot = rootAccessible->wrapper();
1484 if (!axRoot || !ATK_IS_OBJECT(axRoot))
1487 // Ensure the parent is set to make top-down and bottom-up navigation work.
1488 GtkWidget* parentWidget = gtk_widget_get_parent(widget);
1489 AtkObject* axParent = parentWidget ? gtk_widget_get_accessible(parentWidget) : 0;
1491 atk_object_set_parent(axRoot, axParent);
1497 static double screenDPI(GdkScreen* screen)
1499 // gdk_screen_get_resolution() returns -1 when no DPI is set.
1500 double dpi = gdk_screen_get_resolution(screen);
1504 static const double kMillimetresPerInch = 25.4;
1505 double diagonalSizeInPixels = hypot(gdk_screen_get_width(screen), gdk_screen_get_height(screen));
1506 double diagonalSizeInInches = hypot(gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm(screen)) / kMillimetresPerInch;
1507 return diagonalSizeInPixels / diagonalSizeInInches;
1510 static gdouble webViewGetDPI(WebKitWebView* webView)
1512 if (webView->priv->webSettings->priv->enforce96DPI)
1515 static const double defaultDPI = 96;
1516 GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
1517 return screen ? screenDPI(screen) : defaultDPI;
1520 static inline gint webViewConvertFontSizeToPixels(WebKitWebView* webView, double fontSize)
1522 return fontSize / 72.0 * webViewGetDPI(webView);
1525 static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen)
1527 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1528 WebKitWebViewPrivate* priv = webView->priv;
1530 if (priv->disposing)
1533 WebKitWebSettings* webSettings = priv->webSettings.get();
1534 Settings& settings = core(webView)->settings();
1535 guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
1537 g_object_get(webSettings,
1538 "default-font-size", &defaultFontSize,
1539 "default-monospace-font-size", &defaultMonospaceFontSize,
1540 "minimum-font-size", &minimumFontSize,
1541 "minimum-logical-font-size", &minimumLogicalFontSize,
1544 settings.setDefaultFontSize(webViewConvertFontSizeToPixels(webView, defaultFontSize));
1545 settings.setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, defaultMonospaceFontSize));
1546 settings.setMinimumFontSize(webViewConvertFontSizeToPixels(webView, minimumFontSize));
1547 settings.setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, minimumLogicalFontSize));
1550 #if ENABLE(DRAG_SUPPORT)
1551 static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
1553 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1554 if (!webView->priv->dragAndDropHelper.handleDragEnd(context))
1557 Frame& frame = core(webView)->focusController().focusedOrMainFrame();
1559 // Synthesize a button release event to send with the drag end action.
1560 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_RELEASE));
1561 int x, y, xRoot, yRoot;
1562 GdkModifierType modifiers = static_cast<GdkModifierType>(0);
1563 #ifdef GTK_API_VERSION_2
1564 GdkDisplay* display = gdk_display_get_default();
1565 gdk_display_get_pointer(display, 0, &xRoot, &yRoot, &modifiers);
1566 event->button.window = gdk_display_get_window_at_pointer(display, &x, &y);
1568 GdkDevice* device = gdk_drag_context_get_device(context);
1569 event->button.window = gdk_device_get_window_at_position(device, &x, &y);
1570 gdk_device_get_position(device, 0, &xRoot, &yRoot);
1573 if (event->button.window)
1574 g_object_ref(event->button.window);
1575 event->button.x = x;
1576 event->button.y = y;
1577 event->button.x_root = xRoot;
1578 event->button.y_root = yRoot;
1579 event->button.state = modifiers;
1581 PlatformMouseEvent platformEvent(&event->button);
1582 frame.eventHandler().dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
1585 static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint)
1587 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
1590 static void dragExitedCallback(GtkWidget* widget, DragData& dragData, bool dropHappened)
1592 // Don't call dragExited if we have just received a drag-drop signal. This
1593 // happens in the case of a successful drop onto the view.
1595 core(WEBKIT_WEB_VIEW(widget))->dragController().dragExited(dragData);
1596 core(WEBKIT_WEB_VIEW(widget))->dragController().dragEnded();
1599 static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time)
1601 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback);
1604 static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1606 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1607 IntPoint position(x, y);
1608 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragMotion(context, position, time);
1612 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
1613 DragOperation operation = core(webView)->dragController().dragUpdated(dragData).operation;
1614 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1618 static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time)
1620 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1622 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info, position);
1626 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
1627 DragOperation operation = core(webView)->dragController().dragEntered(dragData).operation;
1628 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
1631 static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
1633 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1634 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragDrop(context);
1638 IntPoint position(x, y);
1639 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context)));
1640 core(webView)->dragController().performDrag(dragData);
1641 gtk_drag_finish(context, TRUE, FALSE, time);
1644 #endif // ENABLE(DRAG_SUPPORT)
1646 static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip)
1648 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv;
1650 if (keyboard_mode) {
1651 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
1653 // Get the title of the current focused element.
1654 Frame& coreFrame = core(webView)->focusController().focusedOrMainFrame();
1656 Node* node = getFocusedNode(&coreFrame);
1660 for (Node* titleNode = node; titleNode; titleNode = titleNode->parentNode()) {
1661 if (titleNode->isElementNode()) {
1662 String title = toElement(titleNode)->title();
1663 if (!title.isEmpty()) {
1664 if (FrameView* view = coreFrame.view()) {
1665 GdkRectangle area = view->contentsToWindow(node->pixelSnappedBoundingBox());
1666 gtk_tooltip_set_tip_area(tooltip, &area);
1668 gtk_tooltip_set_text(tooltip, title.utf8().data());
1678 if (priv->tooltipText.length() > 0) {
1679 if (!keyboard_mode) {
1680 if (!priv->tooltipArea.isEmpty()) {
1681 GdkRectangle area = priv->tooltipArea;
1682 gtk_tooltip_set_tip_area(tooltip, &area);
1684 gtk_tooltip_set_tip_area(tooltip, 0);
1686 gtk_tooltip_set_text(tooltip, priv->tooltipText.data());
1693 static gboolean webkit_web_view_show_help(GtkWidget* widget, GtkWidgetHelpType help_type)
1695 if (help_type == GTK_WIDGET_HELP_TOOLTIP)
1696 gtk_widget_set_has_tooltip(widget, TRUE);
1698 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->show_help(widget, help_type);
1701 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
1703 GtkBindingSet* binding_set;
1712 * WebKitWebView::create-web-view:
1713 * @web_view: the object on which the signal is emitted
1714 * @frame: the #WebKitWebFrame
1716 * Emitted when the creation of a new window is requested.
1717 * If this signal is handled the signal handler should return the
1718 * newly created #WebKitWebView.
1720 * The new #WebKitWebView should not be displayed to the user
1721 * until the #WebKitWebView::web-view-ready signal is emitted.
1723 * The signal handlers should not try to deal with the reference count for
1724 * the new #WebKitWebView. The widget to which the widget is added will
1727 * Return value: (transfer full): a newly allocated #WebKitWebView, or %NULL
1731 webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
1732 G_TYPE_FROM_CLASS(webViewClass),
1733 (GSignalFlags)G_SIGNAL_RUN_LAST,
1734 G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view),
1735 webkit_signal_accumulator_object_handled,
1737 webkit_marshal_OBJECT__OBJECT,
1738 WEBKIT_TYPE_WEB_VIEW , 1,
1739 WEBKIT_TYPE_WEB_FRAME);
1742 * WebKitWebView::web-view-ready:
1743 * @web_view: the object on which the signal is emitted
1745 * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView
1746 * should be displayed to the user. When this signal is emitted
1747 * all the information about how the window should look, including
1748 * size, position, whether the location, status and scroll bars
1749 * should be displayed, is already set on the
1750 * #WebKitWebWindowFeatures object contained by the #WebKitWebView.
1752 * Notice that some of that information may change during the life
1753 * time of the window, so you may want to connect to the ::notify
1754 * signal of the #WebKitWebWindowFeatures object to handle those.
1756 * Return value: %TRUE to stop handlers from being invoked for the event or
1757 * %FALSE to propagate the event furter
1761 webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
1762 G_TYPE_FROM_CLASS(webViewClass),
1763 (GSignalFlags)G_SIGNAL_RUN_LAST,
1764 G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready),
1765 g_signal_accumulator_true_handled,
1767 webkit_marshal_BOOLEAN__VOID,
1771 * WebKitWebView::close-web-view:
1772 * @web_view: the object on which the signal is emitted
1774 * Emitted when closing a #WebKitWebView is requested. This occurs when a
1775 * call is made from JavaScript's window.close function. The default
1776 * signal handler does not do anything. It is the owner's responsibility
1777 * to hide or delete the web view, if necessary.
1779 * Return value: %TRUE to stop handlers from being invoked for the event or
1780 * %FALSE to propagate the event furter
1784 webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
1785 G_TYPE_FROM_CLASS(webViewClass),
1786 (GSignalFlags)G_SIGNAL_RUN_LAST,
1787 G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view),
1788 g_signal_accumulator_true_handled,
1790 webkit_marshal_BOOLEAN__VOID,
1794 * WebKitWebView::navigation-requested:
1795 * @web_view: the object on which the signal is emitted
1796 * @frame: the #WebKitWebFrame that required the navigation
1797 * @request: a #WebKitNetworkRequest
1799 * Emitted when @frame requests a navigation to another page.
1801 * Return value: a #WebKitNavigationResponse
1803 * Deprecated: Use WebKitWebView::navigation-policy-decision-requested
1806 webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
1807 G_TYPE_FROM_CLASS(webViewClass),
1808 (GSignalFlags)G_SIGNAL_RUN_LAST,
1809 G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
1810 webkit_navigation_request_handled,
1812 webkit_marshal_ENUM__OBJECT_OBJECT,
1813 WEBKIT_TYPE_NAVIGATION_RESPONSE, 2,
1814 WEBKIT_TYPE_WEB_FRAME,
1815 WEBKIT_TYPE_NETWORK_REQUEST);
1818 * WebKitWebView::new-window-policy-decision-requested:
1819 * @web_view: the object on which the signal is emitted
1820 * @frame: the #WebKitWebFrame that required the navigation
1821 * @request: a #WebKitNetworkRequest
1822 * @navigation_action: a #WebKitWebNavigationAction
1823 * @policy_decision: a #WebKitWebPolicyDecision
1825 * Emitted when @frame requests opening a new window. With this
1826 * signal the browser can use the context of the request to decide
1827 * about the new window. If the request is not handled the default
1828 * behavior is to allow opening the new window to load the URI,
1829 * which will cause a create-web-view signal emission where the
1830 * browser handles the new window action but without information
1831 * of the context that caused the navigation. The following
1832 * navigation-policy-decision-requested emissions will load the
1833 * page after the creation of the new window just with the
1834 * information of this new navigation context, without any
1835 * information about the action that made this new window to be
1838 * Notice that if you return TRUE, meaning that you handled the
1839 * signal, you are expected to have decided what to do, by calling
1840 * webkit_web_policy_decision_ignore(),
1841 * webkit_web_policy_decision_use(), or
1842 * webkit_web_policy_decision_download() on the @policy_decision
1845 * Return value: %TRUE if a decision was made, %FALSE to have the
1846 * default behavior apply
1850 webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] = g_signal_new("new-window-policy-decision-requested",
1851 G_TYPE_FROM_CLASS(webViewClass),
1852 (GSignalFlags)G_SIGNAL_RUN_LAST,
1854 g_signal_accumulator_true_handled,
1856 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1858 WEBKIT_TYPE_WEB_FRAME,
1859 WEBKIT_TYPE_NETWORK_REQUEST,
1860 WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1861 WEBKIT_TYPE_WEB_POLICY_DECISION);
1864 * WebKitWebView::navigation-policy-decision-requested:
1865 * @web_view: the object on which the signal is emitted
1866 * @frame: the #WebKitWebFrame that required the navigation
1867 * @request: a #WebKitNetworkRequest
1868 * @navigation_action: a #WebKitWebNavigationAction
1869 * @policy_decision: a #WebKitWebPolicyDecision
1871 * Emitted when @frame requests a navigation to another page.
1872 * If this signal is not handled, the default behavior is to allow the
1875 * Notice that if you return TRUE, meaning that you handled the
1876 * signal, you are expected to have decided what to do, by calling
1877 * webkit_web_policy_decision_ignore(),
1878 * webkit_web_policy_decision_use(), or
1879 * webkit_web_policy_decision_download() on the @policy_decision
1882 * Return value: %TRUE if a decision was made, %FALSE to have the
1883 * default behavior apply
1887 webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested",
1888 G_TYPE_FROM_CLASS(webViewClass),
1889 (GSignalFlags)G_SIGNAL_RUN_LAST,
1891 g_signal_accumulator_true_handled,
1893 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT,
1895 WEBKIT_TYPE_WEB_FRAME,
1896 WEBKIT_TYPE_NETWORK_REQUEST,
1897 WEBKIT_TYPE_WEB_NAVIGATION_ACTION,
1898 WEBKIT_TYPE_WEB_POLICY_DECISION);
1901 * WebKitWebView::mime-type-policy-decision-requested:
1902 * @web_view: the object on which the signal is emitted
1903 * @frame: the #WebKitWebFrame that required the policy decision
1904 * @request: a WebKitNetworkRequest
1905 * @mimetype: the MIME type attempted to load
1906 * @policy_decision: a #WebKitWebPolicyDecision
1908 * Decide whether or not to display the given MIME type. If this
1909 * signal is not handled, the default behavior is to show the
1910 * content of the requested URI if WebKit can show this MIME
1911 * type and the content disposition is not a download; if WebKit
1912 * is not able to show the MIME type nothing happens.
1914 * Notice that if you return TRUE, meaning that you handled the
1915 * signal, you are expected to be aware of the "Content-Disposition"
1916 * header. A value of "attachment" usually indicates a download
1917 * regardless of the MIME type, see also
1918 * soup_message_headers_get_content_disposition(). And you must call
1919 * webkit_web_policy_decision_ignore(),
1920 * webkit_web_policy_decision_use(), or
1921 * webkit_web_policy_decision_download() on the @policy_decision
1924 * Return value: %TRUE if a decision was made, %FALSE to have the
1925 * default behavior apply
1929 webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
1930 G_TYPE_FROM_CLASS(webViewClass),
1931 (GSignalFlags)G_SIGNAL_RUN_LAST,
1933 g_signal_accumulator_true_handled,
1935 webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT,
1937 WEBKIT_TYPE_WEB_FRAME,
1938 WEBKIT_TYPE_NETWORK_REQUEST,
1940 WEBKIT_TYPE_WEB_POLICY_DECISION);
1943 * WebKitWebView::window-object-cleared:
1944 * @web_view: the object on which the signal is emitted
1945 * @frame: the #WebKitWebFrame to which @window_object belongs
1946 * @context: the #JSGlobalContextRef holding the global object and other
1947 * execution state; equivalent to the return value of
1948 * webkit_web_frame_get_global_context(@frame)
1949 * @window_object: the #JSObjectRef representing the frame's JavaScript
1952 * Emitted when the JavaScript window object in a #WebKitWebFrame has been
1953 * cleared in preparation for a new load. This is the preferred place to
1954 * set custom properties on the window object using the JavaScriptCore API.
1956 webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared",
1957 G_TYPE_FROM_CLASS(webViewClass),
1958 (GSignalFlags)G_SIGNAL_RUN_LAST,
1959 G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared),
1962 webkit_marshal_VOID__OBJECT_POINTER_POINTER,
1964 WEBKIT_TYPE_WEB_FRAME,
1969 * WebKitWebView::download-requested:
1970 * @web_view: the object on which the signal is emitted
1971 * @download: a #WebKitDownload object that lets you control the
1974 * A new Download is being requested. By default, if the signal is
1975 * not handled, the download is cancelled. If you handle the download
1976 * and call webkit_download_set_destination_uri(), it will be
1977 * started for you. If you need to set the destination asynchronously
1978 * you are responsible for starting or cancelling it yourself.
1980 * If you intend to handle downloads yourself rather than using
1981 * the #WebKitDownload helper object you must handle this signal,
1982 * and return %FALSE.
1984 * Also, keep in mind that the default policy for WebKitGTK+ is to
1985 * ignore files with a MIME type that it does not know how to
1986 * handle, which means this signal won't be emitted in the default
1987 * setup. One way to trigger downloads is to connect to
1988 * WebKitWebView::mime-type-policy-decision-requested and call
1989 * webkit_web_policy_decision_download() on the
1990 * #WebKitWebPolicyDecision in the parameter list for the kind of
1991 * files you want your application to download (a common solution
1992 * is to download anything that WebKit can't handle, which you can
1993 * figure out by using webkit_web_view_can_show_mime_type()).
1995 * Return value: TRUE if the download should be performed, %FALSE to
2000 webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested",
2001 G_TYPE_FROM_CLASS(webViewClass),
2002 (GSignalFlags)G_SIGNAL_RUN_LAST,
2004 g_signal_accumulator_true_handled,
2006 webkit_marshal_BOOLEAN__OBJECT,
2008 WEBKIT_TYPE_DOWNLOAD);
2011 * WebKitWebView::load-started:
2012 * @web_view: the object on which the signal is emitted
2013 * @frame: the frame going to do the load
2015 * When a #WebKitWebFrame begins to load this signal is emitted.
2017 * Deprecated: Use the "load-status" property instead.
2019 webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
2020 G_TYPE_FROM_CLASS(webViewClass),
2021 (GSignalFlags)G_SIGNAL_RUN_LAST,
2025 g_cclosure_marshal_VOID__OBJECT,
2027 WEBKIT_TYPE_WEB_FRAME);
2030 * WebKitWebView::load-committed:
2031 * @web_view: the object on which the signal is emitted
2032 * @frame: the main frame that received the first data
2034 * When a #WebKitWebFrame loaded the first data this signal is emitted.
2036 * Deprecated: Use the "load-status" property instead.
2038 webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
2039 G_TYPE_FROM_CLASS(webViewClass),
2040 (GSignalFlags)G_SIGNAL_RUN_LAST,
2044 g_cclosure_marshal_VOID__OBJECT,
2046 WEBKIT_TYPE_WEB_FRAME);
2050 * WebKitWebView::load-progress-changed:
2051 * @web_view: the #WebKitWebView
2052 * @progress: the global progress
2054 * Deprecated: Use the "progress" property instead.
2056 webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
2057 G_TYPE_FROM_CLASS(webViewClass),
2058 (GSignalFlags)G_SIGNAL_RUN_LAST,
2062 g_cclosure_marshal_VOID__INT,
2067 * WebKitWebView::load-error:
2068 * @web_view: the object on which the signal is emitted
2069 * @web_frame: the #WebKitWebFrame
2070 * @uri: the URI that triggered the error
2071 * @web_error: the #GError that was triggered
2073 * An error occurred while loading. By default, if the signal is not
2074 * handled, the @web_view will display a stock error page. You need to
2075 * handle the signal if you want to provide your own error page.
2079 * Return value: %TRUE to stop other handlers from being invoked for the
2080 * event. %FALSE to propagate the event further.
2082 webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error",
2083 G_TYPE_FROM_CLASS(webViewClass),
2084 (GSignalFlags)(G_SIGNAL_RUN_LAST),
2086 g_signal_accumulator_true_handled,
2088 webkit_marshal_BOOLEAN__OBJECT_STRING_BOXED,
2090 WEBKIT_TYPE_WEB_FRAME,
2095 * WebKitWebView::load-finished:
2096 * @web_view: the #WebKitWebView
2097 * @frame: the #WebKitWebFrame
2099 * Deprecated: Use the "load-status" property instead.
2101 webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
2102 G_TYPE_FROM_CLASS(webViewClass),
2103 (GSignalFlags)G_SIGNAL_RUN_LAST,
2107 g_cclosure_marshal_VOID__OBJECT,
2109 WEBKIT_TYPE_WEB_FRAME);
2112 * WebKitWebView::onload-event:
2113 * @web_view: the object on which the signal is emitted
2116 * When a #WebKitWebFrame receives an onload event this signal is emitted.
2118 webkit_web_view_signals[ONLOAD_EVENT] = g_signal_new("onload-event",
2119 G_TYPE_FROM_CLASS(webViewClass),
2120 (GSignalFlags)G_SIGNAL_RUN_LAST,
2124 g_cclosure_marshal_VOID__OBJECT,
2126 WEBKIT_TYPE_WEB_FRAME);
2129 * WebKitWebView::title-changed:
2130 * @web_view: the object on which the signal is emitted
2131 * @frame: the main frame
2132 * @title: the new title
2134 * When a #WebKitWebFrame changes the document title this signal is emitted.
2136 * Deprecated: 1.1.4: Use "notify::title" instead.
2138 webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed",
2139 G_TYPE_FROM_CLASS(webViewClass),
2140 (GSignalFlags)G_SIGNAL_RUN_LAST,
2144 webkit_marshal_VOID__OBJECT_STRING,
2146 WEBKIT_TYPE_WEB_FRAME,
2150 * WebKitWebView::hovering-over-link:
2151 * @web_view: the object on which the signal is emitted
2152 * @title: the link's title
2153 * @uri: the URI the link points to
2155 * When the cursor is over a link, this signal is emitted.
2157 webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
2158 G_TYPE_FROM_CLASS(webViewClass),
2159 (GSignalFlags)G_SIGNAL_RUN_LAST,
2163 webkit_marshal_VOID__STRING_STRING,
2169 * WebKitWebView::populate-popup:
2170 * @web_view: the object on which the signal is emitted
2171 * @menu: the context menu
2173 * When a context menu is about to be displayed this signal is emitted.
2175 * Add menu items to #menu to extend the context menu.
2177 * Deprecated: 1.10: Use #WebKitWebView::context-menu signal instead.
2179 webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
2180 G_TYPE_FROM_CLASS(webViewClass),
2181 (GSignalFlags)G_SIGNAL_RUN_LAST,
2185 g_cclosure_marshal_VOID__OBJECT,
2190 * WebKitWebView::print-requested:
2191 * @web_view: the object in which the signal is emitted
2192 * @web_frame: the frame that is requesting to be printed
2194 * Emitted when printing is requested by the frame, usually
2195 * because of a javascript call. When handling this signal you
2196 * should call webkit_web_frame_print_full() or
2197 * webkit_web_frame_print() to do the actual printing.
2199 * The default handler will present a print dialog and carry a
2200 * print operation. Notice that this means that if you intend to
2201 * ignore a print request you must connect to this signal, and
2204 * Return value: %TRUE if the print request has been handled, %FALSE if
2205 * the default handler should run
2209 webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested",
2210 G_TYPE_FROM_CLASS(webViewClass),
2211 (GSignalFlags)G_SIGNAL_RUN_LAST,
2213 g_signal_accumulator_true_handled,
2215 webkit_marshal_BOOLEAN__OBJECT,
2217 WEBKIT_TYPE_WEB_FRAME);
2219 webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
2220 G_TYPE_FROM_CLASS(webViewClass),
2221 (GSignalFlags)G_SIGNAL_RUN_LAST,
2225 g_cclosure_marshal_VOID__STRING,
2230 * WebKitWebView::icon-loaded:
2231 * @web_view: the object on which the signal is emitted
2232 * @icon_uri: the URI for the icon
2234 * This signal is emitted when the main frame has got a favicon.
2235 * See WebKitIconDatabase::icon-loaded if you want to keep track of
2236 * icons for child frames.
2240 webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded",
2241 G_TYPE_FROM_CLASS(webViewClass),
2242 (GSignalFlags)G_SIGNAL_RUN_LAST,
2246 g_cclosure_marshal_VOID__STRING,
2251 * WebKitWebView::console-message:
2252 * @web_view: the object on which the signal is emitted
2253 * @message: the message text
2254 * @line: the line where the error occured
2255 * @source_id: the source id
2257 * A JavaScript console message was created.
2259 * Return value: %TRUE to stop other handlers from being invoked for the
2260 * event. %FALSE to propagate the event further.
2262 webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message",
2263 G_TYPE_FROM_CLASS(webViewClass),
2264 (GSignalFlags)G_SIGNAL_RUN_LAST,
2265 G_STRUCT_OFFSET(WebKitWebViewClass, console_message),
2266 g_signal_accumulator_true_handled,
2268 webkit_marshal_BOOLEAN__STRING_INT_STRING,
2270 G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
2273 * WebKitWebView::script-alert:
2274 * @web_view: the object on which the signal is emitted
2275 * @frame: the relevant frame
2276 * @message: the message text
2278 * A JavaScript alert dialog was created.
2280 * Return value: %TRUE to stop other handlers from being invoked for the
2281 * event. %FALSE to propagate the event further.
2283 webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert",
2284 G_TYPE_FROM_CLASS(webViewClass),
2285 (GSignalFlags)G_SIGNAL_RUN_LAST,
2286 G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
2287 g_signal_accumulator_true_handled,
2289 webkit_marshal_BOOLEAN__OBJECT_STRING,
2291 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING);
2294 * WebKitWebView::script-confirm:
2295 * @web_view: the object on which the signal is emitted
2296 * @frame: the relevant frame
2297 * @message: the message text
2298 * @confirmed: a pointer to a #gboolean where the callback should store
2299 * whether the user confirmed the dialog, when handling this signal
2301 * A JavaScript confirm dialog was created, providing Yes and No buttons.
2303 * Return value: %TRUE to stop other handlers from being invoked for the
2304 * event. %FALSE to propagate the event further.
2306 webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm",
2307 G_TYPE_FROM_CLASS(webViewClass),
2308 (GSignalFlags)G_SIGNAL_RUN_LAST,
2309 G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
2310 g_signal_accumulator_true_handled,
2312 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
2314 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_POINTER);
2317 * WebKitWebView::script-prompt:
2318 * @web_view: the object on which the signal is emitted
2319 * @frame: the relevant frame
2320 * @message: the message text
2321 * @default: the default value
2322 * @text: To be filled with the return value or NULL if the dialog was cancelled.
2324 * A JavaScript prompt dialog was created, providing an entry to input text.
2326 * Return value: %TRUE to stop other handlers from being invoked for the
2327 * event. %FALSE to propagate the event further.
2329 webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt",
2330 G_TYPE_FROM_CLASS(webViewClass),
2331 (GSignalFlags)G_SIGNAL_RUN_LAST,
2332 G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
2333 g_signal_accumulator_true_handled,
2335 webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING,
2337 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
2340 * WebKitWebView::select-all:
2341 * @web_view: the object which received the signal
2343 * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to
2344 * select the complete contents of the text view.
2346 * The default bindings for this signal is Ctrl-a.
2348 webkit_web_view_signals[::SELECT_ALL] = g_signal_new("select-all",
2349 G_TYPE_FROM_CLASS(webViewClass),
2350 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2351 G_STRUCT_OFFSET(WebKitWebViewClass, select_all),
2353 g_cclosure_marshal_VOID__VOID,
2357 * WebKitWebView::cut-clipboard:
2358 * @web_view: the object which received the signal
2360 * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to
2361 * cut the selection to the clipboard.
2363 * The default bindings for this signal are Ctrl-x and Shift-Delete.
2365 webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut-clipboard",
2366 G_TYPE_FROM_CLASS(webViewClass),
2367 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2368 G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard),
2370 g_cclosure_marshal_VOID__VOID,
2374 * WebKitWebView::copy-clipboard:
2375 * @web_view: the object which received the signal
2377 * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to
2378 * copy the selection to the clipboard.
2380 * The default bindings for this signal are Ctrl-c and Ctrl-Insert.
2382 webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy-clipboard",
2383 G_TYPE_FROM_CLASS(webViewClass),
2384 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2385 G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard),
2387 g_cclosure_marshal_VOID__VOID,
2391 * WebKitWebView::paste-clipboard:
2392 * @web_view: the object which received the signal
2394 * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to
2395 * paste the contents of the clipboard into the Web view.
2397 * The default bindings for this signal are Ctrl-v and Shift-Insert.
2399 webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste-clipboard",
2400 G_TYPE_FROM_CLASS(webViewClass),
2401 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2402 G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard),
2404 g_cclosure_marshal_VOID__VOID,
2408 * WebKitWebView::undo:
2409 * @web_view: the object which received the signal
2411 * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to
2412 * undo the last editing command.
2414 * The default binding for this signal is Ctrl-z
2418 webkit_web_view_signals[UNDO] = g_signal_new("undo",
2419 G_TYPE_FROM_CLASS(webViewClass),
2420 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2421 G_STRUCT_OFFSET(WebKitWebViewClass, undo),
2423 g_cclosure_marshal_VOID__VOID,
2427 * WebKitWebView::redo:
2428 * @web_view: the object which received the signal
2430 * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to
2431 * redo the last editing command.
2433 * The default binding for this signal is Ctrl-Shift-z
2437 webkit_web_view_signals[REDO] = g_signal_new("redo",
2438 G_TYPE_FROM_CLASS(webViewClass),
2439 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2440 G_STRUCT_OFFSET(WebKitWebViewClass, redo),
2442 g_cclosure_marshal_VOID__VOID,
2446 * WebKitWebView::move-cursor:
2447 * @web_view: the object which received the signal
2448 * @step: the type of movement, one of #GtkMovementStep
2449 * @count: an integer indicating the subtype of movement. Currently
2450 * the permitted values are '1' = forward, '-1' = backwards.
2452 * The #WebKitWebView::move-cursor will be emitted to apply the
2453 * cursor movement described by its parameters to the @view.
2455 * Return value: %TRUE or %FALSE
2459 webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor",
2460 G_TYPE_FROM_CLASS(webViewClass),
2461 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2462 G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor),
2464 webkit_marshal_BOOLEAN__ENUM_INT,
2466 GTK_TYPE_MOVEMENT_STEP,
2470 * WebKitWebView::create-plugin-widget:
2471 * @web_view: the object which received the signal
2472 * @mime_type: the mimetype of the requested object
2473 * @uri: the URI to load
2474 * @param: a #GHashTable with additional attributes (strings)
2476 * The #WebKitWebView::create-plugin-widget signal will be emitted to
2477 * create a plugin widget for embed or object HTML tags. This
2478 * allows to embed a GtkWidget as a plugin into HTML content. In
2479 * case of a textual selection of the GtkWidget WebCore will attempt
2480 * to set the property value of "webkit-widget-is-selected". This can
2481 * be used to draw a visual indicator of the selection.
2483 * Return value: (transfer full): a new #GtkWidget, or %NULL
2487 webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget",
2488 G_TYPE_FROM_CLASS(webViewClass),
2489 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2491 webkit_signal_accumulator_object_handled,
2493 webkit_marshal_OBJECT__STRING_STRING_POINTER,
2495 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
2498 * WebKitWebView::database-quota-exceeded:
2499 * @web_view: the object which received the signal
2500 * @frame: the relevant frame
2501 * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin
2503 * The #WebKitWebView::database-quota-exceeded signal will be emitted when
2504 * a Web Database exceeds the quota of its security origin. This signal
2505 * may be used to increase the size of the quota before the originating
2510 webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded",
2511 G_TYPE_FROM_CLASS(webViewClass),
2512 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2515 webkit_marshal_VOID__OBJECT_OBJECT,
2517 G_TYPE_OBJECT, G_TYPE_OBJECT);
2520 * WebKitWebView::resource-request-starting:
2521 * @web_view: the object which received the signal
2522 * @web_frame: the #WebKitWebFrame whose load dispatched this request
2523 * @web_resource: an empty #WebKitWebResource object
2524 * @request: the #WebKitNetworkRequest that will be dispatched
2525 * @response: the #WebKitNetworkResponse representing the redirect
2528 * Emitted when a request is about to be sent. You can modify the
2529 * request while handling this signal. You can set the URI in the
2530 * #WebKitNetworkRequest object itself, and add/remove/replace
2531 * headers using the #SoupMessage object it carries, if it is
2532 * present. See webkit_network_request_get_message(). Setting the
2533 * request URI to "about:blank" will effectively cause the request
2534 * to load nothing, and can be used to disable the loading of
2535 * specific resources.
2537 * Notice that information about an eventual redirect is available
2538 * in @response's #SoupMessage, not in the #SoupMessage carried by
2539 * the @request. If @response is %NULL, then this is not a
2540 * redirected request.
2542 * The #WebKitWebResource object will be the same throughout all
2543 * the lifetime of the resource, but the contents may change from
2544 * inbetween signal emissions.
2548 webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
2549 G_TYPE_FROM_CLASS(webViewClass),
2550 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2553 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT,
2555 WEBKIT_TYPE_WEB_FRAME,
2556 WEBKIT_TYPE_WEB_RESOURCE,
2557 WEBKIT_TYPE_NETWORK_REQUEST,
2558 WEBKIT_TYPE_NETWORK_RESPONSE);
2561 * WebKitWebView::geolocation-policy-decision-requested:
2562 * @web_view: the object on which the signal is emitted
2563 * @frame: the frame that requests permission
2564 * @policy_decision: a WebKitGeolocationPolicyDecision
2566 * This signal is emitted when a @frame wants to obtain the user's
2567 * location. The decision can be made asynchronously, but you must
2568 * call g_object_ref() the @policy_decision, and return %TRUE if
2569 * you are going to handle the request. To actually make the
2570 * decision you need to call webkit_geolocation_policy_allow() or
2571 * webkit_geolocation_policy_deny() on @policy_decision.
2575 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested",
2576 G_TYPE_FROM_CLASS(webViewClass),
2577 (GSignalFlags)(G_SIGNAL_RUN_LAST),
2580 webkit_marshal_BOOLEAN__OBJECT_OBJECT,
2582 WEBKIT_TYPE_WEB_FRAME,
2583 WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION);
2586 * WebKitWebView::geolocation-policy-decision-cancelled:
2587 * @web_view: the object on which the signal is emitted
2588 * @frame: the frame that cancels geolocation request.
2590 * When a @frame wants to cancel geolocation permission it had requested
2595 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled",
2596 G_TYPE_FROM_CLASS(webViewClass),
2597 (GSignalFlags)(G_SIGNAL_RUN_LAST),
2600 g_cclosure_marshal_VOID__OBJECT,
2602 WEBKIT_TYPE_WEB_FRAME);
2605 * DOM-related signals. These signals are experimental, for now,
2606 * and may change API and ABI. Their comments lack one * on
2607 * purpose, to make them not be catched by gtk-doc.
2611 * WebKitWebView::document-load-finished:
2612 * @web_view: the object which received the signal
2613 * @web_frame: the #WebKitWebFrame whose load dispatched this request
2615 * Emitted when the DOM document object load is finished for the
2618 webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished",
2619 G_TYPE_FROM_CLASS(webViewClass),
2620 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2623 g_cclosure_marshal_VOID__OBJECT,
2625 WEBKIT_TYPE_WEB_FRAME);
2628 * WebKitWebView::frame-created:
2629 * @web_view: the object which received the signal
2630 * @web_frame: the #WebKitWebFrame which was just created.
2632 * Emitted when a WebKitWebView has created a new frame. This signal will
2633 * be emitted for all sub-frames created during page load. It will not be
2634 * emitted for the main frame, which originates in the WebKitWebView constructor
2635 * and may be accessed at any time using webkit_web_view_get_main_frame.
2639 webkit_web_view_signals[FRAME_CREATED] = g_signal_new("frame-created",
2640 G_TYPE_FROM_CLASS(webViewClass),
2641 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2644 g_cclosure_marshal_VOID__OBJECT,
2646 WEBKIT_TYPE_WEB_FRAME);
2649 * WebKitWebView::run-file-chooser:
2650 * @web_view: the #WebKitWebView on which the signal is emitted
2651 * @request: a #WebKitFileChooserRequest
2653 * This signal is emitted when the user interacts with a <input
2654 * type='file' /> HTML element, requesting from WebKit to show
2655 * a dialog to select one or more files to be uploaded. To let the
2656 * application know the details of the file chooser, as well as to
2657 * allow the client application to either cancel the request or
2658 * perform an actual selection of files, the signal will pass an
2659 * instance of the #WebKitFileChooserRequest in the @request
2662 * The default signal handler will asynchronously run a regular
2663 * #GtkFileChooserDialog for the user to interact with.
2665 * If this signal is to be handled asynchronously, you must
2666 * call g_object_ref() on the @request, and return %TRUE to indicate
2667 * that the request is being handled. When you are ready to complete the
2668 * request, call webkit_file_chooser_request_select_files().
2670 * Returns: %TRUE to stop other handlers from being invoked for the event.
2671 * %FALSE to propagate the event further.
2674 webkit_web_view_signals[RUN_FILE_CHOOSER] = g_signal_new("run-file-chooser",
2675 G_TYPE_FROM_CLASS(webViewClass),
2677 G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser),
2678 g_signal_accumulator_true_handled, 0 /* accumulator data */,
2679 webkit_marshal_BOOLEAN__OBJECT,
2680 G_TYPE_BOOLEAN, 1, /* number of parameters */
2681 WEBKIT_TYPE_FILE_CHOOSER_REQUEST);
2684 * WebKitWebView::should-begin-editing:
2685 * @web_view: the #WebKitWebView on which the signal is emitted
2686 * @range: a #WebKitDOMRange
2689 webkit_web_view_signals[SHOULD_BEGIN_EDITING] = g_signal_new("should-begin-editing",
2690 G_TYPE_FROM_CLASS(webViewClass),
2691 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2692 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2693 g_signal_accumulator_first_wins, 0,
2694 webkit_marshal_BOOLEAN__OBJECT,
2696 WEBKIT_TYPE_DOM_RANGE);
2699 * WebKitWebView::should-end-editing:
2700 * @web_view: the #WebKitWebView on which the signal is emitted
2701 * @range: a #WebKitDOMRange
2704 webkit_web_view_signals[SHOULD_END_EDITING] = g_signal_new("should-end-editing",
2705 G_TYPE_FROM_CLASS(webViewClass),
2706 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2707 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2708 g_signal_accumulator_first_wins, 0,
2709 webkit_marshal_BOOLEAN__OBJECT,
2711 WEBKIT_TYPE_DOM_RANGE);
2714 * WebKitWebView::should-insert-node:
2715 * @web_view: the #WebKitWebView on which the signal is emitted
2716 * @node: a #WebKitDOMNode
2717 * @range: a #WebKitDOMRange
2718 * @action: a #WebKitInsertAction
2721 webkit_web_view_signals[SHOULD_INSERT_NODE] = g_signal_new("should-insert-node",
2722 G_TYPE_FROM_CLASS(webViewClass),
2723 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2724 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2725 g_signal_accumulator_first_wins, 0,
2726 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM,
2728 WEBKIT_TYPE_DOM_NODE,
2729 WEBKIT_TYPE_DOM_RANGE,
2730 WEBKIT_TYPE_INSERT_ACTION);
2733 * WebKitWebView::should-insert-text:
2734 * @web_view: the #WebKitWebView on which the signal is emitted
2736 * @range: a #WebKitDOMRange
2737 * @action: a #WebKitInsertAction
2740 webkit_web_view_signals[SHOULD_INSERT_TEXT] = g_signal_new("should-insert-text",
2741 G_TYPE_FROM_CLASS(webViewClass),
2742 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2743 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2744 g_signal_accumulator_first_wins, 0,
2745 webkit_marshal_BOOLEAN__STRING_OBJECT_ENUM,
2748 WEBKIT_TYPE_DOM_RANGE,
2749 WEBKIT_TYPE_INSERT_ACTION);
2751 // Only exists for GTK+ API compatibility.
2753 * WebKitWebView::should-delete-range:
2754 * @web_view: the #WebKitWebView on which the signal is emitted
2755 * @range: a #WebKitDOMRange
2758 webkit_web_view_signals[SHOULD_DELETE_RANGE] = g_signal_new("should-delete-range",
2759 G_TYPE_FROM_CLASS(webViewClass),
2760 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2761 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2762 g_signal_accumulator_first_wins, 0,
2763 webkit_marshal_BOOLEAN__OBJECT,
2765 WEBKIT_TYPE_DOM_RANGE);
2768 * WebKitWebView::should-show-delete-interface-for-element:
2769 * @web_view: the #WebKitWebView on which the signal is emitted
2770 * @element: a #WebKitDOMHTMLElement
2773 webkit_web_view_signals[SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT] = g_signal_new("should-show-delete-interface-for-element",
2774 G_TYPE_FROM_CLASS(webViewClass),
2775 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2777 g_signal_accumulator_first_wins, 0,
2778 webkit_marshal_BOOLEAN__OBJECT,
2780 WEBKIT_TYPE_DOM_HTML_ELEMENT);
2783 * WebKitWebView::should-change-selected-range:
2784 * @web_view: the #WebKitWebView on which the signal is emitted
2785 * @fromRange: a #WebKitDOMRange
2786 * @toRange: a #WebKitDOMRange
2787 * @affinity: a #WebKitSelectionAffinity
2788 * @stillSelecting: bool
2791 webkit_web_view_signals[SHOULD_CHANGE_SELECTED_RANGE] = g_signal_new("should-change-selected-range",
2792 G_TYPE_FROM_CLASS(webViewClass),
2793 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2794 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2795 g_signal_accumulator_first_wins, 0,
2796 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM_BOOLEAN,
2798 WEBKIT_TYPE_DOM_RANGE,
2799 WEBKIT_TYPE_DOM_RANGE,
2800 WEBKIT_TYPE_SELECTION_AFFINITY,
2804 * WebKitWebView::should-apply-style:
2805 * @web_view: the #WebKitWebView on which the signal is emitted
2806 * @set: a #WebKitDOMCSSStyleDeclaration
2807 * @range: a #WebKitDOMRange
2810 webkit_web_view_signals[SHOULD_APPLY_STYLE] = g_signal_new("should-apply-style",
2811 G_TYPE_FROM_CLASS(webViewClass),
2812 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2813 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action),
2814 g_signal_accumulator_first_wins, 0,
2815 webkit_marshal_BOOLEAN__OBJECT_OBJECT,
2817 WEBKIT_TYPE_DOM_CSS_STYLE_DECLARATION,
2818 WEBKIT_TYPE_DOM_RANGE);
2821 * WebKitWebView::editing-began:
2822 * @web_view: the #WebKitWebView on which the signal is emitted
2825 webkit_web_view_signals[EDITING_BEGAN] = g_signal_new("editing-began",
2826 G_TYPE_FROM_CLASS(webViewClass),
2827 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2830 g_cclosure_marshal_VOID__VOID,
2834 * WebKitWebView::user-changed-contents:
2835 * @web_view: the #WebKitWebView on which the signal is emitted
2838 webkit_web_view_signals[USER_CHANGED_CONTENTS] = g_signal_new("user-changed-contents",
2839 G_TYPE_FROM_CLASS(webViewClass),
2840 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2843 g_cclosure_marshal_VOID__VOID,
2847 * WebKitWebView::editing-ended:
2848 * @web_view: the #WebKitWebView on which the signal is emitted
2851 webkit_web_view_signals[EDITING_ENDED] = g_signal_new("editing-ended",
2852 G_TYPE_FROM_CLASS(webViewClass),
2853 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2856 g_cclosure_marshal_VOID__VOID,
2860 * WebKitWebView::selection-changed:
2861 * @web_view: the #WebKitWebView on which the signal is emitted
2864 webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed",
2865 G_TYPE_FROM_CLASS(webViewClass),
2866 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2869 g_cclosure_marshal_VOID__VOID,
2873 * WebKitWebView::viewport-attributes-recompute-requested:
2874 * @web_view: the object which received the signal
2875 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2877 * The #WebKitWebView::viewport-attributes-recompute-requested
2878 * signal will be emitted when a page with a viewport meta tag
2879 * loads and when webkit_viewport_attributes_recompute is called.
2881 * The #WebKitViewportAttributes will have device size, available size,
2882 * desktop width, and device DPI pre-filled by values that make sense
2883 * for the current screen and widget, but you can override those values
2884 * if you have special requirements (for instance, if you made your
2885 * widget bigger than the available visible area, you should override
2886 * the available-width and available-height properties to the actual
2891 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested",
2892 G_TYPE_FROM_CLASS(webViewClass),
2893 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2896 g_cclosure_marshal_VOID__OBJECT,
2898 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2901 * WebKitWebView::viewport-attributes-changed:
2902 * @web_view: the object which received the signal
2903 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes.
2905 * The #WebKitWebView::viewport-attributes-changed signal will be emitted
2906 * after the emission of #WebKitWebView::viewport-attributes-recompute-requested
2907 * and the subsequent viewport attribute recomputation. At this point,
2908 * if the #WebKitViewportAttributes are valid, the viewport attributes are available.
2912 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed",
2913 G_TYPE_FROM_CLASS(webViewClass),
2914 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
2917 g_cclosure_marshal_VOID__OBJECT,
2919 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES);
2922 * WebKitWebView::entering-fullscreen:
2923 * @web_view: the #WebKitWebView on which the signal is emitted.
2924 * @element: the #WebKitDOMHTMLElement which has requested full screen display.
2926 * Emitted when JavaScript code calls
2927 * <function>element.webkitRequestFullScreen</function>. If the
2928 * signal is not handled the WebView will proceed to full screen
2929 * its top level window. This signal can be used by client code to
2930 * request permission to the user prior doing the full screen
2931 * transition and eventually prepare the top-level window
2932 * (e.g. hide some widgets that would otherwise be part of the
2933 * full screen window).
2935 * Returns: %TRUE to stop other handlers from being invoked for the event.
2936 * %FALSE to continue emission of the event.
2940 webkit_web_view_signals[ENTERING_FULLSCREEN] = g_signal_new("entering-fullscreen",
2941 G_TYPE_FROM_CLASS(webViewClass),
2943 G_STRUCT_OFFSET(WebKitWebViewClass, entering_fullscreen),
2944 g_signal_accumulator_true_handled, 0,
2945 webkit_marshal_BOOLEAN__OBJECT,
2946 G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2950 * WebKitWebView::leaving-fullscreen:
2951 * @web_view: the #WebKitWebView on which the signal is emitted.
2952 * @element: the #WebKitDOMHTMLElement which is currently displayed full screen.
2954 * Emitted when the WebView is about to restore its top level
2955 * window out of its full screen state. This signal can be used by
2956 * client code to restore widgets hidden during the
2957 * entering-fullscreen stage for instance.
2959 * Returns: %TRUE to stop other handlers from being invoked for the event.
2960 * %FALSE to continue emission of the event.
2964 webkit_web_view_signals[LEAVING_FULLSCREEN] = g_signal_new("leaving-fullscreen",
2965 G_TYPE_FROM_CLASS(webViewClass),
2967 G_STRUCT_OFFSET(WebKitWebViewClass, leaving_fullscreen),
2968 g_signal_accumulator_true_handled, 0,
2969 webkit_marshal_BOOLEAN__OBJECT,
2970 G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT);
2973 * WebKitWebView::resource-response-received:
2974 * @web_view: the object which received the signal
2975 * @web_frame: the #WebKitWebFrame the response was received for
2976 * @web_resource: the #WebKitWebResource being loaded
2977 * @response: the #WebKitNetworkResponse that was received
2979 * Emitted when the first byte of data arrives
2983 webkit_web_view_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received",
2984 G_TYPE_FROM_CLASS(webViewClass),
2988 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT,
2990 WEBKIT_TYPE_WEB_FRAME,
2991 WEBKIT_TYPE_WEB_RESOURCE,
2992 WEBKIT_TYPE_NETWORK_RESPONSE);
2995 * WebKitWebView::resource-load-finished:
2996 * @web_view: the object which received the signal
2997 * @web_frame: the #WebKitWebFrame the response was received for
2998 * @web_resource: the #WebKitWebResource that was loaded
3000 * Emitted when all the data for the resource was loaded
3004 webkit_web_view_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished",
3005 G_TYPE_FROM_CLASS(webViewClass),
3009 webkit_marshal_VOID__OBJECT_OBJECT,
3011 WEBKIT_TYPE_WEB_FRAME,
3012 WEBKIT_TYPE_WEB_RESOURCE);
3015 * WebKitWebView::resource-content-length-received:
3016 * @web_view: the object which received the signal
3017 * @web_frame: the #WebKitWebFrame the response was received for
3018 * @web_resource: the #WebKitWebResource that was loaded
3019 * @length_received: the amount of data received since the last signal emission
3021 * Emitted when new resource data has been received. The
3022 * @length_received variable stores the amount of bytes received
3023 * since the last time this signal was emitted. This is useful to
3024 * provide progress information about the resource load operation.
3028 webkit_web_view_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received",
3029 G_TYPE_FROM_CLASS(webViewClass),
3033 webkit_marshal_VOID__OBJECT_OBJECT_INT,
3035 WEBKIT_TYPE_WEB_FRAME,
3036 WEBKIT_TYPE_WEB_RESOURCE,
3040 * WebKitWebView::resource-load-failed:
3041 * @web_view: the object which received the signal
3042 * @web_frame: the #WebKitWebFrame the response was received for
3043 * @web_resource: the #WebKitWebResource that was loaded
3044 * @error: the #GError that was triggered
3046 * Invoked when a resource failed to load
3050 webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed",
3051 G_TYPE_FROM_CLASS(webViewClass),
3055 webkit_marshal_VOID__OBJECT_OBJECT_BOXED,
3057 WEBKIT_TYPE_WEB_FRAME,
3058 WEBKIT_TYPE_WEB_RESOURCE,
3062 * WebKitWebView::context-menu:
3063 * @web_view: the object which received the signal
3064 * @default_menu: the default context menu
3065 * @hit_test_result: a #WebKitHitTestResult with the context of the current position.
3066 * @triggered_with_keyboard: %TRUE if the context menu was triggered using the keyboard
3068 * Emmited when a context menu is about to be displayed to give the application
3069 * a chance to create and handle its own context menu. If you only want to add custom
3070 * options to the default context menu you can simply modify the given @default_menu.
3072 * When @triggered_with_keyboard is %TRUE the coordinates of the given @hit_test_result should be
3073 * used to position the popup menu. When the context menu has been triggered by a
3074 * mouse event you could either use the @hit_test_result coordinates or pass %NULL
3075 * to the #GtkMenuPositionFunc parameter of gtk_menu_popup() function.
3076 * Note that coordinates of @hit_test_result are relative to @web_view window.
3078 * If your application will create and display its own popup menu, %TRUE should be returned.
3079 * Note that when the context menu is handled by the application, the #WebKitWebSettings:enable-default-context-menu
3080 * setting will be ignored and the #WebKitWebView::populate-popup signal won't be emitted.
3081 * If you don't want any context menu to be shown, you can simply connect to this signal
3082 * and return %TRUE without doing anything else.
3086 webkit_web_view_signals[CONTEXT_MENU] = g_signal_new("context-menu",
3087 G_TYPE_FROM_CLASS(webViewClass),
3090 webkit_marshal_BOOLEAN__OBJECT_OBJECT_BOOLEAN,
3093 WEBKIT_TYPE_HIT_TEST_RESULT,
3097 * implementations of virtual methods
3099 webViewClass->create_web_view = webkit_web_view_real_create_web_view;
3100 webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
3101 webViewClass->close_web_view = webkit_web_view_real_close_web_view;
3102 webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
3103 webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
3104 webViewClass->choose_file = webkit_web_view_real_choose_file;
3105 webViewClass->script_alert = webkit_web_view_real_script_alert;
3106 webViewClass->script_confirm = webkit_web_view_real_script_confirm;
3107 webViewClass->script_prompt = webkit_web_view_real_script_prompt;
3108 webViewClass->console_message = webkit_web_view_real_console_message;
3109 webViewClass->select_all = webkit_web_view_real_select_all;
3110 webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
3111 webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
3112 webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
3113 webViewClass->undo = webkit_web_view_real_undo;
3114 webViewClass->redo = webkit_web_view_real_redo;
3115 webViewClass->move_cursor = webkit_web_view_real_move_cursor;
3116 webViewClass->should_allow_editing_action = webkit_web_view_real_should_allow_editing_action;
3117 webViewClass->entering_fullscreen = webkit_web_view_real_entering_fullscreen;
3118 webViewClass->leaving_fullscreen = webkit_web_view_real_leaving_fullscreen;
3119 webViewClass->run_file_chooser = webkitWebViewRealRunFileChooser;
3121 GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
3122 objectClass->dispose = webkit_web_view_dispose;
3123 objectClass->finalize = webkit_web_view_finalize;
3124 objectClass->get_property = webkit_web_view_get_property;
3125 objectClass->set_property = webkit_web_view_set_property;
3127 GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass);
3128 widgetClass->realize = webkit_web_view_realize;
3129 #ifdef GTK_API_VERSION_2
3130 widgetClass->expose_event = webkit_web_view_expose_event;
3132 widgetClass->draw = webkit_web_view_draw;
3134 widgetClass->key_press_event = webkit_web_view_key_press_event;
3135 widgetClass->key_release_event = webkit_web_view_key_release_event;
3136 widgetClass->button_press_event = webkit_web_view_button_press_event;
3137 widgetClass->button_release_event = webkit_web_view_button_release_event;
3138 widgetClass->motion_notify_event = webkit_web_view_motion_event;
3139 widgetClass->scroll_event = webkit_web_view_scroll_event;
3140 widgetClass->size_allocate = webkit_web_view_size_allocate;
3141 #ifdef GTK_API_VERSION_2
3142 widgetClass->size_request = webkit_web_view_size_request;
3144 widgetClass->get_preferred_width = webkit_web_view_get_preferred_width;
3145 widgetClass->get_preferred_height = webkit_web_view_get_preferred_height;
3147 #if ENABLE(CONTEXT_MENUS)
3148 widgetClass->popup_menu = webkit_web_view_popup_menu_handler;
3150 widgetClass->popup_menu = NULL;
3152 widgetClass->grab_focus = webkit_web_view_grab_focus;
3153 widgetClass->focus_in_event = webkit_web_view_focus_in_event;
3154 widgetClass->focus_out_event = webkit_web_view_focus_out_event;
3155 #if HAVE(ACCESSIBILITY)
3156 widgetClass->get_accessible = webkit_web_view_get_accessible;
3158 widgetClass->screen_changed = webkit_web_view_screen_changed;
3159 #if ENABLE(DRAG_SUPPORT)
3160 widgetClass->drag_end = webkit_web_view_drag_end;
3161 widgetClass->drag_data_get = webkit_web_view_drag_data_get;
3162 widgetClass->drag_motion = webkit_web_view_drag_motion;
3163 widgetClass->drag_leave = webkit_web_view_drag_leave;
3164 widgetClass->drag_drop = webkit_web_view_drag_drop;
3165 widgetClass->drag_data_received = webkit_web_view_drag_data_received;
3167 widgetClass->drag_end = NULL;
3168 widgetClass->drag_data_get = NULL;
3169 widgetClass->drag_motion = NULL;
3170 widgetClass->drag_leave = NULL;
3171 widgetClass->drag_drop = NULL;
3172 widgetClass->drag_data_received = NULL;
3174 widgetClass->query_tooltip = webkit_web_view_query_tooltip;
3175 widgetClass->show_help = webkit_web_view_show_help;
3176 widgetClass->map = webkitWebViewMap;
3178 GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
3179 containerClass->add = webkit_web_view_container_add;
3180 containerClass->remove = webkit_web_view_container_remove;
3181 containerClass->forall = webkit_web_view_container_forall;
3184 * make us scrollable (e.g. addable to a GtkScrolledWindow)
3186 #ifdef GTK_API_VERSION_2
3187 webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments;
3188 GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments",
3189 G_TYPE_FROM_CLASS(webViewClass),
3190 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
3191 G_STRUCT_OFFSET(WebKitWebViewClass, set_scroll_adjustments),
3193 webkit_marshal_VOID__OBJECT_OBJECT,
3195 GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
3197 g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment");
3198 g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment");
3199 g_object_class_override_property(objectClass, PROP_HSCROLL_POLICY, "hscroll-policy");
3200 g_object_class_override_property(objectClass, PROP_VSCROLL_POLICY, "vscroll-policy");
3207 binding_set = gtk_binding_set_by_class(webViewClass);
3209 gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK,
3212 /* Cut/copy/paste */
3214 gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK,
3215 "cut_clipboard", 0);
3216 gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK,
3217 "copy_clipboard", 0);
3218 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK,
3219 "paste_clipboard", 0);
3220 gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK,
3222 gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
3225 gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK,
3226 "cut_clipboard", 0);
3227 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK,
3228 "copy_clipboard", 0);
3229 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
3230 "paste_clipboard", 0);
3234 gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0),
3236 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
3238 gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0),
3240 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
3242 gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0),
3244 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
3246 gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0),
3248 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
3250 gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0),
3252 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3254 gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK,
3256 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3258 gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0),
3260 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3262 gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0),
3264 G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
3266 gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0),
3268 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
3270 gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0),
3272 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
3280 * WebKitWebView:title:
3282 * Returns: the @web_view's document title.
3286 g_object_class_install_property(objectClass, PROP_TITLE,
3287 g_param_spec_string("title",
3289 _("Returns the @web_view's document title"),
3291 WEBKIT_PARAM_READABLE));
3294 * WebKitWebView:uri:
3296 * Returns: the current URI of the contents displayed by the @web_view.
3300 g_object_class_install_property(objectClass, PROP_URI,
3301 g_param_spec_string("uri",
3303 _("Returns the current URI of the contents displayed by the @web_view"),
3305 WEBKIT_PARAM_READABLE));
3308 * WebKitWebView:copy-target-list:
3310 * The list of targets this web view supports for clipboard copying.
3314 g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
3315 g_param_spec_boxed("copy-target-list",
3316 _("Copy target list"),
3317 _("The list of targets this web view supports for clipboard copying"),
3318 GTK_TYPE_TARGET_LIST,
3319 WEBKIT_PARAM_READABLE));
3322 * WebKitWebView:paste-target-list:
3324 * The list of targets this web view supports for clipboard pasting.
3328 g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
3329 g_param_spec_boxed("paste-target-list",
3330 _("Paste target list"),
3331 _("The list of targets this web view supports for clipboard pasting"),
3332 GTK_TYPE_TARGET_LIST,
3333 WEBKIT_PARAM_READABLE));
3335 g_object_class_install_property(objectClass, PROP_SETTINGS,
3336 g_param_spec_object("settings",
3338 _("An associated WebKitWebSettings instance"),
3339 WEBKIT_TYPE_WEB_SETTINGS,
3340 WEBKIT_PARAM_READWRITE));
3343 * WebKitWebView:web-inspector:
3345 * The associated WebKitWebInspector instance.
3349 g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
3350 g_param_spec_object("web-inspector",
3352 _("The associated WebKitWebInspector instance"),
3353 WEBKIT_TYPE_WEB_INSPECTOR,
3354 WEBKIT_PARAM_READABLE));
3357 * WebKitWebView:viewport-attributes:
3359 * The associated #WebKitViewportAttributes instance.
3363 g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES,
3364 g_param_spec_object("viewport-attributes",
3365 _("Viewport Attributes"),
3366 _("The associated WebKitViewportAttributes instance"),