1/* 2 * Copyright (C) 2007, 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2007, 2008, 2009 Christian Dywan <christian@imendio.com> 4 * Copyright (C) 2007 Xan Lopez <xan@gnome.org> 5 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> 6 * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com> 7 * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> 8 * Copyright (C) 2008 Nuanti Ltd. 9 * Copyright (C) 2008, 2009, 2010 Collabora Ltd. 10 * Copyright (C) 2009, 2010, 2012 Igalia S.L. 11 * Copyright (C) 2009 Movial Creative Technologies Inc. 12 * Copyright (C) 2009 Bobby Powers 13 * Copyright (C) 2010 Joone Hur <joone@kldp.org> 14 * Copyright (C) 2012 Igalia S.L. 15 * 16 * This library is free software; you can redistribute it and/or 17 * modify it under the terms of the GNU Lesser General Public 18 * License as published by the Free Software Foundation; either 19 * version 2 of the License, or (at your option) any later version. 20 * 21 * This library is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 * Lesser General Public License for more details. 25 * 26 * You should have received a copy of the GNU Lesser General Public 27 * License along with this library; if not, write to the Free Software 28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 29 */ 30 31#include "config.h" 32#include "webkitwebview.h" 33 34#include "AXObjectCache.h" 35#include "ArchiveResource.h" 36#include "BackForwardListImpl.h" 37#include "CairoUtilities.h" 38#include "Chrome.h" 39#include "ChromeClientGtk.h" 40#include "ClipboardUtilitiesGtk.h" 41#include "ContextMenu.h" 42#include "ContextMenuClientGtk.h" 43#include "ContextMenuController.h" 44#include "Cursor.h" 45#include "DatabaseManager.h" 46#include "Document.h" 47#include "DocumentLoader.h" 48#include "DragActions.h" 49#include "DragClientGtk.h" 50#include "DragController.h" 51#include "DragData.h" 52#include "DragSession.h" 53#include "DumpRenderTreeSupportGtk.h" 54#include "Editor.h" 55#include "EditorClientGtk.h" 56#include "EventHandler.h" 57#include "FloatQuad.h" 58#include "FocusController.h" 59#include "FrameLoader.h" 60#include "FrameLoaderClient.h" 61#include "FrameLoaderTypes.h" 62#include "FrameView.h" 63#include "GOwnPtrGtk.h" 64#include "GeolocationClientGtk.h" 65#include "GeolocationController.h" 66#include "GraphicsContext.h" 67#include "GtkUtilities.h" 68#include "GtkVersioning.h" 69#include "HTMLNames.h" 70#include "HitTestRequest.h" 71#include "HitTestResult.h" 72#include "InspectorClientGtk.h" 73#include "MemoryCache.h" 74#include "MouseEventWithHitTestResults.h" 75#include "NotImplemented.h" 76#include "PageCache.h" 77#include "Pasteboard.h" 78#include "PasteboardHelper.h" 79#include "PlatformKeyboardEvent.h" 80#include "PlatformWheelEvent.h" 81#include "ProgressTracker.h" 82#include "RenderView.h" 83#include "ResourceHandle.h" 84#include "RuntimeEnabledFeatures.h" 85#include "ScriptController.h" 86#include "ScriptValue.h" 87#include "Settings.h" 88#include "WebKitDOMDocumentPrivate.h" 89#include "webkitdownload.h" 90#include "webkitdownloadprivate.h" 91#include "webkitenumtypes.h" 92#include "webkitfavicondatabase.h" 93#include "webkitgeolocationpolicydecision.h" 94#include "webkitglobalsprivate.h" 95#include "webkithittestresultprivate.h" 96#include "webkiticondatabase.h" 97#include "webkitmarshal.h" 98#include "webkitnetworkrequest.h" 99#include "webkitnetworkresponse.h" 100#include "webkitviewportattributes.h" 101#include "webkitviewportattributesprivate.h" 102#include "webkitwebbackforwardlist.h" 103#include "webkitwebframeprivate.h" 104#include "webkitwebhistoryitem.h" 105#include "webkitwebhistoryitemprivate.h" 106#include "webkitwebinspector.h" 107#include "webkitwebinspectorprivate.h" 108#include "webkitwebpolicydecision.h" 109#include "webkitwebresource.h" 110#include "webkitwebresourceprivate.h" 111#include "webkitwebsettingsprivate.h" 112#include "webkitwebplugindatabaseprivate.h" 113#include "webkitwebwindowfeatures.h" 114#include "webkitwebviewprivate.h" 115#include <gdk/gdkkeysyms.h> 116#include <glib/gi18n-lib.h> 117#include <wtf/gobject/GOwnPtr.h> 118#include <wtf/text/CString.h> 119 120#if ENABLE(DEVICE_ORIENTATION) 121#include "DeviceMotionClientGtk.h" 122#include "DeviceOrientationClientGtk.h" 123#endif 124 125/** 126 * SECTION:webkitwebview 127 * @short_description: The central class of the WebKitGTK+ API 128 * @see_also: #WebKitWebSettings, #WebKitWebFrame 129 * 130 * #WebKitWebView is the central class of the WebKitGTK+ API. It is a 131 * #GtkWidget implementing the scrolling interface which means you can 132 * embed in a #GtkScrolledWindow. It is responsible for managing the 133 * drawing of the content, forwarding of events. You can load any URI 134 * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings 135 * you can control various aspects of the rendering and loading of the content. 136 * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A 137 * #WebKitWebFrame can have n children. 138 * 139 * <programlisting> 140 * /<!-- -->* Create the widgets *<!-- -->/ 141 * GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); 142 * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); 143 * GtkWidget *web_view = webkit_web_view_new (); 144 * 145 * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/ 146 * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view); 147 * gtk_container_add (GTK_CONTAINER (main_window), scrolled_window); 148 * 149 * /<!-- -->* Open a webpage *<!-- -->/ 150 * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org"); 151 * 152 * /<!-- -->* Show the result *<!-- -->/ 153 * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600); 154 * gtk_widget_show_all (main_window); 155 * </programlisting> 156 */ 157 158using namespace WebKit; 159using namespace WebCore; 160 161enum { 162 /* normal signals */ 163 NAVIGATION_REQUESTED, 164 NEW_WINDOW_POLICY_DECISION_REQUESTED, 165 NAVIGATION_POLICY_DECISION_REQUESTED, 166 MIME_TYPE_POLICY_DECISION_REQUESTED, 167 CREATE_WEB_VIEW, 168 WEB_VIEW_READY, 169 WINDOW_OBJECT_CLEARED, 170 LOAD_STARTED, 171 LOAD_COMMITTED, 172 LOAD_PROGRESS_CHANGED, 173 LOAD_ERROR, 174 LOAD_FINISHED, 175 TITLE_CHANGED, 176 HOVERING_OVER_LINK, 177 POPULATE_POPUP, 178 STATUS_BAR_TEXT_CHANGED, 179 ICON_LOADED, 180 SELECTION_CHANGED, 181 CONSOLE_MESSAGE, 182 SCRIPT_ALERT, 183 SCRIPT_CONFIRM, 184 SCRIPT_PROMPT, 185 SELECT_ALL, 186 COPY_CLIPBOARD, 187 PASTE_CLIPBOARD, 188 CUT_CLIPBOARD, 189 DOWNLOAD_REQUESTED, 190 MOVE_CURSOR, 191 PRINT_REQUESTED, 192 PLUGIN_WIDGET, 193 CLOSE_WEB_VIEW, 194 UNDO, 195 REDO, 196 DATABASE_QUOTA_EXCEEDED, 197 RESOURCE_REQUEST_STARTING, 198 DOCUMENT_LOAD_FINISHED, 199 GEOLOCATION_POLICY_DECISION_REQUESTED, 200 GEOLOCATION_POLICY_DECISION_CANCELLED, 201 ONLOAD_EVENT, 202 FRAME_CREATED, 203 SHOULD_BEGIN_EDITING, 204 SHOULD_END_EDITING, 205 SHOULD_INSERT_NODE, 206 SHOULD_INSERT_TEXT, 207 SHOULD_DELETE_RANGE, 208 SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT, 209 SHOULD_CHANGE_SELECTED_RANGE, 210 SHOULD_APPLY_STYLE, 211 EDITING_BEGAN, 212 USER_CHANGED_CONTENTS, 213 EDITING_ENDED, 214 VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED, 215 VIEWPORT_ATTRIBUTES_CHANGED, 216 RESOURCE_RESPONSE_RECEIVED, 217 RESOURCE_LOAD_FINISHED, 218 RESOURCE_CONTENT_LENGTH_RECEIVED, 219 RESOURCE_LOAD_FAILED, 220 ENTERING_FULLSCREEN, 221 LEAVING_FULLSCREEN, 222 CONTEXT_MENU, 223 RUN_FILE_CHOOSER, 224 225 LAST_SIGNAL 226}; 227 228enum { 229 PROP_0, 230 231 PROP_TITLE, 232 PROP_URI, 233 PROP_COPY_TARGET_LIST, 234 PROP_PASTE_TARGET_LIST, 235 PROP_EDITABLE, 236 PROP_SETTINGS, 237 PROP_WEB_INSPECTOR, 238 PROP_VIEWPORT_ATTRIBUTES, 239 PROP_WINDOW_FEATURES, 240 PROP_TRANSPARENT, 241 PROP_ZOOM_LEVEL, 242 PROP_FULL_CONTENT_ZOOM, 243 PROP_LOAD_STATUS, 244 PROP_PROGRESS, 245 PROP_ENCODING, 246 PROP_CUSTOM_ENCODING, 247 PROP_ICON_URI, 248 PROP_IM_CONTEXT, 249#ifdef GTK_API_VERSION_2 250 PROP_VIEW_MODE, 251#else 252 PROP_VIEW_MODE, 253 PROP_HADJUSTMENT, 254 PROP_VADJUSTMENT, 255 PROP_HSCROLL_POLICY, 256 PROP_VSCROLL_POLICY, 257#endif 258 259 // Undocumented. Leave these properties at the end of the list 260 // so that we can remove them without breaking ABI compatibility. 261 PROP_SELF_SCROLLING 262}; 263 264static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, }; 265 266#ifdef GTK_API_VERSION_2 267G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER) 268#else 269G_DEFINE_TYPE_WITH_CODE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER, 270 G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE, 0)) 271#endif 272 273static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView); 274static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures); 275static void webkitWebViewDirectionChanged(WebKitWebView*, GtkTextDirection previousDirection, gpointer); 276 277#if ENABLE(CONTEXT_MENUS) 278static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData) 279{ 280 WebKitWebView* view = WEBKIT_WEB_VIEW(userData); 281 WebKitWebViewPrivate* priv = view->priv; 282 GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view)); 283 GtkRequisition menuSize; 284 285#ifdef GTK_API_VERSION_2 286 gtk_widget_size_request(GTK_WIDGET(menu), &menuSize); 287#else 288 gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, NULL); 289#endif 290 291 *x = priv->lastPopupXPosition; 292 if ((*x + menuSize.width) >= gdk_screen_get_width(screen)) 293 *x -= menuSize.width; 294 295 *y = priv->lastPopupYPosition; 296 if ((*y + menuSize.height) >= gdk_screen_get_height(screen)) 297 *y -= menuSize.height; 298 299 *pushIn = FALSE; 300} 301#endif 302 303static Node* getFocusedNode(Frame* frame) 304{ 305 if (Document* doc = frame->document()) 306 return doc->focusedElement(); 307 return 0; 308} 309 310#if ENABLE(CONTEXT_MENUS) 311static void contextMenuItemActivated(GtkMenuItem* item, ContextMenuController* controller) 312{ 313 ContextMenuItem contextItem(item); 314 controller->contextMenuItemSelected(&contextItem); 315} 316 317static void contextMenuConnectActivate(GtkMenuItem* item, ContextMenuController* controller) 318{ 319 if (GTK_IS_SEPARATOR_MENU_ITEM(item)) 320 return; 321 322 if (GtkWidget* menu = gtk_menu_item_get_submenu(item)) { 323 gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller); 324 return; 325 } 326 327 g_signal_connect(item, "activate", G_CALLBACK(contextMenuItemActivated), controller); 328} 329 330static MouseEventWithHitTestResults prepareMouseEventForFrame(Frame* frame, const PlatformMouseEvent& event) 331{ 332 HitTestRequest request(HitTestRequest::Active| HitTestRequest::DisallowShadowContent); 333 IntPoint point = frame->view()->windowToContents(event.position()); 334 return frame->document()->prepareMouseEvent(request, point, event); 335} 336 337// Check enable-default-context-menu setting for compatibility. 338static bool defaultContextMenuEnabled(WebKitWebView* webView) 339{ 340 gboolean enableDefaultContextMenu; 341 g_object_get(webkit_web_view_get_settings(webView), "enable-default-context-menu", &enableDefaultContextMenu, NULL); 342 return enableDefaultContextMenu; 343} 344 345static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event, bool triggeredWithKeyboard) 346{ 347 Page* page = core(webView); 348 page->contextMenuController()->clearContextMenu(); 349 Frame* focusedFrame; 350 Frame* mainFrame = page->mainFrame(); 351 gboolean mousePressEventResult = FALSE; 352 GRefPtr<WebKitHitTestResult> hitTestResult; 353 354 if (!mainFrame->view()) 355 return FALSE; 356 357 mainFrame->view()->setCursor(pointerCursor()); 358 if (page->subframeCount()) { 359 MouseEventWithHitTestResults mev = prepareMouseEventForFrame(mainFrame, event); 360 Frame* targetFrame = EventHandler::subframeForHitTestResult(mev); 361 if (!targetFrame) 362 targetFrame = mainFrame; 363 364 focusedFrame = page->focusController()->focusedOrMainFrame(); 365 if (targetFrame != focusedFrame) { 366 page->focusController()->setFocusedFrame(targetFrame); 367 focusedFrame = targetFrame; 368 } 369 if (focusedFrame == mainFrame) 370 hitTestResult = adoptGRef(kit(mev.hitTestResult())); 371 } else 372 focusedFrame = mainFrame; 373 374 if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event)) 375 mousePressEventResult = TRUE; 376 377 bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event); 378 if (!handledEvent) 379 return FALSE; 380 381 // If coreMenu is NULL, this means WebCore decided to not create 382 // the default context menu; this may happen when the page is 383 // handling the right-click for reasons other than the context menu. 384 ContextMenuController* controller = page->contextMenuController(); 385 ContextMenu* coreMenu = controller->contextMenu(); 386 if (!coreMenu) 387 return mousePressEventResult; 388 389 GtkMenu* defaultMenu = coreMenu->platformDescription(); 390 ASSERT(defaultMenu); 391 392 // We connect the "activate" signal here rather than in ContextMenuGtk to avoid 393 // a layering violation. ContextMenuGtk should not know about the ContextMenuController. 394 gtk_container_foreach(GTK_CONTAINER(defaultMenu), reinterpret_cast<GtkCallback>(contextMenuConnectActivate), controller); 395 396 if (!hitTestResult) { 397 MouseEventWithHitTestResults mev = prepareMouseEventForFrame(focusedFrame, event); 398 hitTestResult = adoptGRef(kit(mev.hitTestResult())); 399 } 400 401 gboolean handled; 402 g_signal_emit(webView, webkit_web_view_signals[CONTEXT_MENU], 0, defaultMenu, hitTestResult.get(), triggeredWithKeyboard, &handled); 403 if (handled) 404 return TRUE; 405 406 // Return now if default context menu is disabled by enable-default-context-menu setting. 407 // Check enable-default-context-menu setting for compatibility. 408 if (!defaultContextMenuEnabled(webView)) 409 return FALSE; 410 411 // Emit populate-popup signal for compatibility. 412 g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, defaultMenu); 413 414 // If the context menu is now empty, don't show it. 415 GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(defaultMenu))); 416 if (!items) 417 return FALSE; 418 419 WebKitWebViewPrivate* priv = webView->priv; 420 priv->currentMenu = defaultMenu; 421 priv->lastPopupXPosition = event.globalPosition().x(); 422 priv->lastPopupYPosition = event.globalPosition().y(); 423 424 gtk_menu_popup(defaultMenu, 0, 0, &PopupMenuPositionFunc, webView, event.button() + 1, gtk_get_current_event_time()); 425 return TRUE; 426} 427 428static const int gContextMenuMargin = 1; 429static IntPoint getLocationForKeyboardGeneratedContextMenu(Frame* frame) 430{ 431 FrameSelection* selection = frame->selection(); 432 if (!selection->selection().isNonOrphanedCaretOrRange() 433 || (selection->selection().isCaret() && !selection->selection().isContentEditable())) { 434 if (Node* focusedNode = getFocusedNode(frame)) 435 return focusedNode->pixelSnappedBoundingBox().location(); 436 437 // There was no selection and no focused node, so just put the context 438 // menu into the corner of the view, offset slightly. 439 return IntPoint(gContextMenuMargin, gContextMenuMargin); 440 } 441 442 // selection->selection().firstRange can return 0 here, but if that was the case 443 // selection->selection().isNonOrphanedCaretOrRange() would have returned false 444 // above, so we do not have to check it. 445 IntRect firstRect = frame->editor().firstRectForRange(selection->selection().firstRange().get()); 446 return IntPoint(firstRect.x(), firstRect.maxY()); 447} 448 449static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) 450{ 451 Frame* frame = core(WEBKIT_WEB_VIEW(widget))->focusController()->focusedOrMainFrame(); 452 IntPoint location = getLocationForKeyboardGeneratedContextMenu(frame); 453 454 FrameView* view = frame->view(); 455 if (!view) 456 return FALSE; 457 458 // Never let the context menu touch the very edge of the view. 459 location = view->contentsToWindow(location); 460 location.expandedTo(IntPoint(gContextMenuMargin, gContextMenuMargin)); 461 location.shrunkTo(IntPoint(view->width() - gContextMenuMargin, view->height() - gContextMenuMargin)); 462 463 IntPoint globalPoint(convertWidgetPointToScreenPoint(widget, location)); 464 PlatformMouseEvent event(location, globalPoint, RightButton, PlatformEvent::MousePressed, 0, false, false, false, false, gtk_get_current_event_time()); 465 return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event, true); 466} 467#endif // ENABLE(CONTEXT_MENUS) 468 469static void setHorizontalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment) 470{ 471 // This may be called after the page has been destroyed, in which case we do nothing. 472 Page* page = core(webView); 473 if (page) 474 static_cast<WebKit::ChromeClient*>(page->chrome().client())->adjustmentWatcher()->setHorizontalAdjustment(adjustment); 475} 476 477static void setVerticalAdjustment(WebKitWebView* webView, GtkAdjustment* adjustment) 478{ 479 // This may be called after the page has been destroyed, in which case we do nothing. 480 Page* page = core(webView); 481 if (page) 482 static_cast<WebKit::ChromeClient*>(page->chrome().client())->adjustmentWatcher()->setVerticalAdjustment(adjustment); 483} 484 485#ifndef GTK_API_VERSION_2 486static GtkAdjustment* getHorizontalAdjustment(WebKitWebView* webView) 487{ 488 Page* page = core(webView); 489 if (page) 490 return static_cast<WebKit::ChromeClient*>(page->chrome().client())->adjustmentWatcher()->horizontalAdjustment(); 491 return 0; 492} 493 494static GtkAdjustment* getVerticalAdjustment(WebKitWebView* webView) 495{ 496 Page* page = core(webView); 497 if (page) 498 return static_cast<WebKit::ChromeClient*>(page->chrome().client())->adjustmentWatcher()->verticalAdjustment(); 499 return 0; 500} 501 502static void setHorizontalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy) 503{ 504 webView->priv->horizontalScrollingPolicy = policy; 505 gtk_widget_queue_resize(GTK_WIDGET(webView)); 506} 507 508static void setVerticalScrollPolicy(WebKitWebView* webView, GtkScrollablePolicy policy) 509{ 510 webView->priv->verticalScrollingPolicy = policy; 511 gtk_widget_queue_resize(GTK_WIDGET(webView)); 512} 513 514static GtkScrollablePolicy getHorizontalScrollPolicy(WebKitWebView* webView) 515{ 516 return webView->priv->horizontalScrollingPolicy; 517} 518 519static GtkScrollablePolicy getVerticalScrollPolicy(WebKitWebView* webView) 520{ 521 return webView->priv->verticalScrollingPolicy; 522} 523 524#endif 525 526static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) 527{ 528 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 529 530 switch(prop_id) { 531 case PROP_TITLE: 532 g_value_set_string(value, webkit_web_view_get_title(webView)); 533 break; 534 case PROP_URI: 535 g_value_set_string(value, webkit_web_view_get_uri(webView)); 536 break; 537 case PROP_COPY_TARGET_LIST: 538 g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView)); 539 break; 540 case PROP_PASTE_TARGET_LIST: 541 g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView)); 542 break; 543 case PROP_EDITABLE: 544 g_value_set_boolean(value, webkit_web_view_get_editable(webView)); 545 break; 546 case PROP_SETTINGS: 547 g_value_set_object(value, webkit_web_view_get_settings(webView)); 548 break; 549 case PROP_WEB_INSPECTOR: 550 g_value_set_object(value, webkit_web_view_get_inspector(webView)); 551 break; 552 case PROP_VIEWPORT_ATTRIBUTES: 553 g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView)); 554 break; 555 case PROP_WINDOW_FEATURES: 556 g_value_set_object(value, webkit_web_view_get_window_features(webView)); 557 break; 558 case PROP_TRANSPARENT: 559 g_value_set_boolean(value, webkit_web_view_get_transparent(webView)); 560 break; 561 case PROP_ZOOM_LEVEL: 562 g_value_set_float(value, webkit_web_view_get_zoom_level(webView)); 563 break; 564 case PROP_FULL_CONTENT_ZOOM: 565 g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView)); 566 break; 567 case PROP_ENCODING: 568 g_value_set_string(value, webkit_web_view_get_encoding(webView)); 569 break; 570 case PROP_CUSTOM_ENCODING: 571 g_value_set_string(value, webkit_web_view_get_custom_encoding(webView)); 572 break; 573 case PROP_LOAD_STATUS: 574 g_value_set_enum(value, webkit_web_view_get_load_status(webView)); 575 break; 576 case PROP_PROGRESS: 577 g_value_set_double(value, webkit_web_view_get_progress(webView)); 578 break; 579 case PROP_ICON_URI: 580 g_value_set_string(value, webkit_web_view_get_icon_uri(webView)); 581 break; 582 case PROP_IM_CONTEXT: 583 g_value_set_object(value, webView->priv->imFilter.context()); 584 break; 585 case PROP_VIEW_MODE: 586 g_value_set_enum(value, webkit_web_view_get_view_mode(webView)); 587 break; 588#ifndef GTK_API_VERSION_2 589 case PROP_HADJUSTMENT: 590 g_value_set_object(value, getHorizontalAdjustment(webView)); 591 break; 592 case PROP_VADJUSTMENT: 593 g_value_set_object(value, getVerticalAdjustment(webView)); 594 break; 595 case PROP_HSCROLL_POLICY: 596 g_value_set_enum(value, getHorizontalScrollPolicy(webView)); 597 break; 598 case PROP_VSCROLL_POLICY: 599 g_value_set_enum(value, getVerticalScrollPolicy(webView)); 600 break; 601#endif 602 case PROP_SELF_SCROLLING: 603 g_value_set_boolean(value, webView->priv->selfScrolling); 604 break; 605 default: 606 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); 607 } 608} 609 610static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec) 611{ 612 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 613 614 switch(prop_id) { 615 case PROP_EDITABLE: 616 webkit_web_view_set_editable(webView, g_value_get_boolean(value)); 617 break; 618 case PROP_SETTINGS: 619 webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value))); 620 break; 621 case PROP_WINDOW_FEATURES: 622 webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value))); 623 break; 624 case PROP_TRANSPARENT: 625 webkit_web_view_set_transparent(webView, g_value_get_boolean(value)); 626 break; 627 case PROP_ZOOM_LEVEL: 628 webkit_web_view_set_zoom_level(webView, g_value_get_float(value)); 629 break; 630 case PROP_FULL_CONTENT_ZOOM: 631 webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value)); 632 break; 633 case PROP_CUSTOM_ENCODING: 634 webkit_web_view_set_custom_encoding(webView, g_value_get_string(value)); 635 break; 636 case PROP_VIEW_MODE: 637 webkit_web_view_set_view_mode(webView, static_cast<WebKitWebViewViewMode>(g_value_get_enum(value))); 638 break; 639#ifndef GTK_API_VERSION_2 640 case PROP_HADJUSTMENT: 641 setHorizontalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value))); 642 break; 643 case PROP_VADJUSTMENT: 644 setVerticalAdjustment(webView, static_cast<GtkAdjustment*>(g_value_get_object(value))); 645 break; 646 case PROP_HSCROLL_POLICY: 647 setHorizontalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value))); 648 break; 649 case PROP_VSCROLL_POLICY: 650 setVerticalScrollPolicy(webView, static_cast<GtkScrollablePolicy>(g_value_get_enum(value))); 651 break; 652#endif 653 case PROP_SELF_SCROLLING: 654 webView->priv->selfScrolling = g_value_get_boolean(value); 655 break; 656 default: 657 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); 658 } 659} 660 661#ifdef GTK_API_VERSION_2 662static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event) 663{ 664 int rectCount; 665 GOwnPtr<GdkRectangle> rects; 666 gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount); 667 668 RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window)); 669 for (int i = 0; i < rectCount; i++) { 670 copyRectFromCairoSurfaceToContext(WEBKIT_WEB_VIEW(widget)->priv->backingStore->cairoSurface(), 671 cr.get(), IntSize(), IntRect(rects.get()[i])); 672 } 673 674 // Chaining up to the parent forces child widgets to be drawn. 675 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->expose_event(widget, event); 676 return FALSE; 677} 678#else 679static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr) 680{ 681 GdkRectangle clipRect; 682 if (!gdk_cairo_get_clip_rectangle(cr, &clipRect)) 683 return FALSE; 684 685 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; 686#if USE(TEXTURE_MAPPER) 687 if (priv->acceleratedCompositingContext->renderLayersToWindow(cr, clipRect)) { 688 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr); 689 return FALSE; 690 } 691#endif 692 693 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); 694 if (rectList->status || !rectList->num_rectangles) { 695 cairo_rectangle_list_destroy(rectList); 696 return FALSE; 697 } 698 699 Vector<IntRect> rects; 700 for (int i = 0; i < rectList->num_rectangles; i++) { 701 copyRectFromCairoSurfaceToContext(priv->backingStore->cairoSurface(), cr, IntSize(), 702 enclosingIntRect(FloatRect(rectList->rectangles[i]))); 703 } 704 cairo_rectangle_list_destroy(rectList); 705 706 // Chaining up to the parent forces child widgets to be drawn. 707 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->draw(widget, cr); 708 return FALSE; 709} 710#endif // GTK_API_VERSION_2 711 712static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* event) 713{ 714 if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event)) 715 return TRUE; 716 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event); 717} 718 719static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey* event) 720{ 721 if (WEBKIT_WEB_VIEW(widget)->priv->imFilter.filterKeyEvent(event)) 722 return TRUE; 723 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_release_event(widget, event); 724} 725 726static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventButton* event) 727{ 728 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 729 WebKitWebViewPrivate* priv = webView->priv; 730 731 // FIXME: need to keep track of subframe focus for key events 732 gtk_widget_grab_focus(widget); 733 734 if (!priv->clickCounter.shouldProcessButtonEvent(event)) 735 return TRUE; 736 737 PlatformMouseEvent platformEvent(event); 738 int count = priv->clickCounter.clickCountForGdkButtonEvent(widget, event); 739 platformEvent.setClickCount(count); 740 741#if ENABLE(CONTEXT_MENUS) 742 if (event->button == 3) 743 return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event), false); 744#endif 745 746 Frame* frame = core(webView)->mainFrame(); 747 if (!frame->view()) 748 return FALSE; 749 750 priv->imFilter.notifyMouseButtonPress(); 751 gboolean result = frame->eventHandler()->handleMousePressEvent(platformEvent); 752 753 return result; 754} 755 756static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event) 757{ 758 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 759 760 Frame* mainFrame = core(webView)->mainFrame(); 761 if (mainFrame->view()) 762 mainFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); 763 764 /* We always return FALSE here because WebKit can, for the same click, decide 765 * to not handle press-event but handle release-event, which can totally confuse 766 * some GTK+ containers when there are no other events in between. This way we 767 * guarantee that this case never happens, and that if press-event goes through 768 * release-event also goes through. 769 */ 770 771 return FALSE; 772} 773 774static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event) 775{ 776 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 777 778 Frame* frame = core(webView)->mainFrame(); 779 if (!frame->view()) 780 return FALSE; 781 782 return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event)); 783} 784 785static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* event) 786{ 787 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 788 789 Frame* frame = core(webView)->mainFrame(); 790 if (!frame->view()) 791 return FALSE; 792 793 PlatformWheelEvent wheelEvent(event); 794 return frame->eventHandler()->handleWheelEvent(wheelEvent); 795} 796 797#ifdef GTK_API_VERSION_2 798static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition) 799{ 800 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget); 801 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view)); 802 if (!coreFrame) 803 return; 804 805 FrameView* view = coreFrame->view(); 806 if (!view) 807 return; 808 809 requisition->width = view->contentsWidth(); 810 requisition->height = view->contentsHeight(); 811} 812#else 813static void webkit_web_view_get_preferred_width(GtkWidget* widget, gint* minimum, gint* natural) 814{ 815 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget); 816 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view)); 817 if (!coreFrame) 818 return; 819 820 FrameView* view = coreFrame->view(); 821 if (!view) 822 return; 823 824 *minimum = *natural = view->contentsWidth(); 825} 826 827static void webkit_web_view_get_preferred_height(GtkWidget* widget, gint* minimum, gint* natural) 828{ 829 WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget); 830 Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view)); 831 if (!coreFrame) 832 return; 833 834 FrameView* view = coreFrame->view(); 835 if (!view) 836 return; 837 838 *minimum = *natural = view->contentsHeight(); 839} 840#endif 841 842static void updateChildAllocationFromPendingAllocation(GtkWidget* child, void*) 843{ 844 if (!gtk_widget_get_visible(child)) 845 return; 846 847 GtkAllocation* allocation = static_cast<GtkAllocation*>(g_object_get_data(G_OBJECT(child), "delayed-allocation")); 848 if (!allocation) 849 return; 850 851 g_object_set_data(G_OBJECT(child), "delayed-allocation", 0); 852 gtk_widget_size_allocate(child, allocation); 853 *allocation = IntRect(); 854} 855 856static void resizeWebViewFromAllocation(WebKitWebView* webView, GtkAllocation* allocation, bool sizeChanged) 857{ 858 Page* page = core(webView); 859 IntSize oldSize; 860 FrameView* frameView = page->mainFrame()->view(); 861 if (sizeChanged && frameView) { 862 oldSize = frameView->size(); 863 frameView->resize(allocation->width, allocation->height); 864 } 865 866 gtk_container_forall(GTK_CONTAINER(webView), updateChildAllocationFromPendingAllocation, 0); 867 868 if (!sizeChanged) 869 return; 870 871 WebKit::ChromeClient* chromeClient = static_cast<WebKit::ChromeClient*>(page->chrome().client()); 872 chromeClient->widgetSizeChanged(oldSize, IntSize(allocation->width, allocation->height)); 873 chromeClient->adjustmentWatcher()->updateAdjustmentsFromScrollbars(); 874} 875 876static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation) 877{ 878 GtkAllocation oldAllocation; 879 gtk_widget_get_allocation(widget, &oldAllocation); 880 bool sizeChanged = allocation->width != oldAllocation.width || allocation->height != oldAllocation.height; 881 882 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget, allocation); 883 884 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 885 if (sizeChanged && !gtk_widget_get_mapped(widget)) { 886 webView->priv->needsResizeOnMap = true; 887 return; 888 } 889 resizeWebViewFromAllocation(webView, allocation, sizeChanged); 890} 891 892static void webkitWebViewMap(GtkWidget* widget) 893{ 894 GTK_WIDGET_CLASS(webkit_web_view_parent_class)->map(widget); 895 896 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 897 if (!webView->priv->needsResizeOnMap) 898 return; 899 900 GtkAllocation allocation; 901 gtk_widget_get_allocation(widget, &allocation); 902 resizeWebViewFromAllocation(webView, &allocation, true); 903 webView->priv->needsResizeOnMap = false; 904} 905 906static void webkit_web_view_grab_focus(GtkWidget* widget) 907{ 908 909 if (gtk_widget_is_sensitive(widget)) { 910 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 911 FocusController* focusController = core(webView)->focusController(); 912 913 focusController->setActive(true); 914 915 if (focusController->focusedFrame()) 916 focusController->setFocused(true); 917 else 918 focusController->setFocusedFrame(core(webView)->mainFrame()); 919 } 920 921 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget); 922} 923 924static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event) 925{ 926 // TODO: Improve focus handling as suggested in 927 // http://bugs.webkit.org/show_bug.cgi?id=16910 928 GtkWidget* toplevel = gtk_widget_get_toplevel(widget); 929 if (!widgetIsOnscreenToplevelWindow(toplevel) || !gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) 930 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event); 931 932 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 933 FocusController* focusController = core(webView)->focusController(); 934 935 focusController->setActive(true); 936 if (focusController->focusedFrame()) 937 focusController->setFocused(true); 938 else 939 focusController->setFocusedFrame(core(webView)->mainFrame()); 940 941 if (focusController->focusedFrame()->editor().canEdit()) 942 webView->priv->imFilter.notifyFocusedIn(); 943 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event); 944} 945 946static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event) 947{ 948 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 949 950 // We may hit this code while destroying the widget, and we might 951 // no longer have a page, then. 952 if (Page* page = core(webView)) { 953 page->focusController()->setActive(false); 954 page->focusController()->setFocused(false); 955 } 956 957 webView->priv->imFilter.notifyFocusedOut(); 958 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event); 959} 960 961static void webkit_web_view_realize(GtkWidget* widget) 962{ 963 gtk_widget_set_realized(widget, TRUE); 964 965 GtkAllocation allocation; 966 gtk_widget_get_allocation(widget, &allocation); 967 968 GdkWindowAttr attributes; 969 attributes.window_type = GDK_WINDOW_CHILD; 970 attributes.x = allocation.x; 971 attributes.y = allocation.y; 972 attributes.width = allocation.width; 973 attributes.height = allocation.height; 974 attributes.wclass = GDK_INPUT_OUTPUT; 975 attributes.visual = gtk_widget_get_visual(widget); 976#ifdef GTK_API_VERSION_2 977 attributes.colormap = gtk_widget_get_colormap(widget); 978#endif 979 attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK 980 | GDK_EXPOSURE_MASK 981 | GDK_BUTTON_PRESS_MASK 982 | GDK_BUTTON_RELEASE_MASK 983 | GDK_SCROLL_MASK 984#if GTK_CHECK_VERSION(3, 3, 18) 985 | GDK_SMOOTH_SCROLL_MASK 986#endif 987 | GDK_POINTER_MOTION_MASK 988 | GDK_KEY_PRESS_MASK 989 | GDK_KEY_RELEASE_MASK 990 | GDK_BUTTON_MOTION_MASK 991 | GDK_BUTTON1_MOTION_MASK 992 | GDK_BUTTON2_MOTION_MASK 993 | GDK_BUTTON3_MOTION_MASK; 994 995 gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; 996#ifdef GTK_API_VERSION_2 997 attributes_mask |= GDK_WA_COLORMAP; 998#endif 999 GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributes_mask); 1000 1001 gtk_widget_set_window(widget, window); 1002 gdk_window_set_user_data(window, widget); 1003 1004#ifdef GTK_API_VERSION_2 1005 gtk_widget_style_attach(widget); 1006 gtk_style_set_background(gtk_widget_get_style(widget), window, GTK_STATE_NORMAL); 1007#else 1008 gtk_style_context_set_background(gtk_widget_get_style_context(widget), window); 1009#endif 1010} 1011 1012#ifdef GTK_API_VERSION_2 1013static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* horizontalAdjustment, GtkAdjustment* verticalAdjustment) 1014{ 1015 setHorizontalAdjustment(webView, horizontalAdjustment); 1016 setVerticalAdjustment(webView, verticalAdjustment); 1017} 1018#endif 1019 1020static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* widget) 1021{ 1022 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); 1023 WebKitWebViewPrivate* priv = webView->priv; 1024 1025 priv->children.add(widget); 1026 gtk_widget_set_parent(widget, GTK_WIDGET(container)); 1027} 1028 1029static void webkit_web_view_container_remove(GtkContainer* container, GtkWidget* widget) 1030{ 1031 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); 1032 WebKitWebViewPrivate* priv = webView->priv; 1033 1034 if (priv->children.contains(widget)) { 1035 gtk_widget_unparent(widget); 1036 priv->children.remove(widget); 1037 } 1038} 1039 1040static void webkit_web_view_container_forall(GtkContainer* container, gboolean, GtkCallback callback, gpointer callbackData) 1041{ 1042 WebKitWebView* webView = WEBKIT_WEB_VIEW(container); 1043 WebKitWebViewPrivate* priv = webView->priv; 1044 1045 HashSet<GtkWidget*> children = priv->children; 1046 HashSet<GtkWidget*>::const_iterator end = children.end(); 1047 for (HashSet<GtkWidget*>::const_iterator current = children.begin(); current != end; ++current) 1048 (*callback)(*current, callbackData); 1049} 1050 1051static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*) 1052{ 1053 return 0; 1054} 1055 1056static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*) 1057{ 1058 return FALSE; 1059} 1060 1061static gboolean webkit_web_view_real_close_web_view(WebKitWebView*) 1062{ 1063 return FALSE; 1064} 1065 1066static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*) 1067{ 1068 return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; 1069} 1070 1071static void webkit_web_view_real_window_object_cleared(WebKitWebView*, WebKitWebFrame*, JSGlobalContextRef context, JSObjectRef window_object) 1072{ 1073 notImplemented(); 1074} 1075 1076static gchar* webkit_web_view_real_choose_file(WebKitWebView*, WebKitWebFrame*, const gchar* old_name) 1077{ 1078 notImplemented(); 1079 return g_strdup(old_name); 1080} 1081 1082typedef enum { 1083 WEBKIT_SCRIPT_DIALOG_ALERT, 1084 WEBKIT_SCRIPT_DIALOG_CONFIRM, 1085 WEBKIT_SCRIPT_DIALOG_PROMPT 1086 } WebKitScriptDialogType; 1087 1088static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, WebKitScriptDialogType type, const gchar* defaultValue, gchar** value) 1089{ 1090 GtkMessageType messageType; 1091 GtkButtonsType buttons; 1092 gint defaultResponse; 1093 GtkWidget* window; 1094 GtkWidget* dialog; 1095 GtkWidget* entry = 0; 1096 gboolean didConfirm = FALSE; 1097 1098 switch (type) { 1099 case WEBKIT_SCRIPT_DIALOG_ALERT: 1100 messageType = GTK_MESSAGE_WARNING; 1101 buttons = GTK_BUTTONS_CLOSE; 1102 defaultResponse = GTK_RESPONSE_CLOSE; 1103 break; 1104 case WEBKIT_SCRIPT_DIALOG_CONFIRM: 1105 messageType = GTK_MESSAGE_QUESTION; 1106 buttons = GTK_BUTTONS_OK_CANCEL; 1107 defaultResponse = GTK_RESPONSE_OK; 1108 break; 1109 case WEBKIT_SCRIPT_DIALOG_PROMPT: 1110 messageType = GTK_MESSAGE_QUESTION; 1111 buttons = GTK_BUTTONS_OK_CANCEL; 1112 defaultResponse = GTK_RESPONSE_OK; 1113 break; 1114 default: 1115 g_warning("Unknown value for WebKitScriptDialogType."); 1116 return FALSE; 1117 } 1118 1119 window = gtk_widget_get_toplevel(GTK_WIDGET(webView)); 1120 dialog = gtk_message_dialog_new(widgetIsOnscreenToplevelWindow(window) ? GTK_WINDOW(window) : 0, 1121 GTK_DIALOG_DESTROY_WITH_PARENT, 1122 messageType, 1123 buttons, 1124 "%s", 1125 message); 1126 gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL); 1127 gtk_window_set_title(GTK_WINDOW(dialog), title); 1128 g_free(title); 1129 1130 if (type == WEBKIT_SCRIPT_DIALOG_PROMPT) { 1131 entry = gtk_entry_new(); 1132 gtk_entry_set_text(GTK_ENTRY(entry), defaultValue); 1133 gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry); 1134 gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); 1135 gtk_widget_show(entry); 1136 } 1137 1138 gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse); 1139 gint response = gtk_dialog_run(GTK_DIALOG(dialog)); 1140 1141 switch (response) { 1142 case GTK_RESPONSE_OK: 1143 didConfirm = TRUE; 1144 if (entry) 1145 *value = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); 1146 break; 1147 case GTK_RESPONSE_CANCEL: 1148 didConfirm = FALSE; 1149 break; 1150 1151 } 1152 gtk_widget_destroy(GTK_WIDGET(dialog)); 1153 return didConfirm; 1154} 1155 1156static gboolean webkit_web_view_real_script_alert(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message) 1157{ 1158 webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_ALERT, 0, 0); 1159 return TRUE; 1160} 1161 1162static gboolean webkit_web_view_real_script_confirm(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, gboolean* didConfirm) 1163{ 1164 *didConfirm = webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_CONFIRM, 0, 0); 1165 return TRUE; 1166} 1167 1168static gboolean webkit_web_view_real_script_prompt(WebKitWebView* webView, WebKitWebFrame* frame, const gchar* message, const gchar* defaultValue, gchar** value) 1169{ 1170 if (!webkit_web_view_script_dialog(webView, frame, message, WEBKIT_SCRIPT_DIALOG_PROMPT, defaultValue, value)) 1171 *value = NULL; 1172 return TRUE; 1173} 1174 1175static gboolean webkit_web_view_real_console_message(WebKitWebView* webView, const gchar* message, unsigned int line, const gchar* sourceId) 1176{ 1177 g_message("console message: %s @%d: %s\n", sourceId, line, message); 1178 return TRUE; 1179} 1180 1181static void webkit_web_view_real_select_all(WebKitWebView* webView) 1182{ 1183 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1184 frame->editor().command("SelectAll").execute(); 1185} 1186 1187static void webkit_web_view_real_cut_clipboard(WebKitWebView* webView) 1188{ 1189 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1190 frame->editor().command("Cut").execute(); 1191} 1192 1193static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView) 1194{ 1195 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1196 frame->editor().command("Copy").execute(); 1197} 1198 1199static void webkit_web_view_real_undo(WebKitWebView* webView) 1200{ 1201 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1202 frame->editor().command("Undo").execute(); 1203} 1204 1205static void webkit_web_view_real_redo(WebKitWebView* webView) 1206{ 1207 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1208 frame->editor().command("Redo").execute(); 1209} 1210 1211static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count) 1212{ 1213 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE); 1214 g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS || 1215 step == GTK_MOVEMENT_DISPLAY_LINES || 1216 step == GTK_MOVEMENT_PAGES || 1217 step == GTK_MOVEMENT_BUFFER_ENDS, FALSE); 1218 g_return_val_if_fail(count == 1 || count == -1, FALSE); 1219 1220 ScrollDirection direction; 1221 ScrollGranularity granularity; 1222 1223 switch (step) { 1224 case GTK_MOVEMENT_DISPLAY_LINES: 1225 granularity = ScrollByLine; 1226 if (count == 1) 1227 direction = ScrollDown; 1228 else 1229 direction = ScrollUp; 1230 break; 1231 case GTK_MOVEMENT_VISUAL_POSITIONS: 1232 granularity = ScrollByLine; 1233 if (count == 1) 1234 direction = ScrollRight; 1235 else 1236 direction = ScrollLeft; 1237 break; 1238 case GTK_MOVEMENT_PAGES: 1239 granularity = ScrollByPage; 1240 if (count == 1) 1241 direction = ScrollDown; 1242 else 1243 direction = ScrollUp; 1244 break; 1245 case GTK_MOVEMENT_BUFFER_ENDS: 1246 granularity = ScrollByDocument; 1247 if (count == 1) 1248 direction = ScrollDown; 1249 else 1250 direction = ScrollUp; 1251 break; 1252 default: 1253 g_assert_not_reached(); 1254 return false; 1255 } 1256 1257 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1258 if (!frame->eventHandler()->scrollOverflow(direction, granularity)) 1259 frame->view()->scroll(direction, granularity); 1260 1261 return true; 1262} 1263 1264static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView) 1265{ 1266 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1267 frame->editor().command("Paste").execute(); 1268} 1269 1270static gboolean webkit_web_view_real_should_allow_editing_action(WebKitWebView*) 1271{ 1272 return TRUE; 1273} 1274 1275static gboolean webkit_web_view_real_entering_fullscreen(WebKitWebView* webView) 1276{ 1277 return FALSE; 1278} 1279 1280static gboolean webkit_web_view_real_leaving_fullscreen(WebKitWebView* webView) 1281{ 1282 return FALSE; 1283} 1284 1285static void fileChooserDialogResponseCallback(GtkDialog* dialog, gint responseID, WebKitFileChooserRequest* request) 1286{ 1287 GRefPtr<WebKitFileChooserRequest> adoptedRequest = adoptGRef(request); 1288 if (responseID == GTK_RESPONSE_ACCEPT) { 1289 GOwnPtr<GSList> filesList(gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog))); 1290 GRefPtr<GPtrArray> filesArray = adoptGRef(g_ptr_array_new()); 1291 for (GSList* file = filesList.get(); file; file = g_slist_next(file)) 1292 g_ptr_array_add(filesArray.get(), file->data); 1293 g_ptr_array_add(filesArray.get(), 0); 1294 webkit_file_chooser_request_select_files(adoptedRequest.get(), reinterpret_cast<const gchar* const*>(filesArray->pdata)); 1295 } 1296 1297 gtk_widget_destroy(GTK_WIDGET(dialog)); 1298} 1299 1300static gboolean webkitWebViewRealRunFileChooser(WebKitWebView* webView, WebKitFileChooserRequest* request) 1301{ 1302 GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webView)); 1303 if (!widgetIsOnscreenToplevelWindow(toplevel)) 1304 toplevel = 0; 1305 1306 gboolean allowsMultipleSelection = webkit_file_chooser_request_get_select_multiple(request); 1307 GtkWidget* dialog = gtk_file_chooser_dialog_new(allowsMultipleSelection ? _("Select Files") : _("Select File"), 1308 toplevel ? GTK_WINDOW(toplevel) : 0, 1309 GTK_FILE_CHOOSER_ACTION_OPEN, 1310 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 1311 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 1312 NULL); 1313 1314 if (GtkFileFilter* filter = webkit_file_chooser_request_get_mime_types_filter(request)) 1315 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); 1316 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), allowsMultipleSelection); 1317 1318 if (const gchar* const* selectedFiles = webkit_file_chooser_request_get_selected_files(request)) 1319 gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(dialog), selectedFiles[0]); 1320 1321 g_signal_connect(dialog, "response", G_CALLBACK(fileChooserDialogResponseCallback), g_object_ref(request)); 1322 gtk_widget_show(dialog); 1323 1324 return TRUE; 1325} 1326 1327static void webkit_web_view_dispose(GObject* object) 1328{ 1329 WebKitWebView* webView = WEBKIT_WEB_VIEW(object); 1330 WebKitWebViewPrivate* priv = webView->priv; 1331 1332 priv->disposing = TRUE; 1333 1334 // Make sure GtkAdjustmentWatcher won't be reacting to adjustment changes after the 1335 // WebView is destroyed. 1336 setHorizontalAdjustment(webView, 0); 1337 setVerticalAdjustment(webView, 0); 1338 1339 // These smart pointers are cleared manually, because some cleanup operations are 1340 // very sensitive to their value. We may crash if these are done in the wrong order. 1341 priv->backForwardList.clear(); 1342 1343 if (priv->corePage) { 1344 webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object)); 1345 core(priv->mainFrame)->loader()->detachFromParent(); 1346 delete priv->corePage; 1347 priv->corePage = 0; 1348 } 1349 1350 if (priv->webSettings) { 1351 g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView); 1352 priv->webSettings.clear(); 1353 } 1354 1355 if (priv->currentMenu) { 1356 gtk_widget_destroy(GTK_WIDGET(priv->currentMenu)); 1357 priv->currentMenu = 0; 1358 } 1359 1360 priv->webInspector.clear(); 1361 priv->viewportAttributes.clear(); 1362 priv->webWindowFeatures.clear(); 1363 priv->mainResource.clear(); 1364 priv->subResources.clear(); 1365 1366 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); 1367} 1368 1369static void webkit_web_view_finalize(GObject* object) 1370{ 1371 // We need to manually call the destructor here, since this object's memory is managed 1372 // by GLib. This calls all C++ members' destructors and prevents memory leaks. 1373 WEBKIT_WEB_VIEW(object)->priv->~WebKitWebViewPrivate(); 1374 G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object); 1375} 1376 1377static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) 1378{ 1379 gpointer newWebView = g_value_get_object(handlerReturn); 1380 g_value_set_object(returnAccu, newWebView); 1381 1382 // Continue if we don't have a newWebView 1383 return !newWebView; 1384} 1385 1386static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) 1387{ 1388 WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn); 1389 g_value_set_enum(returnAccu, navigationResponse); 1390 1391 if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT) 1392 return FALSE; 1393 1394 return TRUE; 1395} 1396 1397static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget) 1398{ 1399 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1400 if (!core(webView)) 1401 return 0; 1402 1403 if (!AXObjectCache::accessibilityEnabled()) 1404 AXObjectCache::enableAccessibility(); 1405 1406 Frame* coreFrame = core(webView)->mainFrame(); 1407 if (!coreFrame) 1408 return 0; 1409 1410 Document* doc = coreFrame->document(); 1411 if (!doc) 1412 return 0; 1413 1414 AccessibilityObject* rootAccessible = doc->axObjectCache()->rootObject(); 1415 if (!rootAccessible) 1416 return 0; 1417 1418 AtkObject* axRoot = rootAccessible->wrapper(); 1419 if (!axRoot || !ATK_IS_OBJECT(axRoot)) 1420 return 0; 1421 1422 // Ensure the parent is set to make top-down and bottom-up navigation work. 1423 GtkWidget* parentWidget = gtk_widget_get_parent(widget); 1424 AtkObject* axParent = parentWidget ? gtk_widget_get_accessible(parentWidget) : 0; 1425 if (axParent) 1426 atk_object_set_parent(axRoot, axParent); 1427 1428 return axRoot; 1429} 1430 1431static double screenDPI(GdkScreen* screen) 1432{ 1433 // gdk_screen_get_resolution() returns -1 when no DPI is set. 1434 double dpi = gdk_screen_get_resolution(screen); 1435 if (dpi != -1) 1436 return dpi; 1437 1438 static const double kMillimetresPerInch = 25.4; 1439 double diagonalSizeInPixels = hypot(gdk_screen_get_width(screen), gdk_screen_get_height(screen)); 1440 double diagonalSizeInInches = hypot(gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm(screen)) / kMillimetresPerInch; 1441 return diagonalSizeInPixels / diagonalSizeInInches; 1442} 1443 1444static gdouble webViewGetDPI(WebKitWebView* webView) 1445{ 1446 if (webView->priv->webSettings->priv->enforce96DPI) 1447 return 96; 1448 1449 static const double defaultDPI = 96; 1450 GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default(); 1451 return screen ? screenDPI(screen) : defaultDPI; 1452} 1453 1454static inline gint webViewConvertFontSizeToPixels(WebKitWebView* webView, double fontSize) 1455{ 1456 return fontSize / 72.0 * webViewGetDPI(webView); 1457} 1458 1459static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen) 1460{ 1461 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1462 WebKitWebViewPrivate* priv = webView->priv; 1463 1464 if (priv->disposing) 1465 return; 1466 1467 WebKitWebSettings* webSettings = priv->webSettings.get(); 1468 Settings* settings = core(webView)->settings(); 1469 guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize; 1470 1471 g_object_get(webSettings, 1472 "default-font-size", &defaultFontSize, 1473 "default-monospace-font-size", &defaultMonospaceFontSize, 1474 "minimum-font-size", &minimumFontSize, 1475 "minimum-logical-font-size", &minimumLogicalFontSize, 1476 NULL); 1477 1478 settings->setDefaultFontSize(webViewConvertFontSizeToPixels(webView, defaultFontSize)); 1479 settings->setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, defaultMonospaceFontSize)); 1480 settings->setMinimumFontSize(webViewConvertFontSizeToPixels(webView, minimumFontSize)); 1481 settings->setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, minimumLogicalFontSize)); 1482} 1483 1484#if ENABLE(DRAG_SUPPORT) 1485static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) 1486{ 1487 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1488 if (!webView->priv->dragAndDropHelper.handleDragEnd(context)) 1489 return; 1490 1491 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 1492 if (!frame) 1493 return; 1494 1495 // Synthesize a button release event to send with the drag end action. 1496 GOwnPtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_RELEASE)); 1497 int x, y, xRoot, yRoot; 1498 GdkModifierType modifiers = static_cast<GdkModifierType>(0); 1499#ifdef GTK_API_VERSION_2 1500 GdkDisplay* display = gdk_display_get_default(); 1501 gdk_display_get_pointer(display, 0, &xRoot, &yRoot, &modifiers); 1502 event->button.window = gdk_display_get_window_at_pointer(display, &x, &y); 1503#else 1504 GdkDevice* device = gdk_drag_context_get_device(context); 1505 event->button.window = gdk_device_get_window_at_position(device, &x, &y); 1506 gdk_device_get_position(device, 0, &xRoot, &yRoot); 1507#endif 1508 1509 if (event->button.window) 1510 g_object_ref(event->button.window); 1511 event->button.x = x; 1512 event->button.y = y; 1513 event->button.x_root = xRoot; 1514 event->button.y_root = yRoot; 1515 event->button.state = modifiers; 1516 1517 PlatformMouseEvent platformEvent(&event->button); 1518 frame->eventHandler()->dragSourceEndedAt(platformEvent, gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context))); 1519} 1520 1521static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint) 1522{ 1523 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info); 1524} 1525 1526static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened) 1527{ 1528 // Don't call dragExited if we have just received a drag-drop signal. This 1529 // happens in the case of a successful drop onto the view. 1530 if (!dropHappened) 1531 core(WEBKIT_WEB_VIEW(widget))->dragController()->dragExited(dragData); 1532 core(WEBKIT_WEB_VIEW(widget))->dragController()->dragEnded(); 1533} 1534 1535static void webkit_web_view_drag_leave(GtkWidget* widget, GdkDragContext* context, guint time) 1536{ 1537 WEBKIT_WEB_VIEW(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback); 1538} 1539 1540static gboolean webkit_web_view_drag_motion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) 1541{ 1542 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1543 IntPoint position(x, y); 1544 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragMotion(context, position, time); 1545 if (!dataObject) 1546 return TRUE; 1547 1548 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1549 DragOperation operation = core(webView)->dragController()->dragUpdated(&dragData).operation; 1550 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 1551 return TRUE; 1552} 1553 1554static void webkit_web_view_drag_data_received(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time) 1555{ 1556 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1557 IntPoint position; 1558 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info, position); 1559 if (!dataObject) 1560 return; 1561 1562 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1563 DragOperation operation = core(webView)->dragController()->dragEntered(&dragData).operation; 1564 gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time); 1565} 1566 1567static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time) 1568{ 1569 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1570 DataObjectGtk* dataObject = webView->priv->dragAndDropHelper.handleDragDrop(context); 1571 if (!dataObject) 1572 return FALSE; 1573 1574 IntPoint position(x, y); 1575 DragData dragData(dataObject, position, convertWidgetPointToScreenPoint(widget, position), gdkDragActionToDragOperation(gdk_drag_context_get_actions(context))); 1576 core(webView)->dragController()->performDrag(&dragData); 1577 gtk_drag_finish(context, TRUE, FALSE, time); 1578 return TRUE; 1579} 1580#endif // ENABLE(DRAG_SUPPORT) 1581 1582static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) 1583{ 1584 WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; 1585 1586 if (keyboard_mode) { 1587 WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); 1588 1589 // Get the title of the current focused element. 1590 Frame* coreFrame = core(webView)->focusController()->focusedOrMainFrame(); 1591 if (!coreFrame) 1592 return FALSE; 1593 1594 Node* node = getFocusedNode(coreFrame); 1595 if (!node) 1596 return FALSE; 1597 1598 for (Node* titleNode = node; titleNode; titleNode = titleNode->parentNode()) { 1599 if (titleNode->isElementNode()) { 1600 String title = toElement(titleNode)->title(); 1601 if (!title.isEmpty()) { 1602 if (FrameView* view = coreFrame->view()) { 1603 GdkRectangle area = view->contentsToWindow(node->pixelSnappedBoundingBox()); 1604 gtk_tooltip_set_tip_area(tooltip, &area); 1605 } 1606 gtk_tooltip_set_text(tooltip, title.utf8().data()); 1607 1608 return TRUE; 1609 } 1610 } 1611 } 1612 1613 return FALSE; 1614 } 1615 1616 if (priv->tooltipText.length() > 0) { 1617 if (!keyboard_mode) { 1618 if (!priv->tooltipArea.isEmpty()) { 1619 GdkRectangle area = priv->tooltipArea; 1620 gtk_tooltip_set_tip_area(tooltip, &area); 1621 } else 1622 gtk_tooltip_set_tip_area(tooltip, 0); 1623 } 1624 gtk_tooltip_set_text(tooltip, priv->tooltipText.data()); 1625 return TRUE; 1626 } 1627 1628 return FALSE; 1629} 1630 1631static gboolean webkit_web_view_show_help(GtkWidget* widget, GtkWidgetHelpType help_type) 1632{ 1633 if (help_type == GTK_WIDGET_HELP_TOOLTIP) 1634 gtk_widget_set_has_tooltip(widget, TRUE); 1635 1636 return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->show_help(widget, help_type); 1637} 1638 1639static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) 1640{ 1641 GtkBindingSet* binding_set; 1642 1643 webkitInit(); 1644 1645 /* 1646 * Signals 1647 */ 1648 1649 /** 1650 * WebKitWebView::create-web-view: 1651 * @web_view: the object on which the signal is emitted 1652 * @frame: the #WebKitWebFrame 1653 * 1654 * Emitted when the creation of a new window is requested. 1655 * If this signal is handled the signal handler should return the 1656 * newly created #WebKitWebView. 1657 * 1658 * The new #WebKitWebView should not be displayed to the user 1659 * until the #WebKitWebView::web-view-ready signal is emitted. 1660 * 1661 * The signal handlers should not try to deal with the reference count for 1662 * the new #WebKitWebView. The widget to which the widget is added will 1663 * handle that. 1664 * 1665 * Return value: (transfer full): a newly allocated #WebKitWebView, or %NULL 1666 * 1667 * Since: 1.0.3 1668 */ 1669 webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view", 1670 G_TYPE_FROM_CLASS(webViewClass), 1671 (GSignalFlags)G_SIGNAL_RUN_LAST, 1672 G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view), 1673 webkit_signal_accumulator_object_handled, 1674 NULL, 1675 webkit_marshal_OBJECT__OBJECT, 1676 WEBKIT_TYPE_WEB_VIEW , 1, 1677 WEBKIT_TYPE_WEB_FRAME); 1678 1679 /** 1680 * WebKitWebView::web-view-ready: 1681 * @web_view: the object on which the signal is emitted 1682 * 1683 * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView 1684 * should be displayed to the user. When this signal is emitted 1685 * all the information about how the window should look, including 1686 * size, position, whether the location, status and scroll bars 1687 * should be displayed, is already set on the 1688 * #WebKitWebWindowFeatures object contained by the #WebKitWebView. 1689 * 1690 * Notice that some of that information may change during the life 1691 * time of the window, so you may want to connect to the ::notify 1692 * signal of the #WebKitWebWindowFeatures object to handle those. 1693 * 1694 * Return value: %TRUE to stop handlers from being invoked for the event or 1695 * %FALSE to propagate the event furter 1696 * 1697 * Since: 1.0.3 1698 */ 1699 webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready", 1700 G_TYPE_FROM_CLASS(webViewClass), 1701 (GSignalFlags)G_SIGNAL_RUN_LAST, 1702 G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready), 1703 g_signal_accumulator_true_handled, 1704 NULL, 1705 webkit_marshal_BOOLEAN__VOID, 1706 G_TYPE_BOOLEAN, 0); 1707 1708 /** 1709 * WebKitWebView::close-web-view: 1710 * @web_view: the object on which the signal is emitted 1711 * 1712 * Emitted when closing a #WebKitWebView is requested. This occurs when a 1713 * call is made from JavaScript's window.close function. The default 1714 * signal handler does not do anything. It is the owner's responsibility 1715 * to hide or delete the web view, if necessary. 1716 * 1717 * Return value: %TRUE to stop handlers from being invoked for the event or 1718 * %FALSE to propagate the event furter 1719 * 1720 * Since: 1.1.11 1721 */ 1722 webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view", 1723 G_TYPE_FROM_CLASS(webViewClass), 1724 (GSignalFlags)G_SIGNAL_RUN_LAST, 1725 G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view), 1726 g_signal_accumulator_true_handled, 1727 NULL, 1728 webkit_marshal_BOOLEAN__VOID, 1729 G_TYPE_BOOLEAN, 0); 1730 1731 /** 1732 * WebKitWebView::navigation-requested: 1733 * @web_view: the object on which the signal is emitted 1734 * @frame: the #WebKitWebFrame that required the navigation 1735 * @request: a #WebKitNetworkRequest 1736 * 1737 * Emitted when @frame requests a navigation to another page. 1738 * 1739 * Return value: a #WebKitNavigationResponse 1740 * 1741 * Deprecated: Use WebKitWebView::navigation-policy-decision-requested 1742 * instead 1743 */ 1744 webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested", 1745 G_TYPE_FROM_CLASS(webViewClass), 1746 (GSignalFlags)G_SIGNAL_RUN_LAST, 1747 G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested), 1748 webkit_navigation_request_handled, 1749 NULL, 1750 webkit_marshal_ENUM__OBJECT_OBJECT, 1751 WEBKIT_TYPE_NAVIGATION_RESPONSE, 2, 1752 WEBKIT_TYPE_WEB_FRAME, 1753 WEBKIT_TYPE_NETWORK_REQUEST); 1754 1755 /** 1756 * WebKitWebView::new-window-policy-decision-requested: 1757 * @web_view: the object on which the signal is emitted 1758 * @frame: the #WebKitWebFrame that required the navigation 1759 * @request: a #WebKitNetworkRequest 1760 * @navigation_action: a #WebKitWebNavigationAction 1761 * @policy_decision: a #WebKitWebPolicyDecision 1762 * 1763 * Emitted when @frame requests opening a new window. With this 1764 * signal the browser can use the context of the request to decide 1765 * about the new window. If the request is not handled the default 1766 * behavior is to allow opening the new window to load the URI, 1767 * which will cause a create-web-view signal emission where the 1768 * browser handles the new window action but without information 1769 * of the context that caused the navigation. The following 1770 * navigation-policy-decision-requested emissions will load the 1771 * page after the creation of the new window just with the 1772 * information of this new navigation context, without any 1773 * information about the action that made this new window to be 1774 * opened. 1775 * 1776 * Notice that if you return TRUE, meaning that you handled the 1777 * signal, you are expected to have decided what to do, by calling 1778 * webkit_web_policy_decision_ignore(), 1779 * webkit_web_policy_decision_use(), or 1780 * webkit_web_policy_decision_download() on the @policy_decision 1781 * object. 1782 * 1783 * Return value: %TRUE if a decision was made, %FALSE to have the 1784 * default behavior apply 1785 * 1786 * Since: 1.1.4 1787 */ 1788 webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] = g_signal_new("new-window-policy-decision-requested", 1789 G_TYPE_FROM_CLASS(webViewClass), 1790 (GSignalFlags)G_SIGNAL_RUN_LAST, 1791 0, 1792 g_signal_accumulator_true_handled, 1793 NULL, 1794 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, 1795 G_TYPE_BOOLEAN, 4, 1796 WEBKIT_TYPE_WEB_FRAME, 1797 WEBKIT_TYPE_NETWORK_REQUEST, 1798 WEBKIT_TYPE_WEB_NAVIGATION_ACTION, 1799 WEBKIT_TYPE_WEB_POLICY_DECISION); 1800 1801 /** 1802 * WebKitWebView::navigation-policy-decision-requested: 1803 * @web_view: the object on which the signal is emitted 1804 * @frame: the #WebKitWebFrame that required the navigation 1805 * @request: a #WebKitNetworkRequest 1806 * @navigation_action: a #WebKitWebNavigationAction 1807 * @policy_decision: a #WebKitWebPolicyDecision 1808 * 1809 * Emitted when @frame requests a navigation to another page. 1810 * If this signal is not handled, the default behavior is to allow the 1811 * navigation. 1812 * 1813 * Notice that if you return TRUE, meaning that you handled the 1814 * signal, you are expected to have decided what to do, by calling 1815 * webkit_web_policy_decision_ignore(), 1816 * webkit_web_policy_decision_use(), or 1817 * webkit_web_policy_decision_download() on the @policy_decision 1818 * object. 1819 * 1820 * Return value: %TRUE if a decision was made, %FALSE to have the 1821 * default behavior apply 1822 * 1823 * Since: 1.0.3 1824 */ 1825 webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested", 1826 G_TYPE_FROM_CLASS(webViewClass), 1827 (GSignalFlags)G_SIGNAL_RUN_LAST, 1828 0, 1829 g_signal_accumulator_true_handled, 1830 NULL, 1831 webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, 1832 G_TYPE_BOOLEAN, 4, 1833 WEBKIT_TYPE_WEB_FRAME, 1834 WEBKIT_TYPE_NETWORK_REQUEST, 1835 WEBKIT_TYPE_WEB_NAVIGATION_ACTION, 1836 WEBKIT_TYPE_WEB_POLICY_DECISION); 1837 1838 /** 1839 * WebKitWebView::mime-type-policy-decision-requested: 1840 * @web_view: the object on which the signal is emitted 1841 * @frame: the #WebKitWebFrame that required the policy decision 1842 * @request: a WebKitNetworkRequest 1843 * @mimetype: the MIME type attempted to load 1844 * @policy_decision: a #WebKitWebPolicyDecision 1845 * 1846 * Decide whether or not to display the given MIME type. If this 1847 * signal is not handled, the default behavior is to show the 1848 * content of the requested URI if WebKit can show this MIME 1849 * type and the content disposition is not a download; if WebKit 1850 * is not able to show the MIME type nothing happens. 1851 * 1852 * Notice that if you return TRUE, meaning that you handled the 1853 * signal, you are expected to be aware of the "Content-Disposition" 1854 * header. A value of "attachment" usually indicates a download 1855 * regardless of the MIME type, see also 1856 * soup_message_headers_get_content_disposition(). And you must call 1857 * webkit_web_policy_decision_ignore(), 1858 * webkit_web_policy_decision_use(), or 1859 * webkit_web_policy_decision_download() on the @policy_decision 1860 * object. 1861 * 1862 * Return value: %TRUE if a decision was made, %FALSE to have the 1863 * default behavior apply 1864 * 1865 * Since: 1.0.3 1866 */ 1867 webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested", 1868 G_TYPE_FROM_CLASS(webViewClass), 1869 (GSignalFlags)G_SIGNAL_RUN_LAST, 1870 0, 1871 g_signal_accumulator_true_handled, 1872 NULL, 1873 webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT, 1874 G_TYPE_BOOLEAN, 4, 1875 WEBKIT_TYPE_WEB_FRAME, 1876 WEBKIT_TYPE_NETWORK_REQUEST, 1877 G_TYPE_STRING, 1878 WEBKIT_TYPE_WEB_POLICY_DECISION); 1879 1880 /** 1881 * WebKitWebView::window-object-cleared: 1882 * @web_view: the object on which the signal is emitted 1883 * @frame: the #WebKitWebFrame to which @window_object belongs 1884 * @context: the #JSGlobalContextRef holding the global object and other 1885 * execution state; equivalent to the return value of 1886 * webkit_web_frame_get_global_context(@frame) 1887 * @window_object: the #JSObjectRef representing the frame's JavaScript 1888 * window object 1889 * 1890 * Emitted when the JavaScript window object in a #WebKitWebFrame has been 1891 * cleared in preparation for a new load. This is the preferred place to 1892 * set custom properties on the window object using the JavaScriptCore API. 1893 */ 1894 webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared", 1895 G_TYPE_FROM_CLASS(webViewClass), 1896 (GSignalFlags)G_SIGNAL_RUN_LAST, 1897 G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared), 1898 NULL, 1899 NULL, 1900 webkit_marshal_VOID__OBJECT_POINTER_POINTER, 1901 G_TYPE_NONE, 3, 1902 WEBKIT_TYPE_WEB_FRAME, 1903 G_TYPE_POINTER, 1904 G_TYPE_POINTER); 1905 1906 /** 1907 * WebKitWebView::download-requested: 1908 * @web_view: the object on which the signal is emitted 1909 * @download: a #WebKitDownload object that lets you control the 1910 * download process 1911 * 1912 * A new Download is being requested. By default, if the signal is 1913 * not handled, the download is cancelled. If you handle the download 1914 * and call webkit_download_set_destination_uri(), it will be 1915 * started for you. If you need to set the destination asynchronously 1916 * you are responsible for starting or cancelling it yourself. 1917 * 1918 * If you intend to handle downloads yourself rather than using 1919 * the #WebKitDownload helper object you must handle this signal, 1920 * and return %FALSE. 1921 * 1922 * Also, keep in mind that the default policy for WebKitGTK+ is to 1923 * ignore files with a MIME type that it does not know how to 1924 * handle, which means this signal won't be emitted in the default 1925 * setup. One way to trigger downloads is to connect to 1926 * WebKitWebView::mime-type-policy-decision-requested and call 1927 * webkit_web_policy_decision_download() on the 1928 * #WebKitWebPolicyDecision in the parameter list for the kind of 1929 * files you want your application to download (a common solution 1930 * is to download anything that WebKit can't handle, which you can 1931 * figure out by using webkit_web_view_can_show_mime_type()). 1932 * 1933 * Return value: TRUE if the download should be performed, %FALSE to 1934 * cancel it 1935 * 1936 * Since: 1.1.2 1937 */ 1938 webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested", 1939 G_TYPE_FROM_CLASS(webViewClass), 1940 (GSignalFlags)G_SIGNAL_RUN_LAST, 1941 0, 1942 g_signal_accumulator_true_handled, 1943 NULL, 1944 webkit_marshal_BOOLEAN__OBJECT, 1945 G_TYPE_BOOLEAN, 1, 1946 G_TYPE_OBJECT); 1947 1948 /** 1949 * WebKitWebView::load-started: 1950 * @web_view: the object on which the signal is emitted 1951 * @frame: the frame going to do the load 1952 * 1953 * When a #WebKitWebFrame begins to load this signal is emitted. 1954 * 1955 * Deprecated: Use the "load-status" property instead. 1956 */ 1957 webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started", 1958 G_TYPE_FROM_CLASS(webViewClass), 1959 (GSignalFlags)G_SIGNAL_RUN_LAST, 1960 0, 1961 NULL, 1962 NULL, 1963 g_cclosure_marshal_VOID__OBJECT, 1964 G_TYPE_NONE, 1, 1965 WEBKIT_TYPE_WEB_FRAME); 1966 1967 /** 1968 * WebKitWebView::load-committed: 1969 * @web_view: the object on which the signal is emitted 1970 * @frame: the main frame that received the first data 1971 * 1972 * When a #WebKitWebFrame loaded the first data this signal is emitted. 1973 * 1974 * Deprecated: Use the "load-status" property instead. 1975 */ 1976 webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed", 1977 G_TYPE_FROM_CLASS(webViewClass), 1978 (GSignalFlags)G_SIGNAL_RUN_LAST, 1979 0, 1980 NULL, 1981 NULL, 1982 g_cclosure_marshal_VOID__OBJECT, 1983 G_TYPE_NONE, 1, 1984 WEBKIT_TYPE_WEB_FRAME); 1985 1986 1987 /** 1988 * WebKitWebView::load-progress-changed: 1989 * @web_view: the #WebKitWebView 1990 * @progress: the global progress 1991 * 1992 * Deprecated: Use the "progress" property instead. 1993 */ 1994 webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed", 1995 G_TYPE_FROM_CLASS(webViewClass), 1996 (GSignalFlags)G_SIGNAL_RUN_LAST, 1997 0, 1998 NULL, 1999 NULL, 2000 g_cclosure_marshal_VOID__INT, 2001 G_TYPE_NONE, 1, 2002 G_TYPE_INT); 2003 2004 /** 2005 * WebKitWebView::load-error: 2006 * @web_view: the object on which the signal is emitted 2007 * @web_frame: the #WebKitWebFrame 2008 * @uri: the URI that triggered the error 2009 * @web_error: the #GError that was triggered 2010 * 2011 * An error occurred while loading. By default, if the signal is not 2012 * handled, the @web_view will display a stock error page. You need to 2013 * handle the signal if you want to provide your own error page. 2014 * 2015 * Since: 1.1.6 2016 * 2017 * Return value: %TRUE to stop other handlers from being invoked for the 2018 * event. %FALSE to propagate the event further. 2019 */ 2020 webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error", 2021 G_TYPE_FROM_CLASS(webViewClass), 2022 (GSignalFlags)(G_SIGNAL_RUN_LAST), 2023 0, 2024 g_signal_accumulator_true_handled, 2025 NULL, 2026 webkit_marshal_BOOLEAN__OBJECT_STRING_BOXED, 2027 G_TYPE_BOOLEAN, 3, 2028 WEBKIT_TYPE_WEB_FRAME, 2029 G_TYPE_STRING, 2030 G_TYPE_ERROR); 2031 2032 /** 2033 * WebKitWebView::load-finished: 2034 * @web_view: the #WebKitWebView 2035 * @frame: the #WebKitWebFrame 2036 * 2037 * Deprecated: Use the "load-status" property instead. 2038 */ 2039 webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished", 2040 G_TYPE_FROM_CLASS(webViewClass), 2041 (GSignalFlags)G_SIGNAL_RUN_LAST, 2042 0, 2043 NULL, 2044 NULL, 2045 g_cclosure_marshal_VOID__OBJECT, 2046 G_TYPE_NONE, 1, 2047 WEBKIT_TYPE_WEB_FRAME); 2048 2049 /** 2050 * WebKitWebView::onload-event: 2051 * @web_view: the object on which the signal is emitted 2052 * @frame: the frame 2053 * 2054 * When a #WebKitWebFrame receives an onload event this signal is emitted. 2055 */ 2056 webkit_web_view_signals[ONLOAD_EVENT] = g_signal_new("onload-event", 2057 G_TYPE_FROM_CLASS(webViewClass), 2058 (GSignalFlags)G_SIGNAL_RUN_LAST, 2059 0, 2060 NULL, 2061 NULL, 2062 g_cclosure_marshal_VOID__OBJECT, 2063 G_TYPE_NONE, 1, 2064 WEBKIT_TYPE_WEB_FRAME); 2065 2066 /** 2067 * WebKitWebView::title-changed: 2068 * @web_view: the object on which the signal is emitted 2069 * @frame: the main frame 2070 * @title: the new title 2071 * 2072 * When a #WebKitWebFrame changes the document title this signal is emitted. 2073 * 2074 * Deprecated: 1.1.4: Use "notify::title" instead. 2075 */ 2076 webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed", 2077 G_TYPE_FROM_CLASS(webViewClass), 2078 (GSignalFlags)G_SIGNAL_RUN_LAST, 2079 0, 2080 NULL, 2081 NULL, 2082 webkit_marshal_VOID__OBJECT_STRING, 2083 G_TYPE_NONE, 2, 2084 WEBKIT_TYPE_WEB_FRAME, 2085 G_TYPE_STRING); 2086 2087 /** 2088 * WebKitWebView::hovering-over-link: 2089 * @web_view: the object on which the signal is emitted 2090 * @title: the link's title 2091 * @uri: the URI the link points to 2092 * 2093 * When the cursor is over a link, this signal is emitted. 2094 */ 2095 webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link", 2096 G_TYPE_FROM_CLASS(webViewClass), 2097 (GSignalFlags)G_SIGNAL_RUN_LAST, 2098 0, 2099 NULL, 2100 NULL, 2101 webkit_marshal_VOID__STRING_STRING, 2102 G_TYPE_NONE, 2, 2103 G_TYPE_STRING, 2104 G_TYPE_STRING); 2105 2106 /** 2107 * WebKitWebView::populate-popup: 2108 * @web_view: the object on which the signal is emitted 2109 * @menu: the context menu 2110 * 2111 * When a context menu is about to be displayed this signal is emitted. 2112 * 2113 * Add menu items to #menu to extend the context menu. 2114 * 2115 * Deprecated: 1.10: Use #WebKitWebView::context-menu signal instead. 2116 */ 2117 webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup", 2118 G_TYPE_FROM_CLASS(webViewClass), 2119 (GSignalFlags)G_SIGNAL_RUN_LAST, 2120 0, 2121 NULL, 2122 NULL, 2123 g_cclosure_marshal_VOID__OBJECT, 2124 G_TYPE_NONE, 1, 2125 GTK_TYPE_MENU); 2126 2127 /** 2128 * WebKitWebView::print-requested: 2129 * @web_view: the object in which the signal is emitted 2130 * @web_frame: the frame that is requesting to be printed 2131 * 2132 * Emitted when printing is requested by the frame, usually 2133 * because of a javascript call. When handling this signal you 2134 * should call webkit_web_frame_print_full() or 2135 * webkit_web_frame_print() to do the actual printing. 2136 * 2137 * The default handler will present a print dialog and carry a 2138 * print operation. Notice that this means that if you intend to 2139 * ignore a print request you must connect to this signal, and 2140 * return %TRUE. 2141 * 2142 * Return value: %TRUE if the print request has been handled, %FALSE if 2143 * the default handler should run 2144 * 2145 * Since: 1.1.5 2146 */ 2147 webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested", 2148 G_TYPE_FROM_CLASS(webViewClass), 2149 (GSignalFlags)G_SIGNAL_RUN_LAST, 2150 0, 2151 g_signal_accumulator_true_handled, 2152 NULL, 2153 webkit_marshal_BOOLEAN__OBJECT, 2154 G_TYPE_BOOLEAN, 1, 2155 WEBKIT_TYPE_WEB_FRAME); 2156 2157 webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed", 2158 G_TYPE_FROM_CLASS(webViewClass), 2159 (GSignalFlags)G_SIGNAL_RUN_LAST, 2160 0, 2161 NULL, 2162 NULL, 2163 g_cclosure_marshal_VOID__STRING, 2164 G_TYPE_NONE, 1, 2165 G_TYPE_STRING); 2166 2167 /** 2168 * WebKitWebView::icon-loaded: 2169 * @web_view: the object on which the signal is emitted 2170 * @icon_uri: the URI for the icon 2171 * 2172 * This signal is emitted when the main frame has got a favicon. 2173 * See WebKitIconDatabase::icon-loaded if you want to keep track of 2174 * icons for child frames. 2175 * 2176 * Since: 1.1.18 2177 */ 2178 webkit_web_view_signals[ICON_LOADED] = g_signal_new("icon-loaded", 2179 G_TYPE_FROM_CLASS(webViewClass), 2180 (GSignalFlags)G_SIGNAL_RUN_LAST, 2181 0, 2182 NULL, 2183 NULL, 2184 g_cclosure_marshal_VOID__STRING, 2185 G_TYPE_NONE, 1, 2186 G_TYPE_STRING); 2187 2188 /** 2189 * WebKitWebView::console-message: 2190 * @web_view: the object on which the signal is emitted 2191 * @message: the message text 2192 * @line: the line where the error occured 2193 * @source_id: the source id 2194 * 2195 * A JavaScript console message was created. 2196 * 2197 * Return value: %TRUE to stop other handlers from being invoked for the 2198 * event. %FALSE to propagate the event further. 2199 */ 2200 webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message", 2201 G_TYPE_FROM_CLASS(webViewClass), 2202 (GSignalFlags)G_SIGNAL_RUN_LAST, 2203 G_STRUCT_OFFSET(WebKitWebViewClass, console_message), 2204 g_signal_accumulator_true_handled, 2205 NULL, 2206 webkit_marshal_BOOLEAN__STRING_INT_STRING, 2207 G_TYPE_BOOLEAN, 3, 2208 G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING); 2209 2210 /** 2211 * WebKitWebView::script-alert: 2212 * @web_view: the object on which the signal is emitted 2213 * @frame: the relevant frame 2214 * @message: the message text 2215 * 2216 * A JavaScript alert dialog was created. 2217 * 2218 * Return value: %TRUE to stop other handlers from being invoked for the 2219 * event. %FALSE to propagate the event further. 2220 */ 2221 webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert", 2222 G_TYPE_FROM_CLASS(webViewClass), 2223 (GSignalFlags)G_SIGNAL_RUN_LAST, 2224 G_STRUCT_OFFSET(WebKitWebViewClass, script_alert), 2225 g_signal_accumulator_true_handled, 2226 NULL, 2227 webkit_marshal_BOOLEAN__OBJECT_STRING, 2228 G_TYPE_BOOLEAN, 2, 2229 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING); 2230 2231 /** 2232 * WebKitWebView::script-confirm: 2233 * @web_view: the object on which the signal is emitted 2234 * @frame: the relevant frame 2235 * @message: the message text 2236 * @confirmed: a pointer to a #gboolean where the callback should store 2237 * whether the user confirmed the dialog, when handling this signal 2238 * 2239 * A JavaScript confirm dialog was created, providing Yes and No buttons. 2240 * 2241 * Return value: %TRUE to stop other handlers from being invoked for the 2242 * event. %FALSE to propagate the event further. 2243 */ 2244 webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm", 2245 G_TYPE_FROM_CLASS(webViewClass), 2246 (GSignalFlags)G_SIGNAL_RUN_LAST, 2247 G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm), 2248 g_signal_accumulator_true_handled, 2249 NULL, 2250 webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER, 2251 G_TYPE_BOOLEAN, 3, 2252 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_POINTER); 2253 2254 /** 2255 * WebKitWebView::script-prompt: 2256 * @web_view: the object on which the signal is emitted 2257 * @frame: the relevant frame 2258 * @message: the message text 2259 * @default: the default value 2260 * @text: To be filled with the return value or NULL if the dialog was cancelled. 2261 * 2262 * A JavaScript prompt dialog was created, providing an entry to input text. 2263 * 2264 * Return value: %TRUE to stop other handlers from being invoked for the 2265 * event. %FALSE to propagate the event further. 2266 */ 2267 webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt", 2268 G_TYPE_FROM_CLASS(webViewClass), 2269 (GSignalFlags)G_SIGNAL_RUN_LAST, 2270 G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt), 2271 g_signal_accumulator_true_handled, 2272 NULL, 2273 webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING, 2274 G_TYPE_BOOLEAN, 4, 2275 WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); 2276 2277 /** 2278 * WebKitWebView::select-all: 2279 * @web_view: the object which received the signal 2280 * 2281 * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to 2282 * select the complete contents of the text view. 2283 * 2284 * The default bindings for this signal is Ctrl-a. 2285 */ 2286 webkit_web_view_signals[::SELECT_ALL] = g_signal_new("select-all", 2287 G_TYPE_FROM_CLASS(webViewClass), 2288 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2289 G_STRUCT_OFFSET(WebKitWebViewClass, select_all), 2290 NULL, NULL, 2291 g_cclosure_marshal_VOID__VOID, 2292 G_TYPE_NONE, 0); 2293 2294 /** 2295 * WebKitWebView::cut-clipboard: 2296 * @web_view: the object which received the signal 2297 * 2298 * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to 2299 * cut the selection to the clipboard. 2300 * 2301 * The default bindings for this signal are Ctrl-x and Shift-Delete. 2302 */ 2303 webkit_web_view_signals[CUT_CLIPBOARD] = g_signal_new("cut-clipboard", 2304 G_TYPE_FROM_CLASS(webViewClass), 2305 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2306 G_STRUCT_OFFSET(WebKitWebViewClass, cut_clipboard), 2307 NULL, NULL, 2308 g_cclosure_marshal_VOID__VOID, 2309 G_TYPE_NONE, 0); 2310 2311 /** 2312 * WebKitWebView::copy-clipboard: 2313 * @web_view: the object which received the signal 2314 * 2315 * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to 2316 * copy the selection to the clipboard. 2317 * 2318 * The default bindings for this signal are Ctrl-c and Ctrl-Insert. 2319 */ 2320 webkit_web_view_signals[COPY_CLIPBOARD] = g_signal_new("copy-clipboard", 2321 G_TYPE_FROM_CLASS(webViewClass), 2322 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2323 G_STRUCT_OFFSET(WebKitWebViewClass, copy_clipboard), 2324 NULL, NULL, 2325 g_cclosure_marshal_VOID__VOID, 2326 G_TYPE_NONE, 0); 2327 2328 /** 2329 * WebKitWebView::paste-clipboard: 2330 * @web_view: the object which received the signal 2331 * 2332 * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to 2333 * paste the contents of the clipboard into the Web view. 2334 * 2335 * The default bindings for this signal are Ctrl-v and Shift-Insert. 2336 */ 2337 webkit_web_view_signals[PASTE_CLIPBOARD] = g_signal_new("paste-clipboard", 2338 G_TYPE_FROM_CLASS(webViewClass), 2339 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2340 G_STRUCT_OFFSET(WebKitWebViewClass, paste_clipboard), 2341 NULL, NULL, 2342 g_cclosure_marshal_VOID__VOID, 2343 G_TYPE_NONE, 0); 2344 2345 /** 2346 * WebKitWebView::undo: 2347 * @web_view: the object which received the signal 2348 * 2349 * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to 2350 * undo the last editing command. 2351 * 2352 * The default binding for this signal is Ctrl-z 2353 * 2354 * Since: 1.1.14 2355 */ 2356 webkit_web_view_signals[UNDO] = g_signal_new("undo", 2357 G_TYPE_FROM_CLASS(webViewClass), 2358 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2359 G_STRUCT_OFFSET(WebKitWebViewClass, undo), 2360 NULL, NULL, 2361 g_cclosure_marshal_VOID__VOID, 2362 G_TYPE_NONE, 0); 2363 2364 /** 2365 * WebKitWebView::redo: 2366 * @web_view: the object which received the signal 2367 * 2368 * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to 2369 * redo the last editing command. 2370 * 2371 * The default binding for this signal is Ctrl-Shift-z 2372 * 2373 * Since: 1.1.14 2374 */ 2375 webkit_web_view_signals[REDO] = g_signal_new("redo", 2376 G_TYPE_FROM_CLASS(webViewClass), 2377 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2378 G_STRUCT_OFFSET(WebKitWebViewClass, redo), 2379 NULL, NULL, 2380 g_cclosure_marshal_VOID__VOID, 2381 G_TYPE_NONE, 0); 2382 2383 /** 2384 * WebKitWebView::move-cursor: 2385 * @web_view: the object which received the signal 2386 * @step: the type of movement, one of #GtkMovementStep 2387 * @count: an integer indicating the subtype of movement. Currently 2388 * the permitted values are '1' = forward, '-1' = backwards. 2389 * 2390 * The #WebKitWebView::move-cursor will be emitted to apply the 2391 * cursor movement described by its parameters to the @view. 2392 * 2393 * Return value: %TRUE or %FALSE 2394 * 2395 * Since: 1.1.4 2396 */ 2397 webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor", 2398 G_TYPE_FROM_CLASS(webViewClass), 2399 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2400 G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor), 2401 NULL, NULL, 2402 webkit_marshal_BOOLEAN__ENUM_INT, 2403 G_TYPE_BOOLEAN, 2, 2404 GTK_TYPE_MOVEMENT_STEP, 2405 G_TYPE_INT); 2406 2407 /** 2408 * WebKitWebView::create-plugin-widget: 2409 * @web_view: the object which received the signal 2410 * @mime_type: the mimetype of the requested object 2411 * @uri: the URI to load 2412 * @param: a #GHashTable with additional attributes (strings) 2413 * 2414 * The #WebKitWebView::create-plugin-widget signal will be emitted to 2415 * create a plugin widget for embed or object HTML tags. This 2416 * allows to embed a GtkWidget as a plugin into HTML content. In 2417 * case of a textual selection of the GtkWidget WebCore will attempt 2418 * to set the property value of "webkit-widget-is-selected". This can 2419 * be used to draw a visual indicator of the selection. 2420 * 2421 * Return value: (transfer full): a new #GtkWidget, or %NULL 2422 * 2423 * Since: 1.1.8 2424 */ 2425 webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget", 2426 G_TYPE_FROM_CLASS(webViewClass), 2427 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2428 0, 2429 webkit_signal_accumulator_object_handled, 2430 NULL, 2431 webkit_marshal_OBJECT__STRING_STRING_POINTER, 2432 GTK_TYPE_WIDGET, 3, 2433 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE); 2434 2435 /** 2436 * WebKitWebView::database-quota-exceeded: 2437 * @web_view: the object which received the signal 2438 * @frame: the relevant frame 2439 * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin 2440 * 2441 * The #WebKitWebView::database-quota-exceeded signal will be emitted when 2442 * a Web Database exceeds the quota of its security origin. This signal 2443 * may be used to increase the size of the quota before the originating 2444 * operation fails. 2445 * 2446 * Since: 1.1.14 2447 */ 2448 webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded", 2449 G_TYPE_FROM_CLASS(webViewClass), 2450 (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2451 0, 2452 NULL, NULL, 2453 webkit_marshal_VOID__OBJECT_OBJECT, 2454 G_TYPE_NONE, 2, 2455 G_TYPE_OBJECT, G_TYPE_OBJECT); 2456 2457 /** 2458 * WebKitWebView::resource-request-starting: 2459 * @web_view: the object which received the signal 2460 * @web_frame: the #WebKitWebFrame whose load dispatched this request 2461 * @web_resource: an empty #WebKitWebResource object 2462 * @request: the #WebKitNetworkRequest that will be dispatched 2463 * @response: the #WebKitNetworkResponse representing the redirect 2464 * response, if any 2465 * 2466 * Emitted when a request is about to be sent. You can modify the 2467 * request while handling this signal. You can set the URI in the 2468 * #WebKitNetworkRequest object itself, and add/remove/replace 2469 * headers using the #SoupMessage object it carries, if it is 2470 * present. See webkit_network_request_get_message(). Setting the 2471 * request URI to "about:blank" will effectively cause the request 2472 * to load nothing, and can be used to disable the loading of 2473 * specific resources. 2474 * 2475 * Notice that information about an eventual redirect is available 2476 * in @response's #SoupMessage, not in the #SoupMessage carried by 2477 * the @request. If @response is %NULL, then this is not a 2478 * redirected request. 2479 * 2480 * The #WebKitWebResource object will be the same throughout all 2481 * the lifetime of the resource, but the contents may change from 2482 * inbetween signal emissions. 2483 * 2484 * Since: 1.1.14 2485 */ 2486 webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting", 2487 G_TYPE_FROM_CLASS(webViewClass), 2488 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2489 0, 2490 NULL, NULL, 2491 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT, 2492 G_TYPE_NONE, 4, 2493 WEBKIT_TYPE_WEB_FRAME, 2494 WEBKIT_TYPE_WEB_RESOURCE, 2495 WEBKIT_TYPE_NETWORK_REQUEST, 2496 WEBKIT_TYPE_NETWORK_RESPONSE); 2497 2498 /** 2499 * WebKitWebView::geolocation-policy-decision-requested: 2500 * @web_view: the object on which the signal is emitted 2501 * @frame: the frame that requests permission 2502 * @policy_decision: a WebKitGeolocationPolicyDecision 2503 * 2504 * This signal is emitted when a @frame wants to obtain the user's 2505 * location. The decision can be made asynchronously, but you must 2506 * call g_object_ref() the @policy_decision, and return %TRUE if 2507 * you are going to handle the request. To actually make the 2508 * decision you need to call webkit_geolocation_policy_allow() or 2509 * webkit_geolocation_policy_deny() on @policy_decision. 2510 * 2511 * Since: 1.1.23 2512 */ 2513 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested", 2514 G_TYPE_FROM_CLASS(webViewClass), 2515 (GSignalFlags)(G_SIGNAL_RUN_LAST), 2516 0, 2517 NULL, NULL, 2518 webkit_marshal_BOOLEAN__OBJECT_OBJECT, 2519 G_TYPE_BOOLEAN, 2, 2520 WEBKIT_TYPE_WEB_FRAME, 2521 WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION); 2522 2523 /** 2524 * WebKitWebView::geolocation-policy-decision-cancelled: 2525 * @web_view: the object on which the signal is emitted 2526 * @frame: the frame that cancels geolocation request. 2527 * 2528 * When a @frame wants to cancel geolocation permission it had requested 2529 * before. 2530 * 2531 * Since: 1.1.23 2532 */ 2533 webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled", 2534 G_TYPE_FROM_CLASS(webViewClass), 2535 (GSignalFlags)(G_SIGNAL_RUN_LAST), 2536 0, 2537 NULL, NULL, 2538 g_cclosure_marshal_VOID__OBJECT, 2539 G_TYPE_NONE, 1, 2540 WEBKIT_TYPE_WEB_FRAME); 2541 2542 /* 2543 * DOM-related signals. These signals are experimental, for now, 2544 * and may change API and ABI. Their comments lack one * on 2545 * purpose, to make them not be catched by gtk-doc. 2546 */ 2547 2548 /** 2549 * WebKitWebView::document-load-finished: 2550 * @web_view: the object which received the signal 2551 * @web_frame: the #WebKitWebFrame whose load dispatched this request 2552 * 2553 * Emitted when the DOM document object load is finished for the 2554 * given frame. 2555 */ 2556 webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished", 2557 G_TYPE_FROM_CLASS(webViewClass), 2558 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2559 0, 2560 NULL, NULL, 2561 g_cclosure_marshal_VOID__OBJECT, 2562 G_TYPE_NONE, 1, 2563 WEBKIT_TYPE_WEB_FRAME); 2564 2565 /** 2566 * WebKitWebView::frame-created: 2567 * @web_view: the object which received the signal 2568 * @web_frame: the #WebKitWebFrame which was just created. 2569 * 2570 * Emitted when a WebKitWebView has created a new frame. This signal will 2571 * be emitted for all sub-frames created during page load. It will not be 2572 * emitted for the main frame, which originates in the WebKitWebView constructor 2573 * and may be accessed at any time using webkit_web_view_get_main_frame. 2574 * 2575 * Since: 1.3.4 2576 */ 2577 webkit_web_view_signals[FRAME_CREATED] = g_signal_new("frame-created", 2578 G_TYPE_FROM_CLASS(webViewClass), 2579 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2580 0, 2581 NULL, NULL, 2582 g_cclosure_marshal_VOID__OBJECT, 2583 G_TYPE_NONE, 1, 2584 WEBKIT_TYPE_WEB_FRAME); 2585 2586 /** 2587 * WebKitWebView::run-file-chooser: 2588 * @web_view: the #WebKitWebView on which the signal is emitted 2589 * @request: a #WebKitFileChooserRequest 2590 * 2591 * This signal is emitted when the user interacts with a <input 2592 * type='file' /> HTML element, requesting from WebKit to show 2593 * a dialog to select one or more files to be uploaded. To let the 2594 * application know the details of the file chooser, as well as to 2595 * allow the client application to either cancel the request or 2596 * perform an actual selection of files, the signal will pass an 2597 * instance of the #WebKitFileChooserRequest in the @request 2598 * argument. 2599 * 2600 * The default signal handler will asynchronously run a regular 2601 * #GtkFileChooserDialog for the user to interact with. 2602 * 2603 * If this signal is to be handled asynchronously, you must 2604 * call g_object_ref() on the @request, and return %TRUE to indicate 2605 * that the request is being handled. When you are ready to complete the 2606 * request, call webkit_file_chooser_request_select_files(). 2607 * 2608 * Returns: %TRUE to stop other handlers from being invoked for the event. 2609 * %FALSE to propagate the event further. 2610 * 2611 */ 2612 webkit_web_view_signals[RUN_FILE_CHOOSER] = g_signal_new("run-file-chooser", 2613 G_TYPE_FROM_CLASS(webViewClass), 2614 G_SIGNAL_RUN_LAST, 2615 G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser), 2616 g_signal_accumulator_true_handled, 0 /* accumulator data */, 2617 webkit_marshal_BOOLEAN__OBJECT, 2618 G_TYPE_BOOLEAN, 1, /* number of parameters */ 2619 WEBKIT_TYPE_FILE_CHOOSER_REQUEST); 2620 2621 /** 2622 * WebKitWebView::should-begin-editing: 2623 * @web_view: the #WebKitWebView on which the signal is emitted 2624 * @range: a #WebKitDOMRange 2625 * 2626 */ 2627 webkit_web_view_signals[SHOULD_BEGIN_EDITING] = g_signal_new("should-begin-editing", 2628 G_TYPE_FROM_CLASS(webViewClass), 2629 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2630 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2631 g_signal_accumulator_first_wins, 0, 2632 webkit_marshal_BOOLEAN__OBJECT, 2633 G_TYPE_BOOLEAN, 1, 2634 WEBKIT_TYPE_DOM_RANGE); 2635 2636 /** 2637 * WebKitWebView::should-end-editing: 2638 * @web_view: the #WebKitWebView on which the signal is emitted 2639 * @range: a #WebKitDOMRange 2640 * 2641 */ 2642 webkit_web_view_signals[SHOULD_END_EDITING] = g_signal_new("should-end-editing", 2643 G_TYPE_FROM_CLASS(webViewClass), 2644 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2645 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2646 g_signal_accumulator_first_wins, 0, 2647 webkit_marshal_BOOLEAN__OBJECT, 2648 G_TYPE_BOOLEAN, 1, 2649 WEBKIT_TYPE_DOM_RANGE); 2650 2651 /** 2652 * WebKitWebView::should-insert-node: 2653 * @web_view: the #WebKitWebView on which the signal is emitted 2654 * @node: a #WebKitDOMNode 2655 * @range: a #WebKitDOMRange 2656 * @action: a #WebKitInsertAction 2657 * 2658 */ 2659 webkit_web_view_signals[SHOULD_INSERT_NODE] = g_signal_new("should-insert-node", 2660 G_TYPE_FROM_CLASS(webViewClass), 2661 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2662 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2663 g_signal_accumulator_first_wins, 0, 2664 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM, 2665 G_TYPE_BOOLEAN, 3, 2666 WEBKIT_TYPE_DOM_NODE, 2667 WEBKIT_TYPE_DOM_RANGE, 2668 WEBKIT_TYPE_INSERT_ACTION); 2669 2670 /** 2671 * WebKitWebView::should-insert-text: 2672 * @web_view: the #WebKitWebView on which the signal is emitted 2673 * @string: a string 2674 * @range: a #WebKitDOMRange 2675 * @action: a #WebKitInsertAction 2676 * 2677 */ 2678 webkit_web_view_signals[SHOULD_INSERT_TEXT] = g_signal_new("should-insert-text", 2679 G_TYPE_FROM_CLASS(webViewClass), 2680 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2681 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2682 g_signal_accumulator_first_wins, 0, 2683 webkit_marshal_BOOLEAN__STRING_OBJECT_ENUM, 2684 G_TYPE_BOOLEAN, 3, 2685 G_TYPE_STRING, 2686 WEBKIT_TYPE_DOM_RANGE, 2687 WEBKIT_TYPE_INSERT_ACTION); 2688 2689 // Only exists for GTK+ API compatibility. 2690 /** 2691 * WebKitWebView::should-delete-range: 2692 * @web_view: the #WebKitWebView on which the signal is emitted 2693 * @range: a #WebKitDOMRange 2694 * 2695 */ 2696 webkit_web_view_signals[SHOULD_DELETE_RANGE] = g_signal_new("should-delete-range", 2697 G_TYPE_FROM_CLASS(webViewClass), 2698 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2699 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2700 g_signal_accumulator_first_wins, 0, 2701 webkit_marshal_BOOLEAN__OBJECT, 2702 G_TYPE_BOOLEAN, 1, 2703 WEBKIT_TYPE_DOM_RANGE); 2704 2705 /** 2706 * WebKitWebView::should-show-delete-interface-for-element: 2707 * @web_view: the #WebKitWebView on which the signal is emitted 2708 * @element: a #WebKitDOMHtmlElement 2709 * 2710 */ 2711 webkit_web_view_signals[SHOULD_SHOW_DELETE_INTERFACE_FOR_ELEMENT] = g_signal_new("should-show-delete-interface-for-element", 2712 G_TYPE_FROM_CLASS(webViewClass), 2713 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2714 0, 2715 g_signal_accumulator_first_wins, 0, 2716 webkit_marshal_BOOLEAN__OBJECT, 2717 G_TYPE_BOOLEAN, 1, 2718 WEBKIT_TYPE_DOM_HTML_ELEMENT); 2719 2720 /** 2721 * WebKitWebView::should-change-selected-range: 2722 * @web_view: the #WebKitWebView on which the signal is emitted 2723 * @fromRange: a #WebKitDOMRange 2724 * @toRange: a #WebKitDOMRange 2725 * @affinity: a #WebKitElectionAffinity 2726 * @stillSelecting: bool 2727 * 2728 */ 2729 webkit_web_view_signals[SHOULD_CHANGE_SELECTED_RANGE] = g_signal_new("should-change-selected-range", 2730 G_TYPE_FROM_CLASS(webViewClass), 2731 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2732 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2733 g_signal_accumulator_first_wins, 0, 2734 webkit_marshal_BOOLEAN__OBJECT_OBJECT_ENUM_BOOLEAN, 2735 G_TYPE_BOOLEAN, 4, 2736 WEBKIT_TYPE_DOM_RANGE, 2737 WEBKIT_TYPE_DOM_RANGE, 2738 WEBKIT_TYPE_SELECTION_AFFINITY, 2739 G_TYPE_BOOLEAN); 2740 2741 /** 2742 * WebKitWebView::should-apply-style: 2743 * @web_view: the #WebKitWebView on which the signal is emitted 2744 * @set: a #WebKitDOMCSSStyleDeclaration 2745 * @range: a #WebKitDOMRange 2746 * 2747 */ 2748 webkit_web_view_signals[SHOULD_APPLY_STYLE] = g_signal_new("should-apply-style", 2749 G_TYPE_FROM_CLASS(webViewClass), 2750 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2751 G_STRUCT_OFFSET(WebKitWebViewClass, should_allow_editing_action), 2752 g_signal_accumulator_first_wins, 0, 2753 webkit_marshal_BOOLEAN__OBJECT_OBJECT, 2754 G_TYPE_BOOLEAN, 2, 2755 WEBKIT_TYPE_DOM_CSS_STYLE_DECLARATION, 2756 WEBKIT_TYPE_DOM_RANGE); 2757 2758 /** 2759 * WebKitWebView::editing-began: 2760 * @web_view: the #WebKitWebView on which the signal is emitted 2761 * 2762 */ 2763 webkit_web_view_signals[EDITING_BEGAN] = g_signal_new("editing-began", 2764 G_TYPE_FROM_CLASS(webViewClass), 2765 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2766 0, 2767 0, 0, 2768 g_cclosure_marshal_VOID__VOID, 2769 G_TYPE_NONE, 0); 2770 2771 /** 2772 * WebKitWebView::user-changed-contents: 2773 * @web_view: the #WebKitWebView on which the signal is emitted 2774 * 2775 */ 2776 webkit_web_view_signals[USER_CHANGED_CONTENTS] = g_signal_new("user-changed-contents", 2777 G_TYPE_FROM_CLASS(webViewClass), 2778 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2779 0, 2780 0, 0, 2781 g_cclosure_marshal_VOID__VOID, 2782 G_TYPE_NONE, 0); 2783 2784 /** 2785 * WebKitWebView::editing-ended: 2786 * @web_view: the #WebKitWebView on which the signal is emitted 2787 * 2788 */ 2789 webkit_web_view_signals[EDITING_ENDED] = g_signal_new("editing-ended", 2790 G_TYPE_FROM_CLASS(webViewClass), 2791 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2792 0, 2793 0, 0, 2794 g_cclosure_marshal_VOID__VOID, 2795 G_TYPE_NONE, 0); 2796 2797 /** 2798 * WebKitWebView::selection-changed: 2799 * @web_view: the #WebKitWebView on which the signal is emitted 2800 * 2801 */ 2802 webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed", 2803 G_TYPE_FROM_CLASS(webViewClass), 2804 static_cast<GSignalFlags>(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2805 0, 2806 0, 0, 2807 g_cclosure_marshal_VOID__VOID, 2808 G_TYPE_NONE, 0); 2809 2810 /* 2811 * WebKitWebView::viewport-attributes-recompute-requested: 2812 * @web_view: the object which received the signal 2813 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes. 2814 * 2815 * The #WebKitWebView::viewport-attributes-recompute-requested 2816 * signal will be emitted when a page with a viewport meta tag 2817 * loads and when webkit_viewport_attributes_recompute is called. 2818 * 2819 * The #WebKitViewportAttributes will have device size, available size, 2820 * desktop width, and device DPI pre-filled by values that make sense 2821 * for the current screen and widget, but you can override those values 2822 * if you have special requirements (for instance, if you made your 2823 * widget bigger than the available visible area, you should override 2824 * the available-width and available-height properties to the actual 2825 * visible area). 2826 * 2827 * Since: 1.3.8 2828 */ 2829 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested", 2830 G_TYPE_FROM_CLASS(webViewClass), 2831 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2832 0, 2833 0, 0, 2834 g_cclosure_marshal_VOID__OBJECT, 2835 G_TYPE_NONE, 1, 2836 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES); 2837 2838 /* 2839 * WebKitWebView::viewport-attributes-changed: 2840 * @web_view: the object which received the signal 2841 * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes. 2842 * 2843 * The #WebKitWebView::viewport-attributes-changed signal will be emitted 2844 * after the emission of #WebKitWebView::viewport-attributes-recompute-requested 2845 * and the subsequent viewport attribute recomputation. At this point, 2846 * if the #WebKitViewportAttributes are valid, the viewport attributes are available. 2847 * 2848 * Since: 1.3.8 2849 */ 2850 webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed", 2851 G_TYPE_FROM_CLASS(webViewClass), 2852 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 2853 0, 2854 0, 0, 2855 g_cclosure_marshal_VOID__OBJECT, 2856 G_TYPE_NONE, 1, 2857 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES); 2858 2859 /** 2860 * WebKitWebView::entering-fullscreen: 2861 * @web_view: the #WebKitWebView on which the signal is emitted. 2862 * @element: the #WebKitDOMHTMLElement which has requested full screen display. 2863 * 2864 * Emitted when JavaScript code calls 2865 * <function>element.webkitRequestFullScreen</function>. If the 2866 * signal is not handled the WebView will proceed to full screen 2867 * its top level window. This signal can be used by client code to 2868 * request permission to the user prior doing the full screen 2869 * transition and eventually prepare the top-level window 2870 * (e.g. hide some widgets that would otherwise be part of the 2871 * full screen window). 2872 * 2873 * Returns: %TRUE to stop other handlers from being invoked for the event. 2874 * %FALSE to continue emission of the event. 2875 * 2876 * Since: 1.9.0 2877 */ 2878 webkit_web_view_signals[ENTERING_FULLSCREEN] = g_signal_new("entering-fullscreen", 2879 G_TYPE_FROM_CLASS(webViewClass), 2880 G_SIGNAL_RUN_LAST, 2881 G_STRUCT_OFFSET(WebKitWebViewClass, entering_fullscreen), 2882 g_signal_accumulator_true_handled, 0, 2883 webkit_marshal_BOOLEAN__OBJECT, 2884 G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT); 2885 2886 2887 /** 2888 * WebKitWebView::leaving-fullscreen: 2889 * @web_view: the #WebKitWebView on which the signal is emitted. 2890 * @element: the #WebKitDOMHTMLElement which is currently displayed full screen. 2891 * 2892 * Emitted when the WebView is about to restore its top level 2893 * window out of its full screen state. This signal can be used by 2894 * client code to restore widgets hidden during the 2895 * entering-fullscreen stage for instance. 2896 * 2897 * Returns: %TRUE to stop other handlers from being invoked for the event. 2898 * %FALSE to continue emission of the event. 2899 * 2900 * Since: 1.9.0 2901 */ 2902 webkit_web_view_signals[LEAVING_FULLSCREEN] = g_signal_new("leaving-fullscreen", 2903 G_TYPE_FROM_CLASS(webViewClass), 2904 G_SIGNAL_RUN_LAST, 2905 G_STRUCT_OFFSET(WebKitWebViewClass, leaving_fullscreen), 2906 g_signal_accumulator_true_handled, 0, 2907 webkit_marshal_BOOLEAN__OBJECT, 2908 G_TYPE_BOOLEAN, 1, WEBKIT_TYPE_DOM_HTML_ELEMENT); 2909 2910 /** 2911 * WebKitWebView::resource-response-received: 2912 * @web_view: the object which received the signal 2913 * @web_frame: the #WebKitWebFrame the response was received for 2914 * @web_resource: the #WebKitWebResource being loaded 2915 * @response: the #WebKitNetworkResponse that was received 2916 * 2917 * Emitted when the first byte of data arrives 2918 * 2919 * Since: 1.7.5 2920 */ 2921 webkit_web_view_signals[RESOURCE_RESPONSE_RECEIVED] = g_signal_new("resource-response-received", 2922 G_TYPE_FROM_CLASS(webViewClass), 2923 G_SIGNAL_RUN_LAST, 2924 0, 2925 0, 0, 2926 webkit_marshal_VOID__OBJECT_OBJECT_OBJECT, 2927 G_TYPE_NONE, 3, 2928 WEBKIT_TYPE_WEB_FRAME, 2929 WEBKIT_TYPE_WEB_RESOURCE, 2930 WEBKIT_TYPE_NETWORK_RESPONSE); 2931 2932 /** 2933 * WebKitWebView::resource-load-finished: 2934 * @web_view: the object which received the signal 2935 * @web_frame: the #WebKitWebFrame the response was received for 2936 * @web_resource: the #WebKitWebResource that was loaded 2937 * 2938 * Emitted when all the data for the resource was loaded 2939 * 2940 * Since: 1.7.5 2941 */ 2942 webkit_web_view_signals[RESOURCE_LOAD_FINISHED] = g_signal_new("resource-load-finished", 2943 G_TYPE_FROM_CLASS(webViewClass), 2944 G_SIGNAL_RUN_LAST, 2945 0, 2946 0, 0, 2947 webkit_marshal_VOID__OBJECT_OBJECT, 2948 G_TYPE_NONE, 2, 2949 WEBKIT_TYPE_WEB_FRAME, 2950 WEBKIT_TYPE_WEB_RESOURCE); 2951 2952 /** 2953 * WebKitWebView::resource-content-length-received: 2954 * @web_view: the object which received the signal 2955 * @web_frame: the #WebKitWebFrame the response was received for 2956 * @web_resource: the #WebKitWebResource that was loaded 2957 * @length_received: the amount of data received since the last signal emission 2958 * 2959 * Emitted when new resource data has been received. The 2960 * @length_received variable stores the amount of bytes received 2961 * since the last time this signal was emitted. This is useful to 2962 * provide progress information about the resource load operation. 2963 * 2964 * Since: 1.7.5 2965 */ 2966 webkit_web_view_signals[RESOURCE_CONTENT_LENGTH_RECEIVED] = g_signal_new("resource-content-length-received", 2967 G_TYPE_FROM_CLASS(webViewClass), 2968 G_SIGNAL_RUN_LAST, 2969 0, 2970 0, 0, 2971 webkit_marshal_VOID__OBJECT_OBJECT_INT, 2972 G_TYPE_NONE, 3, 2973 WEBKIT_TYPE_WEB_FRAME, 2974 WEBKIT_TYPE_WEB_RESOURCE, 2975 G_TYPE_INT); 2976 2977 /** 2978 * WebKitWebView::resource-load-failed: 2979 * @web_view: the object which received the signal 2980 * @web_frame: the #WebKitWebFrame the response was received for 2981 * @web_resource: the #WebKitWebResource that was loaded 2982 * @error: the #GError that was triggered 2983 * 2984 * Invoked when a resource failed to load 2985 * 2986 * Since: 1.7.5 2987 */ 2988 webkit_web_view_signals[RESOURCE_LOAD_FAILED] = g_signal_new("resource-load-failed", 2989 G_TYPE_FROM_CLASS(webViewClass), 2990 G_SIGNAL_RUN_LAST, 2991 0, 2992 0, 0, 2993 webkit_marshal_VOID__OBJECT_OBJECT_BOXED, 2994 G_TYPE_NONE, 3, 2995 WEBKIT_TYPE_WEB_FRAME, 2996 WEBKIT_TYPE_WEB_RESOURCE, 2997 G_TYPE_ERROR); 2998 2999 /** 3000 * WebKitWebView::context-menu: 3001 * @web_view: the object which received the signal 3002 * @default_menu: the default context menu 3003 * @hit_test_result: a #WebKitHitTestResult with the context of the current position. 3004 * @triggered_with_keyboard: %TRUE if the context menu was triggered using the keyboard 3005 * 3006 * Emmited when a context menu is about to be displayed to give the application 3007 * a chance to create and handle its own context menu. If you only want to add custom 3008 * options to the default context menu you can simply modify the given @default_menu. 3009 * 3010 * When @triggered_with_keyboard is %TRUE the coordinates of the given @hit_test_result should be 3011 * used to position the popup menu. When the context menu has been triggered by a 3012 * mouse event you could either use the @hit_test_result coordinates or pass %NULL 3013 * to the #GtkMenuPositionFunc parameter of gtk_menu_popup() function. 3014 * Note that coordinates of @hit_test_result are relative to @web_view window. 3015 * 3016 * If your application will create and display its own popup menu, %TRUE should be returned. 3017 * Note that when the context menu is handled by the application, the #WebKitWebSettings:enable-default-context-menu 3018 * setting will be ignored and the #WebKitWebView::populate-popup signal won't be emitted. 3019 * If you don't want any context menu to be shown, you can simply connect to this signal 3020 * and return %TRUE without doing anything else. 3021 * 3022 * Since: 1.10 3023 */ 3024 webkit_web_view_signals[CONTEXT_MENU] = g_signal_new("context-menu", 3025 G_TYPE_FROM_CLASS(webViewClass), 3026 G_SIGNAL_RUN_LAST, 3027 0, 0, 0, 3028 webkit_marshal_BOOLEAN__OBJECT_OBJECT_BOOLEAN, 3029 G_TYPE_BOOLEAN, 3, 3030 GTK_TYPE_WIDGET, 3031 WEBKIT_TYPE_HIT_TEST_RESULT, 3032 G_TYPE_BOOLEAN); 3033 3034 /* 3035 * implementations of virtual methods 3036 */ 3037 webViewClass->create_web_view = webkit_web_view_real_create_web_view; 3038 webViewClass->web_view_ready = webkit_web_view_real_web_view_ready; 3039 webViewClass->close_web_view = webkit_web_view_real_close_web_view; 3040 webViewClass->navigation_requested = webkit_web_view_real_navigation_requested; 3041 webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared; 3042 webViewClass->choose_file = webkit_web_view_real_choose_file; 3043 webViewClass->script_alert = webkit_web_view_real_script_alert; 3044 webViewClass->script_confirm = webkit_web_view_real_script_confirm; 3045 webViewClass->script_prompt = webkit_web_view_real_script_prompt; 3046 webViewClass->console_message = webkit_web_view_real_console_message; 3047 webViewClass->select_all = webkit_web_view_real_select_all; 3048 webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard; 3049 webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard; 3050 webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard; 3051 webViewClass->undo = webkit_web_view_real_undo; 3052 webViewClass->redo = webkit_web_view_real_redo; 3053 webViewClass->move_cursor = webkit_web_view_real_move_cursor; 3054 webViewClass->should_allow_editing_action = webkit_web_view_real_should_allow_editing_action; 3055 webViewClass->entering_fullscreen = webkit_web_view_real_entering_fullscreen; 3056 webViewClass->leaving_fullscreen = webkit_web_view_real_leaving_fullscreen; 3057 webViewClass->run_file_chooser = webkitWebViewRealRunFileChooser; 3058 3059 GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass); 3060 objectClass->dispose = webkit_web_view_dispose; 3061 objectClass->finalize = webkit_web_view_finalize; 3062 objectClass->get_property = webkit_web_view_get_property; 3063 objectClass->set_property = webkit_web_view_set_property; 3064 3065 GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass); 3066 widgetClass->realize = webkit_web_view_realize; 3067#ifdef GTK_API_VERSION_2 3068 widgetClass->expose_event = webkit_web_view_expose_event; 3069#else 3070 widgetClass->draw = webkit_web_view_draw; 3071#endif 3072 widgetClass->key_press_event = webkit_web_view_key_press_event; 3073 widgetClass->key_release_event = webkit_web_view_key_release_event; 3074 widgetClass->button_press_event = webkit_web_view_button_press_event; 3075 widgetClass->button_release_event = webkit_web_view_button_release_event; 3076 widgetClass->motion_notify_event = webkit_web_view_motion_event; 3077 widgetClass->scroll_event = webkit_web_view_scroll_event; 3078 widgetClass->size_allocate = webkit_web_view_size_allocate; 3079#ifdef GTK_API_VERSION_2 3080 widgetClass->size_request = webkit_web_view_size_request; 3081#else 3082 widgetClass->get_preferred_width = webkit_web_view_get_preferred_width; 3083 widgetClass->get_preferred_height = webkit_web_view_get_preferred_height; 3084#endif 3085#if ENABLE(CONTEXT_MENUS) 3086 widgetClass->popup_menu = webkit_web_view_popup_menu_handler; 3087#else 3088 widgetClass->popup_menu = NULL; 3089#endif 3090 widgetClass->grab_focus = webkit_web_view_grab_focus; 3091 widgetClass->focus_in_event = webkit_web_view_focus_in_event; 3092 widgetClass->focus_out_event = webkit_web_view_focus_out_event; 3093 widgetClass->get_accessible = webkit_web_view_get_accessible; 3094 widgetClass->screen_changed = webkit_web_view_screen_changed; 3095#if ENABLE(DRAG_SUPPORT) 3096 widgetClass->drag_end = webkit_web_view_drag_end; 3097 widgetClass->drag_data_get = webkit_web_view_drag_data_get; 3098 widgetClass->drag_motion = webkit_web_view_drag_motion; 3099 widgetClass->drag_leave = webkit_web_view_drag_leave; 3100 widgetClass->drag_drop = webkit_web_view_drag_drop; 3101 widgetClass->drag_data_received = webkit_web_view_drag_data_received; 3102#else 3103 widgetClass->drag_end = NULL; 3104 widgetClass->drag_data_get = NULL; 3105 widgetClass->drag_motion = NULL; 3106 widgetClass->drag_leave = NULL; 3107 widgetClass->drag_drop = NULL; 3108 widgetClass->drag_data_received = NULL; 3109#endif 3110 widgetClass->query_tooltip = webkit_web_view_query_tooltip; 3111 widgetClass->show_help = webkit_web_view_show_help; 3112 widgetClass->map = webkitWebViewMap; 3113 3114 GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass); 3115 containerClass->add = webkit_web_view_container_add; 3116 containerClass->remove = webkit_web_view_container_remove; 3117 containerClass->forall = webkit_web_view_container_forall; 3118 3119 /* 3120 * make us scrollable (e.g. addable to a GtkScrolledWindow) 3121 */ 3122#ifdef GTK_API_VERSION_2 3123 webViewClass->set_scroll_adjustments = webkit_web_view_set_scroll_adjustments; 3124 GTK_WIDGET_CLASS(webViewClass)->set_scroll_adjustments_signal = g_signal_new("set-scroll-adjustments", 3125 G_TYPE_FROM_CLASS(webViewClass), 3126 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 3127 G_STRUCT_OFFSET(WebKitWebViewClass, set_scroll_adjustments), 3128 NULL, NULL, 3129 webkit_marshal_VOID__OBJECT_OBJECT, 3130 G_TYPE_NONE, 2, 3131 GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); 3132#else 3133 g_object_class_override_property(objectClass, PROP_HADJUSTMENT, "hadjustment"); 3134 g_object_class_override_property(objectClass, PROP_VADJUSTMENT, "vadjustment"); 3135 g_object_class_override_property(objectClass, PROP_HSCROLL_POLICY, "hscroll-policy"); 3136 g_object_class_override_property(objectClass, PROP_VSCROLL_POLICY, "vscroll-policy"); 3137#endif 3138 3139 /* 3140 * Key bindings 3141 */ 3142 3143 binding_set = gtk_binding_set_by_class(webViewClass); 3144 3145 gtk_binding_entry_add_signal(binding_set, GDK_a, GDK_CONTROL_MASK, 3146 "select_all", 0); 3147 3148 /* Cut/copy/paste */ 3149 3150 gtk_binding_entry_add_signal(binding_set, GDK_x, GDK_CONTROL_MASK, 3151 "cut_clipboard", 0); 3152 gtk_binding_entry_add_signal(binding_set, GDK_c, GDK_CONTROL_MASK, 3153 "copy_clipboard", 0); 3154 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK, 3155 "paste_clipboard", 0); 3156 gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK, 3157 "undo", 0); 3158 gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK), 3159 "redo", 0); 3160 3161 gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK, 3162 "cut_clipboard", 0); 3163 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_CONTROL_MASK, 3164 "copy_clipboard", 0); 3165 gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK, 3166 "paste_clipboard", 0); 3167 3168 /* Movement */ 3169 3170 gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0), 3171 "move-cursor", 2, 3172 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES, 3173 G_TYPE_INT, 1); 3174 gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0), 3175 "move-cursor", 2, 3176 G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES, 3177 G_TYPE_INT, -1); 3178 gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0), 3179 "move-cursor", 2, 3180 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, 3181 G_TYPE_INT, 1); 3182 gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0), 3183 "move-cursor", 2, 3184 G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS, 3185 G_TYPE_INT, -1); 3186 gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0), 3187 "move-cursor", 2, 3188 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, 3189 G_TYPE_INT, 1); 3190 gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK, 3191 "move-cursor", 2, 3192 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, 3193 G_TYPE_INT, -1); 3194 gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0), 3195 "move-cursor", 2, 3196 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, 3197 G_TYPE_INT, 1); 3198 gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0), 3199 "move-cursor", 2, 3200 G_TYPE_ENUM, GTK_MOVEMENT_PAGES, 3201 G_TYPE_INT, -1); 3202 gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0), 3203 "move-cursor", 2, 3204 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS, 3205 G_TYPE_INT, 1); 3206 gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0), 3207 "move-cursor", 2, 3208 G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS, 3209 G_TYPE_INT, -1); 3210 3211 /* 3212 * properties 3213 */ 3214 3215 /** 3216 * WebKitWebView:title: 3217 * 3218 * Returns: the @web_view's document title. 3219 * 3220 * Since: 1.1.4 3221 */ 3222 g_object_class_install_property(objectClass, PROP_TITLE, 3223 g_param_spec_string("title", 3224 _("Title"), 3225 _("Returns the @web_view's document title"), 3226 NULL, 3227 WEBKIT_PARAM_READABLE)); 3228 3229 /** 3230 * WebKitWebView:uri: 3231 * 3232 * Returns: the current URI of the contents displayed by the @web_view. 3233 * 3234 * Since: 1.1.4 3235 */ 3236 g_object_class_install_property(objectClass, PROP_URI, 3237 g_param_spec_string("uri", 3238 _("URI"), 3239 _("Returns the current URI of the contents displayed by the @web_view"), 3240 NULL, 3241 WEBKIT_PARAM_READABLE)); 3242 3243 /** 3244 * WebKitWebView:copy-target-list: 3245 * 3246 * The list of targets this web view supports for clipboard copying. 3247 * 3248 * Since: 1.0.2 3249 */ 3250 g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST, 3251 g_param_spec_boxed("copy-target-list", 3252 _("Copy target list"), 3253 _("The list of targets this web view supports for clipboard copying"), 3254 GTK_TYPE_TARGET_LIST, 3255 WEBKIT_PARAM_READABLE)); 3256 3257 /** 3258 * WebKitWebView:paste-target-list: 3259 * 3260 * The list of targets this web view supports for clipboard pasting. 3261 * 3262 * Since: 1.0.2 3263 */ 3264 g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST, 3265 g_param_spec_boxed("paste-target-list", 3266 _("Paste target list"), 3267 _("The list of targets this web view supports for clipboard pasting"), 3268 GTK_TYPE_TARGET_LIST, 3269 WEBKIT_PARAM_READABLE)); 3270 3271 g_object_class_install_property(objectClass, PROP_SETTINGS, 3272 g_param_spec_object("settings", 3273 _("Settings"), 3274 _("An associated WebKitWebSettings instance"), 3275 WEBKIT_TYPE_WEB_SETTINGS, 3276 WEBKIT_PARAM_READWRITE)); 3277 3278 /** 3279 * WebKitWebView:web-inspector: 3280 * 3281 * The associated WebKitWebInspector instance. 3282 * 3283 * Since: 1.0.3 3284 */ 3285 g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR, 3286 g_param_spec_object("web-inspector", 3287 _("Web Inspector"), 3288 _("The associated WebKitWebInspector instance"), 3289 WEBKIT_TYPE_WEB_INSPECTOR, 3290 WEBKIT_PARAM_READABLE)); 3291 3292 /** 3293 * WebKitWebView:viewport-attributes: 3294 * 3295 * The associated #WebKitViewportAttributes instance. 3296 * 3297 * Since: 1.3.8 3298 */ 3299 g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES, 3300 g_param_spec_object("viewport-attributes", 3301 _("Viewport Attributes"), 3302 _("The associated WebKitViewportAttributes instance"), 3303 WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, 3304 WEBKIT_PARAM_READABLE)); 3305 3306 /** 3307 * WebKitWebView:window-features: 3308 * 3309 * An associated WebKitWebWindowFeatures instance. 3310 * 3311 * Since: 1.0.3 3312 */ 3313 g_object_class_install_property(objectClass, PROP_WINDOW_FEATURES, 3314 g_param_spec_object("window-features", 3315 "Window Features", 3316 "An associated WebKitWebWindowFeatures instance", 3317 WEBKIT_TYPE_WEB_WINDOW_FEATURES, 3318 WEBKIT_PARAM_READWRITE)); 3319 3320 g_object_class_install_property(objectClass, PROP_EDITABLE, 3321 g_param_spec_boolean("editable", 3322 _("Editable"), 3323 _("Whether content can be modified by the user"), 3324 FALSE, 3325 WEBKIT_PARAM_READWRITE)); 3326 3327 g_object_class_install_property(objectClass, PROP_TRANSPARENT, 3328 g_param_spec_boolean("transparent", 3329 _("Transparent"), 3330 _("Whether content has a transparent background"), 3331 FALSE, 3332 WEBKIT_PARAM_READWRITE)); 3333 3334 /** 3335 * WebKitWebView:zoom-level: 3336 * 3337 * The level of zoom of the content. 3338 * 3339 * Since: 1.0.1 3340 */ 3341 g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL, 3342 g_param_spec_float("zoom-level", 3343 _("Zoom level"), 3344 _("The level of zoom of the content"), 3345 G_MINFLOAT, 3346 G_MAXFLOAT, 3347 1.0f, 3348 WEBKIT_PARAM_READWRITE)); 3349 3350 /** 3351 * WebKitWebView:full-content-zoom: 3352 * 3353 * Whether the full content is scaled when zooming. 3354 * 3355 * Since: 1.0.1 3356 */ 3357 g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM, 3358 g_param_spec_boolean("full-content-zoom", 3359 _("Full content zoom"), 3360 _("Whether the full content is scaled when zooming"), 3361 FALSE, 3362 WEBKIT_PARAM_READWRITE)); 3363 3364 /** 3365 * WebKitWebView:encoding: 3366 * 3367 * The default encoding of the web view. 3368 * 3369 * Since: 1.1.2 3370 */ 3371 g_object_class_install_property(objectClass, PROP_ENCODING, 3372 g_param_spec_string("encoding", 3373 _("Encoding"), 3374 _("The default encoding of the web view"), 3375 NULL, 3376 WEBKIT_PARAM_READABLE)); 3377 3378 /** 3379 * WebKitWebView:custom-encoding: 3380 * 3381 * The custom encoding of the web view. 3382 * 3383 * Since: 1.1.2 3384 */ 3385 g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING, 3386 g_param_spec_string("custom-encoding", 3387 _("Custom Encoding"), 3388 _("The custom encoding of the web view"), 3389 NULL, 3390 WEBKIT_PARAM_READWRITE)); 3391 3392 /** 3393 * WebKitWebView:load-status: 3394 * 3395 * Determines the current status of the load. 3396 * 3397 * Connect to "notify::load-status" to monitor loading. 3398 * 3399 * Some versions of WebKitGTK+ emitted this signal for the default 3400 * error page, while loading it. This behavior was considered bad, 3401 * because it was essentially exposing an implementation 3402 * detail. From 1.1.19 onwards this signal is no longer emitted for 3403 * the default error pages, but keep in mind that if you override 3404 * the error pages by using webkit_web_frame_load_alternate_string() 3405 * the signals will be emitted. 3406 * 3407 * Since: 1.1.7 3408 */ 3409 g_object_class_install_property(objectClass, PROP_LOAD_STATUS, 3410 g_param_spec_enum("load-status", 3411 "Load Status", 3412 "Determines the current status of the load", 3413 WEBKIT_TYPE_LOAD_STATUS, 3414 WEBKIT_LOAD_FINISHED, 3415 WEBKIT_PARAM_READABLE)); 3416 3417 /** 3418 * WebKitWebView:progress: 3419 * 3420 * Determines the current progress of the load. 3421 * 3422 * Since: 1.1.7 3423 */ 3424 g_object_class_install_property(objectClass, PROP_PROGRESS, 3425 g_param_spec_double("progress", 3426 "Progress", 3427 "Determines the current progress of the load", 3428 0.0, 1.0, 1.0, 3429 WEBKIT_PARAM_READABLE)); 3430 3431 /** 3432 * WebKitWebView:icon-uri: 3433 * 3434 * The URI for the favicon for the #WebKitWebView. 3435 * 3436 * Since: 1.1.18 3437 */ 3438 g_object_class_install_property(objectClass, PROP_ICON_URI, 3439 g_param_spec_string("icon-uri", 3440 _("Icon URI"), 3441 _("The URI for the favicon for the #WebKitWebView."), 3442 NULL, 3443 WEBKIT_PARAM_READABLE)); 3444 /** 3445 * WebKitWebView:im-context: 3446 * 3447 * The GtkIMMulticontext for the #WebKitWebView. 3448 * 3449 * This is the input method context used for all text entry widgets inside 3450 * the #WebKitWebView. It can be used to generate context menu items for 3451 * controlling the active input method. 3452 * 3453 * Since: 1.1.20 3454 */ 3455 g_object_class_install_property(objectClass, PROP_IM_CONTEXT, 3456 g_param_spec_object("im-context", 3457 "IM Context", 3458 "The GtkIMMultiContext for the #WebKitWebView.", 3459 GTK_TYPE_IM_CONTEXT, 3460 WEBKIT_PARAM_READABLE)); 3461 3462 /** 3463 * WebKitWebView:view-mode: 3464 * 3465 * The "view-mode" media feature for the #WebKitWebView. 3466 * 3467 * The "view-mode" media feature is additional information for web 3468 * applications about how the application is running, when it comes 3469 * to user experience. Whether the application is running inside a 3470 * regular browser window, in a dedicated window, fullscreen, for 3471 * instance. 3472 * 3473 * This property stores a %WebKitWebViewViewMode value that matches 3474 * the "view-mode" media feature the web application will see. 3475 * 3476 * See http://www.w3.org/TR/view-mode/ for more information. 3477 * 3478 * Since: 1.3.4 3479 */ 3480 g_object_class_install_property(objectClass, PROP_VIEW_MODE, 3481 g_param_spec_enum("view-mode", 3482 "View Mode", 3483 "The view-mode media feature for the #WebKitWebView.", 3484 WEBKIT_TYPE_WEB_VIEW_VIEW_MODE, 3485 WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED, 3486 WEBKIT_PARAM_READWRITE)); 3487 3488 // This property should be undocumented for now. It's only used by DRT. 3489 g_object_class_install_property(objectClass, PROP_SELF_SCROLLING, 3490 g_param_spec_boolean("self-scrolling", "Self-scrolling", 3491 "Whether or not this WebView draws its own scrollbars.", 3492 FALSE, 3493 static_cast<GParamFlags>(G_PARAM_CONSTRUCT_ONLY | WEBKIT_PARAM_READWRITE))); 3494 3495 g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); 3496} 3497 3498static void webkit_web_view_update_settings(WebKitWebView* webView) 3499{ 3500 WebKitWebSettingsPrivate* settingsPrivate = webView->priv->webSettings->priv; 3501 Settings* coreSettings = core(webView)->settings(); 3502 3503 coreSettings->setDefaultTextEncodingName(settingsPrivate->defaultEncoding.data()); 3504 coreSettings->setCursiveFontFamily(settingsPrivate->cursiveFontFamily.data()); 3505 coreSettings->setStandardFontFamily(settingsPrivate->defaultFontFamily.data()); 3506 coreSettings->setFantasyFontFamily(settingsPrivate->fantasyFontFamily.data()); 3507 coreSettings->setFixedFontFamily(settingsPrivate->monospaceFontFamily.data()); 3508 coreSettings->setSansSerifFontFamily(settingsPrivate->sansSerifFontFamily.data()); 3509 coreSettings->setSerifFontFamily(settingsPrivate->serifFontFamily.data()); 3510 coreSettings->setLoadsImagesAutomatically(settingsPrivate->autoLoadImages); 3511 coreSettings->setShrinksStandaloneImagesToFit(settingsPrivate->autoShrinkImages); 3512 coreSettings->setShouldRespectImageOrientation(settingsPrivate->respectImageOrientation); 3513 coreSettings->setShouldPrintBackgrounds(settingsPrivate->printBackgrounds); 3514 coreSettings->setScriptEnabled(settingsPrivate->enableScripts); 3515 coreSettings->setPluginsEnabled(settingsPrivate->enablePlugins); 3516 coreSettings->setTextAreasAreResizable(settingsPrivate->resizableTextAreas); 3517 coreSettings->setUserStyleSheetLocation(KURL(KURL(), settingsPrivate->userStylesheetURI.data())); 3518 coreSettings->setDeveloperExtrasEnabled(settingsPrivate->enableDeveloperExtras); 3519 coreSettings->setPrivateBrowsingEnabled(settingsPrivate->enablePrivateBrowsing); 3520 coreSettings->setCaretBrowsingEnabled(settingsPrivate->enableCaretBrowsing); 3521 coreSettings->setLocalStorageEnabled(settingsPrivate->enableHTML5LocalStorage); 3522 coreSettings->setLocalStorageDatabasePath(settingsPrivate->html5LocalStorageDatabasePath.data()); 3523 coreSettings->setXSSAuditorEnabled(settingsPrivate->enableXSSAuditor); 3524 coreSettings->setSpatialNavigationEnabled(settingsPrivate->enableSpatialNavigation); 3525 coreSettings->setFrameFlatteningEnabled(settingsPrivate->enableFrameFlattening); 3526 coreSettings->setJavaScriptCanOpenWindowsAutomatically(settingsPrivate->javascriptCanOpenWindowsAutomatically); 3527 coreSettings->setJavaScriptCanAccessClipboard(settingsPrivate->javascriptCanAccessClipboard); 3528 coreSettings->setOfflineWebApplicationCacheEnabled(settingsPrivate->enableOfflineWebApplicationCache); 3529 coreSettings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(settingsPrivate->editingBehavior)); 3530 coreSettings->setAllowUniversalAccessFromFileURLs(settingsPrivate->enableUniversalAccessFromFileURIs); 3531 coreSettings->setAllowFileAccessFromFileURLs(settingsPrivate->enableFileAccessFromFileURIs); 3532 coreSettings->setDOMPasteAllowed(settingsPrivate->enableDOMPaste); 3533 coreSettings->setNeedsSiteSpecificQuirks(settingsPrivate->enableSiteSpecificQuirks); 3534 coreSettings->setUsesPageCache(settingsPrivate->enablePageCache); 3535 coreSettings->setJavaEnabled(settingsPrivate->enableJavaApplet); 3536 coreSettings->setHyperlinkAuditingEnabled(settingsPrivate->enableHyperlinkAuditing); 3537 coreSettings->setDNSPrefetchingEnabled(settingsPrivate->enableDNSPrefetching); 3538 coreSettings->setMediaPlaybackRequiresUserGesture(settingsPrivate->mediaPlaybackRequiresUserGesture); 3539 coreSettings->setMediaPlaybackAllowsInline(settingsPrivate->mediaPlaybackAllowsInline); 3540 coreSettings->setAllowDisplayOfInsecureContent(settingsPrivate->enableDisplayOfInsecureContent); 3541 coreSettings->setAllowRunningOfInsecureContent(settingsPrivate->enableRunningOfInsecureContent); 3542 3543#if ENABLE(SQL_DATABASE) 3544 DatabaseManager::manager().setIsAvailable(settingsPrivate->enableHTML5Database); 3545#endif 3546 3547#if ENABLE(FULLSCREEN_API) 3548 coreSettings->setFullScreenEnabled(settingsPrivate->enableFullscreen); 3549#endif 3550 3551#if ENABLE(SPELLCHECK) 3552 if (settingsPrivate->enableSpellChecking) { 3553 WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient()); 3554 static_cast<WebKit::TextCheckerClientGtk*>(client->textChecker())->updateSpellCheckingLanguage(settingsPrivate->spellCheckingLanguages.data()); 3555 } 3556#endif 3557 3558#if ENABLE(WEBGL) 3559 coreSettings->setWebGLEnabled(settingsPrivate->enableWebgl); 3560#endif 3561 3562#if ENABLE(MEDIA_STREAM) 3563 WebCore::RuntimeEnabledFeatures::setMediaStreamEnabled(settingsPrivate->enableMediaStream); 3564#endif 3565 3566#if USE(ACCELERATED_COMPOSITING) 3567 coreSettings->setAcceleratedCompositingEnabled(settingsPrivate->enableAcceleratedCompositing); 3568 char* debugVisualsEnvironment = getenv("WEBKIT_SHOW_COMPOSITING_DEBUG_VISUALS"); 3569 bool showDebugVisuals = debugVisualsEnvironment && !strcmp(debugVisualsEnvironment, "1"); 3570 coreSettings->setShowDebugBorders(showDebugVisuals); 3571 coreSettings->setShowRepaintCounter(showDebugVisuals); 3572#endif 3573 3574#if ENABLE(WEB_AUDIO) 3575 coreSettings->setWebAudioEnabled(settingsPrivate->enableWebAudio); 3576#endif 3577 3578#if ENABLE(SMOOTH_SCROLLING) 3579 coreSettings->setScrollAnimatorEnabled(settingsPrivate->enableSmoothScrolling); 3580#endif 3581 3582#if ENABLE(CSS_SHADERS) 3583 coreSettings->setCSSCustomFilterEnabled(settingsPrivate->enableCSSShaders); 3584#endif 3585 3586 // Use mock scrollbars if in DumpRenderTree mode (i.e. testing layout tests). 3587 coreSettings->setMockScrollbarsEnabled(DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()); 3588 3589 if (Page* page = core(webView)) 3590 page->setTabKeyCyclesThroughElements(settingsPrivate->tabKeyCyclesThroughElements); 3591 3592 webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); 3593} 3594 3595static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView) 3596{ 3597 Settings* settings = core(webView)->settings(); 3598 3599 const gchar* name = g_intern_string(pspec->name); 3600 GValue value = { 0, { { 0 } } }; 3601 g_value_init(&value, pspec->value_type); 3602 g_object_get_property(G_OBJECT(webSettings), name, &value); 3603 3604 if (name == g_intern_string("default-encoding")) 3605 settings->setDefaultTextEncodingName(g_value_get_string(&value)); 3606 else if (name == g_intern_string("cursive-font-family")) 3607 settings->setCursiveFontFamily(g_value_get_string(&value)); 3608 else if (name == g_intern_string("default-font-family")) 3609 settings->setStandardFontFamily(g_value_get_string(&value)); 3610 else if (name == g_intern_string("fantasy-font-family")) 3611 settings->setFantasyFontFamily(g_value_get_string(&value)); 3612 else if (name == g_intern_string("monospace-font-family")) 3613 settings->setFixedFontFamily(g_value_get_string(&value)); 3614 else if (name == g_intern_string("sans-serif-font-family")) 3615 settings->setSansSerifFontFamily(g_value_get_string(&value)); 3616 else if (name == g_intern_string("serif-font-family")) 3617 settings->setSerifFontFamily(g_value_get_string(&value)); 3618 else if (name == g_intern_string("default-font-size")) 3619 settings->setDefaultFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); 3620 else if (name == g_intern_string("default-monospace-font-size")) 3621 settings->setDefaultFixedFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); 3622 else if (name == g_intern_string("minimum-font-size")) 3623 settings->setMinimumFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); 3624 else if (name == g_intern_string("minimum-logical-font-size")) 3625 settings->setMinimumLogicalFontSize(webViewConvertFontSizeToPixels(webView, g_value_get_int(&value))); 3626 else if (name == g_intern_string("enforce-96-dpi")) 3627 webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL); 3628 else if (name == g_intern_string("auto-load-images")) 3629 settings->setLoadsImagesAutomatically(g_value_get_boolean(&value)); 3630 else if (name == g_intern_string("auto-shrink-images")) 3631 settings->setShrinksStandaloneImagesToFit(g_value_get_boolean(&value)); 3632 else if (name == g_intern_string("respect-image-orientation")) 3633 settings->setShouldRespectImageOrientation(g_value_get_boolean(&value)); 3634 else if (name == g_intern_string("print-backgrounds")) 3635 settings->setShouldPrintBackgrounds(g_value_get_boolean(&value)); 3636 else if (name == g_intern_string("enable-scripts")) 3637 settings->setScriptEnabled(g_value_get_boolean(&value)); 3638 else if (name == g_intern_string("enable-plugins")) 3639 settings->setPluginsEnabled(g_value_get_boolean(&value)); 3640 else if (name == g_intern_string("enable-dns-prefetching")) 3641 settings->setDNSPrefetchingEnabled(g_value_get_boolean(&value)); 3642 else if (name == g_intern_string("resizable-text-areas")) 3643 settings->setTextAreasAreResizable(g_value_get_boolean(&value)); 3644 else if (name == g_intern_string("user-stylesheet-uri")) 3645 settings->setUserStyleSheetLocation(KURL(KURL(), g_value_get_string(&value))); 3646 else if (name == g_intern_string("enable-developer-extras")) 3647 settings->setDeveloperExtrasEnabled(g_value_get_boolean(&value)); 3648 else if (name == g_intern_string("enable-private-browsing")) 3649 settings->setPrivateBrowsingEnabled(g_value_get_boolean(&value)); 3650 else if (name == g_intern_string("enable-caret-browsing")) 3651 settings->setCaretBrowsingEnabled(g_value_get_boolean(&value)); 3652#if ENABLE(SQL_DATABASE) 3653 else if (name == g_intern_string("enable-html5-database")) { 3654 DatabaseManager::manager().setIsAvailable(g_value_get_boolean(&value)); 3655 } 3656#endif 3657 else if (name == g_intern_string("enable-html5-local-storage")) 3658 settings->setLocalStorageEnabled(g_value_get_boolean(&value)); 3659 else if (name == g_intern_string("html5-local-storage-database-path")) 3660 settings->setLocalStorageDatabasePath(g_value_get_string(&value)); 3661 else if (name == g_intern_string("enable-xss-auditor")) 3662 settings->setXSSAuditorEnabled(g_value_get_boolean(&value)); 3663 else if (name == g_intern_string("enable-spatial-navigation")) 3664 settings->setSpatialNavigationEnabled(g_value_get_boolean(&value)); 3665 else if (name == g_intern_string("enable-frame-flattening")) 3666 settings->setFrameFlatteningEnabled(g_value_get_boolean(&value)); 3667 else if (name == g_intern_string("javascript-can-open-windows-automatically")) 3668 settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value)); 3669 else if (name == g_intern_string("javascript-can-access-clipboard")) 3670 settings->setJavaScriptCanAccessClipboard(g_value_get_boolean(&value)); 3671 else if (name == g_intern_string("enable-offline-web-application-cache")) 3672 settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value)); 3673 else if (name == g_intern_string("editing-behavior")) 3674 settings->setEditingBehaviorType(static_cast<WebCore::EditingBehaviorType>(g_value_get_enum(&value))); 3675 else if (name == g_intern_string("enable-universal-access-from-file-uris")) 3676 settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value)); 3677 else if (name == g_intern_string("enable-file-access-from-file-uris")) 3678 settings->setAllowFileAccessFromFileURLs(g_value_get_boolean(&value)); 3679 else if (name == g_intern_string("enable-dom-paste")) 3680 settings->setDOMPasteAllowed(g_value_get_boolean(&value)); 3681 else if (name == g_intern_string("tab-key-cycles-through-elements")) { 3682 Page* page = core(webView); 3683 if (page) 3684 page->setTabKeyCyclesThroughElements(g_value_get_boolean(&value)); 3685 } else if (name == g_intern_string("enable-site-specific-quirks")) 3686 settings->setNeedsSiteSpecificQuirks(g_value_get_boolean(&value)); 3687 else if (name == g_intern_string("enable-page-cache")) 3688 settings->setUsesPageCache(g_value_get_boolean(&value)); 3689 else if (name == g_intern_string("enable-java-applet")) 3690 settings->setJavaEnabled(g_value_get_boolean(&value)); 3691 else if (name == g_intern_string("enable-hyperlink-auditing")) 3692 settings->setHyperlinkAuditingEnabled(g_value_get_boolean(&value)); 3693 else if (name == g_intern_string("media-playback-requires-user-gesture")) 3694 settings->setMediaPlaybackRequiresUserGesture(g_value_get_boolean(&value)); 3695 else if (name == g_intern_string("media-playback-allows-inline")) 3696 settings->setMediaPlaybackAllowsInline(g_value_get_boolean(&value)); 3697 3698#if ENABLE(SPELLCHECK) 3699 else if (name == g_intern_string("spell-checking-languages")) { 3700 gboolean enableSpellChecking; 3701 g_object_get(G_OBJECT(webSettings), "enable-spell-checking", &enableSpellChecking, NULL); 3702 if (enableSpellChecking) { 3703 WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient()); 3704 static_cast<WebKit::TextCheckerClientGtk*>(client->textChecker())->updateSpellCheckingLanguage(g_value_get_string(&value)); 3705 } 3706 } 3707#endif 3708 3709#if ENABLE(WEBGL) 3710 else if (name == g_intern_string("enable-webgl")) 3711 settings->setWebGLEnabled(g_value_get_boolean(&value)); 3712#endif 3713 3714#if USE(ACCELERATED_COMPOSITING) 3715 else if (name == g_intern_string("enable-accelerated-compositing")) 3716 settings->setAcceleratedCompositingEnabled(g_value_get_boolean(&value)); 3717#endif 3718 3719#if ENABLE(WEB_AUDIO) 3720 else if (name == g_intern_string("enable-webaudio")) 3721 settings->setWebAudioEnabled(g_value_get_boolean(&value)); 3722#endif 3723 3724#if ENABLE(SMOOTH_SCROLLING) 3725 else if (name == g_intern_string("enable-smooth-scrolling")) 3726 settings->setScrollAnimatorEnabled(g_value_get_boolean(&value)); 3727#endif 3728 3729#if ENABLE(CSS_SHADERS) 3730 else if (name == g_intern_string("enable-css-shaders")) 3731 settings->setCSSCustomFilterEnabled(g_value_get_boolean(&value)); 3732#endif 3733 3734 else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name)) 3735 g_warning("Unexpected setting '%s'", name); 3736 g_value_unset(&value); 3737} 3738 3739static void webkit_web_view_init(WebKitWebView* webView) 3740{ 3741 WebKitWebViewPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(webView, WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate); 3742 webView->priv = priv; 3743 // This is the placement new syntax: http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10 3744 // It allows us to call a constructor on manually allocated locations in memory. We must use it 3745 // in this case, because GLib manages the memory for the private data section, but we wish it 3746 // to contain C++ object members. The use of placement new calls the constructor on all C++ data 3747 // members, which ensures they are initialized properly. 3748 new (priv) WebKitWebViewPrivate(); 3749 3750 priv->imFilter.setWebView(webView); 3751 3752 Page::PageClients pageClients; 3753 pageClients.chromeClient = new WebKit::ChromeClient(webView); 3754#if ENABLE(CONTEXT_MENUS) 3755 pageClients.contextMenuClient = new WebKit::ContextMenuClient(webView); 3756#endif 3757 pageClients.editorClient = new WebKit::EditorClient(webView); 3758#if ENABLE(DRAG_SUPPORT) 3759 pageClients.dragClient = new WebKit::DragClient(webView); 3760#endif 3761 pageClients.inspectorClient = new WebKit::InspectorClient(webView); 3762 3763 priv->corePage = new Page(pageClients); 3764 3765 priv->corePage->addLayoutMilestones(DidFirstVisuallyNonEmptyLayout); 3766 3767#if ENABLE(GEOLOCATION) 3768 if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()) { 3769 priv->geolocationClientMock = adoptPtr(new GeolocationClientMock); 3770 WebCore::provideGeolocationTo(priv->corePage, priv->geolocationClientMock.get()); 3771 priv->geolocationClientMock.get()->setController(GeolocationController::from(priv->corePage)); 3772 } else 3773 WebCore::provideGeolocationTo(priv->corePage, new WebKit::GeolocationClient(webView)); 3774#endif 3775#if ENABLE(DEVICE_ORIENTATION) 3776 WebCore::provideDeviceMotionTo(priv->corePage, new DeviceMotionClientGtk); 3777 WebCore::provideDeviceOrientationTo(priv->corePage, new DeviceOrientationClientGtk); 3778#endif 3779 3780#if ENABLE(MEDIA_STREAM) 3781 priv->userMediaClient = adoptPtr(new UserMediaClientGtk); 3782 WebCore::provideUserMediaTo(priv->corePage, priv->userMediaClient.get()); 3783#endif 3784 3785#if ENABLE(NAVIGATOR_CONTENT_UTILS) 3786 priv->navigatorContentUtilsClient = WebKit::NavigatorContentUtilsClient::create(); 3787 WebCore::provideNavigatorContentUtilsTo(priv->corePage, priv->navigatorContentUtilsClient.get()); 3788#endif 3789 3790 if (DumpRenderTreeSupportGtk::dumpRenderTreeModeEnabled()) { 3791 // Set some testing-specific settings 3792 priv->corePage->settings()->setInteractiveFormValidationEnabled(true); 3793 priv->corePage->settings()->setValidationMessageTimerMagnification(-1); 3794 } 3795 3796 // Pages within a same session need to be linked together otherwise some functionalities such 3797 // as visited link coloration (across pages) and changing popup window location will not work. 3798 // To keep the default behavior simple (and because no PageGroup API exist in WebKitGTK at the 3799 // time of writing this comment), we simply set all the pages to the same group. 3800 priv->corePage->setGroupName(webkitPageGroupName()); 3801 3802 // We also add a simple wrapper class to provide the public 3803 // interface for the Web Inspector. 3804 priv->webInspector = adoptGRef(WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL))); 3805 webkit_web_inspector_set_inspector_client(priv->webInspector.get(), priv->corePage); 3806 3807 // And our ViewportAttributes friend. 3808 priv->viewportAttributes = adoptGRef(WEBKIT_VIEWPORT_ATTRIBUTES(g_object_new(WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, NULL))); 3809 priv->viewportAttributes->priv->webView = webView; 3810 3811 gtk_widget_set_can_focus(GTK_WIDGET(webView), TRUE); 3812 3813 priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView)); 3814 priv->lastPopupXPosition = priv->lastPopupYPosition = -1; 3815 3816 priv->backForwardList = adoptGRef(webkit_web_back_forward_list_new_with_web_view(webView)); 3817 3818 priv->zoomFullContent = FALSE; 3819 3820 priv->webSettings = adoptGRef(webkit_web_settings_new()); 3821 webkit_web_view_update_settings(webView); 3822 g_signal_connect(priv->webSettings.get(), "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); 3823 3824 priv->webWindowFeatures = adoptGRef(webkit_web_window_features_new()); 3825 3826 priv->subResources = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref)); 3827 3828#if ENABLE(DRAG_SUPPORT) 3829 priv->dragAndDropHelper.setWidget(GTK_WIDGET(webView)); 3830 gtk_drag_dest_set(GTK_WIDGET(webView), static_cast<GtkDestDefaults>(0), 0, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE)); 3831 gtk_drag_dest_set_target_list(GTK_WIDGET(webView), PasteboardHelper::defaultPasteboardHelper()->targetList()); 3832#endif 3833 3834 priv->selfScrolling = false; 3835 3836#if USE(ACCELERATED_COMPOSITING) 3837 priv->acceleratedCompositingContext = AcceleratedCompositingContext::create(webView); 3838#endif 3839 3840 g_signal_connect(webView, "direction-changed", G_CALLBACK(webkitWebViewDirectionChanged), 0); 3841} 3842 3843GtkWidget* webkit_web_view_new(void) 3844{ 3845 WebKitWebView* webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL)); 3846 3847 return GTK_WIDGET(webView); 3848} 3849 3850void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChooserRequest* request) 3851{ 3852 gboolean returnValue; 3853 g_signal_emit(webView, webkit_web_view_signals[RUN_FILE_CHOOSER], 0, request, &returnValue); 3854} 3855 3856// for internal use only 3857void webkit_web_view_notify_ready(WebKitWebView* webView) 3858{ 3859 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 3860 3861 gboolean isHandled = FALSE; 3862 g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled); 3863} 3864 3865void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response, ResourceHandle* handle) 3866{ 3867 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 3868 3869 WebKitDownload* download; 3870 3871 if (handle) 3872 download = webkit_download_new_with_handle(request, handle, response); 3873 else 3874 download = webkit_download_new(request); 3875 3876 gboolean handled; 3877 g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled); 3878 3879 if (!handled) { 3880 webkit_download_cancel(download); 3881 g_object_unref(download); 3882 return; 3883 } 3884 3885 /* Start the download now if it has a destination URI, otherwise it 3886 may be handled asynchronously by the application. */ 3887 if (webkit_download_get_destination_uri(download)) 3888 webkit_download_start(download); 3889} 3890 3891/** 3892 * webkit_web_view_set_settings: 3893 * @web_view: a #WebKitWebView 3894 * @settings: (transfer none): the #WebKitWebSettings to be set 3895 * 3896 * Replaces the #WebKitWebSettings instance that is currently attached 3897 * to @web_view with @settings. The reference held by the @web_view on 3898 * the old #WebKitWebSettings instance is dropped, and the reference 3899 * count of @settings is inscreased. 3900 * 3901 * The settings are automatically applied to @web_view. 3902 */ 3903void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings) 3904{ 3905 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 3906 g_return_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings)); 3907 3908 WebKitWebViewPrivate* priv = webView->priv; 3909 g_signal_handlers_disconnect_by_func(priv->webSettings.get(), reinterpret_cast<void*>(webkit_web_view_settings_notify), webView); 3910 3911 priv->webSettings = webSettings; 3912 webkit_web_view_update_settings(webView); 3913 g_signal_connect(webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); 3914 g_object_notify(G_OBJECT(webView), "settings"); 3915} 3916 3917/** 3918 * webkit_web_view_get_settings: 3919 * @web_view: a #WebKitWebView 3920 * 3921 * Obtains the #WebKitWebSettings associated with the 3922 * #WebKitWebView. The #WebKitWebView always has an associated 3923 * instance of #WebKitWebSettings. The reference that is returned by 3924 * this call is owned by the #WebKitWebView. You may need to increase 3925 * its reference count if you intend to keep it alive for longer than 3926 * the #WebKitWebView. 3927 * 3928 * Return value: (transfer none): the #WebKitWebSettings instance 3929 */ 3930WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) 3931{ 3932 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 3933 return webView->priv->webSettings.get(); 3934} 3935 3936/** 3937 * webkit_web_view_get_inspector: 3938 * @web_view: a #WebKitWebView 3939 * 3940 * Obtains the #WebKitWebInspector associated with the 3941 * #WebKitWebView. Every #WebKitWebView object has a 3942 * #WebKitWebInspector object attached to it as soon as it is created, 3943 * so this function will only return NULL if the argument is not a 3944 * valid #WebKitWebView. 3945 * 3946 * Return value: (transfer none): the #WebKitWebInspector instance. 3947 * 3948 * Since: 1.0.3 3949 */ 3950WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) 3951{ 3952 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 3953 return webView->priv->webInspector.get(); 3954} 3955 3956/** 3957 * webkit_web_view_get_viewport_attributes: 3958 * @web_view: a #WebKitWebView 3959 * 3960 * Obtains the #WebKitViewportAttributes associated with the 3961 * #WebKitWebView. Every #WebKitWebView object has a 3962 * #WebKitViewportAttributes object attached to it as soon as it is 3963 * created, so this function will only return NULL if the argument is 3964 * not a valid #WebKitWebView. Do note however that the viewport 3965 * attributes object only contains valid information when the current 3966 * page has a viewport meta tag. You can check whether the data should 3967 * be used by checking the #WebKitViewportAttributes:valid property. 3968 * 3969 * Return value: (transfer none): the #WebKitViewportAttributes instance. 3970 * 3971 * Since: 1.3.8 3972 */ 3973WebKitViewportAttributes* webkit_web_view_get_viewport_attributes(WebKitWebView* webView) 3974{ 3975 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 3976 return webView->priv->viewportAttributes.get(); 3977} 3978 3979// internal 3980static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures) 3981{ 3982 if (!webWindowFeatures) 3983 return; 3984 if (webkit_web_window_features_equal(webView->priv->webWindowFeatures.get(), webWindowFeatures)) 3985 return; 3986 webView->priv->webWindowFeatures = webWindowFeatures; 3987} 3988 3989/** 3990 * webkit_web_view_get_window_features: 3991 * @web_view: a #WebKitWebView 3992 * 3993 * Returns: (transfer none): the instance of #WebKitWebWindowFeatures held by the given 3994 * #WebKitWebView. 3995 * 3996 * Since: 1.0.3 3997 */ 3998WebKitWebWindowFeatures* webkit_web_view_get_window_features(WebKitWebView* webView) 3999{ 4000 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 4001 return webView->priv->webWindowFeatures.get(); 4002} 4003 4004/** 4005 * webkit_web_view_get_title: 4006 * @web_view: a #WebKitWebView 4007 * 4008 * Returns the @web_view's document title 4009 * 4010 * Since: 1.1.4 4011 * 4012 * Return value: the title of @web_view 4013 */ 4014const gchar* webkit_web_view_get_title(WebKitWebView* webView) 4015{ 4016 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4017 4018 WebKitWebViewPrivate* priv = webView->priv; 4019 return priv->mainFrame->priv->title; 4020} 4021 4022/** 4023 * webkit_web_view_get_uri: 4024 * @web_view: a #WebKitWebView 4025 * 4026 * Returns the current URI of the contents displayed by the @web_view 4027 * 4028 * Since: 1.1.4 4029 * 4030 * Return value: the URI of @web_view 4031 */ 4032const gchar* webkit_web_view_get_uri(WebKitWebView* webView) 4033{ 4034 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4035 4036 WebKitWebViewPrivate* priv = webView->priv; 4037 return priv->mainFrame->priv->uri; 4038} 4039 4040/** 4041 * webkit_web_view_set_maintains_back_forward_list: 4042 * @web_view: a #WebKitWebView 4043 * @flag: to tell the view to maintain a back or forward list 4044 * 4045 * Set the view to maintain a back or forward list of history items. 4046 */ 4047void webkit_web_view_set_maintains_back_forward_list(WebKitWebView* webView, gboolean flag) 4048{ 4049 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4050 4051 static_cast<BackForwardListImpl*>(core(webView)->backForwardList())->setEnabled(flag); 4052} 4053 4054/** 4055 * webkit_web_view_get_back_forward_list: 4056 * @web_view: a #WebKitWebView 4057 * 4058 * Obtains the #WebKitWebBackForwardList associated with the given #WebKitWebView. The 4059 * #WebKitWebBackForwardList is owned by the #WebKitWebView. 4060 * 4061 * Return value: (transfer none): the #WebKitWebBackForwardList 4062 */ 4063WebKitWebBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView) 4064{ 4065 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 4066 if (!core(webView) || !static_cast<BackForwardListImpl*>(core(webView)->backForwardList())->enabled()) 4067 return 0; 4068 return webView->priv->backForwardList.get(); 4069} 4070 4071/** 4072 * webkit_web_view_go_to_back_forward_item: 4073 * @web_view: a #WebKitWebView 4074 * @item: a #WebKitWebHistoryItem* 4075 * 4076 * Go to the specified #WebKitWebHistoryItem 4077 * 4078 * Return value: %TRUE if loading of item is successful, %FALSE if not 4079 */ 4080gboolean webkit_web_view_go_to_back_forward_item(WebKitWebView* webView, WebKitWebHistoryItem* item) 4081{ 4082 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4083 g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(item), FALSE); 4084 4085 WebKitWebBackForwardList* backForwardList = webkit_web_view_get_back_forward_list(webView); 4086 if (!webkit_web_back_forward_list_contains_item(backForwardList, item)) 4087 return FALSE; 4088 4089 core(webView)->goToItem(core(item), FrameLoadTypeIndexedBackForward); 4090 return TRUE; 4091} 4092 4093/** 4094 * webkit_web_view_go_back: 4095 * @web_view: a #WebKitWebView 4096 * 4097 * Loads the previous history item. 4098 */ 4099void webkit_web_view_go_back(WebKitWebView* webView) 4100{ 4101 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4102 4103 core(webView)->goBack(); 4104} 4105 4106/** 4107 * webkit_web_view_go_back_or_forward: 4108 * @web_view: a #WebKitWebView 4109 * @steps: the number of steps 4110 * 4111 * Loads the history item that is the number of @steps away from the current 4112 * item. Negative values represent steps backward while positive values 4113 * represent steps forward. 4114 */ 4115void webkit_web_view_go_back_or_forward(WebKitWebView* webView, gint steps) 4116{ 4117 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4118 4119 core(webView)->goBackOrForward(steps); 4120} 4121 4122/** 4123 * webkit_web_view_go_forward: 4124 * @web_view: a #WebKitWebView 4125 * 4126 * Loads the next history item. 4127 */ 4128void webkit_web_view_go_forward(WebKitWebView* webView) 4129{ 4130 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4131 4132 core(webView)->goForward(); 4133} 4134 4135/** 4136 * webkit_web_view_can_go_back: 4137 * @web_view: a #WebKitWebView 4138 * 4139 * Determines whether #web_view has a previous history item. 4140 * 4141 * Return value: %TRUE if able to move back, %FALSE otherwise 4142 */ 4143gboolean webkit_web_view_can_go_back(WebKitWebView* webView) 4144{ 4145 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4146 4147 if (!core(webView) || !core(webView)->backForwardList()->backItem()) 4148 return FALSE; 4149 4150 return TRUE; 4151} 4152 4153/** 4154 * webkit_web_view_can_go_back_or_forward: 4155 * @web_view: a #WebKitWebView 4156 * @steps: the number of steps 4157 * 4158 * Determines whether #web_view has a history item of @steps. Negative values 4159 * represent steps backward while positive values represent steps forward. 4160 * 4161 * Return value: %TRUE if able to move back or forward the given number of 4162 * steps, %FALSE otherwise 4163 */ 4164gboolean webkit_web_view_can_go_back_or_forward(WebKitWebView* webView, gint steps) 4165{ 4166 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4167 4168 return core(webView)->canGoBackOrForward(steps); 4169} 4170 4171/** 4172 * webkit_web_view_can_go_forward: 4173 * @web_view: a #WebKitWebView 4174 * 4175 * Determines whether #web_view has a next history item. 4176 * 4177 * Return value: %TRUE if able to move forward, %FALSE otherwise 4178 */ 4179gboolean webkit_web_view_can_go_forward(WebKitWebView* webView) 4180{ 4181 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4182 4183 Page* page = core(webView); 4184 4185 if (!page) 4186 return FALSE; 4187 4188 if (!page->backForwardList()->forwardItem()) 4189 return FALSE; 4190 4191 return TRUE; 4192} 4193 4194/** 4195 * webkit_web_view_open: 4196 * @web_view: a #WebKitWebView 4197 * @uri: an URI 4198 * 4199 * Requests loading of the specified URI string. 4200 * 4201 * Deprecated: 1.1.1: Use webkit_web_view_load_uri() instead. 4202 */ 4203void webkit_web_view_open(WebKitWebView* webView, const gchar* uri) 4204{ 4205 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4206 g_return_if_fail(uri); 4207 4208 // We used to support local paths, unlike the newer 4209 // function webkit_web_view_load_uri 4210 if (g_path_is_absolute(uri)) { 4211 gchar* fileUri = g_filename_to_uri(uri, NULL, NULL); 4212 webkit_web_view_load_uri(webView, fileUri); 4213 g_free(fileUri); 4214 } 4215 else 4216 webkit_web_view_load_uri(webView, uri); 4217} 4218 4219void webkit_web_view_reload(WebKitWebView* webView) 4220{ 4221 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4222 4223 core(webView)->mainFrame()->loader()->reload(); 4224} 4225 4226/** 4227 * webkit_web_view_reload_bypass_cache: 4228 * @web_view: a #WebKitWebView 4229 * 4230 * Reloads the @web_view without using any cached data. 4231 * 4232 * Since: 1.0.3 4233 */ 4234void webkit_web_view_reload_bypass_cache(WebKitWebView* webView) 4235{ 4236 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4237 4238 core(webView)->mainFrame()->loader()->reload(true); 4239} 4240 4241/** 4242 * webkit_web_view_load_uri: 4243 * @web_view: a #WebKitWebView 4244 * @uri: an URI string 4245 * 4246 * Requests loading of the specified URI string. 4247 * 4248 * Since: 1.1.1 4249 */ 4250void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri) 4251{ 4252 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4253 g_return_if_fail(uri); 4254 4255 WebKitWebFrame* frame = webView->priv->mainFrame; 4256 webkit_web_frame_load_uri(frame, uri); 4257} 4258 4259/** 4260 * webkit_web_view_load_string: 4261 * @web_view: a #WebKitWebView 4262 * @content: an URI string 4263 * @mime_type: the MIME type, or %NULL 4264 * @encoding: the encoding, or %NULL 4265 * @base_uri: the base URI for relative locations 4266 * 4267 * Requests loading of the given @content with the specified @mime_type, 4268 * @encoding and @base_uri. 4269 * 4270 * If @mime_type is %NULL, "text/html" is assumed. 4271 * 4272 * If @encoding is %NULL, "UTF-8" is assumed. 4273 */ 4274void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, const gchar* mimeType, const gchar* encoding, const gchar* baseUri) 4275{ 4276 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4277 g_return_if_fail(content); 4278 4279 WebKitWebFrame* frame = webView->priv->mainFrame; 4280 webkit_web_frame_load_string(frame, content, mimeType, encoding, baseUri); 4281} 4282/** 4283 * webkit_web_view_load_html_string: 4284 * @web_view: a #WebKitWebView 4285 * @content: an URI string 4286 * @base_uri: the base URI for relative locations 4287 * 4288 * Requests loading of the given @content with the specified @base_uri. 4289 * 4290 * Deprecated: 1.1.1: Use webkit_web_view_load_string() instead. 4291 */ 4292void webkit_web_view_load_html_string(WebKitWebView* webView, const gchar* content, const gchar* baseUri) 4293{ 4294 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4295 g_return_if_fail(content); 4296 4297 webkit_web_view_load_string(webView, content, NULL, NULL, baseUri); 4298} 4299 4300/** 4301 * webkit_web_view_load_request: 4302 * @web_view: a #WebKitWebView 4303 * @request: a #WebKitNetworkRequest 4304 * 4305 * Requests loading of the specified asynchronous client request. 4306 * 4307 * Creates a provisional data source that will transition to a committed data 4308 * source once any data has been received. Use webkit_web_view_stop_loading() to 4309 * stop the load. 4310 * 4311 * Since: 1.1.1 4312 */ 4313void webkit_web_view_load_request(WebKitWebView* webView, WebKitNetworkRequest* request) 4314{ 4315 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4316 g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request)); 4317 4318 WebKitWebFrame* frame = webView->priv->mainFrame; 4319 webkit_web_frame_load_request(frame, request); 4320} 4321 4322/** 4323 * webkit_web_view_stop_loading: 4324 * @web_view: a #WebKitWebView 4325 * 4326 * Stops any ongoing load in the @web_view. 4327 **/ 4328void webkit_web_view_stop_loading(WebKitWebView* webView) 4329{ 4330 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4331 4332 core(webView)->mainFrame()->loader()->stopForUserCancel(); 4333} 4334 4335/** 4336 * webkit_web_view_search_text: 4337 * @web_view: a #WebKitWebView 4338 * @text: a string to look for 4339 * @forward: whether to find forward or not 4340 * @case_sensitive: whether to respect the case of text 4341 * @wrap: whether to continue looking at the beginning after reaching the end 4342 * 4343 * Looks for a specified string inside #web_view. 4344 * 4345 * Return value: %TRUE on success or %FALSE on failure 4346 */ 4347gboolean webkit_web_view_search_text(WebKitWebView* webView, const gchar* string, gboolean caseSensitive, gboolean forward, gboolean shouldWrap) 4348{ 4349 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4350 g_return_val_if_fail(string, FALSE); 4351 4352 TextCaseSensitivity caseSensitivity = caseSensitive ? TextCaseSensitive : TextCaseInsensitive; 4353 FindDirection direction = forward ? FindDirectionForward : FindDirectionBackward; 4354 4355 return core(webView)->findString(String::fromUTF8(string), caseSensitivity, direction, shouldWrap); 4356} 4357 4358/** 4359 * webkit_web_view_mark_text_matches: 4360 * @web_view: a #WebKitWebView 4361 * @string: a string to look for 4362 * @case_sensitive: whether to respect the case of text 4363 * @limit: the maximum number of strings to look for or 0 for all 4364 * 4365 * Attempts to highlight all occurances of #string inside #web_view. 4366 * 4367 * Return value: the number of strings highlighted 4368 */ 4369guint webkit_web_view_mark_text_matches(WebKitWebView* webView, const gchar* string, gboolean caseSensitive, guint limit) 4370{ 4371 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 4372 g_return_val_if_fail(string, 0); 4373 4374 TextCaseSensitivity caseSensitivity = caseSensitive ? TextCaseSensitive : TextCaseInsensitive; 4375 4376 return core(webView)->markAllMatchesForText(String::fromUTF8(string), caseSensitivity, false, limit); 4377} 4378 4379/** 4380 * webkit_web_view_set_highlight_text_matches: 4381 * @web_view: a #WebKitWebView 4382 * @highlight: whether to highlight text matches 4383 * 4384 * Highlights text matches previously marked by webkit_web_view_mark_text_matches. 4385 */ 4386void webkit_web_view_set_highlight_text_matches(WebKitWebView* webView, gboolean shouldHighlight) 4387{ 4388 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4389 4390 Frame *frame = core(webView)->mainFrame(); 4391 do { 4392 frame->editor().setMarkedTextMatchesAreHighlighted(shouldHighlight); 4393 frame = frame->tree()->traverseNextWithWrap(false); 4394 } while (frame); 4395} 4396 4397/** 4398 * webkit_web_view_unmark_text_matches: 4399 * @web_view: a #WebKitWebView 4400 * 4401 * Removes highlighting previously set by webkit_web_view_mark_text_matches. 4402 */ 4403void webkit_web_view_unmark_text_matches(WebKitWebView* webView) 4404{ 4405 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4406 4407 return core(webView)->unmarkAllTextMatches(); 4408} 4409 4410/** 4411 * webkit_web_view_get_main_frame: 4412 * @web_view: a #WebKitWebView 4413 * 4414 * Returns the main frame for the @web_view. 4415 * 4416 * Return value: (transfer none): the main #WebKitWebFrame for @web_view 4417 */ 4418WebKitWebFrame* webkit_web_view_get_main_frame(WebKitWebView* webView) 4419{ 4420 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4421 4422 return webView->priv->mainFrame; 4423} 4424 4425/** 4426 * webkit_web_view_get_focused_frame: 4427 * @web_view: a #WebKitWebView 4428 * 4429 * Returns the frame that has focus or an active text selection. 4430 * 4431 * Return value: (transfer none): The focused #WebKitWebFrame or %NULL if no frame is focused 4432 */ 4433WebKitWebFrame* webkit_web_view_get_focused_frame(WebKitWebView* webView) 4434{ 4435 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4436 4437 Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); 4438 return kit(focusedFrame); 4439} 4440 4441void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script) 4442{ 4443 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4444 g_return_if_fail(script); 4445 4446 core(webView)->mainFrame()->script()->executeScript(String::fromUTF8(script), true); 4447} 4448 4449/** 4450 * webkit_web_view_can_cut_clipboard: 4451 * @web_view: a #WebKitWebView 4452 * 4453 * Determines whether or not it is currently possible to cut to the clipboard. 4454 * 4455 * Return value: %TRUE if a selection can be cut, %FALSE if not 4456 */ 4457gboolean webkit_web_view_can_cut_clipboard(WebKitWebView* webView) 4458{ 4459 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4460 4461 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 4462 return frame->editor().canCut() || frame->editor().canDHTMLCut(); 4463} 4464 4465/** 4466 * webkit_web_view_can_copy_clipboard: 4467 * @web_view: a #WebKitWebView 4468 * 4469 * Determines whether or not it is currently possible to copy to the clipboard. 4470 * 4471 * Return value: %TRUE if a selection can be copied, %FALSE if not 4472 */ 4473gboolean webkit_web_view_can_copy_clipboard(WebKitWebView* webView) 4474{ 4475 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4476 4477 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 4478 return frame->editor().canCopy() || frame->editor().canDHTMLCopy(); 4479} 4480 4481/** 4482 * webkit_web_view_can_paste_clipboard: 4483 * @web_view: a #WebKitWebView 4484 * 4485 * Determines whether or not it is currently possible to paste from the clipboard. 4486 * 4487 * Return value: %TRUE if a selection can be pasted, %FALSE if not 4488 */ 4489gboolean webkit_web_view_can_paste_clipboard(WebKitWebView* webView) 4490{ 4491 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4492 4493 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 4494 return frame->editor().canPaste() || frame->editor().canDHTMLPaste(); 4495} 4496 4497/** 4498 * webkit_web_view_cut_clipboard: 4499 * @web_view: a #WebKitWebView 4500 * 4501 * Cuts the current selection inside the @web_view to the clipboard. 4502 */ 4503void webkit_web_view_cut_clipboard(WebKitWebView* webView) 4504{ 4505 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4506 4507 if (webkit_web_view_can_cut_clipboard(webView)) 4508 g_signal_emit(webView, webkit_web_view_signals[CUT_CLIPBOARD], 0); 4509} 4510 4511/** 4512 * webkit_web_view_copy_clipboard: 4513 * @web_view: a #WebKitWebView 4514 * 4515 * Copies the current selection inside the @web_view to the clipboard. 4516 */ 4517void webkit_web_view_copy_clipboard(WebKitWebView* webView) 4518{ 4519 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4520 4521 if (webkit_web_view_can_copy_clipboard(webView)) 4522 g_signal_emit(webView, webkit_web_view_signals[COPY_CLIPBOARD], 0); 4523} 4524 4525/** 4526 * webkit_web_view_paste_clipboard: 4527 * @web_view: a #WebKitWebView 4528 * 4529 * Pastes the current contents of the clipboard to the @web_view. 4530 */ 4531void webkit_web_view_paste_clipboard(WebKitWebView* webView) 4532{ 4533 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4534 4535 if (webkit_web_view_can_paste_clipboard(webView)) 4536 g_signal_emit(webView, webkit_web_view_signals[PASTE_CLIPBOARD], 0); 4537} 4538 4539/** 4540 * webkit_web_view_delete_selection: 4541 * @web_view: a #WebKitWebView 4542 * 4543 * Deletes the current selection inside the @web_view. 4544 */ 4545void webkit_web_view_delete_selection(WebKitWebView* webView) 4546{ 4547 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4548 4549 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 4550 frame->editor().performDelete(); 4551} 4552 4553/** 4554 * webkit_web_view_has_selection: 4555 * @web_view: a #WebKitWebView 4556 * 4557 * Determines whether text was selected. 4558 * 4559 * Return value: %TRUE if there is selected text, %FALSE if not 4560 */ 4561gboolean webkit_web_view_has_selection(WebKitWebView* webView) 4562{ 4563 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4564 4565 return !core(webView)->selection().isNone(); 4566} 4567 4568/** 4569 * webkit_web_view_select_all: 4570 * @web_view: a #WebKitWebView 4571 * 4572 * Attempts to select everything inside the @web_view. 4573 */ 4574void webkit_web_view_select_all(WebKitWebView* webView) 4575{ 4576 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4577 4578 g_signal_emit(webView, webkit_web_view_signals[::SELECT_ALL], 0); 4579} 4580 4581/** 4582 * webkit_web_view_get_editable: 4583 * @web_view: a #WebKitWebView 4584 * 4585 * Returns whether the user is allowed to edit the document. 4586 * 4587 * Returns %TRUE if @web_view allows the user to edit the HTML document, %FALSE if 4588 * it doesn't. You can change @web_view's document programmatically regardless of 4589 * this setting. 4590 * 4591 * Return value: a #gboolean indicating the editable state 4592 */ 4593gboolean webkit_web_view_get_editable(WebKitWebView* webView) 4594{ 4595 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4596 4597 return core(webView)->isEditable(); 4598} 4599 4600/** 4601 * webkit_web_view_set_editable: 4602 * @web_view: a #WebKitWebView 4603 * @flag: a #gboolean indicating the editable state 4604 * 4605 * Sets whether @web_view allows the user to edit its HTML document. 4606 * 4607 * If @flag is %TRUE, @web_view allows the user to edit the document. If @flag is 4608 * %FALSE, an element in @web_view's document can only be edited if the 4609 * CONTENTEDITABLE attribute has been set on the element or one of its parent 4610 * elements. You can change @web_view's document programmatically regardless of 4611 * this setting. By default a #WebKitWebView is not editable. 4612 4613 * Normally, an HTML document is not editable unless the elements within the 4614 * document are editable. This function provides a low-level way to make the 4615 * contents of a #WebKitWebView editable without altering the document or DOM 4616 * structure. 4617 */ 4618void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) 4619{ 4620 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4621 4622 flag = flag != FALSE; 4623 if (flag == webkit_web_view_get_editable(webView)) 4624 return; 4625 4626 core(webView)->setEditable(flag); 4627 4628 Frame* frame = core(webView)->mainFrame(); 4629 g_return_if_fail(frame); 4630 4631 if (flag) { 4632 frame->editor().applyEditingStyleToBodyElement(); 4633 // TODO: If the WebKitWebView is made editable and the selection is empty, set it to something. 4634 //if (!webkit_web_view_get_selected_dom_range(webView)) 4635 // mainFrame->setSelectionFromNone(); 4636 } 4637 g_object_notify(G_OBJECT(webView), "editable"); 4638} 4639 4640/** 4641 * webkit_web_view_get_copy_target_list: 4642 * @web_view: a #WebKitWebView 4643 * 4644 * This function returns the list of targets this #WebKitWebView can 4645 * provide for clipboard copying and as DND source. The targets in the list are 4646 * added with values from the #WebKitWebViewTargetInfo enum, 4647 * using gtk_target_list_add() and 4648 * gtk_target_list_add_text_targets(). 4649 * 4650 * Return value: the #GtkTargetList 4651 **/ 4652GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView) 4653{ 4654 return PasteboardHelper::defaultPasteboardHelper()->targetList(); 4655} 4656 4657/** 4658 * webkit_web_view_get_paste_target_list: 4659 * @web_view: a #WebKitWebView 4660 * 4661 * This function returns the list of targets this #WebKitWebView can 4662 * provide for clipboard pasting and as DND destination. The targets in the list are 4663 * added with values from the #WebKitWebViewTargetInfo enum, 4664 * using gtk_target_list_add() and 4665 * gtk_target_list_add_text_targets(). 4666 * 4667 * Return value: the #GtkTargetList 4668 **/ 4669GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) 4670{ 4671 return PasteboardHelper::defaultPasteboardHelper()->targetList(); 4672} 4673 4674/** 4675 * webkit_web_view_can_show_mime_type: 4676 * @web_view: a #WebKitWebView 4677 * @mime_type: a MIME type 4678 * 4679 * This functions returns whether or not a MIME type can be displayed using this view. 4680 * 4681 * Return value: a #gboolean indicating if the MIME type can be displayed 4682 * 4683 * Since: 1.0.3 4684 **/ 4685 4686gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const gchar* mimeType) 4687{ 4688 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4689 4690 Frame* frame = core(webkit_web_view_get_main_frame(webView)); 4691 return frame->loader()->client()->canShowMIMEType(String::fromUTF8(mimeType)); 4692} 4693 4694/** 4695 * webkit_web_view_get_transparent: 4696 * @web_view: a #WebKitWebView 4697 * 4698 * Returns whether the #WebKitWebView has a transparent background. 4699 * 4700 * Return value: %FALSE when the #WebKitWebView draws a solid background 4701 * (the default), otherwise %TRUE. 4702 */ 4703gboolean webkit_web_view_get_transparent(WebKitWebView* webView) 4704{ 4705 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4706 4707 WebKitWebViewPrivate* priv = webView->priv; 4708 return priv->transparent; 4709} 4710 4711/** 4712 * webkit_web_view_set_transparent: 4713 * @web_view: a #WebKitWebView 4714 * @flag: whether or not @web_view should be transparent 4715 * 4716 * Sets whether the #WebKitWebView has a transparent background. 4717 * 4718 * Pass %FALSE to have the #WebKitWebView draw a solid background 4719 * (the default), otherwise %TRUE. 4720 */ 4721void webkit_web_view_set_transparent(WebKitWebView* webView, gboolean flag) 4722{ 4723 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4724 4725 WebKitWebViewPrivate* priv = webView->priv; 4726 priv->transparent = flag; 4727 4728 // TODO: This needs to be made persistent or it could become a problem when 4729 // the main frame is replaced. 4730 Frame* frame = core(webView)->mainFrame(); 4731 g_return_if_fail(frame); 4732 frame->view()->setTransparent(flag); 4733 g_object_notify(G_OBJECT(webView), "transparent"); 4734} 4735 4736/** 4737 * webkit_web_view_get_zoom_level: 4738 * @web_view: a #WebKitWebView 4739 * 4740 * Returns the zoom level of @web_view, i.e. the factor by which elements in 4741 * the page are scaled with respect to their original size. 4742 * If the "full-content-zoom" property is set to %FALSE (the default) 4743 * the zoom level changes the text size, or if %TRUE, scales all 4744 * elements in the page. 4745 * 4746 * Return value: the zoom level of @web_view 4747 * 4748 * Since: 1.0.1 4749 */ 4750gfloat webkit_web_view_get_zoom_level(WebKitWebView* webView) 4751{ 4752 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0f); 4753 4754 Frame* frame = core(webView)->mainFrame(); 4755 if (!frame) 4756 return 1.0f; 4757 4758 WebKitWebViewPrivate* priv = webView->priv; 4759 return priv->zoomFullContent ? frame->pageZoomFactor() : frame->textZoomFactor(); 4760} 4761 4762static void webkit_web_view_apply_zoom_level(WebKitWebView* webView, gfloat zoomLevel) 4763{ 4764 Frame* frame = core(webView)->mainFrame(); 4765 if (!frame) 4766 return; 4767 4768 WebKitWebViewPrivate* priv = webView->priv; 4769 if (priv->zoomFullContent) 4770 frame->setPageZoomFactor(zoomLevel); 4771 else 4772 frame->setTextZoomFactor(zoomLevel); 4773} 4774 4775/** 4776 * webkit_web_view_set_zoom_level: 4777 * @web_view: a #WebKitWebView 4778 * @zoom_level: the new zoom level 4779 * 4780 * Sets the zoom level of @web_view, i.e. the factor by which elements in 4781 * the page are scaled with respect to their original size. 4782 * If the "full-content-zoom" property is set to %FALSE (the default) 4783 * the zoom level changes the text size, or if %TRUE, scales all 4784 * elements in the page. 4785 * 4786 * Since: 1.0.1 4787 */ 4788void webkit_web_view_set_zoom_level(WebKitWebView* webView, gfloat zoomLevel) 4789{ 4790 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4791 4792 webkit_web_view_apply_zoom_level(webView, zoomLevel); 4793 g_object_notify(G_OBJECT(webView), "zoom-level"); 4794} 4795 4796/** 4797 * webkit_web_view_zoom_in: 4798 * @web_view: a #WebKitWebView 4799 * 4800 * Increases the zoom level of @web_view. The current zoom 4801 * level is incremented by the value of the "zoom-step" 4802 * property of the #WebKitWebSettings associated with @web_view. 4803 * 4804 * Since: 1.0.1 4805 */ 4806void webkit_web_view_zoom_in(WebKitWebView* webView) 4807{ 4808 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4809 4810 WebKitWebViewPrivate* priv = webView->priv; 4811 gfloat zoomMultiplierRatio; 4812 g_object_get(priv->webSettings.get(), "zoom-step", &zoomMultiplierRatio, NULL); 4813 4814 webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) + zoomMultiplierRatio); 4815} 4816 4817/** 4818 * webkit_web_view_zoom_out: 4819 * @web_view: a #WebKitWebView 4820 * 4821 * Decreases the zoom level of @web_view. The current zoom 4822 * level is decremented by the value of the "zoom-step" 4823 * property of the #WebKitWebSettings associated with @web_view. 4824 * 4825 * Since: 1.0.1 4826 */ 4827void webkit_web_view_zoom_out(WebKitWebView* webView) 4828{ 4829 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4830 4831 WebKitWebViewPrivate* priv = webView->priv; 4832 gfloat zoomMultiplierRatio; 4833 g_object_get(priv->webSettings.get(), "zoom-step", &zoomMultiplierRatio, NULL); 4834 4835 webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) - zoomMultiplierRatio); 4836} 4837 4838/** 4839 * webkit_web_view_get_full_content_zoom: 4840 * @web_view: a #WebKitWebView 4841 * 4842 * Returns whether the zoom level affects only text or all elements. 4843 * 4844 * Return value: %FALSE if only text should be scaled (the default), 4845 * %TRUE if the full content of the view should be scaled. 4846 * 4847 * Since: 1.0.1 4848 */ 4849gboolean webkit_web_view_get_full_content_zoom(WebKitWebView* webView) 4850{ 4851 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 4852 4853 WebKitWebViewPrivate* priv = webView->priv; 4854 return priv->zoomFullContent; 4855} 4856 4857/** 4858 * webkit_web_view_set_full_content_zoom: 4859 * @web_view: a #WebKitWebView 4860 * @full_content_zoom: %FALSE if only text should be scaled (the default), 4861 * %TRUE if the full content of the view should be scaled. 4862 * 4863 * Sets whether the zoom level affects only text or all elements. 4864 * 4865 * Since: 1.0.1 4866 */ 4867void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoomFullContent) 4868{ 4869 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4870 4871 WebKitWebViewPrivate* priv = webView->priv; 4872 if (priv->zoomFullContent == zoomFullContent) 4873 return; 4874 4875 Frame* frame = core(webView)->mainFrame(); 4876 if (!frame) 4877 return; 4878 4879 gfloat zoomLevel = priv->zoomFullContent ? frame->pageZoomFactor() : frame->textZoomFactor(); 4880 4881 priv->zoomFullContent = zoomFullContent; 4882 if (priv->zoomFullContent) 4883 frame->setPageAndTextZoomFactors(zoomLevel, 1); 4884 else 4885 frame->setPageAndTextZoomFactors(1, zoomLevel); 4886 4887 g_object_notify(G_OBJECT(webView), "full-content-zoom"); 4888} 4889 4890/** 4891 * webkit_web_view_get_load_status: 4892 * @web_view: a #WebKitWebView 4893 * 4894 * Determines the current status of the load. 4895 * 4896 * Returns: a #WebKitLoadStatus specifying the status of the current load 4897 * 4898 * Since: 1.1.7 4899 */ 4900WebKitLoadStatus webkit_web_view_get_load_status(WebKitWebView* webView) 4901{ 4902 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_LOAD_FINISHED); 4903 4904 WebKitWebViewPrivate* priv = webView->priv; 4905 return priv->loadStatus; 4906} 4907 4908/** 4909 * webkit_web_view_get_progress: 4910 * @web_view: a #WebKitWebView 4911 * 4912 * Determines the current progress of the load. 4913 * 4914 * Returns: a gdouble representing the status of the current load. This value 4915 * will be in the range [0, 1]. 4916 * 4917 * Since: 1.1.7 4918 */ 4919gdouble webkit_web_view_get_progress(WebKitWebView* webView) 4920{ 4921 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0); 4922 4923 return core(webView)->progress()->estimatedProgress(); 4924} 4925 4926/** 4927 * webkit_web_view_get_encoding: 4928 * @web_view: a #WebKitWebView 4929 * 4930 * Returns the default encoding of the #WebKitWebView. 4931 * 4932 * Return value: the default encoding 4933 * 4934 * Since: 1.1.1 4935 */ 4936const gchar* webkit_web_view_get_encoding(WebKitWebView* webView) 4937{ 4938 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4939 String encoding = core(webView)->mainFrame()->document()->encoding(); 4940 if (encoding.isEmpty()) 4941 return 0; 4942 webView->priv->encoding = encoding.utf8(); 4943 return webView->priv->encoding.data(); 4944} 4945 4946/** 4947 * webkit_web_view_set_custom_encoding: 4948 * @web_view: a #WebKitWebView 4949 * @encoding: the new encoding, or %NULL to restore the default encoding 4950 * 4951 * Sets the current #WebKitWebView encoding, without modifying the default one, 4952 * and reloads the page. 4953 * 4954 * Since: 1.1.1 4955 */ 4956void webkit_web_view_set_custom_encoding(WebKitWebView* webView, const char* encoding) 4957{ 4958 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4959 4960 core(webView)->mainFrame()->loader()->reloadWithOverrideEncoding(String::fromUTF8(encoding)); 4961} 4962 4963/** 4964 * webkit_web_view_get_custom_encoding: 4965 * @web_view: a #WebKitWebView 4966 * 4967 * Returns the current encoding of the #WebKitWebView, not the default-encoding 4968 * of WebKitWebSettings. 4969 * 4970 * Return value: a string containing the current custom encoding for @web_view, or %NULL if there's none set. 4971 * 4972 * Since: 1.1.1 4973 */ 4974const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView) 4975{ 4976 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 4977 String overrideEncoding = core(webView)->mainFrame()->loader()->documentLoader()->overrideEncoding(); 4978 if (overrideEncoding.isEmpty()) 4979 return 0; 4980 webView->priv->customEncoding = overrideEncoding.utf8(); 4981 return webView->priv->customEncoding.data(); 4982} 4983 4984/** 4985 * webkit_web_view_set_view_mode: 4986 * @web_view: the #WebKitWebView that will have its view mode set 4987 * @mode: the %WebKitWebViewViewMode to be set 4988 * 4989 * Sets the view-mode property of the #WebKitWebView. Check the 4990 * property's documentation for more information. 4991 * 4992 * Since: 1.3.4 4993 */ 4994void webkit_web_view_set_view_mode(WebKitWebView* webView, WebKitWebViewViewMode mode) 4995{ 4996 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 4997 4998 Page* page = core(webView); 4999 5000 switch (mode) { 5001 case WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING: 5002 page->setViewMode(Page::ViewModeFloating); 5003 break; 5004 case WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN: 5005 page->setViewMode(Page::ViewModeFullscreen); 5006 break; 5007 case WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED: 5008 page->setViewMode(Page::ViewModeMaximized); 5009 break; 5010 case WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED: 5011 page->setViewMode(Page::ViewModeMinimized); 5012 break; 5013 default: 5014 page->setViewMode(Page::ViewModeWindowed); 5015 break; 5016 } 5017} 5018 5019/** 5020 * webkit_web_view_get_view_mode: 5021 * @web_view: the #WebKitWebView to obtain the view mode from 5022 * 5023 * Gets the value of the view-mode property of the 5024 * #WebKitWebView. Check the property's documentation for more 5025 * information. 5026 * 5027 * Return value: the %WebKitWebViewViewMode currently set for the 5028 * #WebKitWebView. 5029 * 5030 * Since: 1.3.4 5031 */ 5032WebKitWebViewViewMode webkit_web_view_get_view_mode(WebKitWebView* webView) 5033{ 5034 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED); 5035 5036 Page* page = core(webView); 5037 Page::ViewMode mode = page->viewMode(); 5038 5039 if (mode == Page::ViewModeFloating) 5040 return WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING; 5041 5042 if (mode == Page::ViewModeFullscreen) 5043 return WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN; 5044 5045 if (mode == Page::ViewModeMaximized) 5046 return WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED; 5047 5048 if (mode == Page::ViewModeMinimized) 5049 return WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED; 5050 5051 return WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED; 5052} 5053 5054/** 5055 * webkit_web_view_move_cursor: 5056 * @web_view: a #WebKitWebView 5057 * @step: a #GtkMovementStep 5058 * @count: integer describing the direction of the movement. 1 for forward, -1 for backwards. 5059 * 5060 * Move the cursor in @view as described by @step and @count. 5061 * 5062 * Since: 1.1.4 5063 */ 5064void webkit_web_view_move_cursor(WebKitWebView* webView, GtkMovementStep step, gint count) 5065{ 5066 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5067 g_return_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS || 5068 step == GTK_MOVEMENT_DISPLAY_LINES || 5069 step == GTK_MOVEMENT_PAGES || 5070 step == GTK_MOVEMENT_BUFFER_ENDS); 5071 g_return_if_fail(count == 1 || count == -1); 5072 5073 gboolean handled; 5074 g_signal_emit(webView, webkit_web_view_signals[MOVE_CURSOR], 0, step, count, &handled); 5075} 5076 5077/** 5078 * webkit_web_view_can_undo: 5079 * @web_view: a #WebKitWebView 5080 * 5081 * Determines whether or not it is currently possible to undo the last 5082 * editing command in the view. 5083 * 5084 * Return value: %TRUE if a undo can be done, %FALSE if not 5085 * 5086 * Since: 1.1.14 5087 */ 5088gboolean webkit_web_view_can_undo(WebKitWebView* webView) 5089{ 5090 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 5091 5092 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5093 return frame->editor().canUndo(); 5094} 5095 5096/** 5097 * webkit_web_view_undo: 5098 * @web_view: a #WebKitWebView 5099 * 5100 * Undoes the last editing command in the view, if possible. 5101 * 5102 * Since: 1.1.14 5103 */ 5104void webkit_web_view_undo(WebKitWebView* webView) 5105{ 5106 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5107 5108 if (webkit_web_view_can_undo(webView)) 5109 g_signal_emit(webView, webkit_web_view_signals[UNDO], 0); 5110} 5111 5112/** 5113 * webkit_web_view_can_redo: 5114 * @web_view: a #WebKitWebView 5115 * 5116 * Determines whether or not it is currently possible to redo the last 5117 * editing command in the view. 5118 * 5119 * Return value: %TRUE if a redo can be done, %FALSE if not 5120 * 5121 * Since: 1.1.14 5122 */ 5123gboolean webkit_web_view_can_redo(WebKitWebView* webView) 5124{ 5125 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 5126 5127 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5128 return frame->editor().canRedo(); 5129} 5130 5131/** 5132 * webkit_web_view_redo: 5133 * @web_view: a #WebKitWebView 5134 * 5135 * Redoes the last editing command in the view, if possible. 5136 * 5137 * Since: 1.1.14 5138 */ 5139void webkit_web_view_redo(WebKitWebView* webView) 5140{ 5141 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5142 5143 if (webkit_web_view_can_redo(webView)) 5144 g_signal_emit(webView, webkit_web_view_signals[REDO], 0); 5145} 5146 5147 5148/** 5149 * webkit_web_view_set_view_source_mode: 5150 * @web_view: a #WebKitWebView 5151 * @view_source_mode: the mode to turn on or off view source mode 5152 * 5153 * Set whether the view should be in view source mode. Setting this mode to 5154 * %TRUE before loading a URI will display the source of the web page in a 5155 * nice and readable format. 5156 * 5157 * Since: 1.1.14 5158 */ 5159void webkit_web_view_set_view_source_mode (WebKitWebView* webView, gboolean mode) 5160{ 5161 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5162 5163 if (Frame* mainFrame = core(webView)->mainFrame()) 5164 mainFrame->setInViewSourceMode(mode); 5165} 5166 5167/** 5168 * webkit_web_view_get_view_source_mode: 5169 * @web_view: a #WebKitWebView 5170 * 5171 * Return value: %TRUE if @web_view is in view source mode, %FALSE otherwise. 5172 * 5173 * Since: 1.1.14 5174 */ 5175gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView) 5176{ 5177 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); 5178 5179 if (Frame* mainFrame = core(webView)->mainFrame()) 5180 return mainFrame->inViewSourceMode(); 5181 5182 return FALSE; 5183} 5184 5185// Internal subresource management 5186void webkit_web_view_add_main_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) 5187{ 5188 WebKitWebViewPrivate* priv = webView->priv; 5189 5190 priv->mainResource = adoptGRef(webResource); 5191 priv->mainResourceIdentifier = identifier; 5192} 5193 5194void webkit_web_view_add_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) 5195{ 5196 WebKitWebViewPrivate* priv = webView->priv; 5197 g_hash_table_insert(priv->subResources.get(), g_strdup(identifier), webResource); 5198} 5199 5200void webkitWebViewRemoveSubresource(WebKitWebView* webView, const char* identifier) 5201{ 5202 ASSERT(identifier); 5203 5204 // Don't remove the main resource. 5205 const CString& mainResource = webView->priv->mainResourceIdentifier; 5206 if (!mainResource.isNull() && g_str_equal(identifier, mainResource.data())) 5207 return; 5208 g_hash_table_remove(webView->priv->subResources.get(), identifier); 5209} 5210 5211WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier) 5212{ 5213 WebKitWebViewPrivate* priv = webView->priv; 5214 gpointer webResource = 0; 5215 gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources.get(), identifier, NULL, &webResource); 5216 5217 // The only resource we do not store in this hash table is the 5218 // main! If we did not find a request, it probably means the load 5219 // has been interrupted while while a resource was still being 5220 // loaded. 5221 if (!resourceFound && !g_str_equal(identifier, priv->mainResourceIdentifier.data())) 5222 return 0; 5223 5224 if (!webResource) 5225 return webkit_web_view_get_main_resource(webView); 5226 5227 return WEBKIT_WEB_RESOURCE(webResource); 5228} 5229 5230WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView) 5231{ 5232 return webView->priv->mainResource.get(); 5233} 5234 5235void webkit_web_view_clear_resources(WebKitWebView* webView) 5236{ 5237 WebKitWebViewPrivate* priv = webView->priv; 5238 5239 if (priv->subResources) 5240 g_hash_table_remove_all(priv->subResources.get()); 5241} 5242 5243static gboolean cleanupTemporarilyCachedSubresources(gpointer data) 5244{ 5245 GList* subResources = static_cast<GList*>(data); 5246 g_list_foreach(subResources, reinterpret_cast<GFunc>(g_object_unref), NULL); 5247 g_list_free(subResources); 5248 return FALSE; 5249} 5250 5251GList* webkit_web_view_get_subresources(WebKitWebView* webView) 5252{ 5253 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 5254 GList* subResources = 0; 5255 Vector<PassRefPtr<ArchiveResource> > coreSubResources; 5256 5257 core(webView)->mainFrame()->loader()->documentLoader()->getSubresources(coreSubResources); 5258 5259 for (unsigned i = 0; i < coreSubResources.size(); i++) { 5260 WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL)); 5261 webkit_web_resource_init_with_core_resource(webResource, coreSubResources[i]); 5262 subResources = g_list_append(subResources, webResource); 5263 } 5264 5265 if (subResources) 5266 g_timeout_add(1, cleanupTemporarilyCachedSubresources, g_list_copy(subResources)); 5267 5268 return subResources; 5269} 5270 5271/* From EventHandler.cpp */ 5272static IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint) 5273{ 5274 FrameView* view = frame->view(); 5275 // FIXME: Is it really OK to use the wrong coordinates here when view is 0? 5276 // Historically the code would just crash; this is clearly no worse than that. 5277 return view ? view->windowToContents(windowPoint) : windowPoint; 5278} 5279 5280void webkit_web_view_set_tooltip_text(WebKitWebView* webView, const char* tooltip) 5281{ 5282 WebKitWebViewPrivate* priv = webView->priv; 5283 if (tooltip && *tooltip != '\0') { 5284 priv->tooltipText = tooltip; 5285 gtk_widget_set_has_tooltip(GTK_WIDGET(webView), TRUE); 5286 } else { 5287 priv->tooltipText = ""; 5288 gtk_widget_set_has_tooltip(GTK_WIDGET(webView), FALSE); 5289 } 5290 5291 gtk_widget_trigger_tooltip_query(GTK_WIDGET(webView)); 5292} 5293 5294/** 5295 * webkit_web_view_get_hit_test_result: 5296 * @web_view: a #WebKitWebView 5297 * @event: a #GdkEventButton 5298 * 5299 * Does a 'hit test' in the coordinates specified by @event to figure 5300 * out context information about that position in the @web_view. 5301 * 5302 * Returns: (transfer full): a newly created #WebKitHitTestResult with the context of the 5303 * specified position. 5304 * 5305 * Since: 1.1.15 5306 **/ 5307WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, GdkEventButton* event) 5308{ 5309 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); 5310 g_return_val_if_fail(event, NULL); 5311 5312 PlatformMouseEvent mouseEvent = PlatformMouseEvent(event); 5313 Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); 5314 HitTestRequest request(HitTestRequest::Active | HitTestRequest::DisallowShadowContent); 5315 IntPoint documentPoint = documentPointForWindowPoint(frame, mouseEvent.position()); 5316 MouseEventWithHitTestResults mev = frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent); 5317 5318 return kit(mev.hitTestResult()); 5319} 5320 5321/** 5322 * webkit_web_view_get_icon_uri: 5323 * @web_view: the #WebKitWebView object 5324 * 5325 * Obtains the URI for the favicon for the given #WebKitWebView, or 5326 * %NULL if there is none. 5327 * 5328 * Return value: the URI for the favicon, or %NULL 5329 * 5330 * Since: 1.1.18 5331 */ 5332const gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView) 5333{ 5334 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5335 String iconURL = iconDatabase().synchronousIconURLForPageURL(core(webView)->mainFrame()->document()->url().string()); 5336 webView->priv->iconURI = iconURL.utf8(); 5337 return webView->priv->iconURI.data(); 5338} 5339 5340/** 5341 * webkit_web_view_get_icon_pixbuf: 5342 * @web_view: the #WebKitWebView object 5343 * 5344 * Obtains a #GdkPixbuf of the favicon for the given #WebKitWebView, or 5345 * a default icon if there is no icon for the given page. Use 5346 * webkit_web_view_get_icon_uri() if you need to distinguish these cases. 5347 * Usually you want to connect to WebKitWebView::icon-loaded and call this 5348 * method in the callback. 5349 * 5350 * The pixbuf will have the largest size provided by the server and should 5351 * be resized before it is displayed. 5352 * See also webkit_icon_database_get_icon_pixbuf(). 5353 * 5354 * Returns: (transfer full): a new reference to a #GdkPixbuf, or %NULL 5355 * 5356 * Since: 1.3.13 5357 * 5358 * Deprecated: 1.8: Use webkit_web_view_try_get_favicon_pixbuf() instead. 5359 */ 5360GdkPixbuf* webkit_web_view_get_icon_pixbuf(WebKitWebView* webView) 5361{ 5362 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5363 5364 const gchar* pageURI = webkit_web_view_get_uri(webView); 5365 WebKitIconDatabase* database = webkit_get_icon_database(); 5366 return webkit_icon_database_get_icon_pixbuf(database, pageURI); 5367} 5368 5369/** 5370 * webkit_web_view_try_get_favicon_pixbuf: 5371 * @web_view: the #WebKitWebView object 5372 * @width: the desired width for the icon 5373 * @height: the desired height for the icon 5374 * 5375 * Obtains a #GdkPixbuf of the favicon for the given 5376 * #WebKitWebView. This will return %NULL is there is no icon for the 5377 * current #WebKitWebView or if the icon is in the database but not 5378 * available at the moment of this call. Use 5379 * webkit_web_view_get_icon_uri() if you need to distinguish these 5380 * cases. Usually you want to connect to WebKitWebView::icon-loaded 5381 * and call this method in the callback. 5382 * 5383 * See also webkit_favicon_database_try_get_favicon_pixbuf(). Contrary 5384 * to this function the icon database one returns the URL of the page 5385 * containing the icon. 5386 * 5387 * Returns: (transfer full): a new reference to a #GdkPixbuf, or %NULL 5388 * 5389 * Since: 1.8 5390 */ 5391GdkPixbuf* webkit_web_view_try_get_favicon_pixbuf(WebKitWebView* webView, guint width, guint height) 5392{ 5393 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5394 5395 const gchar* pageURI = webkit_web_view_get_uri(webView); 5396 WebKitFaviconDatabase* database = webkit_get_favicon_database(); 5397 return webkit_favicon_database_try_get_favicon_pixbuf(database, pageURI, width, height); 5398} 5399 5400/** 5401 * webkit_web_view_get_dom_document: 5402 * @web_view: a #WebKitWebView 5403 * 5404 * Returns: (transfer none): the #WebKitDOMDocument currently loaded in 5405 * the main frame of the @web_view or %NULL if no document is loaded 5406 * 5407 * Since: 1.3.1 5408 **/ 5409WebKitDOMDocument* 5410webkit_web_view_get_dom_document(WebKitWebView* webView) 5411{ 5412 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5413 5414 return webkit_web_frame_get_dom_document(webView->priv->mainFrame); 5415} 5416 5417GtkMenu* webkit_web_view_get_context_menu(WebKitWebView* webView) 5418{ 5419 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5420 5421#if ENABLE(CONTEXT_MENUS) 5422 ContextMenu* menu = core(webView)->contextMenuController()->contextMenu(); 5423 if (!menu) 5424 return 0; 5425 return menu->platformDescription(); 5426#else 5427 return 0; 5428#endif 5429} 5430 5431/** 5432 * webkit_web_view_get_snapshot: 5433 * @web_view: a #WebKitWebView 5434 * 5435 * Retrieves a snapshot with the visible contents of @webview. 5436 * 5437 * Returns: (transfer full): a @cairo_surface_t 5438 * 5439 * Since: 1.10 5440 **/ 5441cairo_surface_t* 5442webkit_web_view_get_snapshot(WebKitWebView* webView) 5443{ 5444 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 5445 5446 Frame* frame = core(webView)->mainFrame(); 5447 if (!frame || !frame->contentRenderer() || !frame->view()) 5448 return 0; 5449 5450 frame->view()->updateLayoutAndStyleIfNeededRecursive(); 5451 GtkAllocation allocation; 5452 gtk_widget_get_allocation(GTK_WIDGET(webView), &allocation); 5453 cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); 5454 RefPtr<cairo_t> cr = adoptRef(cairo_create(surface)); 5455 GraphicsContext gc(cr.get()); 5456 5457 IntRect rect = allocation; 5458 gc.applyDeviceScaleFactor(frame->page()->deviceScaleFactor()); 5459 gc.save(); 5460 gc.clip(rect); 5461 if (webView->priv->transparent) 5462 gc.clearRect(rect); 5463 frame->view()->paint(&gc, rect); 5464 gc.restore(); 5465 5466 return surface; 5467} 5468 5469#if ENABLE(ICONDATABASE) 5470void webkitWebViewIconLoaded(WebKitFaviconDatabase* database, const char* frameURI, WebKitWebView* webView) 5471{ 5472 // Since we definitely have an icon the WebView doesn't need to 5473 // listen for notifications any longer. 5474 webkitWebViewRegisterForIconNotification(webView, false); 5475 5476 // webkit_web_view_get_icon_uri() properly updates the "icon-uri" property. 5477 g_object_notify(G_OBJECT(webView), "icon-uri"); 5478 g_signal_emit(webView, webkit_web_view_signals[ICON_LOADED], 0, webkit_web_view_get_icon_uri(webView)); 5479} 5480 5481void webkitWebViewRegisterForIconNotification(WebKitWebView* webView, bool shouldRegister) 5482{ 5483 WebKitFaviconDatabase* database = webkit_get_favicon_database(); 5484 if (shouldRegister) { 5485 if (!g_signal_handler_is_connected(database, webView->priv->iconLoadedHandler)) 5486 webView->priv->iconLoadedHandler = g_signal_connect(database, "icon-loaded", 5487 G_CALLBACK(webkitWebViewIconLoaded), webView); 5488 } else 5489 if (g_signal_handler_is_connected(database, webView->priv->iconLoadedHandler)) 5490 g_signal_handler_disconnect(database, webView->priv->iconLoadedHandler); 5491} 5492#endif 5493 5494void webkitWebViewDirectionChanged(WebKitWebView* webView, GtkTextDirection previousDirection, gpointer) 5495{ 5496 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 5497 5498 GtkTextDirection direction = gtk_widget_get_direction(GTK_WIDGET(webView)); 5499 5500 Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); 5501 if (!focusedFrame) 5502 return; 5503 5504 Editor& editor = focusedFrame->editor(); 5505 if (!editor.canEdit()) 5506 return; 5507 5508 switch (direction) { 5509 case GTK_TEXT_DIR_NONE: 5510 editor.setBaseWritingDirection(NaturalWritingDirection); 5511 break; 5512 case GTK_TEXT_DIR_LTR: 5513 editor.setBaseWritingDirection(LeftToRightWritingDirection); 5514 break; 5515 case GTK_TEXT_DIR_RTL: 5516 editor.setBaseWritingDirection(RightToLeftWritingDirection); 5517 break; 5518 default: 5519 g_assert_not_reached(); 5520 return; 5521 } 5522} 5523 5524namespace WebKit { 5525 5526WebCore::Page* core(WebKitWebView* webView) 5527{ 5528 if (!webView) 5529 return 0; 5530 5531 WebKitWebViewPrivate* priv = webView->priv; 5532 return priv ? priv->corePage : 0; 5533} 5534 5535WebKitWebView* kit(WebCore::Page* corePage) 5536{ 5537 if (!corePage) 5538 return 0; 5539 5540 WebCore::ChromeClient* chromeClient = corePage->chrome().client(); 5541 if (chromeClient->isEmptyChromeClient()) 5542 return 0; 5543 5544 return static_cast<WebKit::ChromeClient*>(chromeClient)->webView(); 5545} 5546 5547} 5548