summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/gtk')
-rw-r--r--WebKit/gtk/ChangeLog1247
-rw-r--r--WebKit/gtk/JSCore-1.0.gir18
-rw-r--r--WebKit/gtk/NEWS67
-rw-r--r--WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp57
-rw-r--r--WebKit/gtk/WebCoreSupport/ChromeClientGtk.h3
-rw-r--r--WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.cpp115
-rw-r--r--WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.h74
-rw-r--r--WebKit/gtk/WebCoreSupport/DragClientGtk.cpp68
-rw-r--r--WebKit/gtk/WebCoreSupport/DragClientGtk.h9
-rw-r--r--WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp181
-rw-r--r--WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp178
-rw-r--r--WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h3
-rw-r--r--WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp9
-rw-r--r--WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp5
-rw-r--r--WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h1
-rw-r--r--WebKit/gtk/docs/GNUmakefile.am2
-rw-r--r--WebKit/gtk/docs/webkitgtk-docs.sgml14
-rw-r--r--WebKit/gtk/docs/webkitgtk-sections.txt166
-rw-r--r--WebKit/gtk/tests/testatk.c2
-rw-r--r--WebKit/gtk/tests/testhittestresult.c152
-rw-r--r--WebKit/gtk/tests/testkeyevents.c186
-rw-r--r--WebKit/gtk/tests/testloading.c217
-rw-r--r--WebKit/gtk/tests/testnetworkresponse.c108
-rw-r--r--WebKit/gtk/tests/testwebdatasource.c184
-rw-r--r--WebKit/gtk/tests/testwebresource.c332
-rw-r--r--WebKit/gtk/tests/testwindow.c128
-rw-r--r--WebKit/gtk/webkit/webkit.h6
-rw-r--r--WebKit/gtk/webkit/webkitdefines.h22
-rw-r--r--WebKit/gtk/webkit/webkitdownload.cpp36
-rw-r--r--WebKit/gtk/webkit/webkitdownload.h4
-rw-r--r--WebKit/gtk/webkit/webkiterror.h4
-rw-r--r--WebKit/gtk/webkit/webkithittestresult.cpp193
-rw-r--r--WebKit/gtk/webkit/webkithittestresult.h83
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.cpp41
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.h4
-rw-r--r--WebKit/gtk/webkit/webkitnetworkresponse.cpp261
-rw-r--r--WebKit/gtk/webkit/webkitnetworkresponse.h74
-rw-r--r--WebKit/gtk/webkit/webkitprivate.cpp90
-rw-r--r--WebKit/gtk/webkit/webkitprivate.h114
-rw-r--r--WebKit/gtk/webkit/webkitsecurityorigin.cpp423
-rw-r--r--WebKit/gtk/webkit/webkitsecurityorigin.h80
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.c176
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.h6
-rw-r--r--WebKit/gtk/webkit/webkitversion.h.in4
-rw-r--r--WebKit/gtk/webkit/webkitwebbackforwardlist.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebdatabase.cpp533
-rw-r--r--WebKit/gtk/webkit/webkitwebdatabase.h96
-rw-r--r--WebKit/gtk/webkit/webkitwebdatasource.cpp436
-rw-r--r--WebKit/gtk/webkit/webkitwebdatasource.h96
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.cpp225
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.h32
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.cpp5
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebinspector.h6
-rw-r--r--WebKit/gtk/webkit/webkitwebnavigationaction.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebpolicydecision.cpp6
-rw-r--r--WebKit/gtk/webkit/webkitwebpolicydecision.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebresource.cpp401
-rw-r--r--WebKit/gtk/webkit/webkitwebresource.h84
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.cpp84
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.h11
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp558
-rw-r--r--WebKit/gtk/webkit/webkitwebview.h37
-rw-r--r--WebKit/gtk/webkit/webkitwebwindowfeatures.cpp4
-rw-r--r--WebKit/gtk/webkit/webkitwebwindowfeatures.h6
-rw-r--r--WebKit/gtk/webkit/webkitworkers.cpp45
-rw-r--r--WebKit/gtk/webkitmarshal.list1
67 files changed, 7417 insertions, 416 deletions
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog
index 4d49861..370fb2b 100644
--- a/WebKit/gtk/ChangeLog
+++ b/WebKit/gtk/ChangeLog
@@ -1,3 +1,1250 @@
+2009-10-07 Xan Lopez <xlopez@igalia.com>
+
+ Fix the GTK+ build.
+
+ * webkit/webkitwebpolicydecision.cpp:
+ (webkit_web_policy_decision_use):
+ (webkit_web_policy_decision_ignore):
+ (webkit_web_policy_decision_download):
+
+2009-10-07 Adam Barth <abarth@webkit.org>
+
+ Reviewed by Darin Adler.
+
+ Factor PolicyChecker out of FrameLoader
+ https://bugs.webkit.org/show_bug.cgi?id=30155
+
+ Move the policy callback to the policy object.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::dispatchWillSubmitForm):
+ (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType):
+ (WebKit::FrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+ (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+
+2009-10-07 Martin Robinson <martin.james.robinson@gmail.com>
+
+ [GTK] Segfault while testing fast/events/keydown-keypress-preventDefault.html
+ https://bugs.webkit.org/show_bug.cgi?id=30121
+
+ Clear previous preedit or pending composition before storing new ones.
+ This can happen when a WebView receives a native keydown event without
+ a matching keyup event or when preventDefault() is called on DOM keydown
+ events.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::setPendingComposition):
+ (WebKit::setPendingPreedit):
+ (WebKit::clearPendingIMData):
+ (WebKit::imContextCommitted):
+ (WebKit::imContextPreeditChanged):
+
+2009-10-06 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Eric Seidel.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25526
+ [Gtk] Additional support is needed for caret browsing
+
+ Remove special cases for caret browsing, they are now handled in
+ cross-platform code.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::EditorClient::handleKeyboardEvent):
+
+2009-10-06 Pavel Feldman <pfeldman@chromium.org>
+
+ Reviewed by Timothy Hatcher.
+
+ Web Inspector: close inspector client view on
+ InspectorController::close API call.
+
+ In order to run batch web inspector layout tests (and not affect
+ subsequent tests) we should close inspector client's view upon
+ InspectorController::close API call.
+
+ https://bugs.webkit.org/show_bug.cgi?id=30009
+
+ * WebCoreSupport/InspectorClientGtk.cpp:
+ (WebKit::InspectorClient::createPage):
+
+2009-10-06 Alejandro G. Castro <alex@igalia.com>
+
+ Reviewed by Xan Lopez.
+
+ ASSERT executing the webhistory unittest in a debug build
+ https://bugs.webkit.org/show_bug.cgi?id=28947
+
+ We have to call g_object_new first to initialize webkit threading
+ before creating the KURL.
+
+ * WebKit/gtk/webkit/webkitwebhistoryitem.cpp:
+
+2009-10-06 José Millán Soto <fid@gpul.org>
+
+ Reviewed by Xan Lopez.
+
+ Header files of WebKitGTK do not comply with WebKit coding style (Patch attached)
+ https://bugs.webkit.org/show_bug.cgi?id=30076
+
+ Solves various issues in header files.
+
+ * WebCoreSupport/DocumentLoaderGtk.h: Added "headed guards"
+ * webkit/webkitdefines.h:
+ * webkit/webkitdownload.h:
+ * webkit/webkiterror.h:
+ * webkit/webkithittestresult.h:
+ * webkit/webkitnetworkrequest.h:
+ * webkit/webkitnetworkresponse.h:
+ * webkit/webkitprivate.h:
+ * webkit/webkitsecurityorigin.h:
+ * webkit/webkitsoupauthdialog.h:
+ * webkit/webkitversion.h.in:
+ * webkit/webkitwebbackforwardlist.h:
+ * webkit/webkitwebdatabase.h:
+ * webkit/webkitwebdatasource.h:
+ * webkit/webkitwebframe.h:
+ * webkit/webkitwebhistoryitem.h:
+ * webkit/webkitwebinspector.h:
+ * webkit/webkitwebnavigationaction.h:
+ * webkit/webkitwebpolicydecision.h:
+ * webkit/webkitwebresource.h:
+ * webkit/webkitwebsettings.h:
+ * webkit/webkitwebview.h:
+ * webkit/webkitwebwindowfeatures.h:
+
+2009-10-03 Adam Barth <abarth@webkit.org>
+
+ More build fixing.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_go_back_or_forward):
+ (webkit_web_view_can_go_back_or_forward):
+
+2009-10-03 Adam Barth <abarth@webkit.org>
+
+ Unreviewed build fix.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_go_back_or_forward):
+
+2009-10-03 Adam Barth <abarth@webkit.org>
+
+ Reviewed by Sam Weinig.
+
+ Factor PageController out of FrameLoader and Page
+ https://bugs.webkit.org/show_bug.cgi?id=30037
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_can_go_back_or_forward):
+
+2009-10-01 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Set the type for the fake event, otherwise the test ASSERTs in
+ debug builds.
+
+ * tests/testhittestresult.c:
+ (load_status_cb):
+
+2009-10-01 Martin Robinson <martin.james.robinson@gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] GtkIMContext filtering interferes with DOM key events
+ https://bugs.webkit.org/show_bug.cgi?id=28733
+
+ Ensure that keyboard events filtered by the GtkIMContext still create
+ the proper DOM events.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::clearPendingIMData):
+ (WebKit::imContextCommitted):
+ (WebKit::imContextPreeditChanged):
+ (WebKit::EditorClient::shouldBeginEditing):
+ (WebKit::EditorClient::shouldEndEditing):
+ (WebKit::interpretEditorCommandKeyEvent):
+ (WebKit::handleCaretBrowsingKeyboardEvent):
+ (WebKit::EditorClient::handleKeyboardEvent):
+ (WebKit::EditorClient::handleInputMethodKeydown):
+ * tests/testkeyevents.c: Added.
+ (test_info_new):
+ (test_info_destroy):
+ (key_event_fixture_setup):
+ (key_event_fixture_teardown):
+ (key_press_event_cb):
+ (key_release_event_cb):
+ (load_status_cb):
+ (map_event_cb):
+ (test_keypress):
+ (main):
+
+2009-09-29 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Do not set a non-default parent window for child widgets. We are
+ just doing the same than the default path does, and on top of that
+ if the widget's window changes (for example, during DnD widgets
+ are usually unrealized/realized) the child widget will we left
+ pointing to a dead window.
+
+ For examples of crashers caused by this see
+ https://bugzilla.gnome.org/show_bug.cgi?id=596397 and
+ https://bugzilla.gnome.org/show_bug.cgi?id=596398
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_container_add):
+
+2009-09-29 Xan Lopez <xlopez@igalia.com>
+
+ Rubber-stamped by Eric Seidel.
+
+ [Gtk] Crash when saving a password
+ https://bugs.webkit.org/show_bug.cgi?id=28070
+
+ Disconnect the 'got-headers' callback when we are done with
+ it. The signal can be emitted more than once if the message is
+ retransmitted, but each time that happens authData is created
+ again and a new callback connected, so we have to get rid of the
+ old one (which will crash because we free authData).
+
+ * webkit/webkitsoupauthdialog.c:
+ (save_password_callback):
+
+2009-09-25 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ Pop down the context menu when the page transitions to committed,
+ to avoid keeping a context menu out of context.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::transitionToCommittedForNewPage):
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebview.cpp:
+ (destroy_menu_cb):
+ (webkit_web_view_forward_context_menu_event):
+
+2009-09-24 Jon Honeycutt <jhoneycutt@apple.com>
+
+ Reviewed by Alice Liu.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_init):
+ Pass 0 for new Page constructor argument.
+
+2009-09-24 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha and Jan Alonzo.
+ [GTK] Add WEBKIT_LOAD_ERROR status
+ https://bugs.webkit.org/show_bug.cgi?id=29644
+
+ Add a new load-status enum value, WEBKIT_LOAD_FAILED, emitted when
+ there's an error during the load process. This is needed if we
+ want notify::load-status to be able to handle all situations,
+ since WEBKIT_LOAD_FINISHED is not emitted when there's an error
+ and we are lacking a notification of the load being stopped.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::dispatchDidFailLoad):
+ * tests/testloading.c:
+ (web_loading_fixture_setup):
+ (load_error_status_changed_cb):
+ (load_error_cb):
+ (test_loading_error):
+ (load_cancelled_cb):
+ (stop_load):
+ (load_cancelled_status_changed_cb):
+ (test_loading_cancelled):
+ (main):
+ * webkit/webkitwebframe.h:
+
+2009-09-24 Xan Lopez <xlopez@igalia.com>
+
+ Revert r48697, since it broke key handling notification to GTK+.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::imContextCommitted):
+ (WebKit::imContextPreeditChanged):
+ (WebKit::EditorClient::shouldBeginEditing):
+ (WebKit::EditorClient::shouldEndEditing):
+ (WebKit::interpretKeyEvent):
+ (WebKit::handleEditingKeyboardEvent):
+ (WebKit::EditorClient::handleKeyboardEvent):
+ (WebKit::EditorClient::handleInputMethodKeydown):
+
+2009-09-23 Martin Robinson <martin.james.robinson@gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] REGRESSION: BitmapImage::getGdkPixbuf fails for non-square images
+ https://bugs.webkit.org/show_bug.cgi?id=29654
+
+ Ensure that even when GTKSimpleIMContext filters non-IME keystrokes,
+ keyboard events are fired properly.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::clearPendingIMData):
+ (WebKit::imContextCommitted):
+ (WebKit::imContextPreeditChanged):
+ (WebKit::EditorClient::shouldBeginEditing):
+ (WebKit::EditorClient::shouldEndEditing):
+ (WebKit::interpretEditorCommandKeyEvent):
+ (WebKit::handleCaretBrowsingKeyboardEvent):
+ (WebKit::EditorClient::handleKeyboardEvent):
+ (WebKit::EditorClient::handleInputMethodKeydown):
+
+2009-09-23 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ [GTK] need to dump number of pending unload handlers
+ https://bugs.webkit.org/show_bug.cgi?id=29685
+
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_get_pending_unload_event_count): New function to
+ satisfy DRT needs.
+
+2009-09-23 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Xan Lopez.
+
+ Minor reorganization to the patch landed in
+ http://trac.webkit.org/changeset/48670. Also move JSCore-1.0.gir
+ in the gtk directory as that's only useful to the Gtk port at the
+ moment.
+
+ * JSCore-1.0.gir: Renamed from JSCore-1.0.gir.
+
+2009-09-22 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ Hardcode element positions at 0,0 so that we know where to
+ generate events to test WebKitHitTestResult.
+
+ * tests/testhittestresult.c:
+ (load_status_cb):
+ (test_webkit_hit_test_result):
+ (main):
+
+2009-09-22 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ [GTK] WebKitHitTestResult is completely broken in gmail
+ https://bugs.webkit.org/show_bug.cgi?id=29527
+
+ We need to use the main or focused frame when doing the coordinate
+ transformation instead of always using the main frame.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_get_hit_test_result):
+
+2009-09-21 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Update documentation control files to 1.1.15.
+
+ * docs/webkitgtk-docs.sgml:
+ * docs/webkitgtk-sections.txt:
+
+2009-09-21 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Unreviewed docs build fix. Current CFLAGS and LIBS variables no
+ longer bring gthread in.
+
+ * docs/GNUmakefile.am:
+
+2009-09-21 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Update for release.
+
+ * NEWS:
+
+2009-09-20 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Small documentation fix.
+
+ * webkit/webkithittestresult.cpp:
+
+2009-09-18 Xan Lopez <xlopez@igalia.com>
+
+ Build fix.
+
+ Add missing file to the repository.
+
+ * tests/testhittestresult.c: Added.
+ (test_info_new):
+ (test_info_destroy):
+ (hit_test_result_fixture_setup):
+ (hit_test_result_fixture_teardown):
+ (load_status_cb):
+ (test_webkit_hit_test_result):
+ (main):
+
+2009-09-18 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ [Gtk] Unreviewed build fix.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::platformPageClient):
+
+2009-09-17 Kenneth Rohde Christiansen <kenneth@webkit.org>
+
+ Reviewed by Simon Hausmann.
+
+ Make PlatformWindow return something else than PlatformWidget
+ https://bugs.webkit.org/show_bug.cgi?id=29085
+
+ Reflect the rename of platformWindow and it's return type.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::platformPageClient):
+ (WebKit::ChromeClient::runOpenPanel):
+ * WebCoreSupport/ChromeClientGtk.h:
+ * webkit/webkitprivate.cpp:
+ (currentToplevelCallback):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_popup_menu_handler):
+
+2009-09-18 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ Document webkit_web_view_stop_loading.
+
+ * webkit/webkitwebview.cpp:
+
+2009-09-18 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha and Jan Alonzo.
+
+ [GTK] context menu overriding API is very limited
+ https://bugs.webkit.org/show_bug.cgi?id=27546
+
+ Add webkit_web_view_get_hit_test_result, a function to get a hit
+ test result from a GdkEventButton. Useful to let applications
+ decide between several actions on button press depending on what
+ is being pressed.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_stop_loading):
+ (documentPointForWindowPoint):
+ (webkit_web_view_get_hit_test_result):
+ * webkit/webkitwebview.h:
+
+2009-09-18 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha and Jan Alonzo.
+
+ [GTK] context menu overriding API is very limited
+ https://bugs.webkit.org/show_bug.cgi?id=27546
+
+ Add WebKitHitTestResult, a wrapper over HitTestResult. It contains
+ context information about a point in the web page.
+
+ * webkit/webkit.h:
+ * webkit/webkitdefines.h:
+ * webkit/webkithittestresult.cpp: Added.
+ (webkit_hit_test_result_finalize):
+ (webkit_hit_test_result_get_property):
+ (webkit_hit_test_result_set_property):
+ (webkit_hit_test_result_class_init):
+ (webkit_hit_test_result_init):
+ * webkit/webkithittestresult.h: Added.
+ * webkit/webkitprivate.cpp:
+ (WebKit::kit):
+ * webkit/webkitprivate.h:
+
+2009-09-14 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez and Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=29134
+ [GTK] Add API to access sub resources
+
+ Implement getting subresources, and improve testing of
+ main, and sub resources loading.
+
+2009-09-11 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ [GTK] Use gtk_style_set_background instead of gdk_window_set_background
+ https://bugs.webkit.org/show_bug.cgi?id=29173
+
+ Use gtk_style_set_background instead of gdk_window_set_background,
+ as suggested by the documentation. Also, use GTK_STATE_NORMAL
+ directly, since that's the default state of a GtkWidget.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_realize):
+
+2009-09-09 Zan Dobersek <zandobersek@gmail.com>
+
+ Reviewed by Gustavo Noronha.
+
+ [GTK] DumpRenderTree needs eventSender object and implementation
+ https://bugs.webkit.org/show_bug.cgi?id=25990
+
+ Creates a function that is accessible from the DumpRenderTree tool
+ and calls the layout method on the frame view.
+
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_layout):
+
+2009-09-08 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ https://bugs.webkit.org/show_bug.cgi?id=29044
+ [GTK] Should update suggested-filename when the response is received
+
+ Set suggested filename also when the response only comes after the
+ download has started.
+
+ * webkit/webkitdownload.cpp:
+ (webkit_download_set_response):
+ (webkit_download_set_suggested_filename):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_request_download):
+
+2009-09-08 Priit Laes <plaes@plaes.org>
+
+ Reviewed by Gustavo Noronha.
+
+ Fix up erroneus 'Since: @version@' tags in documentation.
+
+ * webkit/webkitwebdatasource.cpp:
+ * webkit/webkitwebresource.cpp:
+ (webkit_web_resource_class_init):
+ * webkit/webkitwebsettings.cpp:
+ (webkit_web_settings_class_init):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init):
+ * webkit/webkitwebwindowfeatures.cpp:
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Link new objects documents in the main document.
+
+ * docs/webkitgtk-docs.sgml:
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Documentation control files updated for 1.1.14.
+
+ * docs/webkitgtk-docs.sgml:
+ * docs/webkitgtk-sections.txt:
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ What's new for 1.1.14.
+
+ * NEWS:
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Rubber-stamped by Xan Lopez.
+
+ Use g_return_if_fail to check for the SoupURI creation, instead of
+ printing a custom warning.
+
+ * webkit/webkitnetworkrequest.cpp:
+ (webkit_network_request_set_uri):
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ https://bugs.webkit.org/show_bug.cgi?id=26854
+ [GTK] Needs API to allow more control over outgoing requests
+
+ Map the willSendRequest delegate to the 'resource-request-starting'
+ signal, allowing more control of the resources that are fetched.
+
+ Mapping willSendRequest properly requires an appropriate Response
+ object, so we are introducing WebKitNetworkResponse, which works in a
+ way similar to WebKitNetworkRequest.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::dispatchWillSendRequest):
+ (WebKit::FrameLoaderClient::assignIdentifierToInitialRequest):
+ (WebKit::FrameLoaderClient::dispatchDidFinishLoading):
+ (WebKit::FrameLoaderClient::dispatchDidFailLoading):
+ * tests/testnetworkresponse.c: Added.
+ (test_network_response_create_destroy):
+ (test_network_response_properties):
+ (main):
+ * tests/testwebresource.c:
+ (resource_request_starting_cb):
+ (load_finished_cb):
+ (test_web_resource_loading):
+ (main):
+ * webkit/webkit.h:
+ * webkit/webkitdefines.h:
+ * webkit/webkitnetworkrequest.cpp:
+ * webkit/webkitnetworkresponse.cpp: Added.
+ (webkit_network_response_dispose):
+ (webkit_network_response_finalize):
+ (webkit_network_response_get_property):
+ (webkit_network_response_set_property):
+ (webkit_network_response_class_init):
+ (webkit_network_response_init):
+ (webkit_network_response_new_with_core_response):
+ (webkit_network_response_new):
+ (webkit_network_response_set_uri):
+ (webkit_network_response_get_uri):
+ (webkit_network_response_get_message):
+ * webkit/webkitnetworkresponse.h: Added.
+ * webkit/webkitprivate.cpp:
+ (WTF::SoupMessage):
+ (WTF::WebKitNetworkRequest):
+ (WTF::WebKitNetworkResponse):
+ (WTF::WebKitWebResource):
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebresource.cpp:
+ (webkit_web_resource_cleanup):
+ (webkit_web_resource_finalize):
+ (webkit_web_resource_class_init):
+ (webkit_web_resource_set_property):
+ (webkit_web_resource_get_uri):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init):
+ * webkitmarshal.list:
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28979
+ [GTK] Misc improvments to NetworkRequest
+
+ Unref message in dispose, as it should be, not in finalize.
+
+ * webkit/webkitnetworkrequest.cpp:
+ (webkit_network_request_dispose):
+ (webkit_network_request_finalize):
+ (webkit_network_request_class_init):
+
+2009-09-07 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28979
+ [GTK] Misc improvments to NetworkRequest
+
+ Bring documentation up-to-date with reality regarding NetworkRequest.
+
+ * webkit/webkitnetworkrequest.cpp:
+
+2009-09-07 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Make the auth dialog usable when libsoup does not have a
+ SoupPasswordManager, since it might go away in the next
+ development cycle.
+
+ * webkit/webkitsoupauthdialog.c:
+ (response_callback):
+ (session_can_save_passwords):
+ (session_authenticate):
+2009-09-06 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Update the unitests to latest changes wrt scrollbar policy.
+
+ * tests/testwindow.c:
+ (test_webkit_window_scrollbar_policy):
+
+2009-09-06 Martin Robinson <martin.james.robinson@gmail.com>
+
+ Reviewed by Gustavo Noronha, Jan Alonzo and Xan Lopez.
+
+ [Gtk] Expose a database API
+ https://bugs.webkit.org/show_bug.cgi?id=27899
+
+ Expose an HTML5 database API for GTK+.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::print):
+ * webkit/webkit.h:
+ * webkit/webkitdefines.h:
+ * webkit/webkitprivate.cpp:
+ (webkit_init):
+ * webkit/webkitprivate.h:
+ * webkit/webkitsecurityorigin.cpp: Added.
+ (webkit_security_origin_finalize):
+ (webkit_security_origin_dispose):
+ (webkit_security_origin_set_property):
+ (webkit_security_origin_get_property):
+ (webkit_security_origins):
+ (webkit_security_origin_class_init):
+ (webkit_security_origin_init):
+ (webkit_security_origin_get_protocol):
+ (webkit_security_origin_get_host):
+ (webkit_security_origin_get_port):
+ (webkit_security_origin_get_web_database_usage):
+ (webkit_security_origin_get_web_database_quota):
+ (webkit_security_origin_set_web_database_quota):
+ (webkit_security_origin_get_all_web_databases):
+ (WebKit::kit):
+ (WebKit::core):
+ (webkit_security_origin_get_web_database):
+ * webkit/webkitsecurityorigin.h: Added.
+ * webkit/webkitwebdatabase.cpp: Added.
+ (webkit_web_database_finalize):
+ (webkit_web_database_dispose):
+ (webkit_web_database_set_property):
+ (webkit_web_database_get_property):
+ (webkit_web_database_class_init):
+ (webkit_web_database_init):
+ (webkit_web_database_set_security_origin):
+ (webkit_web_database_set_name):
+ (webkit_web_database_get_security_origin):
+ (webkit_web_database_get_name):
+ (webkit_web_database_get_display_name):
+ (webkit_web_database_get_expected_size):
+ (webkit_web_database_get_size):
+ (webkit_web_database_get_filename):
+ (webkit_web_database_remove):
+ (webkit_remove_all_web_databases):
+ (webkit_get_web_database_directory_path):
+ (webkit_set_web_database_directory_path):
+ (webkit_get_default_web_database_quota):
+ * webkit/webkitwebdatabase.h: Added.
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_new):
+ (webkit_web_frame_get_focused_accessible_element):
+ (webkit_web_frame_get_horizontal_scrollbar_policy):
+ * webkit/webkitwebframe.h:
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init):
+
+2009-09-03 Adam Barth <abarth@webkit.org>
+
+ Reviewed by eric@webkit.org.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24696
+
+ Stub implementations of mixed content methods of FrameLoaderClient.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::didDisplayInsecureContent):
+ (WebKit::FrameLoaderClient::didRunInsecureContent):
+ * WebCoreSupport/FrameLoaderClientGtk.h:
+
+2009-09-03 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Access private member variables directly instead of using the
+ accessor.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::createFrame):
+ (WebKit::FrameLoaderClient::windowObjectCleared):
+
+2009-09-03 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ Remove bogus asserts that break Debug builds at runtime.
+
+ * WebCoreSupport/DocumentLoaderGtk.cpp:
+ (WebKit::DocumentLoader::detachFromFrame):
+ (WebKit::DocumentLoader::decreaseLoadCount):
+
+2009-09-02 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Xan Lopez and Gustavo Noronha.
+
+ [Gtk] Implement a WebDataSource for the gtk port
+ https://bugs.webkit.org/show_bug.cgi?id=24758
+
+ Add data source API getters to WebKitWebFrame.
+ Also add WebKitWebDataSource unit test.
+
+ * tests/testwebdatasource.c: Added.
+ * webkit/webkitwebframe.cpp:
+ * webkit/webkitwebframe.h:
+
+2009-09-02 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Xan Lopez and Gustavo Noronha.
+
+ [Gtk] Implement a WebDataSource for the gtk port
+ https://bugs.webkit.org/show_bug.cgi?id=24758
+
+ Subclass DocumentLoader for Gtk and implement it under the WebKit
+ namespace. Add WebKitWebDataSource implementation that closely
+ follows the mac implementation of the API.
+
+ * WebCoreSupport/DocumentLoaderGtk.cpp: Added.
+ * WebCoreSupport/DocumentLoaderGtk.h: Added.
+ * webkit/webkitwebdatasource.cpp: Added.
+ * webkit/webkitwebdatasource.h: Added.
+
+2009-09-01 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ Avoid causing unexpected issues with window sizing when sites
+ disable scrollbars completely.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::scrollbarsModeDidChange):
+ * tests/testwindow.c:
+ (test_webkit_window_scrollbar_policy):
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_class_init):
+
+2009-09-01 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Xan Lopez and Gustavo Noronha.
+
+ [Gtk] Implement a WebDataSource for the gtk port
+ https://bugs.webkit.org/show_bug.cgi?id=24758
+
+ Implement WebKitWebResource for the resource-related API for
+ WebKitWebDataSource.
+
+ * GNUmakefile.am:
+
+2009-09-01 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28842
+ [GTK] Do not emit extra FINISHED load-status signals
+
+ Do not emit FINISHED load-status signals on our own, just rely on
+ WebCore for that. Avoids emitting FINISHED several times when we
+ fail to load a URI.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::dispatchDidFailProvisionalLoad):
+ (WebKit::FrameLoaderClient::dispatchDidFailLoad):
+ * tests/testloading.c:
+ (web_loading_fixture_setup):
+ (web_loading_fixture_teardown):
+ (load_finished_cb):
+ (status_changed_cb):
+ (test_loading_status):
+ (load_error_status_changed_cb):
+ (load_error_cb):
+ (test_loading_error):
+ (main):
+ * webkit/webkitwebframe.h:
+
+2009-08-31 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Alexey Proskuryakov.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28466
+ When downloading a file, two GET requests are sent to the HTTP server
+
+ Support reusing a connection that is already ongoing, instead of
+ cancelling the connection and creating another.
+
+ * WebCoreSupport/FrameLoaderClientGtk.cpp:
+ (WebKit::FrameLoaderClient::download):
+ * webkit/webkitdownload.cpp:
+ (webkit_download_new_with_handle):
+ (webkit_download_start):
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_request_download):
+
+2009-08-31 Alexey Proskuryakov <ap@apple.com>
+
+ Gtk build fix.
+
+ This is also a behavior fix, at least on debug builds - a caller of
+ webkit_web_history_item_new_with_data() could pass an URL that could cause an assertion
+ failure in KURL.
+
+ * webkit/webkitwebhistoryitem.cpp: (webkit_web_history_item_new_with_data): Pass a null
+ KURL as base to parse properly.
+
+2009-08-28 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Holger Freyther.
+
+ https://bugs.webkit.org/show_bug.cgi?id=25889
+ [GTK] scrollbar policy for main frame is not implementable
+
+ Add properties and a signal to report scrollbar policy changes to
+ client code, and a default handler that does the right thing when
+ using GtkScrolledWindow.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::scrollbarsModeDidChange):
+ * WebCoreSupport/ChromeClientGtk.h:
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_get_property):
+ (webkit_web_frame_class_init):
+ (webkit_web_frame_get_horizontal_scrollbar_policy):
+ (webkit_web_frame_get_vertical_scrollbar_policy):
+ * webkit/webkitwebframe.h:
+ * tests/testwindow.c: Added.
+ (load_finished_cb):
+ (test_webkit_window_scrollbar_policy):
+ (main):
+
+2009-08-28 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Gustavo Noronha and Xan Lopez.
+
+ [Gtk] Add view source mode API
+ https://bugs.webkit.org/show_bug.cgi?id=28805
+
+ Implement setter and getter for "view source" mode.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_set_view_source_mode):
+ (webkit_web_frame_get_view_source_mode):
+ * webkit/webkitwebview.h:
+
+2009-08-26 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28738
+ Expose undo/redo functionality in WebKitWebView
+
+ Expose undo/redo functionality in WebKitWebView, keeping the
+ default bindings as they were.
+
+ * WebCoreSupport/EditorClientGtk.cpp:
+ (WebKit::):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_real_undo):
+ (webkit_web_view_real_redo):
+ (webkit_web_view_class_init):
+ (webkit_web_view_can_undo):
+ (webkit_web_view_undo):
+ (webkit_web_view_can_redo):
+ (webkit_web_view_redo):
+ * webkit/webkitwebview.h:
+
+2009-08-24 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ News about the 1.1.13 release.
+
+ * NEWS:
+
+2009-08-24 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Xan Lopez.
+
+ Add new symbols, and an index of new symbols for the 1.1.13
+ release.
+
+ * docs/webkitgtk-docs.sgml:
+ * docs/webkitgtk-sections.txt:
+
+2009-08-23 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Fix a couple of typos.
+
+ * webkit/webkitwebsettings.cpp:
+ (webkit_web_settings_class_init):
+
+2009-08-23 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Update editing-behavior property here too.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_settings_notify):
+
+2009-08-23 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Rubberstamped by Gustavo Noronha.
+
+ Fix regressions introduced by http://trac.webkit.org/changeset/47690.
+
+ Update the setting whenever the property gets set.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_settings_notify):
+
+2009-08-23 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Xan Lopez.
+
+ [Gtk] API for disabling local file access to web URLs
+ https://bugs.webkit.org/show_bug.cgi?id=28663
+
+ Add a setting to enable or disable file access to web URLs. It's
+ disabled by default for security reasons.
+
+ * webkit/webkitwebsettings.cpp:
+ (webkit_web_settings_class_init):
+ (webkit_web_settings_set_property):
+ (webkit_web_settings_get_property):
+ (webkit_web_settings_copy):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_update_settings):
+
+2009-08-22 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28154
+ clicking below end of text in a textarea moves cursor to wrong position
+
+ Expose the EditingBehavior setting and set it by default to Mac,
+ since that what matches the GTK+ default behavior.
+
+ * webkit/webkitprivate.cpp:
+ (WebKit::core):
+ * webkit/webkitprivate.h:
+ * webkit/webkitwebsettings.cpp:
+ (webkit_web_settings_class_init):
+ (webkit_web_settings_set_property):
+ (webkit_web_settings_get_property):
+ (webkit_web_settings_copy):
+ * webkit/webkitwebsettings.h:
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_update_settings):
+
+2009-08-20 Aaron Boodman <aa@chromium.org>
+
+ Hopefully the last speculative build for gtk.
+
+ * webkit/webkitprivate.cpp:
+ (webkit_white_list_access_from_origin):
+ * webkit/webkitprivate.h:
+
+2009-08-20 David Levin <levin@chromium.org>
+
+ Another speculative build for gtk.
+
+ * webkit/webkitprivate.cpp:
+ (webkit_white_list_access_to_origin):
+
+2009-08-20 David Levin <levin@chromium.org>
+
+ Speculative build for gtk.
+
+ * webkit/webkitprivate.cpp:
+ (webkit_white_list_access_to_origin):
+
+2009-08-19 Aaron Boodman <aa@chromium.org>
+
+ Fix build break.
+
+ * webkit/webkitprivate.h: "WEBKIT API" -> "WEBKIT_API"
+
+2009-08-19 Aaron Boodman <aa@chromium.org>
+
+ Reviewed by David Levin.
+
+ https://bugs.webkit.org/show_bug.cgi?id=24853: Provide a way for WebKit clients to
+ specify a more granular policy for cross-origin XHR access.
+
+ * webkit/webkitprivate.cpp:
+ (webkit_white_list_access_to_origin): Add API to manipulate origin access whitelists.
+ (webkit_reset_origin_access_white_lists): Ditto.
+ * webkit/webkitprivate.h: Ditto.
+
+2009-08-18 Xan Lopez <xlopez@igalia.com>
+
+ Rubber-stamped by Holger Freyther.
+
+ Remove an unneeded include.
+
+ * WebCoreSupport/DragClientGtk.cpp:
+
+2009-08-18 Fumitoshi Ukai <ukai@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ https://bugs.webkit.org/show_bug.cgi?id=28443
+ Fix build break with gtk older than 2.14.
+
+ WebKit gtk port requires gtk 2.10 or later, but DragClientGtk.cpp
+ uses gtk_widget_get_window that is introduced in 2.14.
+
+ * WebCoreSupport/DragClientGtk.cpp:
+ define gtk_widget_get_window for gtk older than 2.14.
+
+2009-08-18 Jan Michael Alonzo <jmalonzo@webkit.org>
+
+ Reviewed by Oliver Hunt.
+
+ [Gtk] crash when closing page from javascript
+ https://bugs.webkit.org/show_bug.cgi?id=27439
+
+ Do not unref the WebView in ChromeClientGtk::closeWindowSoon
+ because (1) a create-web-view handler can return a NULL WebView,
+ (2) the created WebView is owned by its containing widget, and (3)
+ clients may not handle the close-web-view signal so this avoids
+ unreffing a WebView more than once.
+
+ * WebCoreSupport/ChromeClientGtk.cpp:
+ (WebKit::ChromeClient::closeWindowSoon):
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_class_init):
+
+2009-08-18 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Reviewed by Jan Alonzo.
+
+ https://bugs.webkit.org/show_bug.cgi?id=19360
+ Frags on current page don't generate "navigation-requested" events
+
+ Fix order of parameters for the creation of SubstituteData object,
+ so that normal data loads do not have an unreachable URL. Also
+ remove a confusion about the purpose of the last parameter.
+
+ * webkit/webkitwebframe.cpp:
+ (webkit_web_frame_load_data):
+
+2009-08-18 Drew Wilson <atwilson@google.com>
+
+ Reviewed by Eric Seidel.
+
+ Need to extend DumpRenderTree to expose number of worker threads
+ https://bugs.webkit.org/show_bug.cgi?id=28292
+
+ * webkit/webkitprivate.h:
+ * webkit/webkitworkers.cpp: Added.
+ (webkit_worker_thread_count):
+ Exposed WebCore::WorkerThread::workerThreadCount() for the gtk version of DumpRenderTree.
+
+2009-08-18 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Gustavo Noronha.
+
+ Fix the ATK unit test.
+
+ We now support line boundaries in the get_text functions, so we
+ need to make sure the test has the layout we expect by giving it
+ enough space to fit in one line.
+
+ * tests/testatk.c:
+ (test_webkit_atk_get_text_at_offset):
+
+2009-08-15 Zan Dobersek <zandobersek@gmail.com>
+
+ Reviewed by Xan Lopez.
+
+ Fix compiler warnings.
+
+ * webkit/webkitwebview.cpp:
+ (clipboard_contents_received):
+ (webkit_web_view_drag_data_get):
+
+2009-08-14 Jiahua Huang <jhuangjiahua@gmail.com>
+
+ Reviewed by Jan Alonzo.
+
+ [gtk] Pasteboard/GtkClipboard can't handle the "text/html" target.
+ https://bugs.webkit.org/show_bug.cgi?id=27028
+
+ Add a function in WebKit::PasteboardHelperGtk that will return the
+ value of WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
+ and WebCore::clipboard_get_contents_cb will use that.
+
+ * WebCoreSupport/PasteboardHelperGtk.cpp:
+ (WebKit::PasteboardHelperGtk::getWebViewTargetInfoHtml):
+ * WebCoreSupport/PasteboardHelperGtk.h:
+
+2009-08-14 Benjamin Otte <otte@gnome.org>
+
+ Reviewed by Gustavo Noronha.
+
+ Fix webkit_web_view_set_highlight_text_matches() so that highlighting
+ works properly in documents with frames.
+
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_set_highlight_text_matches):
+
+2009-08-13 Zan Dobersek <zandobersek@gmail.com>
+
+ Reviewed by Gustavo Noronha.
+
+ [GTK] Drag and drop support
+ https://bugs.webkit.org/show_bug.cgi?id=23642
+
+ Adds support for drag actions in WebKitWebView and DragClient.
+
+ Defines a support structure that can hold additional drag and drop data,
+ such as selection data or target IDs (infos) and can be passed through
+ clipboard requests.
+
+ Implements DragClient functions that gather start position of the drag
+ and start the GTK drag.
+
+ * WebCoreSupport/DragClientGtk.cpp:
+ (WebKit::DragClient::DragClient):
+ (WebKit::DragClient::willPerformDragSourceAction):
+ (WebKit::DragClient::startDrag):
+ (WebKit::DragClient::createDragImageForLink): A small style fix.
+ * WebCoreSupport/DragClientGtk.h:
+ * webkit/webkitwebview.cpp:
+ (webkit_web_view_drag_end):
+ (clipboard_contents_received): GtkClipboard callback.
+ (webkit_web_view_drag_data_get):
+ (webkit_web_view_class_init):
+ (webkit_web_view_init):
+ * webkit/webkitwebview.h: Add GTK selection targets.
+
+2009-08-12 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk>
+
+ Unreviewed build fix.
+
+ Last-minute change on the new soup API to use the keyring was not
+ reflected in our usage - the documentation says we should use
+ g_slist_free, and soup_auth_free_saved_users doesn't exist.
+
+ * webkit/webkitsoupauthdialog.c:
+ (session_authenticate):
+
+2009-08-12 Xan Lopez <xlopez@igalia.com>
+
+ Reviewed by Jan Alonzo.
+
+ [GTK] Remove keyring optional features
+ https://bugs.webkit.org/show_bug.cgi?id=28173
+
+ Remove keyring support from our code and rely on libsoup to store
+ the authentication data if the user requests that support in their
+ application/library.
+
+ * webkit/webkitsoupauthdialog.c:
+ (response_callback):
+ (show_auth_dialog):
+ (session_authenticate):
+
+2009-08-11 Benjamin Otte <otte@gnome.org>
+
+ Reviewed by Xan Lopez.
+
+ When instructed to print an out-of-range page, print an empty page
+ instead of crashing.
+
+ * webkit/webkitwebframe.cpp:
+ (draw_page_callback):
+
2009-08-10 Brady Eidson <beidson@apple.com>
GTK build fix.
diff --git a/WebKit/gtk/JSCore-1.0.gir b/WebKit/gtk/JSCore-1.0.gir
new file mode 100644
index 0000000..2fb4d46
--- /dev/null
+++ b/WebKit/gtk/JSCore-1.0.gir
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0">
+ <namespace name="JSCore" version="1.0" shared-library="webkit-1.0">
+ <alias name="GlobalContextRef"
+ target="none"
+ c:type="JSGlobalContextRef"/>
+ <alias name="ObjectRef" target="none" c:type="JSObjectRef"/>
+ <function name="EvaluateScript" c:identifier="JSEvaluateScript">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ </parameters>
+ </function>
+ </namespace>
+</repository>
diff --git a/WebKit/gtk/NEWS b/WebKit/gtk/NEWS
index 39a54ff..8d0803c 100644
--- a/WebKit/gtk/NEWS
+++ b/WebKit/gtk/NEWS
@@ -1,4 +1,71 @@
=================
+WebKitGTK+ 1.1.15
+=================
+
+What's new in WebKitGTK+ 1.1.15?
+
+ - New API to get the subresources from a WebKitWebDataSource. This
+ provides a way of accessing all the resources that compose the
+ view to which the data source is attached.
+ - A new function, webkit_web_view_get_hit_test_result, which allows
+ to do a 'hit test' on the coordinates specified by a mouse
+ event. A hit test provides context information about that point in
+ the document, like whether it's an image, a link, an input box,
+ etc.
+ - Our DumpRenderTree implementation now supports eventSender, which
+ allows us to run many more LayoutTests and make WebKitGTK+ more
+ stable and feature-complete.
+ - JSNES runs 6x faster: http://trac.webkit.org/changeset/48573
+ - The usual small improvements and bugfixes.
+
+=================
+WebKitGTK+ 1.1.14
+=================
+
+What's new in WebKitGTK+ 1.1.14?
+
+ - New API has been added to WebKitWebFrame to allow applying
+ scrollbars policy as requested by web applications to the main
+ frame; if the parent of the WebKitWebView widget is a
+ GtkScrolledWindow, policy is applied by the default handler.
+ - A new API has been added to help dealing with the various
+ resources that are downloaded to compose the final rendering; you
+ can now obtain the source code for a page that is loaded, for
+ instance.
+ - A new property has been added to WebKitWebView to allow setting it
+ to "View Source" mode.
+ - HTML5 database has gained API to manage the individual databases,
+ including usage and quota.
+ - A new signal `resource-request-starting' has been added to the
+ WebKitWebView to allow modification of outgoing requests for every
+ resource.
+ - Connection limit has been increased to 60 total connections, 6
+ per-host, matching other browsers more closely; this seems to have
+ improved loading time of some sites.
+ - Undo/redo support has been added to editable texts.
+ - The usual stream of small improvements and bug fixes.
+
+=================
+WebKitGTK+ 1.1.13
+=================
+
+What's new in WebKitGTK+ 1.1.13?
+
+ - GNOME Keyring support was removed in favor of the new Password
+ Manager soup feature; to get exactly the same behavior,
+ applications should use SoupPasswordManagerGNOME. This requires
+ libsoup 2.27.91 or newer.
+ - Several accessibility improvements, including support for testing
+ the a11y infrastructure in our layout tests.
+ - You can now enable/disable HTML5 offline application cache using a
+ new setting added to WebKitWebSettings.
+ - Drag support has landed, meaning you can start playing with HTML5
+ drag and drop support; drop support is still missing.
+ - A crash with scripts closing windows has been fixed.
+ - Image cursors support has been added.
+ - The usual stream of small improvements and bug fixes.
+
+=================
WebKitGTK+ 1.1.12
=================
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
index 1292e99..8d31af3 100644
--- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
@@ -215,6 +215,10 @@ void ChromeClient::setResizable(bool)
void ChromeClient::closeWindowSoon()
{
+ // We may not have a WebView as create-web-view can return NULL.
+ if (!m_webView)
+ return;
+
webkit_web_view_stop_loading(m_webView);
gboolean isHandled = false;
@@ -226,7 +230,6 @@ void ChromeClient::closeWindowSoon()
// FIXME: should we clear the frame group name here explicitly? Mac does it.
// But this gets cleared in Page's destructor anyway.
// webkit_web_view_set_group_name(m_webView, "");
- g_object_unref(m_webView);
}
bool ChromeClient::canTakeFocus(FocusDirection)
@@ -383,7 +386,7 @@ IntPoint ChromeClient::screenToWindow(const IntPoint& point) const
return result;
}
-PlatformWidget ChromeClient::platformWindow() const
+PlatformPageClient ChromeClient::platformPageClient() const
{
return GTK_WIDGET(m_webView);
}
@@ -399,6 +402,40 @@ void ChromeClient::contentsSizeChanged(Frame* frame, const IntSize& size) const
gtk_widget_queue_resize_no_redraw(widget);
}
+void ChromeClient::scrollbarsModeDidChange() const
+{
+ WebKitWebFrame* webFrame = webkit_web_view_get_main_frame(m_webView);
+
+ g_object_notify(G_OBJECT(webFrame), "horizontal-scrollbar-policy");
+ g_object_notify(G_OBJECT(webFrame), "vertical-scrollbar-policy");
+
+ gboolean isHandled;
+ g_signal_emit_by_name(webFrame, "scrollbars-policy-changed", &isHandled);
+
+ if (isHandled)
+ return;
+
+ GtkWidget* parent = gtk_widget_get_parent(GTK_WIDGET(m_webView));
+ if (!parent || !GTK_IS_SCROLLED_WINDOW(parent))
+ return;
+
+ GtkPolicyType horizontalPolicy = webkit_web_frame_get_horizontal_scrollbar_policy(webFrame);
+ GtkPolicyType verticalPolicy = webkit_web_frame_get_vertical_scrollbar_policy(webFrame);
+
+ // ScrolledWindow doesn't like to display only part of a widget if
+ // the scrollbars are completely disabled; We have a disparity
+ // here on what the policy requested by the web app is and what we
+ // can represent; the idea is not to show scrollbars, only.
+ if (horizontalPolicy == GTK_POLICY_NEVER)
+ horizontalPolicy = GTK_POLICY_AUTOMATIC;
+
+ if (verticalPolicy == GTK_POLICY_NEVER)
+ verticalPolicy = GTK_POLICY_AUTOMATIC;
+
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(parent),
+ horizontalPolicy, verticalPolicy);
+}
+
void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags)
{
// If a tooltip must be displayed it will be, afterwards, when
@@ -459,13 +496,17 @@ void ChromeClient::print(Frame* frame)
}
#if ENABLE(DATABASE)
-void ChromeClient::exceededDatabaseQuota(Frame* frame, const String&)
+void ChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName)
{
- // Set to 5M for testing
- // FIXME: Make this configurable
- notImplemented();
- const unsigned long long defaultQuota = 5 * 1024 * 1024;
+ guint64 defaultQuota = webkit_get_default_web_database_quota();
DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), defaultQuota);
+
+ WebKitWebFrame* webFrame = kit(frame);
+ WebKitWebView* webView = getViewFromFrame(webFrame);
+
+ WebKitSecurityOrigin* origin = webkit_web_frame_get_security_origin(webFrame);
+ WebKitWebDatabase* webDatabase = webkit_security_origin_get_web_database(origin, databaseName.utf8().data());
+ g_signal_emit_by_name(webView, "database-quota-exceeded", webFrame, webDatabase);
}
#endif
@@ -482,7 +523,7 @@ void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser)
RefPtr<FileChooser> chooser = prpFileChooser;
GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
- GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformWindow()))),
+ GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformPageClient()))),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
index 0f35e52..e321c35 100644
--- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
@@ -89,9 +89,10 @@ namespace WebKit {
virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect);
virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
- virtual PlatformWidget platformWindow() const;
+ virtual PlatformPageClient platformPageClient() const;
virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const;
+ virtual void scrollbarsModeDidChange() const;
virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags);
virtual void setToolTip(const WebCore::String&, WebCore::TextDirection);
diff --git a/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.cpp b/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.cpp
new file mode 100644
index 0000000..0efc9fa
--- /dev/null
+++ b/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Jan Michael Alonzo
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DocumentLoaderGtk.h"
+
+#include "webkitwebdatasource.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DocumentLoader::DocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
+ : WebCore::DocumentLoader(request, substituteData)
+ , m_isDataSourceReffed(false)
+ , m_dataSource(0)
+{
+}
+
+void DocumentLoader::setDataSource(WebKitWebDataSource* dataSource)
+{
+ ASSERT(!m_dataSource);
+
+ m_dataSource = dataSource;
+ refDataSource();
+}
+
+void DocumentLoader::detachDataSource()
+{
+ unrefDataSource();
+}
+
+void DocumentLoader::attachToFrame()
+{
+ WebCore::DocumentLoader::attachToFrame();
+
+ refDataSource();
+}
+
+void DocumentLoader::detachFromFrame()
+{
+ WebCore::DocumentLoader::detachFromFrame();
+
+ if (m_loadingResources.isEmpty())
+ unrefDataSource();
+}
+
+void DocumentLoader::increaseLoadCount(unsigned long identifier)
+{
+ ASSERT(m_dataSource);
+
+ if (m_loadingResources.contains(identifier))
+ return;
+ m_loadingResources.add(identifier);
+ refDataSource();
+}
+
+void DocumentLoader::decreaseLoadCount(unsigned long identifier)
+{
+ HashSet<unsigned long>::iterator it = m_loadingResources.find(identifier);
+
+ // It is valid for a load to be cancelled before it's started.
+ if (it == m_loadingResources.end())
+ return;
+
+ m_loadingResources.remove(it);
+
+ if (m_loadingResources.isEmpty() && !frame())
+ unrefDataSource();
+}
+
+// helper methos to avoid ref count churn
+void DocumentLoader::refDataSource()
+{
+ if (!m_dataSource || m_isDataSourceReffed)
+ return;
+ m_isDataSourceReffed = true;
+ g_object_ref(m_dataSource);
+}
+void DocumentLoader::unrefDataSource()
+{
+ if (!m_isDataSourceReffed)
+ return;
+ ASSERT(m_dataSource);
+ m_isDataSourceReffed = false;
+ g_object_unref(m_dataSource);
+}
+
+} // end namespace WebKit
diff --git a/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.h b/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.h
new file mode 100644
index 0000000..c601bc5
--- /dev/null
+++ b/WebKit/gtk/WebCoreSupport/DocumentLoaderGtk.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Jan Michael Alonzo
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DocumentLoaderGtk_h
+#define DocumentLoaderGtk_h
+
+#include "DocumentLoader.h"
+#include "webkitdefines.h"
+#include "wtf/HashSet.h"
+
+namespace WebCore {
+ class ResourceRequest;
+ class SubstituteData;
+}
+
+namespace WebKit {
+
+class DocumentLoader : public WebCore::DocumentLoader {
+public:
+ static PassRefPtr<WebKit::DocumentLoader> create(const WebCore::ResourceRequest& request, const WebCore::SubstituteData& data)
+ {
+ return adoptRef(new DocumentLoader(request, data));
+ }
+
+ void setDataSource(WebKitWebDataSource*);
+ void detachDataSource();
+ WebKitWebDataSource* dataSource() const { return m_dataSource; }
+
+ void increaseLoadCount(unsigned long identifier);
+ void decreaseLoadCount(unsigned long identifier);
+
+private:
+ DocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
+
+ virtual void attachToFrame();
+ virtual void detachFromFrame();
+
+ void refDataSource();
+ void unrefDataSource();
+
+ bool m_isDataSourceReffed;
+ WebKitWebDataSource* m_dataSource;
+ HashSet<unsigned long> m_loadingResources;
+};
+
+} // end namespace WebKit
+
+#endif
diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
index f55b6ea..f4b0df1 100644
--- a/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.cpp
@@ -17,20 +17,36 @@
#include "config.h"
#include "DragClientGtk.h"
+#include "Document.h"
+#include "Element.h"
+#include "Frame.h"
#include "NotImplemented.h"
+#include "RenderObject.h"
+#include "webkitwebview.h"
+
+#include <gtk/gtk.h>
+#if !GTK_CHECK_VERSION(2, 14, 0)
+#define gtk_widget_get_window(widget) (widget)->window
+#endif
using namespace WebCore;
namespace WebKit {
+DragClient::DragClient(WebKitWebView* webView)
+ : m_webView(webView)
+ , m_startPos(0, 0)
+{
+}
+
void DragClient::willPerformDragDestinationAction(DragDestinationAction, DragData*)
{
notImplemented();
}
-void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint&, Clipboard*)
+void DragClient::willPerformDragSourceAction(DragSourceAction, const IntPoint& startPos, Clipboard*)
{
- notImplemented();
+ m_startPos = startPos;
}
DragDestinationAction DragClient::actionMaskForDrag(DragData*)
@@ -45,12 +61,53 @@ DragSourceAction DragClient::dragSourceActionMaskForPoint(const IntPoint&)
return DragSourceActionAny;
}
-void DragClient::startDrag(DragImageRef, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool)
+void DragClient::startDrag(DragImageRef image, const IntPoint& dragImageOrigin, const IntPoint& eventPos, Clipboard*, Frame* frame, bool linkDrag)
{
- notImplemented();
+ Element* targetElement = frame->document()->elementFromPoint(m_startPos.x(), m_startPos.y());
+ bool imageDrag = false;
+
+ if (targetElement)
+ imageDrag = targetElement->renderer()->isImage();
+
+ GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
+ GdkAtom netscapeUrl = gdk_atom_intern_static_string("_NETSCAPE_URL");
+
+ GtkTargetList* targetList = gtk_target_list_new(NULL, 0);
+ gtk_target_list_add(targetList, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML);
+ gtk_target_list_add_text_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_TEXT);
+
+ if (linkDrag || imageDrag) {
+ gtk_target_list_add(targetList, netscapeUrl, 0, WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL);
+ gtk_target_list_add_uri_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST);
+ }
+
+ if (imageDrag)
+ gtk_target_list_add_image_targets(targetList, WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE, false);
+
+ GdkDragAction dragAction = GDK_ACTION_COPY;
+ if (linkDrag) {
+ dragAction = GDK_ACTION_LINK;
+ if (imageDrag)
+ dragAction = (GdkDragAction)(dragAction | GDK_ACTION_COPY);
+ }
+
+ GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS);
+ reinterpret_cast<GdkEventButton*>(event)->window = gtk_widget_get_window(GTK_WIDGET(m_webView));
+ reinterpret_cast<GdkEventButton*>(event)->time = GDK_CURRENT_TIME;
+
+ GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(m_webView),
+ targetList, dragAction, 1, event);
+ g_object_ref(context);
+
+ if (image)
+ gtk_drag_set_icon_pixbuf(context, image, eventPos.x() - dragImageOrigin.x(), eventPos.y() - dragImageOrigin.y());
+ else
+ gtk_drag_set_icon_default(context);
+
+ gtk_target_list_unref(targetList);
}
-DragImageRef DragClient::createDragImageForLink(KURL&, const String& label, Frame*)
+DragImageRef DragClient::createDragImageForLink(KURL&, const String&, Frame*)
{
notImplemented();
return 0;
@@ -61,4 +118,3 @@ void DragClient::dragControllerDestroyed()
delete this;
}
}
-
diff --git a/WebKit/gtk/WebCoreSupport/DragClientGtk.h b/WebKit/gtk/WebCoreSupport/DragClientGtk.h
index 4367c68..97ea72a 100644
--- a/WebKit/gtk/WebCoreSupport/DragClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/DragClientGtk.h
@@ -32,9 +32,14 @@
#include "DragClient.h"
+typedef struct _WebKitWebView WebKitWebView;
+
namespace WebKit {
+
class DragClient : public WebCore::DragClient {
public:
+ DragClient(WebKitWebView*);
+
virtual void willPerformDragDestinationAction(WebCore::DragDestinationAction, WebCore::DragData*);
virtual void willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::Clipboard*);
virtual WebCore::DragDestinationAction actionMaskForDrag(WebCore::DragData*);
@@ -45,6 +50,10 @@ namespace WebKit {
virtual WebCore::DragImageRef createDragImageForLink(WebCore::KURL&, const WebCore::String& label, WebCore::Frame*);
virtual void dragControllerDestroyed();
+
+ private:
+ WebKitWebView* m_webView;
+ WebCore::IntPoint m_startPos;
};
}
diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
index b5148d8..7121163 100644
--- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
@@ -49,39 +49,40 @@ using namespace WebCore;
namespace WebKit {
-static void imContextCommitted(GtkIMContext* context, const gchar* str, EditorClient* client)
-{
- Frame* targetFrame = core(client->m_webView)->focusController()->focusedOrMainFrame();
+static gchar* pendingComposition = 0;
+static gchar* pendingPreedit = 0;
- if (!targetFrame || !targetFrame->editor()->canEdit())
- return;
+static void setPendingComposition(gchar* newComposition)
+{
+ g_free(pendingComposition);
+ pendingComposition = newComposition;
+}
- Editor* editor = targetFrame->editor();
+static void setPendingPreedit(gchar* newPreedit)
+{
+ g_free(pendingPreedit);
+ pendingPreedit = newPreedit;
+}
- String commitString = String::fromUTF8(str);
- editor->confirmComposition(commitString);
+static void clearPendingIMData()
+{
+ setPendingComposition(0);
+ setPendingPreedit(0);
+}
+static void imContextCommitted(GtkIMContext* context, const gchar* str, EditorClient* client)
+{
+ // This signal will fire during a keydown event. We want the contents of the
+ // field to change right before the keyup event, so we wait until then to actually
+ // commit this composition.
+ setPendingComposition(g_strdup(str));
}
static void imContextPreeditChanged(GtkIMContext* context, EditorClient* client)
{
- Frame* frame = core(client->m_webView)->focusController()->focusedOrMainFrame();
- Editor* editor = frame->editor();
-
- gchar* preedit = NULL;
- gint cursorPos = 0;
// We ignore the provided PangoAttrList for now.
- gtk_im_context_get_preedit_string(context, &preedit, NULL, &cursorPos);
- String preeditString = String::fromUTF8(preedit);
- g_free(preedit);
-
- // setComposition() will replace the user selection if passed an empty
- // preedit. We don't want this to happen.
- if (preeditString.isEmpty() && !editor->hasComposition())
- return;
-
- Vector<CompositionUnderline> underlines;
- underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
- editor->setComposition(preeditString, underlines, cursorPos, 0);
+ gchar* newPreedit = 0;
+ gtk_im_context_get_preedit_string(context, &newPreedit, NULL, NULL);
+ setPendingPreedit(newPreedit);
}
void EditorClient::setInputMethodState(bool active)
@@ -136,12 +137,16 @@ int EditorClient::spellCheckerDocumentTag()
bool EditorClient::shouldBeginEditing(WebCore::Range*)
{
+ clearPendingIMData();
+
notImplemented();
return true;
}
bool EditorClient::shouldEndEditing(WebCore::Range*)
{
+ clearPendingIMData();
+
notImplemented();
return true;
}
@@ -410,11 +415,6 @@ static const KeyDownEntry keyDownEntries[] = {
{ VK_RETURN, CtrlKey, "InsertNewline" },
{ VK_RETURN, AltKey, "InsertNewline" },
{ VK_RETURN, AltKey | ShiftKey, "InsertNewline" },
-
- // It's not quite clear whether Undo/Redo should be handled
- // in the application or in WebKit. We chose WebKit.
- { 'Z', CtrlKey, "Undo" },
- { 'Z', CtrlKey | ShiftKey, "Redo" },
};
static const KeyPressEntry keyPressEntries[] = {
@@ -426,7 +426,7 @@ static const KeyPressEntry keyPressEntries[] = {
{ '\r', AltKey | ShiftKey, "InsertNewline" },
};
-static const char* interpretKeyEvent(const KeyboardEvent* evt)
+static const char* interpretEditorCommandKeyEvent(const KeyboardEvent* evt)
{
ASSERT(evt->type() == eventNames().keydownEvent || evt->type() == eventNames().keypressEvent);
@@ -461,74 +461,79 @@ static const char* interpretKeyEvent(const KeyboardEvent* evt)
return mapKey ? keyPressCommandsMap->get(mapKey) : 0;
}
-static bool handleEditingKeyboardEvent(KeyboardEvent* evt)
+void EditorClient::handleKeyboardEvent(KeyboardEvent* event)
{
- Node* node = evt->target()->toNode();
+ Node* node = event->target()->toNode();
ASSERT(node);
Frame* frame = node->document()->frame();
ASSERT(frame);
- const PlatformKeyboardEvent* keyEvent = evt->keyEvent();
- if (!keyEvent)
- return false;
-
- bool caretBrowsing = frame->settings()->caretBrowsingEnabled();
- if (caretBrowsing) {
- switch (keyEvent->windowsVirtualKeyCode()) {
- case VK_LEFT:
- frame->selection()->modify(keyEvent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE,
- SelectionController::LEFT,
- keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
- true);
- return true;
- case VK_RIGHT:
- frame->selection()->modify(keyEvent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE,
- SelectionController::RIGHT,
- keyEvent->ctrlKey() ? WordGranularity : CharacterGranularity,
- true);
- return true;
- case VK_UP:
- frame->selection()->modify(keyEvent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE,
- SelectionController::BACKWARD,
- keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
- true);
- return true;
- case VK_DOWN:
- frame->selection()->modify(keyEvent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE,
- SelectionController::FORWARD,
- keyEvent->ctrlKey() ? ParagraphGranularity : LineGranularity,
- true);
- return true;
+ const PlatformKeyboardEvent* platformEvent = event->keyEvent();
+ if (!platformEvent)
+ return;
+
+ // Don't allow editor commands or text insertion for nodes that
+ // cannot edit, unless we are in caret mode.
+ if (!frame->editor()->canEdit() && !(frame->settings() && frame->settings()->caretBrowsingEnabled()))
+ return;
+
+ const gchar* editorCommandString = interpretEditorCommandKeyEvent(event);
+ if (editorCommandString) {
+ Editor::Command command = frame->editor()->command(editorCommandString);
+
+ // On editor commands from key down events, we only want to let the event bubble up to
+ // the DOM if it inserts text. If it doesn't insert text (e.g. Tab that changes focus)
+ // we just want WebKit to handle it immediately without a DOM event.
+ if (platformEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
+ if (!command.isTextInsertion() && command.execute(event))
+ event->setDefaultHandled();
+
+ return;
+ } else if (command.execute(event)) {
+ event->setDefaultHandled();
+ return;
}
}
- Editor::Command command = frame->editor()->command(interpretKeyEvent(evt));
+ // This is just a normal text insertion, so wait to execute the insertion
+ // until a keypress event happens. This will ensure that the insertion will not
+ // be reflected in the contents of the field until the keyup DOM event.
+ if (event->type() == eventNames().keypressEvent) {
- if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) {
- // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated,
- // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated
- // (e.g. Tab that inserts a Tab character, or Enter).
- return !command.isTextInsertion() && command.execute(evt);
- }
+ if (pendingComposition) {
+ String compositionString = String::fromUTF8(pendingComposition);
+ frame->editor()->confirmComposition(compositionString);
- if (command.execute(evt))
- return true;
+ clearPendingIMData();
+ event->setDefaultHandled();
- // Don't insert null or control characters as they can result in unexpected behaviour
- if (evt->charCode() < ' ')
- return false;
+ } else if (pendingPreedit) {
+ String preeditString = String::fromUTF8(pendingPreedit);
- // Don't insert anything if a modifier is pressed
- if (keyEvent->ctrlKey() || keyEvent->altKey())
- return false;
+ // Don't use an empty preedit as it will destroy the current
+ // selection, even if the composition is cancelled or fails later on.
+ if (!preeditString.isEmpty()) {
+ Vector<CompositionUnderline> underlines;
+ underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false));
+ frame->editor()->setComposition(preeditString, underlines, 0, 0);
+ }
- return frame->editor()->insertText(evt->keyEvent()->text(), evt);
-}
+ clearPendingIMData();
+ event->setDefaultHandled();
-void EditorClient::handleKeyboardEvent(KeyboardEvent* event)
-{
- if (handleEditingKeyboardEvent(event))
- event->setDefaultHandled();
+ } else {
+ // Don't insert null or control characters as they can result in unexpected behaviour
+ if (event->charCode() < ' ')
+ return;
+
+ // Don't insert anything if a modifier is pressed
+ if (platformEvent->ctrlKey() || platformEvent->altKey())
+ return;
+
+ if (frame->editor()->insertText(platformEvent->text(), event))
+ event->setDefaultHandled();
+ }
+ }
}
void EditorClient::handleInputMethodKeydown(KeyboardEvent* event)
@@ -537,10 +542,10 @@ void EditorClient::handleInputMethodKeydown(KeyboardEvent* event)
if (!targetFrame || !targetFrame->editor()->canEdit())
return;
+ // TODO: We need to decide which filtered keystrokes should be treated as IM
+ // events and which should not.
WebKitWebViewPrivate* priv = m_webView->priv;
- // TODO: Dispatch IE-compatible text input events for IM events.
- if (gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey()))
- event->setDefaultHandled();
+ gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey());
}
EditorClient::EditorClient(WebKitWebView* webView)
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
index 68c0435..1cf9aee 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
* Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther
* Copyright (C) 2007 Christian Dywan <christian@twotoasts.de>
- * Copyright (C) 2008 Collabora Ltd. All rights reserved.
+ * Copyright (C) 2008, 2009 Collabora Ltd. All rights reserved.
* Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
*
* This library is free software; you can redistribute it and/or
@@ -23,8 +23,10 @@
#include "config.h"
#include "FrameLoaderClientGtk.h"
+#include "ArchiveResource.h"
#include "Color.h"
#include "DocumentLoader.h"
+#include "DocumentLoaderGtk.h"
#include "FormState.h"
#include "FrameLoader.h"
#include "FrameView.h"
@@ -53,6 +55,7 @@
#include "ScriptController.h"
#include "webkiterror.h"
#include "webkitnetworkrequest.h"
+#include "webkitnetworkresponse.h"
#include "webkitprivate.h"
#include "webkitwebframe.h"
#include "webkitwebnavigationaction.h"
@@ -111,7 +114,13 @@ static void loadDone(WebKitWebFrame* frame, bool didSucceed)
WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClient::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData)
{
- return DocumentLoader::create(request, substituteData);
+ RefPtr<WebKit::DocumentLoader> loader = WebKit::DocumentLoader::create(request, substituteData);
+
+ WebKitWebDataSource* webDataSource = webkit_web_data_source_new_with_loader(loader.get());
+ loader->setDataSource(webDataSource);
+ g_object_unref(webDataSource);
+
+ return loader.release();
}
void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunction, PassRefPtr<FormState>)
@@ -120,11 +129,11 @@ void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunctio
ASSERT(policyFunction);
if (!policyFunction)
return;
- (core(m_frame)->loader()->*policyFunction)(PolicyUse);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyUse);
}
-void FrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
+void FrameLoaderClient::committedLoad(WebCore::DocumentLoader* loader, const char* data, int length)
{
if (!m_pluginView) {
ASSERT(loader->frame());
@@ -158,30 +167,68 @@ void FrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data,
}
bool
-FrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier)
+FrameLoaderClient::shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier)
{
notImplemented();
return false;
}
-void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
+void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
{
notImplemented();
}
-void FrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
+void FrameLoaderClient::dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&)
{
notImplemented();
}
-void FrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&)
+// We convert this to string because it's easier to use strings as
+// keys in a GHashTable.
+static char* toString(unsigned long identifier)
{
- notImplemented();
+ return g_strdup_printf("%ld", identifier);
}
-void FrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader*, const ResourceRequest&)
+void FrameLoaderClient::dispatchWillSendRequest(WebCore::DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
{
- notImplemented();
+ GOwnPtr<WebKitNetworkResponse> networkResponse(0);
+
+ // We are adding one more resource to the load, or maybe we are
+ // just redirecting a load.
+ if (redirectResponse.isNull())
+ static_cast<WebKit::DocumentLoader*>(loader)->increaseLoadCount(identifier);
+ else
+ networkResponse.set(webkit_network_response_new_with_core_response(redirectResponse));
+
+ WebKitWebView* webView = getViewFromFrame(m_frame);
+ GOwnPtr<gchar> identifierString(toString(identifier));
+ WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get());
+ GOwnPtr<WebKitNetworkRequest> networkRequest(webkit_network_request_new_with_core_request(request));
+
+ if (!redirectResponse.isNull()) {
+ // This is a redirect, so we need to update the WebResource's knowledge
+ // of the URI.
+ g_free(webResource->priv->uri);
+ webResource->priv->uri = g_strdup(request.url().string().utf8().data());
+ }
+
+ g_signal_emit_by_name(webView, "resource-request-starting", m_frame, webResource, networkRequest.get(), networkResponse.get());
+
+ // Feed any changes back into the ResourceRequest object.
+ SoupMessage* message = webkit_network_request_get_message(networkRequest.get());
+ if (!message) {
+ request.setURL(KURL(KURL(), String::fromUTF8(webkit_network_request_get_uri(networkRequest.get()))));
+ return;
+ }
+
+ request.updateFromSoupMessage(message);
+}
+
+void FrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const ResourceRequest& request)
+{
+ webkit_web_view_add_resource(getViewFromFrame(m_frame), toString(identifier),
+ WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, "uri", request.url().string().utf8().data(), 0)));
}
void FrameLoaderClient::postProgressStartedNotification()
@@ -221,7 +268,7 @@ void FrameLoaderClient::frameLoaderDestroyed()
delete this;
}
-void FrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse& response)
+void FrameLoaderClient::dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long, const ResourceResponse& response)
{
m_response = response;
}
@@ -233,7 +280,7 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli
return;
if (resourceRequest.isNull()) {
- (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore);
return;
}
@@ -300,7 +347,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFuncti
return;
if (resourceRequest.isNull()) {
- (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore);
return;
}
@@ -323,7 +370,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFuncti
// FIXME: I think Qt version marshals this to another thread so when we
// have multi-threaded download, we might need to do the same
if (!isHandled)
- (core(m_frame)->loader()->*policyFunction)(PolicyUse);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyUse);
}
void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>)
@@ -333,7 +380,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct
return;
if (resourceRequest.isNull()) {
- (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore);
return;
}
@@ -350,7 +397,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct
g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response);
if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) {
- (core(m_frame)->loader()->*policyFunction)(PolicyIgnore);
+ (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore);
g_object_unref(request);
return;
}
@@ -403,11 +450,11 @@ PassRefPtr<Widget> FrameLoaderClient::createPlugin(const IntSize& pluginSize, HT
PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool allowsScrolling, int marginWidth, int marginHeight)
{
- Frame* coreFrame = core(webFrame());
+ Frame* coreFrame = core(m_frame);
- ASSERT(core(getViewFromFrame(webFrame())) == coreFrame->page());
+ ASSERT(core(getViewFromFrame(m_frame)) == coreFrame->page());
- RefPtr<Frame> childFrame = webkit_web_frame_init_with_web_view(getViewFromFrame(webFrame()), ownerElement);
+ RefPtr<Frame> childFrame = webkit_web_frame_init_with_web_view(getViewFromFrame(m_frame), ownerElement);
coreFrame->tree()->appendChild(childFrame);
@@ -474,7 +521,7 @@ void FrameLoaderClient::windowObjectCleared()
// Is this obsolete now?
g_signal_emit_by_name(m_frame, "cleared");
- Frame* coreFrame = core(webFrame());
+ Frame* coreFrame = core(m_frame);
ASSERT(coreFrame);
Settings* settings = coreFrame->settings();
@@ -546,7 +593,17 @@ bool FrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
return item != 0;
}
-void FrameLoaderClient::makeRepresentation(DocumentLoader*)
+void FrameLoaderClient::didDisplayInsecureContent()
+{
+ notImplemented();
+}
+
+void FrameLoaderClient::didRunInsecureContent(SecurityOrigin*)
+{
+ notImplemented();
+}
+
+void FrameLoaderClient::makeRepresentation(WebCore::DocumentLoader*)
{
notImplemented();
}
@@ -700,22 +757,22 @@ void FrameLoaderClient::cancelPolicyCheck()
webkit_web_policy_decision_cancel(m_policyDecision);
}
-void FrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*)
+void FrameLoaderClient::dispatchDidLoadMainResource(WebCore::DocumentLoader*)
{
notImplemented();
}
-void FrameLoaderClient::revertToProvisionalState(DocumentLoader*)
+void FrameLoaderClient::revertToProvisionalState(WebCore::DocumentLoader*)
{
notImplemented();
}
-void FrameLoaderClient::willChangeTitle(DocumentLoader*)
+void FrameLoaderClient::willChangeTitle(WebCore::DocumentLoader*)
{
notImplemented();
}
-void FrameLoaderClient::didChangeTitle(DocumentLoader *l)
+void FrameLoaderClient::didChangeTitle(WebCore::DocumentLoader *l)
{
setTitle(l->title(), l->url());
}
@@ -744,7 +801,7 @@ String FrameLoaderClient::generatedMIMETypeForURLScheme(const String&) const
return String();
}
-void FrameLoaderClient::finishedLoading(DocumentLoader* documentLoader)
+void FrameLoaderClient::finishedLoading(WebCore::DocumentLoader* documentLoader)
{
if (!m_pluginView)
committedLoad(documentLoader, 0, 0);
@@ -758,7 +815,10 @@ void FrameLoaderClient::finishedLoading(DocumentLoader* documentLoader)
void FrameLoaderClient::provisionalLoadStarted()
{
- notImplemented();
+ WebKitWebView* webView = getViewFromFrame(m_frame);
+
+ if (m_frame == webkit_web_view_get_main_frame(webView))
+ webkit_web_view_clear_resources(webView);
}
void FrameLoaderClient::didFinishLoad() {
@@ -774,19 +834,45 @@ void FrameLoaderClient::setTitle(const String& title, const KURL& url)
frameData->title = g_strdup(title.utf8().data());
}
-void FrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int lengthReceived)
+void FrameLoaderClient::dispatchDidReceiveContentLength(WebCore::DocumentLoader*, unsigned long identifier, int lengthReceived)
{
notImplemented();
}
-void FrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier)
+void FrameLoaderClient::dispatchDidFinishLoading(WebCore::DocumentLoader* loader, unsigned long identifier)
{
+ static_cast<WebKit::DocumentLoader*>(loader)->decreaseLoadCount(identifier);
+
+ WebKitWebView* webView = getViewFromFrame(m_frame);
+ GOwnPtr<gchar> identifierString(toString(identifier));
+ WebKitWebResource* webResource = webkit_web_view_get_resource(webView, identifierString.get());
+
+ const char* uri = webkit_web_resource_get_uri(webResource);
+ RefPtr<ArchiveResource> coreResource(loader->subresource(KURL(KURL(), uri)));
+
+ // If coreResource is NULL here, the resource failed to load,
+ // unless it's the main resource.
+ if (!coreResource && webResource != webkit_web_view_get_main_resource(webView))
+ return;
+
+ if (!coreResource)
+ coreResource = loader->mainResource().releaseRef();
+
+ webkit_web_resource_init_with_core_resource(webResource, coreResource.get());
+
+ // FIXME: This function should notify the application that the resource
+ // finished loading, maybe using a load-status property in the
+ // WebKitWebResource object, similar to what we do for WebKitWebFrame'
+ // signal.
notImplemented();
}
-void FrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error)
+void FrameLoaderClient::dispatchDidFailLoading(WebCore::DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
{
- // FIXME: when does this occur and what should happen?
+ static_cast<WebKit::DocumentLoader*>(loader)->decreaseLoadCount(identifier);
+
+ // FIXME: This function should notify the application that the resource failed
+ // loading, maybe a 'load-error' signal in the WebKitWebResource object.
notImplemented();
}
@@ -795,7 +881,7 @@ void FrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long, c
notImplemented();
}
-bool FrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
+bool FrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length)
{
notImplemented();
return false;
@@ -804,12 +890,12 @@ bool FrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*,
void FrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error)
{
dispatchDidFailLoad(error);
-
- loadDone(m_frame, false);
}
void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
{
+ notifyStatus(m_frame, WEBKIT_LOAD_FAILED);
+
WebKitWebView* webView = getViewFromFrame(m_frame);
GError* webError = g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
error.errorCode(),
@@ -824,7 +910,6 @@ void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
if (!shouldFallBack(error)) {
g_error_free(webError);
- loadDone(m_frame, false);
return;
}
@@ -852,21 +937,14 @@ void FrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
g_object_unref(errorFile);
g_error_free(webError);
-
- loadDone(m_frame, false);
}
void FrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest&, const ResourceResponse& response)
{
- // FIXME: We could reuse the same handle here, but when I tried
- // implementing that the main load would fail and stop, so I have
- // simplified this case for now.
- handle->cancel();
-
- WebKitNetworkRequest* networkRequest = webkit_network_request_new(request.url().string().utf8().data());
+ WebKitNetworkRequest* networkRequest = webkit_network_request_new_with_core_request(request);
WebKitWebView* view = getViewFromFrame(m_frame);
- webkit_web_view_request_download(view, networkRequest, response);
+ webkit_web_view_request_download(view, networkRequest, response, handle);
g_object_unref(networkRequest);
}
@@ -943,7 +1021,7 @@ void FrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&)
notImplemented();
}
-void FrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error)
+void FrameLoaderClient::setMainDocumentError(WebCore::DocumentLoader*, const ResourceError& error)
{
if (m_pluginView) {
m_pluginView->didFail(error);
@@ -997,6 +1075,14 @@ void FrameLoaderClient::transitionToCommittedForNewPage()
WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow);
frame->view()->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment);
+
+ if (priv->currentMenu) {
+ GtkMenu* menu = priv->currentMenu;
+ priv->currentMenu = NULL;
+
+ gtk_menu_popdown(menu);
+ g_object_unref(menu);
+ }
}
}
diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
index bc64c2f..c820135 100644
--- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
+++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
@@ -136,6 +136,9 @@ namespace WebKit {
virtual void updateGlobalHistoryRedirectLinks();
virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const;
+ virtual void didDisplayInsecureContent();
+ virtual void didRunInsecureContent(WebCore::SecurityOrigin*);
+
virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&);
virtual WebCore::ResourceError blockedError(const WebCore::ResourceRequest&);
virtual WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&);
diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
index 908bffa..fef07c1 100644
--- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp
@@ -68,8 +68,13 @@ void InspectorClient::webViewDestroyed()
Page* InspectorClient::createPage()
{
- if (m_webView)
- return core(m_webView);
+ if (m_webView) {
+ gboolean handled = FALSE;
+ g_signal_emit_by_name(m_webInspector, "destroy", &handled);
+
+ /* we can now dispose our own reference */
+ g_object_unref(m_webInspector);
+ }
// This g_object_get will ref the inspector. We're not doing an
// unref if this method succeeds because the inspector object must
diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
index 5a7157e..f2ea316 100644
--- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
+++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp
@@ -67,4 +67,9 @@ GtkTargetList* PasteboardHelperGtk::getPasteTargetList(Frame* frame) const
return webkit_web_view_get_paste_target_list(webView);
}
+gint PasteboardHelperGtk::getWebViewTargetInfoHtml() const
+{
+ return WEBKIT_WEB_VIEW_TARGET_INFO_HTML;
+}
+
}
diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
index 4e66357..849b417 100644
--- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
+++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.h
@@ -45,6 +45,7 @@ public:
virtual GtkClipboard* getPrimary(Frame*) const;
virtual GtkTargetList* getCopyTargetList(Frame*) const;
virtual GtkTargetList* getPasteTargetList(Frame*) const;
+ virtual gint getWebViewTargetInfoHtml() const;
};
}
diff --git a/WebKit/gtk/docs/GNUmakefile.am b/WebKit/gtk/docs/GNUmakefile.am
index b34dace..968b7f6 100644
--- a/WebKit/gtk/docs/GNUmakefile.am
+++ b/WebKit/gtk/docs/GNUmakefile.am
@@ -80,10 +80,12 @@ INCLUDES= \
-I$(top_builddir)/DerivedSources \
$(GLOBALDEPS_CFLAGS) \
$(CAIRO_CFLAGS) \
+ $(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBSOUP_CFLAGS)
GTKDOC_LIBS= \
$(top_builddir)/libwebkit-1.0.la \
+ $(GLIB_LIBS) \
$(GTK_LIBS) \
$(LIBSOUP_LIBS)
diff --git a/WebKit/gtk/docs/webkitgtk-docs.sgml b/WebKit/gtk/docs/webkitgtk-docs.sgml
index 402b41a..ca608d4 100644
--- a/WebKit/gtk/docs/webkitgtk-docs.sgml
+++ b/WebKit/gtk/docs/webkitgtk-docs.sgml
@@ -19,9 +19,14 @@
<xi:include href="xml/webkitwebnavigationaction.xml"/>
<xi:include href="xml/webkitwebpolicydecision.xml"/>
<xi:include href="xml/webkitnetworkrequest.xml"/>
+ <xi:include href="xml/webkitnetworkresponse.xml"/>
<xi:include href="xml/webkitwebinspector.xml"/>
+ <xi:include href="xml/webkitwebdatabase.xml"/>
+ <xi:include href="xml/webkitwebdatasource.xml"/>
+ <xi:include href="xml/webkitwebresource.xml"/>
<xi:include href="xml/webkitdownload.xml"/>
<xi:include href="xml/webkitsoupauthdialog.xml"/>
+ <xi:include href="xml/webkitsecurityorigin.xml"/>
<xi:include href="xml/webkitwebwindowfeatures.xml"/>
</chapter>
@@ -75,4 +80,13 @@
<index id="index-1.1.11" role="1.1.11">
<title>Index of new symbols in 1.1.11</title>
</index>
+ <index id="index-1.1.13" role="1.1.13">
+ <title>Index of new symbols in 1.1.13</title>
+ </index>
+ <index id="index-1.1.14" role="1.1.14">
+ <title>Index of new symbols in 1.1.14</title>
+ </index>
+ <index id="index-1.1.15" role="1.1.15">
+ <title>Index of new symbols in 1.1.15</title>
+ </index>
</book>
diff --git a/WebKit/gtk/docs/webkitgtk-sections.txt b/WebKit/gtk/docs/webkitgtk-sections.txt
index d038ae9..a7b636c 100644
--- a/WebKit/gtk/docs/webkitgtk-sections.txt
+++ b/WebKit/gtk/docs/webkitgtk-sections.txt
@@ -1,6 +1,7 @@
<SECTION>
<FILE>webkitwebsettings</FILE>
<TITLE>WebKitWebSettings</TITLE>
+WebKitEditingBehavior
WebKitWebSettings
webkit_web_settings_copy
webkit_web_settings_new
@@ -85,12 +86,17 @@ WebKitWebHistoryItemClass
WebKitLoadStatus
WebKitWebFrame
webkit_web_frame_find_frame
+webkit_web_frame_get_data_source
webkit_web_frame_get_global_context
+webkit_web_frame_get_horizontal_scrollbar_policy
webkit_web_frame_get_load_status
webkit_web_frame_get_name
webkit_web_frame_get_parent
+webkit_web_frame_get_provisional_data_source
+webkit_web_frame_get_security_origin
webkit_web_frame_get_title
webkit_web_frame_get_uri
+webkit_web_frame_get_vertical_scrollbar_policy
webkit_web_frame_get_web_view
webkit_web_frame_load_alternate_string
webkit_web_frame_load_request
@@ -154,6 +160,105 @@ WebKitDownloadStatus
</SECTION>
<SECTION>
+<FILE>webkitsecurityorigin</FILE>
+<TITLE>WebKitSecurityOrigin</TITLE>
+WebKitSecurityOrigin
+webkit_security_origin_get_all_web_databases
+webkit_security_origin_get_host
+webkit_security_origin_get_port
+webkit_security_origin_get_protocol
+webkit_security_origin_get_type
+webkit_security_origin_get_web_database_quota
+webkit_security_origin_get_web_database_usage
+webkit_security_origin_set_web_database_quota
+<SUBSECTION Standard>
+WEBKIT_SECURITY_ORIGIN
+WEBKIT_SECURITY_ORIGIN_CLASS
+WEBKIT_SECURITY_ORIGIN_GET_CLASS
+WEBKIT_IS_SECURITY_ORIGIN
+WEBKIT_IS_SECURITY_ORIGIN_CLASS
+WEBKIT_TYPE_SECURITY_ORIGIN
+<SUBSECTION Private>
+WebKitSecurityOrigin
+WebKitSecurityOriginClass
+WebKitSecurityOriginPrivate
+</SECTION>
+
+<SECTION>
+<FILE>webkithittestresult</FILE>
+<TITLE>WebKitHitTestResult</TITLE>
+WebKitHitTestResult
+WebKitHitTestResultContext
+<SUBSECTION Standard>
+WEBKIT_HIT_TEST_RESULT
+WEBKIT_HIT_TEST_RESULT_CLASS
+WEBKIT_HIT_TEST_RESULT_GET_CLASS
+WEBKIT_IS_HIT_TEST_RESULT
+WEBKIT_IS_HIT_TEST_RESULT_CLASS
+WEBKIT_TYPE_HIT_TEST_RESULT
+<SUBSECTION Private>
+WebKitHitTestResult
+WebKitHitTestResultClass
+WebKitHitTestResultContext
+WebKitHitTestResultPrivate
+webkit_hit_test_result_get_type
+</SECTION>
+
+<SECTION>
+<FILE>webkitwebdatasource</FILE>
+<TITLE>WebKitWebDataSource</TITLE>
+WebKitWebDataSource
+webkit_web_data_source_get_data
+webkit_web_data_source_get_encoding
+webkit_web_data_source_get_initial_request
+webkit_web_data_source_get_main_resource
+webkit_web_data_source_get_request
+webkit_web_data_source_get_subresources
+webkit_web_data_source_get_unreachable_uri
+webkit_web_data_source_get_web_frame
+webkit_web_data_source_is_loading
+webkit_web_data_source_new
+<SUBSECTION Standard>
+WEBKIT_IS_WEB_DATA_SOURCE
+WEBKIT_IS_WEB_DATA_SOURCE_CLASS
+WEBKIT_TYPE_WEB_DATA_SOURCE
+WEBKIT_WEB_DATA_SOURCE
+WEBKIT_WEB_DATA_SOURCE_CLASS
+WEBKIT_WEB_DATA_SOURCE_GET_CLASS
+<SUBSECTION Private>
+WebKitWebDataSource
+WebKitWebDataSourceClass
+WebKitWebDataSourcePrivate
+webkit_web_data_source_new_with_request
+webkit_web_data_source_get_type
+</SECTION>
+
+<SECTION>
+<FILE>webkitwebdatabase</FILE>
+<TITLE>WebKitWebDatabase</TITLE>
+WebKitWebDatabase
+webkit_web_database_get_display_name
+webkit_web_database_get_expected_size
+webkit_web_database_get_filename
+webkit_web_database_get_name
+webkit_web_database_get_security_origin
+webkit_web_database_get_size
+webkit_web_database_remove
+<SUBSECTION Standard>
+WEBKIT_IS_WEB_DATABASE
+WEBKIT_IS_WEB_DATABASE_CLASS
+WEBKIT_TYPE_WEB_DATABASE
+WEBKIT_WEB_DATABASE
+WEBKIT_WEB_DATABASE_CLASS
+WEBKIT_WEB_DATABASE_GET_CLASS
+<SUBSECTION Private>
+WebKitWebDatabase
+WebKitWebDatabaseClass
+WebKitWebDatabasePrivate
+webkit_web_database_get_type
+</SECTION>
+
+<SECTION>
<FILE>webkitsoupauthdialog</FILE>
<TITLE>WebKitSoupAuthDialog</TITLE>
WebKitSoupAuthDialog
@@ -199,6 +304,7 @@ webkit_web_navigation_action_get_button
webkit_web_navigation_action_get_modifier_state
webkit_web_navigation_action_get_original_uri
webkit_web_navigation_action_get_reason
+webkit_web_navigation_action_get_target_frame
webkit_web_navigation_action_get_type
webkit_web_navigation_action_set_original_uri
webkit_web_navigation_action_set_reason
@@ -261,6 +367,28 @@ WebKitNetworkRequestClass
</SECTION>
<SECTION>
+<FILE>webkitnetworkresponse</FILE>
+<TITLE>WebKitNetworkResponse</TITLE>
+WebKitNetworkResponse
+webkit_network_response_get_uri
+webkit_network_response_get_message
+webkit_network_response_set_uri
+<SUBSECTION Standard>
+WEBKIT_NETWORK_RESPONSE
+WEBKIT_IS_NETWORK_RESPONSE
+WEBKIT_TYPE_NETWORK_RESPONSE
+WEBKIT_NETWORK_RESPONSE_CLASS
+WEBKIT_IS_NETWORK_RESPONSE_CLASS
+WEBKIT_NETWORK_RESPONSE_GET_CLASS
+<SUBSECTION Private>
+webkit_network_response_get_type
+webkit_network_response_new
+WebKitNetworkResponsePrivate
+WebKitNetworkResponse
+WebKitNetworkResponseClass
+</SECTION>
+
+<SECTION>
<FILE>webkitwebview</FILE>
WebKitNavigationResponse
WebKitWebViewTargetInfo
@@ -272,7 +400,9 @@ webkit_web_view_can_go_back
webkit_web_view_can_go_back_or_forward
webkit_web_view_can_go_forward
webkit_web_view_can_paste_clipboard
+webkit_web_view_can_redo
webkit_web_view_can_show_mime_type
+webkit_web_view_can_undo
webkit_web_view_copy_clipboard
webkit_web_view_cut_clipboard
webkit_web_view_delete_selection
@@ -284,6 +414,7 @@ webkit_web_view_get_editable
webkit_web_view_get_encoding
webkit_web_view_get_focused_frame
webkit_web_view_get_full_content_zoom
+webkit_web_view_get_hit_test_result
webkit_web_view_get_inspector
webkit_web_view_get_load_status
webkit_web_view_get_main_frame
@@ -293,6 +424,7 @@ webkit_web_view_get_settings
webkit_web_view_get_title
webkit_web_view_get_transparent
webkit_web_view_get_uri
+webkit_web_view_get_view_source_mode
webkit_web_view_get_zoom_level
webkit_web_view_go_back
webkit_web_view_go_back_or_forward
@@ -308,6 +440,7 @@ webkit_web_view_move_cursor
webkit_web_view_new
webkit_web_view_open
webkit_web_view_paste_clipboard
+webkit_web_view_redo
webkit_web_view_reload
webkit_web_view_reload_bypass_cache
webkit_web_view_search_text
@@ -319,9 +452,11 @@ webkit_web_view_set_highlight_text_matches
webkit_web_view_set_maintains_back_forward_list
webkit_web_view_set_settings
webkit_web_view_set_transparent
+webkit_web_view_set_view_source_mode
webkit_web_view_set_zoom_level
webkit_web_view_stop_loading
webkit_web_view_target_info_get_type
+webkit_web_view_undo
webkit_web_view_unmark_text_matches
webkit_web_view_zoom_in
webkit_web_view_zoom_out
@@ -366,6 +501,37 @@ WebKitWebWindowFeaturesPrivate
<FILE>webkit</FILE>
webkit_init
webkit_get_default_session
+webkit_get_default_web_database_quota
+webkit_get_web_database_directory_path
+webkit_remove_all_web_databases
+webkit_set_default_web_database_quota
+webkit_set_web_database_directory_path
+</SECTION>
+
+<SECTION>
+<FILE>webkitwebresource</FILE>
+<TITLE>WebKitWebResource</TITLE>
+WebKitWebResource
+webkit_web_resource_get_data
+webkit_web_resource_get_encoding
+webkit_web_resource_get_frame_name
+webkit_web_resource_get_mime_type
+webkit_web_resource_get_type
+webkit_web_resource_get_uri
+webkit_web_resource_new
+<SUBSECTION Standard>
+WEBKIT_WEB_RESOURCE
+WEBKIT_IS_WEB_RESOURCE
+WEBKIT_TYPE_WEB_RESOURCE
+WEBKIT_WEB_RESOURCE_CLASS
+WEBKIT_IS_WEB_RESOURCE_CLASS
+WEBKIT_WEB_RESOURCE_GET_CLASS
+<SUBSECTION Private>
+webkit_web_resource_get_type
+webkit_web_resource_new
+WebKitWebResourcePrivate
+WebKitWebResource
+WebKitWebResourceClass
</SECTION>
<SECTION>
diff --git a/WebKit/gtk/tests/testatk.c b/WebKit/gtk/tests/testatk.c
index 61eae60..3910347 100644
--- a/WebKit/gtk/tests/testatk.c
+++ b/WebKit/gtk/tests/testatk.c
@@ -60,6 +60,8 @@ static void test_webkit_atk_get_text_at_offset(void)
webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
g_object_ref_sink(webView);
+ GtkAllocation alloc = { 0, 0, 800, 600 };
+ gtk_widget_size_allocate(GTK_WIDGET(webView), &alloc);
webkit_web_view_load_string(webView, contents, NULL, NULL, NULL);
loop = g_main_loop_new(NULL, TRUE);
diff --git a/WebKit/gtk/tests/testhittestresult.c b/WebKit/gtk/tests/testhittestresult.c
new file mode 100644
index 0000000..defda7a
--- /dev/null
+++ b/WebKit/gtk/tests/testhittestresult.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2009 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <glib/gstdio.h>
+#include <webkit/webkit.h>
+
+#if GTK_CHECK_VERSION(2, 14, 0)
+
+typedef struct {
+ char* data;
+ guint flag;
+} TestInfo;
+
+static GMainLoop* loop;
+
+typedef struct {
+ WebKitWebView* webView;
+ TestInfo* info;
+} HitTestResultFixture;
+
+TestInfo*
+test_info_new(const char* data, guint flag)
+{
+ TestInfo* info;
+
+ info = g_slice_new(TestInfo);
+ info->data = g_strdup(data);
+ info->flag = flag;
+
+ return info;
+}
+
+void
+test_info_destroy(TestInfo* info)
+{
+ g_free(info->data);
+ g_slice_free(TestInfo, info);
+}
+
+static void hit_test_result_fixture_setup(HitTestResultFixture* fixture, gconstpointer data)
+{
+ fixture->webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(fixture->webView);
+ loop = g_main_loop_new(NULL, TRUE);
+ fixture->info = (TestInfo*)data;
+}
+
+static void hit_test_result_fixture_teardown(HitTestResultFixture* fixture, gconstpointer data)
+{
+ g_object_unref(fixture->webView);
+ g_main_loop_unref(loop);
+ test_info_destroy(fixture->info);
+}
+
+static void
+load_status_cb(WebKitWebView* webView,
+ GParamSpec* spec,
+ gpointer data)
+{
+ WebKitLoadStatus status = webkit_web_view_get_load_status(webView);
+ TestInfo* info = (TestInfo*)data;
+
+ if (status == WEBKIT_LOAD_FINISHED) {
+ WebKitHitTestResult* result;
+ guint context;
+ GdkEventButton event;
+ event.type = GDK_BUTTON_PRESS;
+ /* Close enough to 0,0 */
+ event.x = 5;
+ event.y = 5;
+
+ result = webkit_web_view_get_hit_test_result(webView, &event);
+ g_assert(result);
+ g_object_get(result, "context", &context, NULL);
+ g_assert(context & info->flag);
+ g_object_unref(result);
+ g_main_loop_quit(loop);
+ }
+}
+
+static void
+test_webkit_hit_test_result(HitTestResultFixture* fixture, gconstpointer data)
+{
+ TestInfo* info = (TestInfo*)data;
+ GtkAllocation allocation = { 0, 0, 50, 50 };
+
+ webkit_web_view_load_string(fixture->webView,
+ info->data,
+ "text/html",
+ "utf-8",
+ "file://");
+ gtk_widget_size_allocate(GTK_WIDGET(fixture->webView), &allocation);
+ g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_status_cb), info);
+ g_main_loop_run(loop);
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+
+ g_test_add("/webkit/hittestresult/document", HitTestResultFixture,
+ test_info_new("<html><body><h1>WebKitGTK+!</h1></body></html>",
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT),
+ hit_test_result_fixture_setup, test_webkit_hit_test_result, hit_test_result_fixture_teardown);
+ /* We hardcode all elements to be at 0,0 so that we know where to
+ * generate the button events */
+ g_test_add("/webkit/hittestresult/image", HitTestResultFixture,
+ test_info_new("<html><body><img style='position:absolute; left:0; top:0'src='0xdeadbeef' width=50 height=50></img></body></html>",
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE),
+ hit_test_result_fixture_setup, test_webkit_hit_test_result, hit_test_result_fixture_teardown);
+ g_test_add("/webkit/hittestresult/editable", HitTestResultFixture,
+ test_info_new("<html><body><input style='position:absolute; left:0; top:0' size='35'></input>></body></html>",
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE),
+ hit_test_result_fixture_setup, test_webkit_hit_test_result, hit_test_result_fixture_teardown);
+ g_test_add("/webkit/hittestresult/link", HitTestResultFixture,
+ test_info_new("<html><body><a style='position:absolute; left:0; top:0' href='http://www.example.com'>HELLO WORLD</a></body></html>",
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK),
+ hit_test_result_fixture_setup, test_webkit_hit_test_result, hit_test_result_fixture_teardown);
+
+ return g_test_run ();
+}
+
+#else
+
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least GTK+ 2.14.0 to run the unit tests.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/tests/testkeyevents.c b/WebKit/gtk/tests/testkeyevents.c
new file mode 100644
index 0000000..ee7728c
--- /dev/null
+++ b/WebKit/gtk/tests/testkeyevents.c
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2009 Martin Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <glib/gstdio.h>
+#include <webkit/webkit.h>
+
+#if GTK_CHECK_VERSION(2, 14, 0)
+
+typedef struct {
+ char* page;
+ gboolean shouldBeHandled;
+} TestInfo;
+
+typedef struct {
+ GtkWidget* window;
+ WebKitWebView* webView;
+ GMainLoop* loop;
+ TestInfo* info;
+} KeyEventFixture;
+
+TestInfo*
+test_info_new(const char* page, gboolean shouldBeHandled)
+{
+ TestInfo* info;
+
+ info = g_slice_new(TestInfo);
+ info->page = g_strdup(page);
+ info->shouldBeHandled = shouldBeHandled;
+
+ return info;
+}
+
+void
+test_info_destroy(TestInfo* info)
+{
+ g_free(info->page);
+ g_slice_free(TestInfo, info);
+}
+
+static void key_event_fixture_setup(KeyEventFixture* fixture, gconstpointer data)
+{
+ fixture->loop = g_main_loop_new(NULL, TRUE);
+
+ fixture->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ fixture->webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+
+ gtk_container_add(GTK_CONTAINER(fixture->window), GTK_WIDGET(fixture->webView));
+}
+
+static void key_event_fixture_teardown(KeyEventFixture* fixture, gconstpointer data)
+{
+ gtk_widget_destroy(fixture->window);
+ g_main_loop_unref(fixture->loop);
+ test_info_destroy(fixture->info);
+}
+
+static gboolean key_press_event_cb(WebKitWebView* webView, GdkEvent* event, gpointer data)
+{
+ KeyEventFixture* fixture = (KeyEventFixture*)data;
+ gboolean handled = GTK_WIDGET_GET_CLASS(fixture->webView)->key_press_event(GTK_WIDGET(fixture->webView), &event->key);
+ g_assert_cmpint(handled, ==, fixture->info->shouldBeHandled);
+
+ return FALSE;
+}
+
+
+static gboolean key_release_event_cb(WebKitWebView* webView, GdkEvent* event, gpointer data)
+{
+ // WebCore never seems to mark keyup events as handled.
+ KeyEventFixture* fixture = (KeyEventFixture*)data;
+ gboolean handled = GTK_WIDGET_GET_CLASS(fixture->webView)->key_press_event(GTK_WIDGET(fixture->webView), &event->key);
+ g_assert(!handled);
+
+ g_main_loop_quit(fixture->loop);
+
+ return FALSE;
+}
+
+static void load_status_cb(WebKitWebView* webView, GParamSpec* spec, gpointer data)
+{
+ KeyEventFixture* fixture = (KeyEventFixture*)data;
+ WebKitLoadStatus status = webkit_web_view_get_load_status(webView);
+ if (status == WEBKIT_LOAD_FINISHED) {
+ gtk_test_widget_send_key(GTK_WIDGET(fixture->webView),
+ gdk_unicode_to_keyval('a'), 0);
+ }
+
+}
+
+gboolean map_event_cb(GtkWidget *widget, GdkEvent* event, gpointer data)
+{
+ gtk_widget_grab_focus(widget);
+ KeyEventFixture* fixture = (KeyEventFixture*)data;
+
+ g_signal_connect(fixture->webView, "key-press-event",
+ G_CALLBACK(key_press_event_cb), fixture);
+ g_signal_connect(fixture->webView, "key-release-event",
+ G_CALLBACK(key_release_event_cb), fixture);
+
+ g_signal_connect(fixture->webView, "notify::load-status",
+ G_CALLBACK(load_status_cb), fixture);
+
+ webkit_web_view_load_string(fixture->webView, fixture->info->page,
+ "text/html", "utf-8", "file://");
+
+ return FALSE;
+}
+
+static void test_keypress(KeyEventFixture* fixture, gconstpointer data)
+{
+ fixture->info = (TestInfo*)data;
+
+ g_signal_connect(fixture->window, "map-event",
+ G_CALLBACK(map_event_cb), fixture);
+
+ gtk_widget_show(fixture->window);
+ gtk_widget_show(GTK_WIDGET(fixture->webView));
+ gtk_window_present(GTK_WINDOW(fixture->window));
+
+ g_main_loop_run(fixture->loop);
+
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+
+ g_test_add("/webkit/keyevent/textfield", KeyEventFixture,
+ test_info_new("<html><body><input id=\"in\" type=\"text\">"
+ "<script>document.getElementById('in').focus();"
+ "</script></body></html>", TRUE),
+ key_event_fixture_setup,
+ test_keypress,
+ key_event_fixture_teardown);
+
+ g_test_add("/webkit/keyevent/buttons", KeyEventFixture,
+ test_info_new("<html><body><input id=\"in\" type=\"button\">"
+ "<script>document.getElementById('in').focus();"
+ "</script></body></html>", FALSE),
+ key_event_fixture_setup,
+ test_keypress,
+ key_event_fixture_teardown);
+
+ g_test_add("/webkit/keyevent/link", KeyEventFixture,
+ test_info_new("<html><body><a href=\"http://www.gnome.org\" id=\"in\">"
+ "LINKY MCLINKERSON</a><script>"
+ "document.getElementById('in').focus();</script>"
+ "</body></html>", FALSE),
+ key_event_fixture_setup,
+ test_keypress,
+ key_event_fixture_teardown);
+
+ return g_test_run();
+}
+
+#else
+
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least GTK+ 2.14.0 to run the unit tests.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/tests/testloading.c b/WebKit/gtk/tests/testloading.c
index cd5f08e..c1f0fac 100644
--- a/WebKit/gtk/tests/testloading.c
+++ b/WebKit/gtk/tests/testloading.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Gustavo Noronha Silva
+ * Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -22,77 +23,201 @@
#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
-static gboolean has_been_provisional = FALSE;
-static gboolean has_been_committed = FALSE;
-static gboolean has_been_first_visually_non_empty_layout = FALSE;
+typedef struct {
+ WebKitWebView* webView;
+ GMainLoop *loop;
+ gboolean has_been_provisional;
+ gboolean has_been_committed;
+ gboolean has_been_first_visually_non_empty_layout;
+ gboolean has_been_finished;
+ gboolean has_been_failed;
+ gboolean has_been_load_error;
+} WebLoadingFixture;
+
+static void web_loading_fixture_setup(WebLoadingFixture* fixture, gconstpointer data)
+{
+ fixture->webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ fixture->loop = g_main_loop_new(NULL, TRUE);
+ g_object_ref_sink(fixture->webView);
+ fixture->has_been_provisional = FALSE;
+ fixture->has_been_committed = FALSE;
+ fixture->has_been_first_visually_non_empty_layout = FALSE;
+ fixture->has_been_finished = FALSE;
+ fixture->has_been_failed = FALSE;
+ fixture->has_been_load_error = FALSE;
+}
-static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, gpointer data)
+static void web_loading_fixture_teardown(WebLoadingFixture* fixture, gconstpointer data)
{
- GMainLoop* loop = (GMainLoop*)data;
+ g_object_unref(fixture->webView);
+ g_main_loop_unref(fixture->loop);
+}
- g_assert(has_been_provisional);
- g_assert(has_been_committed);
- g_assert(has_been_first_visually_non_empty_layout);
+static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, WebLoadingFixture* fixture)
+{
+ g_assert(fixture->has_been_provisional);
+ g_assert(fixture->has_been_committed);
+ g_assert(fixture->has_been_first_visually_non_empty_layout);
- g_main_loop_quit(loop);
+ g_main_loop_quit(fixture->loop);
}
-static void status_changed_cb(GObject* object, GParamSpec* pspec, gpointer data)
+static void status_changed_cb(GObject* object, GParamSpec* pspec, WebLoadingFixture* fixture)
{
WebKitLoadStatus status = webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(object));
switch (status) {
case WEBKIT_LOAD_PROVISIONAL:
- g_assert(!has_been_provisional);
- g_assert(!has_been_committed);
- g_assert(!has_been_first_visually_non_empty_layout);
- has_been_provisional = TRUE;
+ g_assert(!fixture->has_been_provisional);
+ g_assert(!fixture->has_been_committed);
+ g_assert(!fixture->has_been_first_visually_non_empty_layout);
+ fixture->has_been_provisional = TRUE;
break;
case WEBKIT_LOAD_COMMITTED:
- g_assert(has_been_provisional);
- g_assert(!has_been_committed);
- g_assert(!has_been_first_visually_non_empty_layout);
- has_been_committed = TRUE;
+ g_assert(fixture->has_been_provisional);
+ g_assert(!fixture->has_been_committed);
+ g_assert(!fixture->has_been_first_visually_non_empty_layout);
+ fixture->has_been_committed = TRUE;
break;
case WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT:
- g_assert(has_been_provisional);
- g_assert(has_been_committed);
- g_assert(!has_been_first_visually_non_empty_layout);
- has_been_first_visually_non_empty_layout = TRUE;
+ g_assert(fixture->has_been_provisional);
+ g_assert(fixture->has_been_committed);
+ g_assert(!fixture->has_been_first_visually_non_empty_layout);
+ fixture->has_been_first_visually_non_empty_layout = TRUE;
break;
case WEBKIT_LOAD_FINISHED:
- g_assert(has_been_provisional);
- g_assert(has_been_committed);
- g_assert(has_been_first_visually_non_empty_layout);
+ g_assert(fixture->has_been_provisional);
+ g_assert(fixture->has_been_committed);
+ g_assert(fixture->has_been_first_visually_non_empty_layout);
break;
default:
g_assert_not_reached();
}
}
-static void test_loading_status()
+static void test_loading_status(WebLoadingFixture* fixture, gconstpointer data)
{
- WebKitWebView* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
- GMainLoop* loop = g_main_loop_new(NULL, TRUE);
+ g_assert_cmpint(webkit_web_view_get_load_status(fixture->webView), ==, WEBKIT_LOAD_PROVISIONAL);
- g_object_ref_sink(web_view);
-
- g_assert_cmpint(webkit_web_view_get_load_status(web_view), ==, WEBKIT_LOAD_PROVISIONAL);
-
- g_object_connect(G_OBJECT(web_view),
- "signal::notify::load-status", G_CALLBACK(status_changed_cb), NULL,
- "signal::load-finished", G_CALLBACK(load_finished_cb), loop,
+ g_object_connect(G_OBJECT(fixture->webView),
+ "signal::notify::load-status", G_CALLBACK(status_changed_cb), fixture,
+ "signal::load-finished", G_CALLBACK(load_finished_cb), fixture,
NULL);
/* load_uri will trigger the navigation-policy-decision-requested
* signal emission;
*/
- webkit_web_view_load_uri(web_view, "http://gnome.org/");
+ webkit_web_view_load_uri(fixture->webView, "http://gnome.org/");
+
+ g_main_loop_run(fixture->loop);
+}
+
+static void load_error_status_changed_cb(GObject* object, GParamSpec* pspec, WebLoadingFixture* fixture)
+{
+ WebKitLoadStatus status = webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(object));
+
+ switch(status) {
+ case WEBKIT_LOAD_PROVISIONAL:
+ /* We are going to go through here twice, so don't assert
+ * anything */
+ fixture->has_been_provisional = TRUE;
+ break;
+ case WEBKIT_LOAD_FINISHED:
+ g_assert(fixture->has_been_provisional);
+ g_assert(fixture->has_been_load_error);
+ g_assert(fixture->has_been_failed);
+ /* We are checking that only one FINISHED is received in the
+ whole cycle, so assert it's FALSE */
+ g_assert(!fixture->has_been_finished);
+ fixture->has_been_finished = TRUE;
+ g_main_loop_quit(fixture->loop);
+ break;
+ case WEBKIT_LOAD_FAILED:
+ g_assert(!fixture->has_been_failed);
+ fixture->has_been_failed = TRUE;
+ break;
+ default:
+ break;
+ }
+}
+
+static gboolean load_error_cb(WebKitWebView* webView, WebKitWebFrame* frame, const char* uri, GError *error, WebLoadingFixture* fixture)
+{
+ g_assert(fixture->has_been_provisional);
+ g_assert(!fixture->has_been_load_error);
+ fixture->has_been_load_error = TRUE;
+
+ return FALSE;
+}
+
+static void test_loading_error(WebLoadingFixture* fixture, gconstpointer data)
+{
+ g_test_bug("28842");
+
+ g_signal_connect(fixture->webView, "load-error", G_CALLBACK(load_error_cb), fixture);
+ g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_error_status_changed_cb), fixture);
+
+ webkit_web_view_load_uri(fixture->webView, "http://snoetuhsetuhseoutoeutc.com/");
+ g_main_loop_run(fixture->loop);
+}
+
+/* Cancelled load */
+
+static gboolean load_cancelled_cb(WebKitWebView* webView, WebKitWebFrame* frame, const char* uri, GError *error, WebLoadingFixture* fixture)
+{
+ g_assert(fixture->has_been_provisional);
+ g_assert(fixture->has_been_failed);
+ g_assert(!fixture->has_been_load_error);
+ g_assert(error->code == WEBKIT_NETWORK_ERROR_CANCELLED);
+ fixture->has_been_load_error = TRUE;
+
+ return TRUE;
+}
+
+static gboolean stop_load (gpointer data)
+{
+ webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(data));
+ return FALSE;
+}
+
+static void load_cancelled_status_changed_cb(GObject* object, GParamSpec* pspec, WebLoadingFixture* fixture)
+{
+ WebKitLoadStatus status = webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(object));
+
+ switch(status) {
+ case WEBKIT_LOAD_PROVISIONAL:
+ g_assert(!fixture->has_been_provisional);
+ g_assert(!fixture->has_been_failed);
+ fixture->has_been_provisional = TRUE;
+ break;
+ case WEBKIT_LOAD_COMMITTED:
+ g_idle_add (stop_load, object);
+ break;
+ case WEBKIT_LOAD_FAILED:
+ g_assert(fixture->has_been_provisional);
+ g_assert(!fixture->has_been_failed);
+ g_assert(!fixture->has_been_load_error);
+ fixture->has_been_failed = TRUE;
+ g_main_loop_quit(fixture->loop);
+ break;
+ case WEBKIT_LOAD_FINISHED:
+ g_assert_not_reached();
+ break;
+ default:
+ break;
+ }
+}
+
+static void test_loading_cancelled(WebLoadingFixture* fixture, gconstpointer data)
+{
+ g_test_bug("29644");
- g_main_loop_run(loop);
+ g_signal_connect(fixture->webView, "load-error", G_CALLBACK(load_cancelled_cb), fixture);
+ g_signal_connect(fixture->webView, "notify::load-status", G_CALLBACK(load_cancelled_status_changed_cb), fixture);
- g_object_unref(web_view);
+ webkit_web_view_load_uri(fixture->webView, "http://google.com/");
+ g_main_loop_run(fixture->loop);
}
int main(int argc, char** argv)
@@ -101,7 +226,21 @@ int main(int argc, char** argv)
gtk_test_init(&argc, &argv, NULL);
g_test_bug_base("https://bugs.webkit.org/");
- g_test_add_func("/webkit/loading/status", test_loading_status);
+ g_test_add("/webkit/loading/status",
+ WebLoadingFixture, NULL,
+ web_loading_fixture_setup,
+ test_loading_status,
+ web_loading_fixture_teardown);
+ g_test_add("/webkit/loading/error",
+ WebLoadingFixture, NULL,
+ web_loading_fixture_setup,
+ test_loading_error,
+ web_loading_fixture_teardown);
+ g_test_add("/webkit/loading/cancelled",
+ WebLoadingFixture, NULL,
+ web_loading_fixture_setup,
+ test_loading_cancelled,
+ web_loading_fixture_teardown);
return g_test_run();
}
diff --git a/WebKit/gtk/tests/testnetworkresponse.c b/WebKit/gtk/tests/testnetworkresponse.c
new file mode 100644
index 0000000..9050c04
--- /dev/null
+++ b/WebKit/gtk/tests/testnetworkresponse.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009 Gustavo Noronha Silva
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include <webkit/webkit.h>
+
+#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+
+static void test_network_response_create_destroy()
+{
+ WebKitNetworkResponse* response;
+ SoupMessage* message;
+
+ /* Test creation with URI */
+ response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", "http://debian.org/", NULL));
+ g_assert(WEBKIT_IS_NETWORK_RESPONSE(response));
+ message = webkit_network_response_get_message(response);
+ g_assert(!message);
+ g_object_unref(response);
+
+ /* Test creation with SoupMessage */
+ message = soup_message_new("GET", "http://debian.org/");
+ response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", message, NULL));
+ g_assert(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_assert_cmpint(G_OBJECT(message)->ref_count, ==, 2);
+ g_object_unref(response);
+ g_assert_cmpint(G_OBJECT(message)->ref_count, ==, 1);
+ g_object_unref(message);
+
+ /* Test creation with both SoupMessage and URI */
+ message = soup_message_new("GET", "http://debian.org/");
+ response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", message, "uri", "http://gnome.org/", NULL));
+ g_assert(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_assert_cmpint(G_OBJECT(message)->ref_count, ==, 2);
+ g_assert_cmpstr(webkit_network_response_get_uri(response), ==, "http://gnome.org/");
+ g_object_unref(response);
+ g_assert_cmpint(G_OBJECT(message)->ref_count, ==, 1);
+ g_object_unref(message);
+}
+
+static void test_network_response_properties()
+{
+ WebKitNetworkResponse* response;
+ SoupMessage* message;
+ gchar* soupURI;
+
+ /* Test URI is set correctly when creating with URI */
+ response = webkit_network_response_new("http://debian.org/");
+ g_assert(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_assert_cmpstr(webkit_network_response_get_uri(response), ==, "http://debian.org/");
+ g_object_unref(response);
+
+ /* Test URI is set correctly when creating with Message */
+ message = soup_message_new("GET", "http://debian.org/");
+ response = WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", message, NULL));
+ g_assert(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_object_unref(message);
+
+ message = webkit_network_response_get_message(response);
+ soupURI = soup_uri_to_string(soup_message_get_uri(message), FALSE);
+ g_assert_cmpstr(soupURI, ==, "http://debian.org/");
+ g_free(soupURI);
+
+ g_assert_cmpstr(webkit_network_response_get_uri(response), ==, "http://debian.org/");
+ g_object_unref(response);
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+ g_test_add_func("/webkit/networkresponse/createdestroy", test_network_response_create_destroy);
+ g_test_add_func("/webkit/networkresponse/properties", test_network_response_properties);
+ return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/tests/testwebdatasource.c b/WebKit/gtk/tests/testwebdatasource.c
new file mode 100644
index 0000000..de2430f
--- /dev/null
+++ b/WebKit/gtk/tests/testwebdatasource.c
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2009 Jan Michael Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+
+static const gshort defaultTimeout = 10;
+guint waitTimer;
+gboolean shouldWait;
+
+typedef struct {
+ WebKitWebView* webView;
+ WebKitWebFrame* mainFrame;
+} WebDataSourceFixture;
+
+static void test_webkit_web_data_source_get_initial_request()
+{
+ WebKitWebView* view;
+ WebKitWebFrame* frame;
+ WebKitWebDataSource* dataSource;
+ WebKitNetworkRequest* initialRequest;
+
+ view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(view);
+ frame = webkit_web_view_get_main_frame(view);
+
+ WebKitNetworkRequest* request = webkit_network_request_new("http://www.google.com");
+ webkit_web_frame_load_request(frame, request);
+ g_object_unref(request);
+
+ dataSource = webkit_web_frame_get_provisional_data_source(frame);
+ g_assert(dataSource);
+ initialRequest = webkit_web_data_source_get_initial_request(dataSource);
+ g_assert_cmpstr(webkit_network_request_get_uri(initialRequest), ==, "http://www.google.com/");
+
+ g_object_unref(view);
+}
+
+static void load_finished_unreachable_cb(WebKitWebView* view, WebKitWebFrame* frame, GMainLoop* loop)
+{
+ if (waitTimer) {
+ g_source_remove(waitTimer);
+ waitTimer = 0;
+ }
+
+ WebKitWebDataSource* datasource;
+ frame = webkit_web_view_get_main_frame(view);
+ datasource = webkit_web_frame_get_data_source(frame);
+
+ g_assert_cmpstr("http://localhost/doireallyexist.html", ==,
+ webkit_web_data_source_get_unreachable_uri(datasource));
+
+ if (g_main_loop_is_running(loop))
+ g_main_loop_quit(loop);
+}
+
+static void load_finished_cb(WebKitWebView* view, WebKitWebFrame* frame, GMainLoop* loop)
+{
+ if (waitTimer) {
+ g_source_remove(waitTimer);
+ waitTimer = 0;
+ }
+
+ WebKitWebDataSource* dataSource;
+ frame = webkit_web_view_get_main_frame(view);
+ dataSource = webkit_web_frame_get_data_source(frame);
+
+ /* Test get_request */
+ g_test_message("Testing webkit_web_data_source_get_request");
+ WebKitNetworkRequest* request = webkit_web_data_source_get_request(dataSource);
+ g_assert_cmpstr(webkit_network_request_get_uri(request), ==, "http://webkit.org/");
+
+ /* Test get_main_resource */
+ g_test_message("Testing webkit_web_data_source_get_main_resource");
+ WebKitWebResource* resource = webkit_web_data_source_get_main_resource(dataSource);
+ g_assert_cmpstr("text/html", ==, webkit_web_resource_get_mime_type(resource));
+ g_assert_cmpstr("http://webkit.org/", ==, webkit_web_resource_get_uri(resource));
+
+ /* Test get_data. We just test if data has certain size for the mean time */
+ g_test_message("Testing webkit_web_data_source_get_data has certain size");
+ GString* data = webkit_web_data_source_get_data(dataSource);
+ g_assert(data->len > 100);
+
+ /* FIXME: Add test for get_encoding */
+
+ if (g_main_loop_is_running(loop))
+ g_main_loop_quit(loop);
+}
+
+static void load_committed_cb(WebKitWebView* view, WebKitWebFrame* frame)
+{
+ WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(frame);
+ g_assert(webkit_web_data_source_is_loading(dataSource));
+}
+
+static gboolean wait_timer_fired(GMainLoop* loop)
+{
+ waitTimer = 0;
+ if (g_main_loop_is_running(loop))
+ g_main_loop_quit(loop);
+
+ return FALSE;
+}
+
+static void test_webkit_web_data_source()
+{
+ WebKitWebView* view;
+ GMainLoop* loop;
+
+ view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(view);
+ loop = g_main_loop_new(NULL, TRUE);
+ g_signal_connect(view, "load-committed", G_CALLBACK(load_committed_cb), loop);
+ g_signal_connect(view, "load-finished", G_CALLBACK(load_finished_cb), loop);
+ webkit_web_view_load_uri(view, "http://webkit.org");
+
+ if (!waitTimer)
+ waitTimer = g_timeout_add_seconds(defaultTimeout, (GSourceFunc)wait_timer_fired, loop);
+
+ g_main_loop_run(loop);
+ g_object_unref(view);
+}
+
+static void test_webkit_web_data_source_unreachable_uri()
+{
+ WebKitWebView* view;
+ GMainLoop* loop;
+
+ view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(view);
+ loop = g_main_loop_new(NULL, TRUE);
+ g_signal_connect(view, "load-finished", G_CALLBACK(load_finished_unreachable_cb), loop);
+ webkit_web_view_load_uri(view, "http://localhost/doireallyexist.html");
+
+ if (!waitTimer)
+ waitTimer = g_timeout_add_seconds(defaultTimeout, (GSourceFunc)wait_timer_fired, loop);
+
+ g_main_loop_run(loop);
+ g_object_unref(view);
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+ g_test_bug("24758");
+ g_test_add_func("/webkit/webdatasource/get_initial_request",
+ test_webkit_web_data_source_get_initial_request);
+ g_test_add_func("/webkit/webdatasource/api",
+ test_webkit_web_data_source);
+ g_test_add_func("/webkit/webdatasource/unreachable_uri",
+ test_webkit_web_data_source_unreachable_uri);
+ return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/tests/testwebresource.c b/WebKit/gtk/tests/testwebresource.c
new file mode 100644
index 0000000..b9cd40b
--- /dev/null
+++ b/WebKit/gtk/tests/testwebresource.c
@@ -0,0 +1,332 @@
+/*
+ * Copyright (C) 2009 Jan Michael Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <string.h>
+#include <webkit/webkit.h>
+
+#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+
+#define INDEX_HTML "<html></html>"
+#define MAIN_HTML "<html><head><script language=\"javascript\" src=\"/javascript.js\"></script></head><body><h1>hah</h1></html>"
+#define JAVASCRIPT "function blah () { var a = 1; }"
+
+GMainLoop* loop;
+SoupSession *session;
+char *base_uri;
+WebKitWebResource* main_resource;
+WebKitWebResource* sub_resource;
+
+typedef struct {
+ WebKitWebResource* webResource;
+ WebKitWebView* webView;
+} WebResourceFixture;
+
+/* For real request testing */
+static void
+server_callback (SoupServer *server, SoupMessage *msg,
+ const char *path, GHashTable *query,
+ SoupClientContext *context, gpointer data)
+{
+ if (msg->method != SOUP_METHOD_GET) {
+ soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status (msg, SOUP_STATUS_OK);
+
+ /* Redirect */
+ if (g_str_equal (path, "/")) {
+ soup_message_set_status (msg, SOUP_STATUS_MOVED_PERMANENTLY);
+
+ soup_message_headers_append (msg->response_headers,
+ "Location", "/index.html");
+ } else if (g_str_equal (path, "/index.html")) {
+ soup_message_body_append (msg->response_body,
+ SOUP_MEMORY_COPY,
+ INDEX_HTML,
+ strlen (INDEX_HTML));
+ } else if (g_str_equal (path, "/main.html")) {
+ soup_message_body_append (msg->response_body,
+ SOUP_MEMORY_COPY,
+ MAIN_HTML,
+ strlen (MAIN_HTML));
+ } else if (g_str_equal (path, "/javascript.js")) {
+ soup_message_body_append (msg->response_body,
+ SOUP_MEMORY_COPY,
+ JAVASCRIPT,
+ strlen (JAVASCRIPT));
+ }
+
+
+ soup_message_body_complete (msg->response_body);
+}
+
+static void web_resource_fixture_setup(WebResourceFixture* fixture, gconstpointer data)
+{
+ fixture->webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ g_object_ref_sink(fixture->webView);
+ const gchar* webData = "<html></html>";
+ fixture->webResource = webkit_web_resource_new(webData, strlen(webData), "http://example.com/", "text/html", "utf8", "Example.com");
+ g_assert(fixture->webResource);
+}
+
+static void web_resource_fixture_teardown(WebResourceFixture* fixture, gconstpointer data)
+{
+ g_assert(fixture->webResource);
+ g_object_unref(fixture->webResource);
+ g_object_unref(fixture->webView);
+}
+
+static void test_webkit_web_resource_get_url(WebResourceFixture* fixture, gconstpointer data)
+{
+ gchar* url;
+ g_object_get(G_OBJECT(fixture->webResource), "uri", &url, NULL);
+ g_assert_cmpstr(url, ==, "http://example.com/");
+ g_assert_cmpstr(webkit_web_resource_get_uri(fixture->webResource) ,==,"http://example.com/");
+ g_free(url);
+}
+
+static void test_webkit_web_resource_get_data(WebResourceFixture* fixture, gconstpointer data)
+{
+ GString* charData = webkit_web_resource_get_data(fixture->webResource);
+ g_assert_cmpstr(charData->str, ==, "<html></html>");
+}
+
+static void test_webkit_web_resource_get_mime_type(WebResourceFixture* fixture, gconstpointer data)
+{
+ gchar* mime_type;
+ g_object_get(G_OBJECT(fixture->webResource), "mime-type", &mime_type, NULL);
+ g_assert_cmpstr(mime_type, ==, "text/html");
+ g_assert_cmpstr(webkit_web_resource_get_mime_type(fixture->webResource),==,"text/html");
+ g_free(mime_type);
+}
+
+static void test_webkit_web_resource_get_encoding(WebResourceFixture* fixture, gconstpointer data)
+{
+ gchar* text_encoding;
+ g_object_get(G_OBJECT(fixture->webResource), "encoding", &text_encoding, NULL);
+ g_assert_cmpstr(text_encoding, ==, "utf8");
+ g_assert_cmpstr(webkit_web_resource_get_encoding(fixture->webResource),==,"utf8");
+ g_free(text_encoding);
+}
+
+static void test_webkit_web_resource_get_frame_name(WebResourceFixture* fixture, gconstpointer data)
+{
+ gchar* frame_name;
+ g_object_get(G_OBJECT(fixture->webResource), "frame-name", &frame_name, NULL);
+ g_assert_cmpstr(frame_name, ==, "Example.com");
+ g_assert_cmpstr(webkit_web_resource_get_frame_name(fixture->webResource),==,"Example.com");
+ g_free(frame_name);
+}
+
+static void resource_request_starting_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, WebKitWebResource* web_resource, WebKitNetworkRequest* request, WebKitNetworkResponse* response, gpointer data)
+{
+ gint* been_there = data;
+ *been_there = *been_there + 1;
+
+ if (*been_there == 1) {
+ g_assert(!main_resource);
+ main_resource = g_object_ref(web_resource);
+
+ g_assert_cmpstr(webkit_web_resource_get_uri(web_resource), ==, base_uri);
+
+ /* This should be a redirect, so the response must be NULL */
+ g_assert(!response);
+ } else if (*been_there == 2) {
+ char* uri = g_strdup_printf("%sindex.html", base_uri);
+
+ g_assert_cmpstr(webkit_web_resource_get_uri(web_resource), ==, uri);
+
+ /* Cancel the request. */
+ webkit_network_request_set_uri(request, "about:blank");
+
+ g_free(uri);
+ }
+}
+
+static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, gpointer data)
+{
+ gboolean* been_there = data;
+ *been_there = TRUE;
+
+ g_assert_cmpstr(webkit_web_view_get_uri(web_view), ==, "about:blank");
+
+ g_main_loop_quit(loop);
+}
+
+static void test_web_resource_loading()
+{
+ WebKitWebView* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ gint been_to_resource_request_starting = 0;
+ gboolean been_to_load_finished = FALSE;
+ WebKitWebFrame* web_frame;
+ WebKitWebDataSource* data_source;
+
+ loop = g_main_loop_new(NULL, TRUE);
+
+ g_object_ref_sink(web_view);
+
+ g_signal_connect(web_view, "resource-request-starting",
+ G_CALLBACK(resource_request_starting_cb),
+ &been_to_resource_request_starting);
+
+ g_signal_connect(web_view, "load-finished",
+ G_CALLBACK(load_finished_cb),
+ &been_to_load_finished);
+
+ webkit_web_view_load_uri(web_view, base_uri);
+
+ /* We won't get finished immediately, because of the redirect */
+ g_main_loop_run(loop);
+
+ web_frame = webkit_web_view_get_main_frame(web_view);
+ data_source = webkit_web_frame_get_data_source(web_frame);
+
+ g_assert(main_resource);
+ g_assert(webkit_web_data_source_get_main_resource(data_source) == main_resource);
+ g_object_unref(main_resource);
+
+ g_assert_cmpint(been_to_resource_request_starting, ==, 2);
+ g_assert_cmpint(been_to_load_finished, ==, TRUE);
+
+ g_object_unref(web_view);
+ g_main_loop_unref(loop);
+}
+
+static void resource_request_starting_sub_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, WebKitWebResource* web_resource, WebKitNetworkRequest* request, WebKitNetworkResponse* response, gpointer data)
+{
+ if (!main_resource)
+ main_resource = g_object_ref(web_resource);
+ else
+ sub_resource = g_object_ref(web_resource);
+}
+
+static void load_finished_sub_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, gpointer data)
+{
+ g_main_loop_quit(loop);
+}
+
+static gboolean idle_quit_loop_cb(gpointer data)
+{
+ g_main_loop_quit(loop);
+ return FALSE;
+}
+
+static void test_web_resource_sub_resource_loading()
+{
+ WebKitWebView* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ WebKitWebFrame* web_frame;
+ WebKitWebDataSource* data_source;
+ GList* sub_resources;
+ char* uri = g_strdup_printf("%smain.html", base_uri);
+
+ main_resource = NULL;
+
+ loop = g_main_loop_new(NULL, TRUE);
+
+ g_object_ref_sink(web_view);
+
+ g_signal_connect(web_view, "resource-request-starting",
+ G_CALLBACK(resource_request_starting_sub_cb),
+ NULL);
+
+ g_signal_connect(web_view, "load-finished",
+ G_CALLBACK(load_finished_sub_cb),
+ NULL);
+
+ webkit_web_view_load_uri(web_view, uri);
+
+ g_main_loop_run(loop);
+
+ /* The main resource should be loaded; now let's wait for the sub-resource to load */
+ g_idle_add(idle_quit_loop_cb, NULL);
+ g_main_loop_run(loop);
+
+ g_assert(main_resource && sub_resource);
+ g_assert(main_resource != sub_resource);
+
+ web_frame = webkit_web_view_get_main_frame(web_view);
+ data_source = webkit_web_frame_get_data_source(web_frame);
+
+ g_assert(webkit_web_data_source_get_main_resource(data_source) == main_resource);
+ g_object_unref(main_resource);
+
+ sub_resources = webkit_web_data_source_get_subresources(data_source);
+ g_assert(sub_resources);
+ g_assert(!sub_resources->next);
+
+ g_assert(WEBKIT_WEB_RESOURCE(sub_resources->data) == sub_resource);
+
+ g_object_unref(web_view);
+ g_main_loop_unref(loop);
+}
+
+int main(int argc, char** argv)
+{
+ SoupServer* server;
+ SoupURI* soup_uri;
+
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ server = soup_server_new(SOUP_SERVER_PORT, 0, NULL);
+ soup_server_run_async(server);
+
+ soup_server_add_handler(server, NULL, server_callback, NULL, NULL);
+
+ soup_uri = soup_uri_new ("http://127.0.0.1/");
+ soup_uri_set_port(soup_uri, soup_server_get_port(server));
+
+ base_uri = soup_uri_to_string(soup_uri, FALSE);
+ soup_uri_free(soup_uri);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+ g_test_add("/webkit/webresource/get_url",
+ WebResourceFixture, 0, web_resource_fixture_setup,
+ test_webkit_web_resource_get_url, web_resource_fixture_teardown);
+ g_test_add("/webkit/webresource/get_mime_type",
+ WebResourceFixture, 0, web_resource_fixture_setup,
+ test_webkit_web_resource_get_mime_type, web_resource_fixture_teardown);
+ g_test_add("/webkit/webresource/get_text_encoding_name",
+ WebResourceFixture, 0, web_resource_fixture_setup,
+ test_webkit_web_resource_get_encoding, web_resource_fixture_teardown);
+ g_test_add("/webkit/webresource/get_frame_name",
+ WebResourceFixture, 0, web_resource_fixture_setup,
+ test_webkit_web_resource_get_frame_name, web_resource_fixture_teardown);
+ g_test_add("/webkit/webresource/get_data",
+ WebResourceFixture, 0, web_resource_fixture_setup,
+ test_webkit_web_resource_get_data, web_resource_fixture_teardown);
+
+ g_test_add_func("/webkit/webresource/loading", test_web_resource_loading);
+ g_test_add_func("/webkit/webresource/sub_resource_loading", test_web_resource_sub_resource_loading);
+
+ return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/tests/testwindow.c b/WebKit/gtk/tests/testwindow.c
new file mode 100644
index 0000000..41ff323
--- /dev/null
+++ b/WebKit/gtk/tests/testwindow.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <gtk/gtk.h>
+#include <webkit/webkit.h>
+
+#if GLIB_CHECK_VERSION(2, 16, 0) && GTK_CHECK_VERSION(2, 14, 0)
+
+static void load_finished_cb(WebKitWebView* web_view, WebKitWebFrame* web_frame, gpointer data)
+{
+ GMainLoop* loop = (GMainLoop*)data;
+
+ g_main_loop_quit(loop);
+}
+
+static void test_webkit_window_scrollbar_policy(void)
+{
+ GMainLoop* loop;
+ GtkWidget* scrolledWindow;
+ GtkWidget* webView;
+ WebKitWebFrame* mainFrame;
+ GtkPolicyType horizontalPolicy;
+ GtkPolicyType verticalPolicy;
+
+ loop = g_main_loop_new(NULL, TRUE);
+
+ scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ webView = webkit_web_view_new();
+ g_object_ref_sink(webView);
+
+ g_signal_connect(webView, "load-finished",
+ G_CALLBACK(load_finished_cb), loop);
+
+ gtk_container_add(GTK_CONTAINER(scrolledWindow), webView);
+
+ mainFrame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(webView));
+
+ /* Test we correctly apply policy for not having scrollbars; This
+ * case is special, because we turn the policy from NEVER to
+ * AUTOMATIC, since we cannot easily represent the same thing
+ * using GtkScrolledWindow */
+ webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(webView),
+ "<html><body>WebKit!</body><script>document.getElementsByTagName('body')[0].style.overflow = 'hidden';</script></html>",
+ "file://");
+
+ g_main_loop_run(loop);
+
+ gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(scrolledWindow),
+ &horizontalPolicy, &verticalPolicy);
+
+ g_assert(horizontalPolicy == GTK_POLICY_AUTOMATIC);
+ g_assert(verticalPolicy == GTK_POLICY_AUTOMATIC);
+
+ g_assert(GTK_POLICY_NEVER == webkit_web_frame_get_horizontal_scrollbar_policy(mainFrame));
+ g_assert(GTK_POLICY_NEVER == webkit_web_frame_get_vertical_scrollbar_policy(mainFrame));
+
+ /* Test we correctly apply policy for always having scrollbars */
+ webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(webView),
+ "<html><body>WebKit!</body><script>document.getElementsByTagName('body')[0].style.overflow = 'scroll';</script></html>",
+ "file://");
+
+ g_main_loop_run(loop);
+
+ gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(scrolledWindow),
+ &horizontalPolicy, &verticalPolicy);
+
+ g_assert(horizontalPolicy == GTK_POLICY_ALWAYS);
+ g_assert(verticalPolicy == GTK_POLICY_ALWAYS);
+
+ g_assert(horizontalPolicy == webkit_web_frame_get_horizontal_scrollbar_policy(mainFrame));
+ g_assert(verticalPolicy == webkit_web_frame_get_vertical_scrollbar_policy(mainFrame));
+
+ /* Test we correctly apply policy for having scrollbars when needed */
+ webkit_web_view_load_html_string(WEBKIT_WEB_VIEW(webView),
+ "<html><body>WebKit!</body><script>document.getElementsByTagName('body')[0].style.overflow = 'auto';</script></html>",
+ "file://");
+
+ g_main_loop_run(loop);
+
+ gtk_scrolled_window_get_policy(GTK_SCROLLED_WINDOW(scrolledWindow),
+ &horizontalPolicy, &verticalPolicy);
+
+ g_assert(horizontalPolicy == GTK_POLICY_AUTOMATIC);
+ g_assert(verticalPolicy == GTK_POLICY_AUTOMATIC);
+
+ g_assert(horizontalPolicy == webkit_web_frame_get_horizontal_scrollbar_policy(mainFrame));
+ g_assert(verticalPolicy == webkit_web_frame_get_vertical_scrollbar_policy(mainFrame));
+
+ g_object_unref(webView);
+}
+
+int main(int argc, char** argv)
+{
+ g_thread_init(NULL);
+ gtk_test_init(&argc, &argv, NULL);
+
+ g_test_bug_base("https://bugs.webkit.org/");
+ g_test_add_func("/webkit/window/scrollbar_policy", test_webkit_window_scrollbar_policy);
+ return g_test_run ();
+}
+
+#else
+int main(int argc, char** argv)
+{
+ g_critical("You will need at least glib-2.16.0 and gtk-2.14.0 to run the unit tests. Doing nothing now.");
+ return 0;
+}
+
+#endif
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h
index c22165e..4cd0709 100644
--- a/WebKit/gtk/webkit/webkit.h
+++ b/WebKit/gtk/webkit/webkit.h
@@ -24,8 +24,11 @@
#include <webkit/webkitversion.h>
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
+#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitnetworkresponse.h>
#include <webkit/webkitsoupauthdialog.h>
+#include <webkit/webkitwebdatasource.h>
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebinspector.h>
@@ -35,6 +38,9 @@
#include <webkit/webkitwebhistoryitem.h>
#include <webkit/webkitwebpolicydecision.h>
#include <webkit/webkitwebnavigationaction.h>
+#include <webkit/webkitwebresource.h>
+#include <webkit/webkitwebdatabase.h>
+#include <webkit/webkitsecurityorigin.h>
#include <webkit/webkitenumtypes.h>
#endif /* __WEBKIT_H__ */
diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h
index b0ab5e9..a5884f3 100644
--- a/WebKit/gtk/webkit/webkitdefines.h
+++ b/WebKit/gtk/webkit/webkitdefines.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_DEFINES_H
-#define WEBKIT_DEFINES_H
+#ifndef webkitdefines_h
+#define webkitdefines_h
#include <glib.h>
@@ -44,6 +44,9 @@ G_BEGIN_DECLS
typedef struct _WebKitNetworkRequest WebKitNetworkRequest;
typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass;
+typedef struct _WebKitNetworkResponse WebKitNetworkResponse;
+typedef struct _WebKitNetworkResponseClass WebKitNetworkResponseClass;
+
typedef struct _WebKitWebBackForwardList WebKitWebBackForwardList;
typedef struct _WebKitWebBackForwardListClass WebKitWebBackForwardListClass;
@@ -71,6 +74,21 @@ typedef struct _WebKitWebViewClass WebKitWebViewClass;
typedef struct _WebKitDownload WebKitDownload;
typedef struct _WebKitDownloadClass WebKitDownloadClass;
+typedef struct _WebKitWebResource WebKitWebResource;
+typedef struct _WebKitWebResourceClass WebKitWebResourceClass;
+
+typedef struct _WebKitWebDataSource WebKitWebDataSource;
+typedef struct _WebKitWebDataSourceClass WebKitWebDataSourceClass;
+
+typedef struct _WebKitWebDatabase WebKitWebDatabase;
+typedef struct _WebKitWebDatabaseClass WebKitWebDatabaseClass;
+
+typedef struct _WebKitSecurityOrigin WebKitSecurityOrigin;
+typedef struct _WebKitSecurityOriginClass WebKitSecurityOriginClass;
+
+typedef struct _WebKitHitTestResult WebKitHitTestResult;
+typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass;
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp
index c0c6ea7..568378c 100644
--- a/WebKit/gtk/webkit/webkitdownload.cpp
+++ b/WebKit/gtk/webkit/webkitdownload.cpp
@@ -25,6 +25,7 @@
#include "Noncopyable.h"
#include "NotImplemented.h"
#include "ResourceHandleClient.h"
+#include "ResourceHandleInternal.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "webkitdownload.h"
@@ -100,6 +101,7 @@ enum {
G_DEFINE_TYPE(WebKitDownload, webkit_download, G_TYPE_OBJECT);
+static void webkit_download_set_response(WebKitDownload* download, const ResourceResponse& response);
static void webkit_download_set_status(WebKitDownload* download, WebKitDownloadStatus status);
static void webkit_download_dispose(GObject* object)
@@ -373,6 +375,25 @@ WebKitDownload* webkit_download_new(WebKitNetworkRequest* request)
return WEBKIT_DOWNLOAD(g_object_new(WEBKIT_TYPE_DOWNLOAD, "network-request", request, NULL));
}
+// Internal usage only
+WebKitDownload* webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response)
+{
+ g_return_val_if_fail(request, NULL);
+
+ ResourceHandleInternal* d = handle->getInternal();
+ soup_session_pause_message(webkit_get_default_session(), d->m_msg);
+
+ WebKitDownload* download = WEBKIT_DOWNLOAD(g_object_new(WEBKIT_TYPE_DOWNLOAD, "network-request", request, NULL));
+ WebKitDownloadPrivate* priv = download->priv;
+
+ handle->ref();
+ priv->resourceHandle = handle;
+
+ webkit_download_set_response(download, response);
+
+ return download;
+}
+
static gboolean webkit_download_open_stream_for_uri(WebKitDownload* download, const gchar* uri, gboolean append=FALSE)
{
g_return_val_if_fail(uri, FALSE);
@@ -425,10 +446,14 @@ void webkit_download_start(WebKitDownload* download)
g_return_if_fail(priv->status == WEBKIT_DOWNLOAD_STATUS_CREATED);
g_return_if_fail(priv->timer == NULL);
- if (priv->resourceHandle)
- priv->resourceHandle->setClient(priv->downloadClient);
- else
+ if (!priv->resourceHandle)
priv->resourceHandle = ResourceHandle::create(core(priv->networkRequest), priv->downloadClient, 0, false, false, false);
+ else {
+ priv->resourceHandle->setClient(priv->downloadClient);
+
+ ResourceHandleInternal* d = priv->resourceHandle->getInternal();
+ soup_session_unpause_message(webkit_get_default_session(), d->m_msg);
+ }
priv->timer = g_timer_new();
webkit_download_open_stream_for_uri(download, priv->destinationURI);
@@ -510,6 +535,9 @@ static void webkit_download_set_response(WebKitDownload* download, const Resourc
// FIXME Use WebKitNetworkResponse when it's merged.
WebKitDownloadPrivate* priv = download->priv;
priv->networkResponse = new ResourceResponse(response);
+
+ if (!response.isNull() && !response.suggestedFilename().isEmpty())
+ webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
}
/**
@@ -544,6 +572,8 @@ void webkit_download_set_suggested_filename(WebKitDownload* download, const gcha
WebKitDownloadPrivate* priv = download->priv;
g_free(priv->suggestedFilename);
priv->suggestedFilename = g_strdup(suggestedFilename);
+
+ g_object_notify(G_OBJECT(download), "suggested-filename");
}
diff --git a/WebKit/gtk/webkit/webkitdownload.h b/WebKit/gtk/webkit/webkitdownload.h
index 7c86c65..6e7f38b 100644
--- a/WebKit/gtk/webkit/webkitdownload.h
+++ b/WebKit/gtk/webkit/webkitdownload.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_DOWNLOAD_H
-#define WEBKIT_DOWNLOAD_H
+#ifndef webkitdownload_h
+#define webkitdownload_h
#include <webkit/webkitdefines.h>
diff --git a/WebKit/gtk/webkit/webkiterror.h b/WebKit/gtk/webkit/webkiterror.h
index 512bc7d..8fec949 100644
--- a/WebKit/gtk/webkit/webkiterror.h
+++ b/WebKit/gtk/webkit/webkiterror.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_ERROR_H
-#define WEBKIT_ERROR_H
+#ifndef webkiterror_h
+#define webkiterror_h
#include <glib.h>
diff --git a/WebKit/gtk/webkit/webkithittestresult.cpp b/WebKit/gtk/webkit/webkithittestresult.cpp
new file mode 100644
index 0000000..be97933
--- /dev/null
+++ b/WebKit/gtk/webkit/webkithittestresult.cpp
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkithittestresult.h"
+
+#include "CString.h"
+#include "GOwnPtr.h"
+#include "webkitenumtypes.h"
+#include "webkitprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkithittestresult
+ * @short_description: The target of a mouse event
+ *
+ * This class holds context information about the coordinates
+ * specified by a GDK event.
+ */
+
+G_DEFINE_TYPE(WebKitHitTestResult, webkit_hit_test_result, G_TYPE_OBJECT)
+
+struct _WebKitHitTestResultPrivate {
+ guint context;
+ char* linkURI;
+ char* imageURI;
+ char* mediaURI;
+};
+
+#define WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate))
+
+enum {
+ PROP_0,
+
+ PROP_CONTEXT,
+ PROP_LINK_URI,
+ PROP_IMAGE_URI,
+ PROP_MEDIA_URI
+};
+
+static void webkit_hit_test_result_finalize(GObject* object)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ g_free(priv->linkURI);
+ g_free(priv->imageURI);
+ g_free(priv->mediaURI);
+
+ G_OBJECT_CLASS(webkit_hit_test_result_parent_class)->finalize(object);
+}
+
+static void webkit_hit_test_result_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ switch(propertyID) {
+ case PROP_CONTEXT:
+ g_value_set_flags(value, priv->context);
+ break;
+ case PROP_LINK_URI:
+ g_value_set_string(value, priv->linkURI);
+ break;
+ case PROP_IMAGE_URI:
+ g_value_set_string(value, priv->imageURI);
+ break;
+ case PROP_MEDIA_URI:
+ g_value_set_string(value, priv->mediaURI);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_hit_test_result_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
+{
+ WebKitHitTestResult* web_hit_test_result = WEBKIT_HIT_TEST_RESULT(object);
+ WebKitHitTestResultPrivate* priv = web_hit_test_result->priv;
+
+ switch(propertyID) {
+ case PROP_CONTEXT:
+ priv->context = g_value_get_flags(value);
+ break;
+ case PROP_LINK_URI:
+ g_free (priv->linkURI);
+ priv->linkURI = g_value_dup_string(value);
+ break;
+ case PROP_IMAGE_URI:
+ g_free (priv->imageURI);
+ priv->imageURI = g_value_dup_string(value);
+ break;
+ case PROP_MEDIA_URI:
+ g_free (priv->mediaURI);
+ priv->mediaURI = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* webHitTestResultClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(webHitTestResultClass);
+
+ objectClass->finalize = webkit_hit_test_result_finalize;
+ objectClass->get_property = webkit_hit_test_result_get_property;
+ objectClass->set_property = webkit_hit_test_result_set_property;
+
+ webkit_init();
+
+ /**
+ * WebKitHitTestResult:context:
+ *
+ * Flags indicating the kind of target that received the event.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_CONTEXT,
+ g_param_spec_flags("context",
+ _("Context"),
+ _("Flags indicating the kind of target that received the event."),
+ WEBKIT_TYPE_HIT_TEST_RESULT_CONTEXT,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT,
+ static_cast<GParamFlags>((WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY))));
+
+ /**
+ * WebKitHitTestResult:link-uri:
+ *
+ * The URI to which the target that received the event points, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_LINK_URI,
+ g_param_spec_string("link-uri",
+ _("Link URI"),
+ _("The URI to which the target that received the event points, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitHitTestResult:image-uri:
+ *
+ * The URI of the image that is part of the target that received the event, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_IMAGE_URI,
+ g_param_spec_string("image-uri",
+ _("Image URI"),
+ _("The URI of the image that is part of the target that received the event, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitHitTestResult:media-uri:
+ *
+ * The URI of the media that is part of the target that received the event, if any.
+ *
+ * Since: 1.1.15
+ */
+ g_object_class_install_property(objectClass, PROP_MEDIA_URI,
+ g_param_spec_string("media-uri",
+ _("Media URI"),
+ _("The URI of the media that is part of the target that received the event, if any."),
+ NULL,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ g_type_class_add_private(webHitTestResultClass, sizeof(WebKitHitTestResultPrivate));
+}
+
+static void webkit_hit_test_result_init(WebKitHitTestResult* web_hit_test_result)
+{
+ web_hit_test_result->priv = WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(web_hit_test_result);
+}
diff --git a/WebKit/gtk/webkit/webkithittestresult.h b/WebKit/gtk/webkit/webkithittestresult.h
new file mode 100644
index 0000000..6caa84e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkithittestresult.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ * Copyright (C) 2009 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkithittestresult_h
+#define webkithittestresult_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_HIT_TEST_RESULT (webkit_hit_test_result_get_type())
+#define WEBKIT_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResult))
+#define WEBKIT_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass))
+#define WEBKIT_IS_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_IS_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_HIT_TEST_RESULT, WebKitHitTestResultClass))
+
+typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
+
+struct _WebKitHitTestResult {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitHitTestResultPrivate *priv;
+};
+
+struct _WebKitHitTestResultClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+/**
+ * WebKitHitTestResultContext
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT: anywhere in the document.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION: the area is selected by
+ * the user.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE: the area is
+ * editable by the user.
+ */
+typedef enum
+{
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION = 1 << 5,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE = 1 << 6,
+} WebKitHitTestResultContext;
+
+WEBKIT_API GType
+webkit_hit_test_result_get_type (void);
+
+G_END_DECLS
+
+#endif
+
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
index e8a225c..be6d5ff 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
@@ -28,26 +28,17 @@
#include <glib/gi18n-lib.h>
-namespace WTF {
-
-template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage)
-{
- if (soupMessage)
- g_object_unref(soupMessage);
-}
-
-}
-
/**
* SECTION:webkitnetworkrequest
* @short_description: The target of a navigation request
- * @see_also: #WebKitWebView::navigation-requested
+ * @see_also: #WebKitWebView::navigation-policy-decision-requested
*
* This class represents the network related aspects of a navigation
- * request. Currently this is only the uri of the target. In the future
- * the state of the web form might be added.
- * Currently this object is only used along with the
- * #WebKitWebView::navigation-requested signal.
+ * request. It is used whenever WebKit wants to provide information
+ * about a request that will be sent, or has been sent. Inside it you
+ * can find the URI of the request, and, for valid URIs, a
+ * #SoupMessage object, which provides access to further information
+ * such as headers.
*
*/
@@ -67,18 +58,26 @@ enum {
PROP_MESSAGE,
};
-static void webkit_network_request_finalize(GObject* object)
+static void webkit_network_request_dispose(GObject* object)
{
WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
WebKitNetworkRequestPrivate* priv = request->priv;
- g_free(priv->uri);
-
if (priv->message) {
g_object_unref(priv->message);
priv->message = NULL;
}
+ G_OBJECT_CLASS(webkit_network_request_parent_class)->dispose(object);
+}
+
+static void webkit_network_request_finalize(GObject* object)
+{
+ WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
+ WebKitNetworkRequestPrivate* priv = request->priv;
+
+ g_free(priv->uri);
+
G_OBJECT_CLASS(webkit_network_request_parent_class)->finalize(object);
}
@@ -119,6 +118,7 @@ static void webkit_network_request_class_init(WebKitNetworkRequestClass* request
{
GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+ objectClass->dispose = webkit_network_request_dispose;
objectClass->finalize = webkit_network_request_finalize;
objectClass->get_property = webkit_network_request_get_property;
objectClass->set_property = webkit_network_request_set_property;
@@ -213,10 +213,7 @@ void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar*
return;
SoupURI* soupURI = soup_uri_new(uri);
- if (!soupURI) {
- g_warning("Invalid URI: %s", uri);
- return;
- }
+ g_return_if_fail(soupURI);
soup_message_set_uri(priv->message, soupURI);
soup_uri_free(soupURI);
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.h b/WebKit/gtk/webkit/webkitnetworkrequest.h
index 78e04a1..825ca9e 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.h
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_NETWORK_REQUEST_H
-#define WEBKIT_NETWORK_REQUEST_H
+#ifndef webkitnetworkrequest_h
+#define webkitnetworkrequest_h
#include <glib-object.h>
#include <libsoup/soup.h>
diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.cpp b/WebKit/gtk/webkit/webkitnetworkresponse.cpp
new file mode 100644
index 0000000..33bcd28
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitnetworkresponse.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2007, 2008 Holger Hans Peter Freyther
+ * Copyright (C) 2009 Gustavo Noronha Silva
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitnetworkresponse.h"
+
+#include "GOwnPtr.h"
+#include "ResourceResponse.h"
+#include "webkitprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitnetworkresponse
+ * @short_description: the response given to a network request
+ * @see_also: #WebKitNetworkRequest
+ *
+ * This class represents the network related aspects of a navigation
+ * response.
+ *
+ * Since: 1.1.14
+ */
+
+G_DEFINE_TYPE(WebKitNetworkResponse, webkit_network_response, G_TYPE_OBJECT);
+
+struct _WebKitNetworkResponsePrivate {
+ gchar* uri;
+ SoupMessage* message;
+};
+
+#define WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponsePrivate))
+
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_MESSAGE,
+};
+
+static void webkit_network_response_dispose(GObject* object)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->message) {
+ g_object_unref(priv->message);
+ priv->message = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_network_response_parent_class)->dispose(object);
+}
+
+static void webkit_network_response_finalize(GObject* object)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ g_free(priv->uri);
+
+ G_OBJECT_CLASS(webkit_network_response_parent_class)->finalize(object);
+}
+
+static void webkit_network_response_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+
+ switch(propertyID) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_network_response_get_uri(response));
+ break;
+ case PROP_MESSAGE:
+ g_value_set_object(value, webkit_network_response_get_message(response));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_network_response_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object);
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ switch(propertyID) {
+ case PROP_URI:
+ webkit_network_response_set_uri(response, g_value_get_string(value));
+ break;
+ case PROP_MESSAGE:
+ priv->message = SOUP_MESSAGE(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_network_response_class_init(WebKitNetworkResponseClass* responseClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(responseClass);
+
+ objectClass->dispose = webkit_network_response_dispose;
+ objectClass->finalize = webkit_network_response_finalize;
+ objectClass->get_property = webkit_network_response_get_property;
+ objectClass->set_property = webkit_network_response_set_property;
+
+ webkit_init();
+
+ /**
+ * WebKitNetworkResponse:uri:
+ *
+ * The URI to which the response will be made.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The URI to which the response will be made."),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE)));
+
+ /**
+ * WebKitNetworkResponse:message:
+ *
+ * The #SoupMessage that backs the response.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_MESSAGE,
+ g_param_spec_object("message",
+ _("Message"),
+ _("The SoupMessage that backs the response."),
+ SOUP_TYPE_MESSAGE,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+
+ g_type_class_add_private(responseClass, sizeof(WebKitNetworkResponsePrivate));
+}
+
+static void webkit_network_response_init(WebKitNetworkResponse* response)
+{
+ response->priv = WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(response);
+}
+
+// for internal use only
+WebKitNetworkResponse* webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse)
+{
+ GOwnPtr<SoupMessage> soupMessage(resourceResponse.toSoupMessage());
+ if (soupMessage)
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL));
+
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", resourceResponse.url().string().utf8().data(), NULL));
+}
+
+/**
+ * webkit_network_response_new:
+ * @uri: an URI
+ *
+ * Creates a new #WebKitNetworkResponse initialized with an URI.
+ *
+ * Returns: a new #WebKitNetworkResponse, or %NULL if the URI is
+ * invalid.
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkResponse* webkit_network_response_new(const gchar* uri)
+{
+ g_return_val_if_fail(uri, NULL);
+
+ return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", uri, NULL));
+}
+
+/**
+ * webkit_network_response_set_uri:
+ * @response: a #WebKitNetworkResponse
+ * @uri: an URI
+ *
+ * Sets the URI held and used by the given response. When the response
+ * has an associated #SoupMessage, its URI will also be set by this
+ * call.
+ *
+ * Since: 1.1.14
+ */
+void webkit_network_response_set_uri(WebKitNetworkResponse* response, const gchar* uri)
+{
+ g_return_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response));
+ g_return_if_fail(uri);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->uri)
+ g_free(priv->uri);
+ priv->uri = g_strdup(uri);
+
+ if (!priv->message)
+ return;
+
+ SoupURI* soupURI = soup_uri_new(uri);
+ g_return_if_fail(soupURI);
+
+ soup_message_set_uri(priv->message, soupURI);
+ soup_uri_free(soupURI);
+}
+
+/**
+ * webkit_network_response_get_uri:
+ * @response: a #WebKitNetworkResponse
+ *
+ * Returns: the uri of the #WebKitNetworkResponse
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_network_response_get_uri(WebKitNetworkResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ if (priv->uri)
+ return priv->uri;
+
+ SoupURI* soupURI = soup_message_get_uri(priv->message);
+ priv->uri = soup_uri_to_string(soupURI, FALSE);
+ return priv->uri;
+}
+
+/**
+ * webkit_network_response_get_soup_message:
+ * @response: a #WebKitNetworkResponse
+ *
+ * Obtains the #SoupMessage that represents the given response. Notice
+ * that only the response side of the HTTP conversation is
+ * represented.
+ *
+ * Returns: the #SoupMessage
+ * Since: 1.1.14
+ */
+SoupMessage* webkit_network_response_get_message(WebKitNetworkResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL);
+
+ WebKitNetworkResponsePrivate* priv = response->priv;
+
+ return priv->message;
+}
diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.h b/WebKit/gtk/webkit/webkitnetworkresponse.h
new file mode 100644
index 0000000..a00308d
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitnetworkresponse.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitnewtorkresponse_h
+#define webkitnewtorkresponse_h
+
+#include <glib-object.h>
+#include <libsoup/soup.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_NETWORK_RESPONSE (webkit_network_response_get_type())
+#define WEBKIT_NETWORK_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponse))
+#define WEBKIT_NETWORK_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponseClass))
+#define WEBKIT_IS_NETWORK_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_NETWORK_RESPONSE))
+#define WEBKIT_IS_NETWORK_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_NETWORK_RESPONSE))
+#define WEBKIT_NETWORK_RESPONSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponseClass))
+
+typedef struct _WebKitNetworkResponsePrivate WebKitNetworkResponsePrivate;
+
+struct _WebKitNetworkResponse {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitNetworkResponsePrivate *priv;
+};
+
+struct _WebKitNetworkResponseClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_network_response_get_type (void);
+
+WEBKIT_API WebKitNetworkResponse *
+webkit_network_response_new (const gchar *uri);
+
+WEBKIT_API void
+webkit_network_response_set_uri (WebKitNetworkResponse *response,
+ const gchar* uri);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_network_response_get_uri (WebKitNetworkResponse *response);
+
+WEBKIT_API SoupMessage *
+webkit_network_response_get_message(WebKitNetworkResponse* response);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index 755b4d3..4425dcd 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -27,6 +27,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
+#include "HitTestResult.h"
#include <libintl.h>
#include "Logging.h"
#include "PageCache.h"
@@ -37,6 +38,7 @@
#include "ResourceHandleClient.h"
#include "ResourceHandleInternal.h"
#include <runtime/InitializeThreading.h>
+#include "SecurityOrigin.h"
#if ENABLE(DATABASE)
#include "DatabaseTracker.h"
@@ -97,7 +99,7 @@ WebKitWebNavigationReason kit(WebCore::NavigationType type)
WebCore::NavigationType core(WebKitWebNavigationReason type)
{
- return (WebCore::NavigationType)type;
+ return static_cast<WebCore::NavigationType>(type);
}
WebCore::ResourceRequest core(WebKitNetworkRequest* request)
@@ -110,8 +112,77 @@ WebCore::ResourceRequest core(WebKitNetworkRequest* request)
return ResourceRequest(url);
}
+WebCore::EditingBehavior core(WebKitEditingBehavior type)
+{
+ return (WebCore::EditingBehavior)type;
+}
+
+WebKitHitTestResult* kit(const WebCore::HitTestResult& result)
+{
+ guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
+ GOwnPtr<char> linkURI(0);
+ GOwnPtr<char> imageURI(0);
+ GOwnPtr<char> mediaURI(0);
+
+ if (!result.absoluteLinkURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
+ linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data()));
+ }
+
+ if (!result.absoluteImageURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
+ imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data()));
+ }
+
+ if (!result.absoluteMediaURL().isEmpty()) {
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
+ mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data()));
+ }
+
+ if (result.isSelected())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION;
+
+ if (result.isContentEditable())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE;
+
+ return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
+ "link-uri", linkURI.get(),
+ "image-uri", imageURI.get(),
+ "media-uri", mediaURI.get(),
+ "context", context,
+ NULL));
+}
+
} /** end namespace WebKit */
+namespace WTF {
+
+template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage)
+{
+ if (soupMessage)
+ g_object_unref(soupMessage);
+}
+
+template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest* request)
+{
+ if (request)
+ g_object_unref(request);
+}
+
+template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse* response)
+{
+ if (response)
+ g_object_unref(response);
+}
+
+template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource* resource)
+{
+ if (resource)
+ g_object_unref(resource);
+}
+
+}
+
static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMessage* message, gpointer userData)
{
gpointer messageData = g_object_get_data(G_OBJECT(message), "resourceHandle");
@@ -130,7 +201,7 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes
if (!frame)
return NULL;
- GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformWindow()));
+ GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformPageClient()));
if (GTK_WIDGET_TOPLEVEL(toplevel))
return toplevel;
else
@@ -156,9 +227,10 @@ void webkit_init()
WebCore::pageCache()->setCapacity(3);
#if ENABLE(DATABASE)
- // FIXME: It should be possible for client applications to override this default location
gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
- WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(databaseDirectory);
+ webkit_set_web_database_directory_path(databaseDirectory);
+
+ // FIXME: It should be possible for client applications to override the default appcache location
WebCore::cacheStorage().setCacheDirectory(databaseDirectory);
g_free(databaseDirectory);
#endif
@@ -178,3 +250,13 @@ void webkit_init()
soup_session_add_feature(session, sniffer);
g_object_unref(sniffer);
}
+
+void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains)
+{
+ SecurityOrigin::whiteListAccessFromOrigin(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
+}
+
+void webkit_reset_origin_access_white_lists()
+{
+ SecurityOrigin::resetOriginAccessWhiteLists();
+}
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 0c3fbd3..44dac04 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_PRIVATE_H
-#define WEBKIT_PRIVATE_H
+#ifndef webkitprivate_h
+#define webkitprivate_h
/*
* This file knows the shared secret of WebKitWebView, WebKitWebFrame,
@@ -30,18 +30,25 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
+#include <webkit/webkithittestresult.h>
#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitwebview.h>
+#include <webkit/webkitwebdatasource.h>
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebpolicydecision.h>
#include <webkit/webkitwebnavigationaction.h>
+#include <webkit/webkitwebresource.h>
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebwindowfeatures.h>
#include <webkit/webkitwebbackforwardlist.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitsecurityorigin.h>
+#include "ArchiveResource.h"
#include "BackForwardList.h"
+#include "CString.h"
#include <enchant.h>
+#include "GOwnPtr.h"
#include "HistoryItem.h"
#include "Settings.h"
#include "Page.h"
@@ -52,6 +59,7 @@
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "WindowFeatures.h"
+#include "SecurityOrigin.h"
#include <atk/atk.h>
#include <glib.h>
@@ -60,6 +68,9 @@
class DownloadClient;
namespace WebKit {
+
+ class DocumentLoader;
+
WebKitWebView* getViewFromFrame(WebKitWebFrame*);
WebCore::Frame* core(WebKitWebFrame*);
@@ -77,6 +88,15 @@ namespace WebKit {
WebCore::NavigationType core(WebKitWebNavigationReason reason);
WebCore::ResourceRequest core(WebKitNetworkRequest* request);
+
+ WebCore::ResourceResponse core(WebKitNetworkResponse* response);
+
+ WebCore::EditingBehavior core(WebKitEditingBehavior type);
+
+ WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*);
+ WebCore::SecurityOrigin* core(WebKitSecurityOrigin*);
+
+ WebKitHitTestResult* kit(const WebCore::HitTestResult&);
}
typedef struct {
@@ -101,6 +121,7 @@ extern "C" {
WebKitWebFrame* mainFrame;
WebKitWebBackForwardList* backForwardList;
+ GtkMenu* currentMenu;
gint lastPopupXPosition;
gint lastPopupYPosition;
@@ -123,6 +144,12 @@ extern "C" {
gboolean disposing;
gboolean usePrimaryForPaste;
+
+ // These are hosted here because the DataSource object is
+ // created too late in the frame loading process.
+ WebKitWebResource* mainResource;
+ char* mainResourceIdentifier;
+ GHashTable* subResources;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
@@ -135,6 +162,17 @@ extern "C" {
gchar* title;
gchar* uri;
WebKitLoadStatus loadStatus;
+ WebKitSecurityOrigin* origin;
+ };
+
+#define WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginPrivate))
+ struct _WebKitSecurityOriginPrivate {
+ RefPtr<WebCore::SecurityOrigin> coreOrigin;
+ gchar* protocol;
+ gchar* host;
+ GHashTable* webDatabases;
+
+ gboolean disposed;
};
PassRefPtr<WebCore::Frame>
@@ -157,6 +195,26 @@ extern "C" {
webkit_web_history_item_get_children(WebKitWebHistoryItem*);
// end WebKitWebHistoryItem private
+ // WebKitWebResource private
+ #define WEBKIT_WEB_RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourcePrivate))
+ struct _WebKitWebResourcePrivate {
+ WebCore::ArchiveResource* resource;
+
+ gchar* uri;
+ gchar* mimeType;
+ gchar* textEncoding;
+ gchar* frameName;
+
+ GString* data;
+ };
+ WebKitWebResource*
+ webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>);
+
+ void
+ webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>);
+
+ // end WebKitWebResource private
+
void
webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebCore::Page*);
@@ -173,7 +231,25 @@ extern "C" {
webkit_web_view_notify_ready (WebKitWebView* web_view);
void
- webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse());
+ webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse(), WebCore::ResourceHandle* handle = 0);
+
+ void
+ webkit_web_view_add_resource(WebKitWebView*, char*, WebKitWebResource*);
+
+ WebKitWebResource*
+ webkit_web_view_get_resource(WebKitWebView*, char*);
+
+ WebKitWebResource*
+ webkit_web_view_get_main_resource(WebKitWebView*);
+
+ void
+ webkit_web_view_clear_resources(WebKitWebView*);
+
+ GList*
+ webkit_web_view_get_subresources(WebKitWebView*);
+
+ WebKitDownload*
+ webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response);
void
webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename);
@@ -187,6 +263,9 @@ extern "C" {
WebKitNetworkRequest*
webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest);
+ WebKitNetworkResponse*
+ webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse);
+
// FIXME: move this to webkitnetworkrequest.h once the API is agreed upon.
WEBKIT_API SoupMessage*
webkit_network_request_get_message(WebKitNetworkRequest* request);
@@ -206,6 +285,9 @@ extern "C" {
WEBKIT_API gchar*
webkit_web_frame_dump_render_tree (WebKitWebFrame* frame);
+ WEBKIT_API guint
+ webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame);
+
WEBKIT_API bool
webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element);
@@ -250,6 +332,32 @@ extern "C" {
WEBKIT_API void
webkit_application_cache_set_maximum_size(unsigned long long size);
+
+ WEBKIT_API unsigned int
+ webkit_worker_thread_count();
+
+ WEBKIT_API void
+ webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains);
+
+ WEBKIT_API void
+ webkit_reset_origin_access_white_lists();
+
+ // WebKitWebDataSource private
+ WebKitWebDataSource*
+ webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader>);
+
+ WEBKIT_API WebKitWebDatabase *
+ webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const char* databaseName);
+
+ WEBKIT_API void
+ webkit_web_frame_layout(WebKitWebFrame* frame);
+}
+
+namespace WTF {
+ template <> void freeOwnedGPtr<SoupMessage>(SoupMessage*);
+ template <> void freeOwnedGPtr<WebKitNetworkRequest>(WebKitNetworkRequest*);
+ template <> void freeOwnedGPtr<WebKitNetworkResponse>(WebKitNetworkResponse*);
+ template <> void freeOwnedGPtr<WebKitWebResource>(WebKitWebResource*);
}
#endif
diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.cpp b/WebKit/gtk/webkit/webkitsecurityorigin.cpp
new file mode 100644
index 0000000..cd80236
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitsecurityorigin.cpp
@@ -0,0 +1,423 @@
+/*
+ * Copyright (C) 2009 Martin Robinson, Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatabase.h"
+
+#include "webkitprivate.h"
+
+#include "CString.h"
+#include "PlatformString.h"
+#include "DatabaseTracker.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitsecurityorigin
+ * @short_description: A security boundary for web sites
+ *
+ * #WebKitSecurityOrigin is a representation of a security domain defined
+ * by web sites. An origin consists of a host name, a protocol, and a port
+ * number. Web sites with the same security origin can access each other's
+ * resources for client-side scripting or database access.
+ *
+ * Use #webkit_web_frame_get_security_origin to get the security origin of a
+ * #WebKitWebFrame.
+ *
+ * Database quotas and usages are also defined per security origin. The
+ * cumulative disk usage of an origin's databases may be retrieved with
+ * #webkit_security_origin_get_web_database_usage. An origin's quota can be
+ * adjusted with #webkit_security_origin_set_web_database_quota.
+ */
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_PROTOCOL,
+ PROP_HOST,
+ PROP_PORT,
+ PROP_DATABASE_USAGE,
+ PROP_DATABASE_QUOTA
+};
+
+G_DEFINE_TYPE(WebKitSecurityOrigin, webkit_security_origin, G_TYPE_OBJECT)
+
+static void webkit_security_origin_finalize(GObject* object)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+
+ g_free(priv->protocol);
+ g_free(priv->host);
+
+ G_OBJECT_CLASS(webkit_security_origin_parent_class)->finalize(object);
+}
+
+static void webkit_security_origin_dispose(GObject* object)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+
+ if (!priv->disposed) {
+ priv->coreOrigin->deref();
+ g_hash_table_destroy(priv->webDatabases);
+ priv->disposed = true;
+ }
+
+ G_OBJECT_CLASS(webkit_security_origin_parent_class)->dispose(object);
+}
+
+static void webkit_security_origin_set_property(GObject* object, guint propId, const GValue* value, GParamSpec* pspec)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+
+ switch (propId) {
+ case PROP_DATABASE_QUOTA:
+ webkit_security_origin_set_web_database_quota(securityOrigin, g_value_get_uint64(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_security_origin_get_property(GObject* object, guint propId, GValue* value, GParamSpec* pspec)
+{
+ WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
+
+ switch (propId) {
+ case PROP_PROTOCOL:
+ g_value_set_string(value, webkit_security_origin_get_protocol(securityOrigin));
+ break;
+ case PROP_HOST:
+ g_value_set_string(value, webkit_security_origin_get_host(securityOrigin));
+ break;
+ case PROP_PORT:
+ g_value_set_uint(value, webkit_security_origin_get_port(securityOrigin));
+ break;
+ case PROP_DATABASE_USAGE:
+ g_value_set_uint64(value, webkit_security_origin_get_web_database_usage(securityOrigin));
+ break;
+ case PROP_DATABASE_QUOTA:
+ g_value_set_uint64(value, webkit_security_origin_get_web_database_quota(securityOrigin));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static GHashTable* webkit_security_origins()
+{
+ static GHashTable* securityOrigins = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref);
+ return securityOrigins;
+}
+
+static void webkit_security_origin_class_init(WebKitSecurityOriginClass* klass)
+{
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+ gobjectClass->dispose = webkit_security_origin_dispose;
+ gobjectClass->finalize = webkit_security_origin_finalize;
+ gobjectClass->set_property = webkit_security_origin_set_property;
+ gobjectClass->get_property = webkit_security_origin_get_property;
+
+ /**
+ * WebKitSecurityOrigin:protocol:
+ *
+ * The protocol of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PROTOCOL,
+ g_param_spec_string("protocol",
+ _("Protocol"),
+ _("The protocol of the security origin"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:host:
+ *
+ * The host of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_HOST,
+ g_param_spec_string("host",
+ _("Host"),
+ _("The host of the security origin"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:port:
+ *
+ * The port of the security origin.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PORT,
+ g_param_spec_uint("port",
+ _("Port"),
+ _("The port of the security origin"),
+ 0, G_MAXUSHORT, 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitSecurityOrigin:web-database-usage:
+ *
+ * The cumulative size of all web databases in the security origin in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DATABASE_USAGE,
+ g_param_spec_uint64("web-database-usage",
+ _("Web Database Usage"),
+ _("The cumulative size of all web databases in the security origin"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitSecurityOrigin:web-database-quota:
+ *
+ * The web database qouta of the security origin in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DATABASE_QUOTA,
+ g_param_spec_uint64("web-database-quota",
+ _("Web Database Quota"),
+ _("The web database quota of the security origin in bytes"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READWRITE));
+
+ g_type_class_add_private(klass, sizeof(WebKitSecurityOriginPrivate));
+}
+
+static void webkit_security_origin_init(WebKitSecurityOrigin* securityOrigin)
+{
+ WebKitSecurityOriginPrivate* priv = WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(securityOrigin);
+ priv->webDatabases = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+ securityOrigin->priv = priv;
+}
+
+/**
+ * webkit_security_origin_get_protocol:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the protocol for the security origin.
+ *
+ * Returns: the protocol for the security origin
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_security_origin_get_protocol(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ WebCore::String protocol = priv->coreOrigin->protocol();
+
+ if (!priv->protocol)
+ priv->protocol = g_strdup(protocol.utf8().data());
+
+ return priv->protocol;
+}
+
+/**
+ * webkit_security_origin_get_host:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the hostname for the security origin.
+ *
+ * Returns: the hostname for the security origin
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_security_origin_get_host(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ WebCore::String host = priv->coreOrigin->host();
+
+ if (!priv->host)
+ priv->host = g_strdup(host.utf8().data());
+
+ return priv->host;
+}
+
+/**
+ * webkit_security_origin_get_port:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the port for the security origin.
+ *
+ * Returns: the port for the security origin
+ *
+ * Since: 1.1.14
+ **/
+guint webkit_security_origin_get_port(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return coreOrigin->port();
+}
+
+/**
+ * webkit_security_origin_get_web_database_usage:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the cumulative size of all Web Database database's in the origin
+ * in bytes.
+ *
+ * Returns: the cumulative size of all databases
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_security_origin_get_web_database_usage(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return WebCore::DatabaseTracker::tracker().usageForOrigin(coreOrigin);
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_security_origin_get_web_database_quota:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns the quota for Web Database storage of the security origin
+ * in bytes.
+ *
+ * Returns: the Web Database quota
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_security_origin_get_web_database_quota(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), 0);
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ return WebCore::DatabaseTracker::tracker().quotaForOrigin(coreOrigin);
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_security_origin_set_web_database_quota:
+ * @security_origin: a #WebKitSecurityOrigin
+ * @quota: a new Web Database quota in bytes
+ *
+ * Adjust the quota for Web Database storage of the security origin
+ *
+ * Since: 1.1.14
+ **/
+void webkit_security_origin_set_web_database_quota(WebKitSecurityOrigin* securityOrigin, guint64 quota)
+{
+ g_return_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin));
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ WebCore::DatabaseTracker::tracker().setQuota(coreOrigin, quota);
+#endif
+}
+
+/**
+ * webkit_security_origin_get_all_web_databases:
+ * @security_origin: a #WebKitSecurityOrigin
+ *
+ * Returns a list of all Web Databases in the security origin.
+ *
+ * Returns: a #Glist of databases in the security origin.
+ *
+ * Since: 1.1.14
+ **/
+GList* webkit_security_origin_get_all_web_databases(WebKitSecurityOrigin* securityOrigin)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+ GList* databases = NULL;
+
+#if ENABLE(DATABASE)
+ WebCore::SecurityOrigin* coreOrigin = core(securityOrigin);
+ Vector<WebCore::String> databaseNames;
+
+ if (!WebCore::DatabaseTracker::tracker().databaseNamesForOrigin(coreOrigin, databaseNames))
+ return NULL;
+
+ for (unsigned i = 0; i < databaseNames.size(); ++i) {
+ WebKitWebDatabase* database = webkit_security_origin_get_web_database(securityOrigin, databaseNames[i].utf8().data());
+ databases = g_list_append(databases, database);
+ }
+#endif
+
+ return databases;
+}
+
+WebKitSecurityOrigin* WebKit::kit(WebCore::SecurityOrigin* coreOrigin)
+{
+ ASSERT(coreOrigin);
+
+ GHashTable* table = webkit_security_origins();
+ WebKitSecurityOrigin* origin = (WebKitSecurityOrigin*) g_hash_table_lookup(table, coreOrigin);
+
+ if (!origin) {
+ origin = WEBKIT_SECURITY_ORIGIN(g_object_new(WEBKIT_TYPE_SECURITY_ORIGIN, NULL));
+ origin->priv->coreOrigin = coreOrigin;
+ g_hash_table_insert(table, coreOrigin, origin);
+ }
+
+ return origin;
+}
+
+
+WebCore::SecurityOrigin* WebKit::core(WebKitSecurityOrigin* securityOrigin)
+{
+ ASSERT(securityOrigin);
+
+ return securityOrigin->priv->coreOrigin.get();
+}
+
+WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const gchar* databaseName)
+{
+ g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL);
+
+ WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
+ GHashTable* databaseHash = priv->webDatabases;
+ WebKitWebDatabase* database = (WebKitWebDatabase*) g_hash_table_lookup(databaseHash, databaseName);
+
+ if (!database) {
+ database = WEBKIT_WEB_DATABASE(g_object_new(WEBKIT_TYPE_WEB_DATABASE,
+ "security-origin", securityOrigin,
+ "name", databaseName,
+ NULL));
+ g_hash_table_insert(databaseHash, g_strdup(databaseName), database);
+ }
+
+ return database;
+}
+
diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.h b/WebKit/gtk/webkit/webkitsecurityorigin.h
new file mode 100644
index 0000000..57bcd19
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitsecurityorigin.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2009 Martin Robinson, Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitsecurityorigin_h
+#define webkitsecurityorigin_h
+
+#include "webkitsecurityorigin.h"
+#include "webkitwebdatabase.h"
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_SECURITY_ORIGIN (webkit_security_origin_get_type())
+#define WEBKIT_SECURITY_ORIGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOrigin))
+#define WEBKIT_SECURITY_ORIGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginClass))
+#define WEBKIT_IS_SECURITY_ORIGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SECURITY_ORIGIN))
+#define WEBKIT_IS_SECURITY_ORIGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SECURITY_ORIGIN))
+#define WEBKIT_SECURITY_ORIGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginClass))
+
+typedef struct _WebKitSecurityOriginPrivate WebKitSecurityOriginPrivate;
+
+struct _WebKitSecurityOrigin {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitSecurityOriginPrivate* priv;
+};
+
+struct _WebKitSecurityOriginClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_security_origin_get_type (void);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_security_origin_get_protocol (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_security_origin_get_host (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint
+webkit_security_origin_get_port (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint64
+webkit_security_origin_get_web_database_usage (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API guint64
+webkit_security_origin_get_web_database_quota (WebKitSecurityOrigin* securityOrigin);
+
+WEBKIT_API void
+webkit_security_origin_set_web_database_quota (WebKitSecurityOrigin* securityOrigin, guint64 quota);
+
+WEBKIT_API GList *
+webkit_security_origin_get_all_web_databases (WebKitSecurityOrigin* securityOrigin);
+
+G_END_DECLS
+
+#endif /* __WEBKIT_SECURITY_ORIGIN_H__ */
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.c b/WebKit/gtk/webkit/webkitsoupauthdialog.c
index 9bc188e..538dbfa 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.c
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.c
@@ -19,25 +19,24 @@
#include "config.h"
+#define LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY
+
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
-#if USE(GNOMEKEYRING)
-#include <gnome-keyring.h>
-#endif
#include "webkitmarshal.h"
#include "webkitsoupauthdialog.h"
/**
* SECTION:webkitsoupauthdialog
- * @short_description: A #SoupFeature to provide a simple
+ * @short_description: A #SoupSessionFeature to provide a simple
* authentication dialog for HTTP basic auth support.
*
- * #WebKitSoupAuthDialog is a #SoupFeature that you can attach to your
- * #SoupSession to provide a simple authentication dialog, with
- * optional GNOME Keyring support, while handling HTTP basic auth. It
- * is built as a simple C-only module to ease reuse.
+ * #WebKitSoupAuthDialog is a #SoupSessionFeature that you can attach to your
+ * #SoupSession to provide a simple authentication dialog while
+ * handling HTTP basic auth. It is built as a simple C-only module
+ * to ease reuse.
*/
static void webkit_soup_auth_dialog_session_feature_init(SoupSessionFeatureInterface* feature_interface, gpointer interface_data);
@@ -88,9 +87,7 @@ typedef struct _WebKitAuthData {
SoupSessionFeature* manager;
GtkWidget* loginEntry;
GtkWidget* passwordEntry;
-#if USE(GNOMEKEYRING)
GtkWidget* checkButton;
-#endif
char *username;
char *password;
} WebKitAuthData;
@@ -103,63 +100,53 @@ static void free_authData(WebKitAuthData* authData)
g_slice_free(WebKitAuthData, authData);
}
-#if USE(GNOMEKEYRING)
-static void set_password_callback(GnomeKeyringResult result, guint32 val, gpointer user_data)
-{
- /* Dummy callback, gnome_keyring_set_network_password does not accept a NULL one */
-}
-
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
static void save_password_callback(SoupMessage* msg, WebKitAuthData* authData)
{
- /* Check only for Success status codes (2xx) */
- if (msg->status_code >= 200 && msg->status_code < 300) {
- SoupURI* uri = soup_message_get_uri(authData->msg);
- gnome_keyring_set_network_password(NULL,
- authData->username,
- soup_auth_get_realm(authData->auth),
- uri->host,
- NULL,
- uri->scheme,
- soup_auth_get_scheme_name(authData->auth),
- uri->port,
- authData->password,
- (GnomeKeyringOperationGetIntCallback)set_password_callback,
- NULL,
- NULL);
- }
+ /* Anything but 401 and 5xx means the password was accepted */
+ if (msg->status_code != 401 && msg->status_code < 500)
+ soup_auth_save_password(authData->auth, authData->username, authData->password);
+
+ /* Disconnect the callback. If the authentication succeeded we are
+ * done, and if it failed we'll create a new authData and we'll
+ * connect to 'got-headers' again in response_callback */
+ g_signal_handlers_disconnect_by_func(msg, save_password_callback, authData);
+
free_authData(authData);
}
#endif
static void response_callback(GtkDialog* dialog, gint response_id, WebKitAuthData* authData)
{
- switch(response_id) {
- case GTK_RESPONSE_OK:
+ gboolean freeAuthData = TRUE;
+
+ if (response_id == GTK_RESPONSE_OK) {
authData->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->loginEntry)));
authData->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->passwordEntry)));
+
soup_auth_authenticate(authData->auth, authData->username, authData->password);
-#if USE(GNOMEKEYRING)
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton)))
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ if (authData->checkButton &&
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton))) {
g_signal_connect(authData->msg, "got-headers", G_CALLBACK(save_password_callback), authData);
+ freeAuthData = FALSE;
+ }
#endif
- default:
- break;
}
soup_session_unpause_message(authData->session, authData->msg);
-#if !USE(GNOMEKEYRING)
- free_authData(authData);
-#endif
+ if (freeAuthData)
+ free_authData(authData);
gtk_widget_destroy(GTK_WIDGET(dialog));
}
static GtkWidget *
-table_add_entry (GtkWidget* table,
- int row,
- const char* label_text,
- const char* value,
- gpointer user_data)
+table_add_entry(GtkWidget* table,
+ int row,
+ const char* label_text,
+ const char* value,
+ gpointer user_data)
{
GtkWidget* entry;
GtkWidget* label;
@@ -182,6 +169,15 @@ table_add_entry (GtkWidget* table,
return entry;
}
+static gboolean session_can_save_passwords(SoupSession* session)
+{
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ return soup_session_get_feature(session, SOUP_TYPE_PASSWORD_MANAGER) != NULL;
+#else
+ return FALSE;
+#endif
+}
+
static void show_auth_dialog(WebKitAuthData* authData, const char* login, const char* password)
{
GtkWidget* toplevel;
@@ -197,10 +193,8 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
GtkWidget* messageLabel;
char* message;
SoupURI* uri;
-#if USE(GNOMEKEYRING)
GtkWidget* rememberBox;
GtkWidget* checkButton;
-#endif
/* From GTK+ gtkmountoperation.c, modified and simplified. LGPL 2 license */
@@ -215,9 +209,9 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
/* Set the dialog up with HIG properties */
gtk_dialog_set_has_separator(dialog, FALSE);
- gtk_container_set_border_width(GTK_CONTAINER (dialog), 5);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
gtk_box_set_spacing(GTK_BOX(dialog->vbox), 2); /* 2 * 5 + 2 = 12 */
- gtk_container_set_border_width(GTK_CONTAINER (dialog->action_area), 5);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog->action_area), 5);
gtk_box_set_spacing(GTK_BOX(dialog->action_area), 6);
gtk_window_set_resizable(window, FALSE);
@@ -256,7 +250,7 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
FALSE, FALSE, 0);
vbox = gtk_vbox_new(FALSE, 6);
- gtk_box_pack_start(GTK_BOX (mainVBox), vbox, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(mainVBox), vbox, FALSE, FALSE, 0);
/* The table that holds the entries */
entryContainer = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -268,8 +262,8 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
FALSE, FALSE, 0);
table = gtk_table_new(2, 2, FALSE);
- gtk_table_set_col_spacings(GTK_TABLE (table), 12);
- gtk_table_set_row_spacings(GTK_TABLE (table), 6);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 12);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 6);
gtk_container_add(GTK_CONTAINER(entryContainer), table);
authData->loginEntry = table_add_entry(table, 0, _("Username:"),
@@ -279,77 +273,55 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
gtk_entry_set_visibility(GTK_ENTRY(authData->passwordEntry), FALSE);
-#if USE(GNOMEKEYRING)
- rememberBox = gtk_vbox_new (FALSE, 6);
- gtk_box_pack_start (GTK_BOX (vbox), rememberBox,
- FALSE, FALSE, 0);
-
- checkButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
- if (login && password)
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
- gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
- gtk_box_pack_start (GTK_BOX (rememberBox), checkButton, FALSE, FALSE, 0);
- authData->checkButton = checkButton;
-#endif
+ if (session_can_save_passwords(authData->session)) {
+ rememberBox = gtk_vbox_new(FALSE, 6);
+ gtk_box_pack_start(GTK_BOX(vbox), rememberBox,
+ FALSE, FALSE, 0);
+ checkButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
+ if (login && password)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
+ gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
+ gtk_box_pack_start(GTK_BOX(rememberBox), checkButton, FALSE, FALSE, 0);
+ authData->checkButton = checkButton;
+ }
g_signal_connect(dialog, "response", G_CALLBACK(response_callback), authData);
gtk_widget_show_all(widget);
}
-#if USE(GNOMEKEYRING)
-static void find_password_callback(GnomeKeyringResult result, GList* list, WebKitAuthData* authData)
-{
- GList* p;
- const char* login = NULL;
- const char* password = NULL;
-
- for (p = list; p; p = p->next) {
- /* FIXME: support multiple logins/passwords ? */
- GnomeKeyringNetworkPasswordData* data = (GnomeKeyringNetworkPasswordData*)p->data;
- login = data->user;
- password = data->password;
- break;
- }
-
- show_auth_dialog(authData, login, password);
-}
-#endif
-
static void session_authenticate(SoupSession* session, SoupMessage* msg, SoupAuth* auth, gboolean retrying, gpointer user_data)
{
SoupURI* uri;
WebKitAuthData* authData;
SoupSessionFeature* manager = (SoupSessionFeature*)user_data;
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ GSList* users;
+#endif
+ const char *login, *password;
soup_session_pause_message(session, msg);
/* We need to make sure the message sticks around when pausing it */
g_object_ref(msg);
uri = soup_message_get_uri(msg);
- authData = g_slice_new(WebKitAuthData);
+ authData = g_slice_new0(WebKitAuthData);
authData->msg = msg;
authData->auth = auth;
authData->session = session;
authData->manager = manager;
- /*
- * If we have gnome-keyring let's try to find the password first in the ring.
- * Otherwise just show the dialog straight away
- */
-#if USE(GNOMEKEYRING)
- gnome_keyring_find_network_password(NULL,
- soup_auth_get_realm(auth),
- uri->host,
- NULL,
- uri->scheme,
- soup_auth_get_scheme_name(auth),
- uri->port,
- (GnomeKeyringOperationGetListCallback)find_password_callback,
- authData,
- NULL);
-#else
- show_auth_dialog(authData, NULL, NULL);
+ login = password = NULL;
+
+#ifdef SOUP_TYPE_PASSWORD_MANAGER
+ users = soup_auth_get_saved_users(auth);
+ if (users) {
+ login = users->data;
+ password = soup_auth_get_saved_password(auth, login);
+ g_slist_free(users);
+ }
#endif
+
+ show_auth_dialog(authData, login, password);
}
static void attach(SoupSessionFeature* manager, SoupSession* session)
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.h b/WebKit/gtk/webkit/webkitsoupauthdialog.h
index 9721c72..01ccfc8 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.h
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.h
@@ -22,8 +22,8 @@
#include <webkit/webkitdefines.h>
-#ifndef WEBKIT_SOUP_AUTH_DIALOG_H
-#define WEBKIT_SOUP_AUTH_DIALOG_H 1
+#ifndef webkitsoupauthdialog_h
+#define webkitsoupauthdialog_h
G_BEGIN_DECLS
@@ -49,4 +49,4 @@ webkit_soup_auth_dialog_get_type (void);
G_END_DECLS
-#endif /* WEBKIT_SOUP_AUTH_DIALOG_H */
+#endif /* webkitsoupauthdialog_h */
diff --git a/WebKit/gtk/webkit/webkitversion.h.in b/WebKit/gtk/webkit/webkitversion.h.in
index 9f1b818..5eb9426 100644
--- a/WebKit/gtk/webkit/webkitversion.h.in
+++ b/WebKit/gtk/webkit/webkitversion.h.in
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_VERSION_H
-#define WEBKIT_VERSION_H
+#ifndef webkitversion_h
+#define webkitversion_h
#include <glib.h>
#include <webkit/webkitdefines.h>
diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.h b/WebKit/gtk/webkit/webkitwebbackforwardlist.h
index a44cbcd..d08566e 100644
--- a/WebKit/gtk/webkit/webkitwebbackforwardlist.h
+++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_BACK_FORWARD_LIST_H
-#define WEBKIT_WEB_BACK_FORWARD_LIST_H
+#ifndef webkitwebbackforwardlist_h
+#define webkitwebbackforwardlist_h
#include <glib.h>
#include <glib-object.h>
@@ -114,4 +114,4 @@ webkit_web_back_forward_list_add_item (WebKitWebBackForwardLi
G_END_DECLS
-#endif /* WEBKIT_WEB_BACK_FORWARD_LIST_H */
+#endif /* webkitwebbackforwardlist_h */
diff --git a/WebKit/gtk/webkit/webkitwebdatabase.cpp b/WebKit/gtk/webkit/webkitwebdatabase.cpp
new file mode 100644
index 0000000..100176e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatabase.cpp
@@ -0,0 +1,533 @@
+/*
+ * Copyright (C) 2009 Martin Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatabase.h"
+
+#include "webkitprivate.h"
+
+#include "CString.h"
+#include "DatabaseDetails.h"
+#include "DatabaseTracker.h"
+
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitwebdatabase
+ * @short_description: A WebKit web application database
+ *
+ * #WebKitWebDatabase is a representation of a Web Database database. The
+ * proposed Web Database standard introduces support for SQL databases that web
+ * sites can create and access on a local computer through JavaScript.
+ *
+ * To get access to all databases defined by a security origin, use
+ * #webkit_security_origin_get_databases. Each database has a canonical
+ * name, as well as a user-friendly display name.
+ *
+ * WebKit uses SQLite to create and access the local SQL databases. The location
+ * of a #WebKitWebDatabase can be accessed wth #webkit_web_database_get_filename.
+ * You can configure the location of all databases with
+ * #webkit_set_database_directory_path.
+ *
+ * For each database the web site can define an estimated size which can be
+ * accessed with #webkit_web_database_get_expected_size. The current size of the
+ * database in bytes is returned by #webkit_web_database_get_size.
+ *
+ * For more information refer to the Web Database specification proposal at
+ * http://dev.w3.org/html5/webdatabase
+ */
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_SECURITY_ORIGIN,
+ PROP_NAME,
+ PROP_DISPLAY_NAME,
+ PROP_EXPECTED_SIZE,
+ PROP_SIZE,
+ PROP_PATH
+};
+
+G_DEFINE_TYPE(WebKitWebDatabase, webkit_web_database, G_TYPE_OBJECT)
+
+struct _WebKitWebDatabasePrivate {
+ WebKitSecurityOrigin* origin;
+ gchar* name;
+ gchar* displayName;
+ gchar* filename;
+};
+
+static gchar* webkit_database_directory_path = NULL;
+static guint64 webkit_default_database_quota = 5 * 1024 * 1024;
+
+#define WEBKIT_WEB_DATABASE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabasePrivate))
+
+static void webkit_web_database_set_security_origin(WebKitWebDatabase* webDatabase, WebKitSecurityOrigin* security_origin);
+
+static void webkit_web_database_set_name(WebKitWebDatabase* webDatabase, const gchar* name);
+
+static void webkit_web_database_finalize(GObject* object)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ g_free(priv->name);
+ g_free(priv->displayName);
+ g_free(priv->filename);
+
+ G_OBJECT_CLASS(webkit_web_database_parent_class)->finalize(object);
+}
+
+static void webkit_web_database_dispose(GObject* object)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ if (priv->origin) {
+ g_object_unref(priv->origin);
+ priv->origin = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_database_parent_class)->dispose(object);
+}
+
+static void webkit_web_database_set_property(GObject* object, guint propId, const GValue* value, GParamSpec* pspec)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+
+ switch (propId) {
+ case PROP_SECURITY_ORIGIN:
+ webkit_web_database_set_security_origin(webDatabase, WEBKIT_SECURITY_ORIGIN(g_value_get_object(value)));
+ break;
+ case PROP_NAME:
+ webkit_web_database_set_name(webDatabase, g_value_get_string(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_web_database_get_property(GObject* object, guint propId, GValue* value, GParamSpec* pspec)
+{
+ WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ switch (propId) {
+ case PROP_SECURITY_ORIGIN:
+ g_value_set_object(value, priv->origin);
+ break;
+ case PROP_NAME:
+ g_value_set_string(value, webkit_web_database_get_name(webDatabase));
+ break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_string(value, webkit_web_database_get_display_name(webDatabase));
+ break;
+ case PROP_EXPECTED_SIZE:
+ g_value_set_uint64(value, webkit_web_database_get_expected_size(webDatabase));
+ break;
+ case PROP_SIZE:
+ g_value_set_uint64(value, webkit_web_database_get_size(webDatabase));
+ break;
+ case PROP_PATH:
+ g_value_set_string(value, webkit_web_database_get_filename(webDatabase));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec);
+ break;
+ }
+}
+
+static void webkit_web_database_class_init(WebKitWebDatabaseClass* klass)
+{
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(klass);
+ gobjectClass->dispose = webkit_web_database_dispose;
+ gobjectClass->finalize = webkit_web_database_finalize;
+ gobjectClass->set_property = webkit_web_database_set_property;
+ gobjectClass->get_property = webkit_web_database_get_property;
+
+ /**
+ * WebKitWebDatabase:security-origin:
+ *
+ * The security origin of the database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_SECURITY_ORIGIN,
+ g_param_spec_object("security-origin",
+ _("Security Origin"),
+ _("The security origin of the database"),
+ WEBKIT_TYPE_SECURITY_ORIGIN,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitWebDatabase:name:
+ *
+ * The name of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_NAME,
+ g_param_spec_string("name",
+ _("Name"),
+ _("The name of the Web Database database"),
+ NULL,
+ (GParamFlags) (G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitWebDatabase:display-name:
+ *
+ * The display name of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_DISPLAY_NAME,
+ g_param_spec_string("display-name",
+ _("Display Name"),
+ _("The display name of the Web Storage database"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebDatabase:expected-size:
+ *
+ * The expected size of the database in bytes as defined by the web author.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_EXPECTED_SIZE,
+ g_param_spec_uint64("expected-size",
+ _("Expected Size"),
+ _("The expected size of the Web Database database"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebDatabase:size:
+ *
+ * The current size of the database in bytes.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_SIZE,
+ g_param_spec_uint64("size",
+ _("Size"),
+ _("The current size of the Web Database database"),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebDatabase:filename:
+ *
+ * The absolute filename of the Web Database database.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobjectClass, PROP_PATH,
+ g_param_spec_string("filename",
+ _("Filename"),
+ _("The absolute filename of the Web Storage database"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ g_type_class_add_private(klass, sizeof(WebKitWebDatabasePrivate));
+}
+
+static void webkit_web_database_init(WebKitWebDatabase* webDatabase)
+{
+ webDatabase->priv = WEBKIT_WEB_DATABASE_GET_PRIVATE(webDatabase);
+}
+
+// Internal use only
+static void webkit_web_database_set_security_origin(WebKitWebDatabase *webDatabase, WebKitSecurityOrigin *securityOrigin)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+ g_return_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin));
+
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ if (priv->origin)
+ g_object_unref(priv->origin);
+
+ g_object_ref(securityOrigin);
+ priv->origin = securityOrigin;
+}
+
+static void webkit_web_database_set_name(WebKitWebDatabase* webDatabase, const gchar* name)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ g_free(priv->name);
+ priv->name = g_strdup(name);
+}
+
+/**
+ * webkit_web_database_get_security_origin:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the security origin of the #WebKitWebDatabase.
+ *
+ * Returns: the security origin of the database
+ *
+ * Since: 1.1.14
+ **/
+WebKitSecurityOrigin* webkit_web_database_get_security_origin(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ return priv->origin;
+}
+
+/**
+ * webkit_web_database_get_name:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the canonical name of the #WebKitWebDatabase.
+ *
+ * Returns: the name of the database
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_name(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+
+ return priv->name;
+}
+
+/**
+ * webkit_web_database_get_display_name:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the name of the #WebKitWebDatabase as seen by the user.
+ *
+ * Returns: the name of the database as seen by the user.
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_display_name(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ WebCore::String displayName = details.displayName();
+
+ if (displayName.isEmpty())
+ return "";
+
+ g_free(priv->displayName);
+ priv->displayName = g_strdup(displayName.utf8().data());
+ return priv->displayName;
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_web_database_get_expected_size:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the expected size of the #WebKitWebDatabase in bytes as defined by the
+ * web author. The Web Database standard allows web authors to specify an expected
+ * size of the database to optimize the user experience.
+ *
+ * Returns: the expected size of the database in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_web_database_get_expected_size(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), 0);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ return details.expectedUsage();
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_web_database_get_size:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the actual size of the #WebKitWebDatabase space on disk in bytes.
+ *
+ * Returns: the actual size of the database in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_web_database_get_size(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), 0);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(priv->name, core(priv->origin));
+ return details.currentUsage();
+#else
+ return 0;
+#endif
+}
+
+/**
+ * webkit_web_database_get_filename:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Returns the absolute filename to the #WebKitWebDatabase file on disk.
+ *
+ * Returns: the absolute filename of the database
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_web_database_get_filename(WebKitWebDatabase* webDatabase)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase), NULL);
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::String coreName = WebCore::String::fromUTF8(priv->name);
+ WebCore::String corePath = WebCore::DatabaseTracker::tracker().fullPathForDatabase(core(priv->origin), coreName);
+
+ if (corePath.isEmpty())
+ return"";
+
+ g_free(priv->filename);
+ priv->filename = g_strdup(corePath.utf8().data());
+ return priv->filename;
+
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_web_database_remove:
+ * @web_database: a #WebKitWebDatabase
+ *
+ * Removes the #WebKitWebDatabase from its security origin and destroys all data
+ * stored in the database.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_web_database_remove(WebKitWebDatabase* webDatabase)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_DATABASE(webDatabase));
+
+#if ENABLE(DATABASE)
+ WebKitWebDatabasePrivate* priv = webDatabase->priv;
+ WebCore::DatabaseTracker::tracker().deleteDatabase(core(priv->origin), priv->name);
+#endif
+}
+
+/**
+ * webkit_remove_all_web_databases:
+ *
+ * Removes all web databases from the current database directory path.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_remove_all_web_databases()
+{
+#if ENABLE(DATABASE)
+ WebCore::DatabaseTracker::tracker().deleteAllDatabases();
+#endif
+}
+
+/**
+ * webkit_get_web_database_directory_path:
+ *
+ * Returns the current path to the directory WebKit will write Web
+ * Database databases. By default this path will be in the user data
+ * directory.
+ *
+ * Returns: the current database directory path
+ *
+ * Since: 1.1.14
+ **/
+G_CONST_RETURN gchar* webkit_get_web_database_directory_path()
+{
+#if ENABLE(DATABASE)
+ WebCore::String path = WebCore::DatabaseTracker::tracker().databaseDirectoryPath();
+
+ if (path.isEmpty())
+ return "";
+
+ g_free(webkit_database_directory_path);
+ webkit_database_directory_path = g_strdup(path.utf8().data());
+ return webkit_database_directory_path;
+#else
+ return "";
+#endif
+}
+
+/**
+ * webkit_set_web_database_directory_path:
+ * @path: the new database directory path
+ *
+ * Sets the current path to the directory WebKit will write Web
+ * Database databases.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_set_web_database_directory_path(const gchar* path)
+{
+#if ENABLE(DATABASE)
+ WebCore::String corePath = WebCore::String::fromUTF8(path);
+ WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(corePath);
+
+ g_free(webkit_database_directory_path);
+ webkit_database_directory_path = g_strdup(corePath.utf8().data());
+#endif
+}
+
+/**
+ * webkit_get_default_web_database_quota:
+ *
+ * Returns the default quota for Web Database databases. By default
+ * this value is 5MB.
+
+ * Returns: the current default database quota in bytes
+ *
+ * Since: 1.1.14
+ **/
+guint64 webkit_get_default_web_database_quota()
+{
+ return webkit_default_database_quota;
+}
+
+/**
+ * webkit_set_default_web_database_quota:
+ * @default_quota: the new default database quota
+ *
+ * Sets the current path to the directory WebKit will write Web
+ * Database databases.
+ *
+ * Since: 1.1.14
+ **/
+void webkit_set_default_web_database_quota(guint64 defaultQuota)
+{
+ webkit_default_database_quota = defaultQuota;
+}
diff --git a/WebKit/gtk/webkit/webkitwebdatabase.h b/WebKit/gtk/webkit/webkitwebdatabase.h
new file mode 100644
index 0000000..8a9a151
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatabase.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Martin Robinson
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebdatabase_h
+#define webkitwebdatabase_h
+
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_DATABASE (webkit_web_database_get_type())
+#define WEBKIT_WEB_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabase))
+#define WEBKIT_WEB_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabaseClass))
+#define WEBKIT_IS_WEB_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_DATABASE))
+#define WEBKIT_IS_WEB_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_DATABASE))
+#define WEBKIT_WEB_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabaseClass))
+
+typedef struct _WebKitWebDatabasePrivate WebKitWebDatabasePrivate;
+
+struct _WebKitWebDatabase {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebDatabasePrivate* priv;
+};
+
+struct _WebKitWebDatabaseClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_web_database_get_type (void);
+
+WEBKIT_API WebKitSecurityOrigin *
+webkit_web_database_get_security_origin (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_name (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_display_name (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API guint64
+webkit_web_database_get_expected_size (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API guint64
+webkit_web_database_get_size (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_web_database_get_filename (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API void
+webkit_web_database_remove (WebKitWebDatabase* webDatabase);
+
+WEBKIT_API void
+webkit_remove_all_web_databases (void);
+
+WEBKIT_API G_CONST_RETURN gchar*
+webkit_get_web_database_directory_path (void);
+
+WEBKIT_API void
+webkit_set_web_database_directory_path (const gchar* path);
+
+WEBKIT_API guint64
+webkit_get_default_web_database_quota (void);
+
+WEBKIT_API void
+webkit_set_default_web_database_quota (guint64 defaultQuota);
+
+G_END_DECLS
+
+#endif /* webkitwebdatabase_h */
diff --git a/WebKit/gtk/webkit/webkitwebdatasource.cpp b/WebKit/gtk/webkit/webkitwebdatasource.cpp
new file mode 100644
index 0000000..059688e
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatasource.cpp
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "webkitwebdatasource.h"
+
+#include "ArchiveResource.h"
+#include "DocumentLoaderGtk.h"
+#include "FrameLoaderClientGtk.h"
+#include "FrameLoader.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "ResourceRequest.h"
+#include "runtime/InitializeThreading.h"
+#include "SharedBuffer.h"
+#include "SubstituteData.h"
+#include "webkitwebresource.h"
+#include "webkitprivate.h"
+#include "wtf/Assertions.h"
+
+#include <glib.h>
+
+/**
+ * SECTION:webkitwebdatasource
+ * @short_description: Encapsulates the content to be displayed in a #WebKitWebFrame.
+ * @see_also: #WebKitWebFrame
+ *
+ * Data source encapsulates the content of a #WebKitWebFrame. A
+ * #WebKitWebFrame has a main resource and subresources and the data source
+ * provides access to these resources. When a request gets loaded initially,
+ * it is set to a provisional state. The application can request for the
+ * request that initiated the load by asking for the provisional data source
+ * and invoking the webkit_web_data_source_get_initial_request method of
+ * #WebKitWebDataSource. This data source may not have enough data and some
+ * methods may return empty values. To get a "full" data source with the data
+ * and resources loaded, you need to get the non-provisional data source
+ * through #WebKitWebFrame's webkit_web_frame_get_data_source method. This
+ * data source will have the data after everything was loaded. Make sure that
+ * the data source was finished loading before using any of its methods. You
+ * can do this via webkit_web_data_source_is_loading.
+ */
+
+using namespace WebCore;
+using namespace WebKit;
+
+struct _WebKitWebDataSourcePrivate {
+ WebKit::DocumentLoader* loader;
+
+ WebKitNetworkRequest* initialRequest;
+ WebKitNetworkRequest* networkRequest;
+ WebKitWebResource* mainresource;
+
+ GString* data;
+
+ gchar* textEncoding;
+ gchar* unreachableURL;
+};
+
+#define WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourcePrivate))
+
+G_DEFINE_TYPE(WebKitWebDataSource, webkit_web_data_source, G_TYPE_OBJECT);
+
+static void webkit_web_data_source_dispose(GObject* object)
+{
+ WebKitWebDataSource* webDataSource = WEBKIT_WEB_DATA_SOURCE(object);
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ ASSERT(priv->loader);
+ ASSERT(!priv->loader->isLoading());
+ priv->loader->detachDataSource();
+ priv->loader->deref();
+
+ if (priv->initialRequest) {
+ g_object_unref(priv->initialRequest);
+ priv->initialRequest = NULL;
+ }
+
+ if (priv->networkRequest) {
+ g_object_unref(priv->networkRequest);
+ priv->networkRequest = NULL;
+ }
+
+ if (priv->mainresource) {
+ g_object_unref(priv->mainresource);
+ priv->mainresource = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_data_source_parent_class)->dispose(object);
+}
+
+static void webkit_web_data_source_finalize(GObject* object)
+{
+ WebKitWebDataSource* dataSource = WEBKIT_WEB_DATA_SOURCE(object);
+ WebKitWebDataSourcePrivate* priv = dataSource->priv;
+
+ g_free(priv->unreachableURL);
+ g_free(priv->textEncoding);
+
+ if (priv->data) {
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+ }
+
+ G_OBJECT_CLASS(webkit_web_data_source_parent_class)->finalize(object);
+}
+
+static void webkit_web_data_source_class_init(WebKitWebDataSourceClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->dispose = webkit_web_data_source_dispose;
+ gobject_class->finalize = webkit_web_data_source_finalize;
+
+ webkit_init();
+
+ g_type_class_add_private(gobject_class, sizeof(WebKitWebDataSourcePrivate));
+}
+
+static void webkit_web_data_source_init(WebKitWebDataSource* webDataSource)
+{
+ webDataSource->priv = WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(webDataSource);
+}
+
+WebKitWebDataSource* webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader> loader)
+{
+ WebKitWebDataSource* webDataSource = WEBKIT_WEB_DATA_SOURCE(g_object_new(WEBKIT_TYPE_WEB_DATA_SOURCE, NULL));
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ priv->loader = loader.releaseRef();
+
+ return webDataSource;
+}
+
+/**
+ * webkit_web_data_source_new:
+ *
+ * Creates a new #WebKitWebDataSource instance. The URL of the
+ * #WebKitWebDataSource will be set to "about:blank".
+ *
+ * Return: a new #WebKitWebDataSource.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_data_source_new()
+{
+ WebKitNetworkRequest* request = webkit_network_request_new("about:blank");
+ WebKitWebDataSource* datasource = webkit_web_data_source_new_with_request(request);
+ g_object_unref(request);
+
+ return datasource;
+}
+
+/**
+ * webkit_web_data_source_new_with_request:
+ * @request: the #WebKitNetworkRequest to use to create this data source
+ *
+ * Creates a new #WebKitWebDataSource from a #WebKitNetworkRequest. Normally,
+ * #WebKitWebFrame objects create their data sources so you will almost never
+ * want to invoke this method directly.
+ *
+ * Returns: a new #WebKitWebDataSource
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_data_source_new_with_request(WebKitNetworkRequest* request)
+{
+ ASSERT(request);
+
+ const gchar* uri = webkit_network_request_get_uri(request);
+
+ WebKitWebDataSource* datasource;
+ datasource = webkit_web_data_source_new_with_loader(
+ WebKit::DocumentLoader::create(ResourceRequest(KURL(KURL(), String::fromUTF8(uri))),
+ SubstituteData()));
+
+ WebKitWebDataSourcePrivate* priv = datasource->priv;
+ priv->initialRequest = request;
+
+ return datasource;
+}
+
+/**
+ * webkit_web_data_source_get_web_frame
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the #WebKitWebFrame that represents this data source
+ *
+ * Return value: the #WebKitWebFrame that represents the @data_source. The
+ * #WebKitWebFrame is owned by WebKit and should not be freed or destroyed.
+ * This will return %NULL of the @data_source is not attached to a frame.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebFrame* webkit_web_data_source_get_web_frame(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ FrameLoader* frameLoader = priv->loader->frameLoader();
+
+ if (!frameLoader)
+ return NULL;
+
+ return static_cast<WebKit::FrameLoaderClient*>(frameLoader->client())->webFrame();
+}
+
+/**
+ * webkit_web_data_source_get_initial_request:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns a reference to the original request that was used to load the web
+ * content. The #WebKitNetworkRequest returned by this method is the request
+ * prior to the "committed" load state. See webkit_web_data_source_get_request
+ * for getting the "committed" request.
+ *
+ * Return value: the original #WebKitNetworkRequest
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkRequest* webkit_web_data_source_get_initial_request(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ ResourceRequest request = priv->loader->originalRequest();
+
+ if (priv->initialRequest)
+ g_object_unref(priv->initialRequest);
+
+ priv->initialRequest = webkit_network_request_new_with_core_request(request);
+ return priv->initialRequest;
+}
+
+/**
+ * webkit_web_data_source_get_request:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns a #WebKitNetworkRequest that was used to create this
+ * #WebKitWebDataSource. The #WebKitNetworkRequest returned by this method is
+ * the request that was "committed", and hence, different from the request you
+ * get from the webkit_web_data_source_get_initial_request method.
+ *
+ * Return value: the #WebKitNetworkRequest that created the @data_source or
+ * %NULL if the @data_source is not attached to the frame or the frame hasn't
+ * been loaded.
+ *
+ * Since: 1.1.14
+ */
+WebKitNetworkRequest* webkit_web_data_source_get_request(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ FrameLoader* frameLoader = priv->loader->frameLoader();
+ if (!frameLoader || !frameLoader->frameHasLoaded())
+ return NULL;
+
+ ResourceRequest request = priv->loader->request();
+
+ if (priv->networkRequest)
+ g_object_unref(priv->networkRequest);
+
+ priv->networkRequest = webkit_network_request_new_with_core_request(request);
+ return priv->networkRequest;
+}
+
+/**
+ * webkit_web_data_source_get_encoding:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the text encoding name as set in the #WebKitWebView, or if not, the
+ * text encoding of the response.
+ *
+ * Return value: the encoding name of the #WebKitWebView or of the response.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_data_source_get_encoding(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ String textEncodingName = priv->loader->overrideEncoding();
+
+ if (!textEncodingName)
+ textEncodingName = priv->loader->response().textEncodingName();
+
+ CString encoding = textEncodingName.utf8();
+ g_free(priv->textEncoding);
+ priv->textEncoding = g_strdup(encoding.data());
+ return priv->textEncoding;
+}
+
+/**
+ * webkit_web_data_source_is_loading:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Determines whether the data source is in the process of loading its content.
+ *
+ * Return value: %TRUE if the @data_source is still loading, %FALSE otherwise
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_data_source_is_loading(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ return priv->loader->isLoadingInAPISense();
+}
+
+/**
+ * webkit_web_data_source_get_data:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the raw data that represents the the frame's content.The data will
+ * be incomplete until the data has finished loading. Returns %NULL if the web
+ * frame hasn't loaded any data. Use webkit_web_data_source_is_loading to test
+ * if data source is in the process of loading.
+ *
+ * Return value: a #GString which contains the raw data that represents the @data_source or %NULL if the
+ * @data_source hasn't loaded any data.
+ *
+ * Since: 1.1.14
+ */
+GString* webkit_web_data_source_get_data(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ RefPtr<SharedBuffer> mainResourceData = priv->loader->mainResourceData();
+
+ if (!mainResourceData)
+ return NULL;
+
+ if (priv->data) {
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+ }
+
+ priv->data = g_string_new_len(mainResourceData->data(), mainResourceData->size());
+ return priv->data;
+}
+
+/**
+ * webkit_web_data_source_get_main_resource:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Returns the main resource of the @data_source
+ *
+ * Return value: a new #WebKitWebResource representing the main resource of
+ * the @data_source.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebResource* webkit_web_data_source_get_main_resource(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+
+ if (priv->mainresource)
+ return priv->mainresource;
+
+ WebKitWebFrame* webFrame = webkit_web_data_source_get_web_frame(webDataSource);
+ WebKitWebView* webView = getViewFromFrame(webFrame);
+
+ priv->mainresource = WEBKIT_WEB_RESOURCE(g_object_ref(webkit_web_view_get_main_resource(webView)));
+
+ return priv->mainresource;
+}
+
+/**
+ * webkit_web_data_source_get_unreachable_uri:
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Return the unreachable URI of @data_source. The @data_source will have an
+ * unreachable URL if it was created using #WebKitWebFrame's
+ * webkit_web_frame_load_alternate_html_string method.
+ *
+ * Return value: the unreachable URL of @data_source or %NULL if there is no unreachable URL.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_data_source_get_unreachable_uri(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebDataSourcePrivate* priv = webDataSource->priv;
+ const KURL& unreachableURL = priv->loader->unreachableURL();
+
+ if (unreachableURL.isEmpty())
+ return NULL;
+
+ g_free(priv->unreachableURL);
+ priv->unreachableURL = g_strdup(unreachableURL.string().utf8().data());
+ return priv->unreachableURL;
+}
+
+/**
+ * webkit_web_data_source_get_subresources
+ * @data_source: a #WebKitWebDataSource
+ *
+ * Gives you a #GList of #WebKitWebResource objects that compose the
+ * #WebView to which this #WebKitWebDataSource is attached.
+ *
+ * Return value: a #GList of #WebKitResource objects; the objects are
+ * owned by WebKit, but the GList must be freed.
+ *
+ * Since: 1.1.15
+ */
+GList* webkit_web_data_source_get_subresources(WebKitWebDataSource* webDataSource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL);
+
+ WebKitWebFrame* webFrame = webkit_web_data_source_get_web_frame(webDataSource);
+ WebKitWebView* webView = getViewFromFrame(webFrame);
+
+ return webkit_web_view_get_subresources(webView);
+}
diff --git a/WebKit/gtk/webkit/webkitwebdatasource.h b/WebKit/gtk/webkit/webkitwebdatasource.h
new file mode 100644
index 0000000..df83118
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebdatasource.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebdatasource_h
+#define webkitwebdatasource_h
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+#include <webkit/webkitwebframe.h>
+#include <webkit/webkitnetworkrequest.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_DATA_SOURCE (webkit_web_data_source_get_type())
+#define WEBKIT_WEB_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSource))
+#define WEBKIT_WEB_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourceClass))
+#define WEBKIT_IS_WEB_DATA_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_DATA_SOURCE))
+#define WEBKIT_IS_WEB_DATA_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_DATA_SOURCE))
+#define WEBKIT_WEB_DATA_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourceClass))
+
+typedef struct _WebKitWebDataSourcePrivate WebKitWebDataSourcePrivate;
+
+struct _WebKitWebDataSource {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebDataSourcePrivate *priv;
+};
+
+struct _WebKitWebDataSourceClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_data_source_get_type (void);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_data_source_new (void);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_data_source_new_with_request (WebKitNetworkRequest *request);
+
+WEBKIT_API WebKitWebFrame *
+webkit_web_data_source_get_web_frame (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitNetworkRequest *
+webkit_web_data_source_get_initial_request (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitNetworkRequest *
+webkit_web_data_source_get_request (WebKitWebDataSource *data_source);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_data_source_get_encoding (WebKitWebDataSource *data_source);
+
+WEBKIT_API gboolean
+webkit_web_data_source_is_loading (WebKitWebDataSource *data_source);
+
+WEBKIT_API GString *
+webkit_web_data_source_get_data (WebKitWebDataSource *data_source);
+
+WEBKIT_API WebKitWebResource *
+webkit_web_data_source_get_main_resource (WebKitWebDataSource *data_source);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_data_source_get_unreachable_uri (WebKitWebDataSource *data_source);
+
+WEBKIT_API GList*
+webkit_web_data_source_get_subresources (WebKitWebDataSource *data_source);
+
+G_END_DECLS
+
+#endif /* webkitwebdatasource_h */
diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index fba084e..67fa632 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -37,6 +37,7 @@
#include "AXObjectCache.h"
#include "CString.h"
#include "DocumentLoader.h"
+#include "DocumentLoaderGtk.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
#include "FrameTree.h"
@@ -85,6 +86,7 @@ enum {
LOAD_DONE,
TITLE_CHANGED,
HOVERING_OVER_LINK,
+ SCROLLBARS_POLICY_CHANGED,
LAST_SIGNAL
};
@@ -94,7 +96,9 @@ enum {
PROP_NAME,
PROP_TITLE,
PROP_URI,
- PROP_LOAD_STATUS
+ PROP_LOAD_STATUS,
+ PROP_HORIZONTAL_SCROLLBAR_POLICY,
+ PROP_VERTICAL_SCROLLBAR_POLICY
};
static guint webkit_web_frame_signals[LAST_SIGNAL] = { 0, };
@@ -118,6 +122,12 @@ static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue
case PROP_LOAD_STATUS:
g_value_set_enum(value, webkit_web_frame_get_load_status(frame));
break;
+ case PROP_HORIZONTAL_SCROLLBAR_POLICY:
+ g_value_set_enum(value, webkit_web_frame_get_horizontal_scrollbar_policy(frame));
+ break;
+ case PROP_VERTICAL_SCROLLBAR_POLICY:
+ g_value_set_enum(value, webkit_web_frame_get_vertical_scrollbar_policy(frame));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -133,6 +143,11 @@ void webkit_web_frame_core_frame_gone(WebKitWebFrame* frame)
frame->priv->coreFrame = 0;
}
+static WebKitWebDataSource* webkit_web_frame_get_data_source_from_core_loader(WebCore::DocumentLoader* loader)
+{
+ return loader ? static_cast<WebKit::DocumentLoader*>(loader)->dataSource() : NULL;
+}
+
static void webkit_web_frame_finalize(GObject* object)
{
WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object);
@@ -214,6 +229,37 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
G_TYPE_NONE, 2,
G_TYPE_STRING, G_TYPE_STRING);
+ /**
+ * WebKitWebFrame::scrollbars-policy-changed:
+ * @web_view: the object which received the signal
+ *
+ * Signal emitted when policy for one or both of the scrollbars of
+ * the view has changed. The default handler will apply the new
+ * policy to the container that holds the #WebKitWebFrame if it is
+ * a #GtkScrolledWindow and the frame is the main frame. If you do
+ * not want this to be handled automatically, you need to handle
+ * this signal.
+ *
+ * The exception to this rule is that policies to disable the
+ * scrollbars are applied as %GTK_POLICY_AUTOMATIC instead, since
+ * the size request of the widget would force browser windows to
+ * not be resizable.
+ *
+ * You can obtain the new policies from the
+ * WebKitWebFrame:horizontal-scrollbar-policy and
+ * WebKitWebFrame:vertical-scrollbar-policy properties.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_frame_signals[SCROLLBARS_POLICY_CHANGED] = g_signal_new("scrollbars-policy-changed",
+ G_TYPE_FROM_CLASS(frameClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+
/*
* implementations of virtual methods
*/
@@ -260,6 +306,42 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
WEBKIT_LOAD_FINISHED,
WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebFrame:horizontal-scrollbar-policy:
+ *
+ * Determines the current policy for the horizontal scrollbar of
+ * the frame. For the main frame, make sure to set the same policy
+ * on the scrollable widget containing the #WebKitWebView, unless
+ * you know what you are doing.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_HORIZONTAL_SCROLLBAR_POLICY,
+ g_param_spec_enum("horizontal-scrollbar-policy",
+ _("Horizontal Scrollbar Policy"),
+ _("Determines the current policy for the horizontal scrollbar of the frame."),
+ GTK_TYPE_POLICY_TYPE,
+ GTK_POLICY_AUTOMATIC,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebFrame:vertical-scrollbar-policy:
+ *
+ * Determines the current policy for the vertical scrollbar of
+ * the frame. For the main frame, make sure to set the same policy
+ * on the scrollable widget containing the #WebKitWebView, unless
+ * you know what you are doing.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(objectClass, PROP_VERTICAL_SCROLLBAR_POLICY,
+ g_param_spec_enum("vertical-scrollbar-policy",
+ _("Vertical Scrollbar Policy"),
+ _("Determines the current policy for the vertical scrollbar of the frame."),
+ GTK_TYPE_POLICY_TYPE,
+ GTK_POLICY_AUTOMATIC,
+ WEBKIT_PARAM_READABLE));
+
g_type_class_add_private(frameClass, sizeof(WebKitWebFramePrivate));
}
@@ -295,6 +377,8 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView)
priv->coreFrame = Frame::create(viewPriv->corePage, 0, client).get();
priv->coreFrame->init();
+ priv->origin = NULL;
+
return frame;
}
@@ -443,7 +527,7 @@ static void webkit_web_frame_load_data(WebKitWebFrame* frame, const gchar* conte
SubstituteData substituteData(sharedBuffer.release(),
mimeType ? String::fromUTF8(mimeType) : String::fromUTF8("text/html"),
encoding ? String::fromUTF8(encoding) : String::fromUTF8("UTF-8"),
- baseKURL,
+ KURL(KURL(), String::fromUTF8(unreachableURL)),
KURL(KURL(), String::fromUTF8(unreachableURL)));
coreFrame->loader()->load(request, substituteData, false);
@@ -603,6 +687,46 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)
}
/**
+ * webkit_web_frame_get_data_source:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the committed data source.
+ *
+ * Return value: the committed #WebKitWebDataSource.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_frame_get_data_source(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+ Frame* coreFrame = core(frame);
+ return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->documentLoader());
+}
+
+/**
+ * webkit_web_frame_get_provisional_data_source:
+ * @frame: a #WebKitWebFrame
+ *
+ * You use the webkit_web_frame_load_request method to initiate a request that
+ * creates a provisional data source. The provisional data source will
+ * transition to a committed data source once any data has been received. Use
+ * webkit_web_frame_get_data_source to get the committed data source.
+ *
+ * Return value: the provisional #WebKitWebDataSource or %NULL if a load
+ * request is not in progress.
+ *
+ * Since: 1.1.14
+ */
+WebKitWebDataSource* webkit_web_frame_get_provisional_data_source(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+ Frame* coreFrame = core(frame);
+ return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->provisionalDocumentLoader());
+}
+
+/**
* webkit_web_frame_get_children:
* @frame: a #WebKitWebFrame
*
@@ -674,6 +798,19 @@ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame)
return g_strdup(string.utf8().data());
}
+/**
+ * webkit_web_frame_get_pending_unload_event_count:
+ * @frame: a #WebKitWebFrame
+ *
+ * Return value: number of pending unload events
+ */
+guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0);
+
+ return core(frame)->domWindow()->pendingUnloadEventListeners();
+}
+
static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
@@ -696,6 +833,9 @@ static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context,
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
+ if (page_nr >= printContext->pageCount())
+ return;
+
cairo_t* cr = gtk_print_context_get_cairo_context(context);
GraphicsContext ctx(cr);
float width = gtk_print_context_get_width(context);
@@ -813,7 +953,7 @@ unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame)
gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame)
{
Frame* coreFrame = core(frame);
- DocumentLoader* docLoader = coreFrame->loader()->documentLoader();
+ WebCore::DocumentLoader* docLoader = coreFrame->loader()->documentLoader();
String mimeType = docLoader->responseMIMEType();
return g_strdup(mimeType.utf8().data());
}
@@ -883,3 +1023,82 @@ AtkObject* webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame
return NULL;
#endif
}
+
+GtkPolicyType webkit_web_frame_get_horizontal_scrollbar_policy(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC);
+
+ Frame* coreFrame = core(frame);
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return GTK_POLICY_AUTOMATIC;
+
+ ScrollbarMode hMode = view->horizontalScrollbarMode();
+
+ if (hMode == ScrollbarAlwaysOn)
+ return GTK_POLICY_ALWAYS;
+
+ if (hMode == ScrollbarAlwaysOff)
+ return GTK_POLICY_NEVER;
+
+ return GTK_POLICY_AUTOMATIC;
+}
+
+GtkPolicyType webkit_web_frame_get_vertical_scrollbar_policy(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC);
+
+ Frame* coreFrame = core(frame);
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return GTK_POLICY_AUTOMATIC;
+
+ ScrollbarMode vMode = view->verticalScrollbarMode();
+
+ if (vMode == ScrollbarAlwaysOn)
+ return GTK_POLICY_ALWAYS;
+
+ if (vMode == ScrollbarAlwaysOff)
+ return GTK_POLICY_NEVER;
+
+ return GTK_POLICY_AUTOMATIC;
+}
+
+/**
+ * webkit_web_frame_get_security_origin:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the @frame's security origin.
+ *
+ * Return value: the security origin of @frame
+ *
+ * Since: 1.1.14
+ */
+WebKitSecurityOrigin* webkit_web_frame_get_security_origin(WebKitWebFrame* frame)
+{
+ WebKitWebFramePrivate* priv = frame->priv;
+ if (!priv->coreFrame || !priv->coreFrame->document() || !priv->coreFrame->document()->securityOrigin())
+ return NULL;
+
+ if (priv->origin && priv->origin->priv->coreOrigin.get() == priv->coreFrame->document()->securityOrigin())
+ return priv->origin;
+
+ if (priv->origin)
+ g_object_unref(priv->origin);
+
+ priv->origin = kit(priv->coreFrame->document()->securityOrigin());
+ return priv->origin;
+}
+
+void webkit_web_frame_layout(WebKitWebFrame* frame)
+{
+ Frame* coreFrame = core(frame);
+ if (!coreFrame)
+ return;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return;
+
+ view->layout();
+}
diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h
index b2e61b9..7a95545 100644
--- a/WebKit/gtk/webkit/webkitwebframe.h
+++ b/WebKit/gtk/webkit/webkitwebframe.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_FRAME_H
-#define WEBKIT_WEB_FRAME_H
+#ifndef webkitwebframe_h
+#define webkitwebframe_h
#include <glib-object.h>
#include <gtk/gtk.h>
@@ -28,6 +28,7 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitnetworkrequest.h>
+#include <webkit/webkitwebdatasource.h>
G_BEGIN_DECLS
@@ -72,15 +73,19 @@ struct _WebKitWebFrameClass {
* actual visible content happened; one or more layouts may have
* happened before that caused nothing to be visible on the screen,
* because the data available at the time was not significant enough.
- * @WEBKIT_LOAD_FINISHED: This state means either that everything that
- * was required to display the page has been loaded, or that an error
- * has happened.
+ * @WEBKIT_LOAD_FINISHED: This state means that everything that was
+ * required to display the page has been loaded.
+ * @WEBKIT_LOAD_FAILED: This state means that some error occurred
+ * during the page load that prevented it from being completed. You
+ * can connect to the #WebKitWebView::load-error signal if you want to
+ * know precisely what kind of error occurred.
*/
typedef enum {
WEBKIT_LOAD_PROVISIONAL,
WEBKIT_LOAD_COMMITTED,
WEBKIT_LOAD_FINISHED,
- WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
+ WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT,
+ WEBKIT_LOAD_FAILED
} WebKitLoadStatus;
WEBKIT_API GType
@@ -152,6 +157,21 @@ webkit_web_frame_print (WebKitWebFrame *frame);
WEBKIT_API WebKitLoadStatus
webkit_web_frame_get_load_status (WebKitWebFrame *frame);
+WEBKIT_API GtkPolicyType
+webkit_web_frame_get_horizontal_scrollbar_policy (WebKitWebFrame *frame);
+
+WEBKIT_API GtkPolicyType
+webkit_web_frame_get_vertical_scrollbar_policy (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_frame_get_data_source (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitWebDataSource *
+webkit_web_frame_get_provisional_data_source (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitSecurityOrigin*
+webkit_web_frame_get_security_origin (WebKitWebFrame *frame);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
index a75bc0d..aab8b51 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
@@ -297,12 +297,11 @@ WebKitWebHistoryItem* webkit_web_history_item_new()
*/
WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, const gchar* title)
{
- WebCore::KURL historyUri(uri);
- WebCore::String historyTitle = WebCore::String::fromUTF8(title);
-
WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
+ WebCore::KURL historyUri(WebCore::KURL(), uri);
+ WebCore::String historyTitle = WebCore::String::fromUTF8(title);
RefPtr<WebCore::HistoryItem> item = WebCore::HistoryItem::create(historyUri, historyTitle, 0);
priv->historyItem = item.release().releaseRef();
webkit_history_item_add(webHistoryItem, priv->historyItem);
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.h b/WebKit/gtk/webkit/webkitwebhistoryitem.h
index c8a754a..cafeb36 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.h
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_HISTORY_ITEM_H
-#define WEBKIT_WEB_HISTORY_ITEM_H
+#ifndef webkitwebhistoryitem_h
+#define webkitwebhistoryitem_h
#include <glib.h>
#include <glib-object.h>
@@ -84,4 +84,4 @@ webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem *web_history
G_END_DECLS
-#endif /* WEBKIT_WEB_HISTORY_ITEM_H */
+#endif /* webkitwebhistoryitem_h */
diff --git a/WebKit/gtk/webkit/webkitwebinspector.h b/WebKit/gtk/webkit/webkitwebinspector.h
index 41ccf92..9010e26 100644
--- a/WebKit/gtk/webkit/webkitwebinspector.h
+++ b/WebKit/gtk/webkit/webkitwebinspector.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __WEBKIT_WEB_INSPECTOR_H__
-#define __WEBKIT_WEB_INSPECTOR_H__
+#ifndef webkitwebinspector_h
+#define webkitwebinspector_h
#include <glib-object.h>
@@ -62,4 +62,4 @@ webkit_web_inspector_get_inspected_uri(WebKitWebInspector* web_inspector);
G_END_DECLS
-#endif /* __WEBKIT_WEB_INSPECTOR_H__ */
+#endif /* webkitwebinspector_h */
diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.h b/WebKit/gtk/webkit/webkitwebnavigationaction.h
index c437c50..dbb47a8 100644
--- a/WebKit/gtk/webkit/webkitwebnavigationaction.h
+++ b/WebKit/gtk/webkit/webkitwebnavigationaction.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_NAVIGATION_ACTION_H
-#define WEBKIT_WEB_NAVIGATION_ACTION_H
+#ifndef webkitwebnavigationaction_h
+#define webkitwebnavigationaction_h
#include <glib-object.h>
diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
index b2bab6b..5ef6310 100644
--- a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
+++ b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
@@ -86,7 +86,7 @@ void webkit_web_policy_decision_use(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyUse);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyUse);
}
/**
@@ -104,7 +104,7 @@ void webkit_web_policy_decision_ignore(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore);
}
/**
@@ -122,7 +122,7 @@ void webkit_web_policy_decision_download(WebKitWebPolicyDecision* decision)
WebKitWebPolicyDecisionPrivate* priv = decision->priv;
if (!priv->isCancelled)
- (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyDownload);
+ (core(priv->frame)->loader()->policyChecker()->*(priv->framePolicyFunction))(WebCore::PolicyDownload);
}
void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision* decision)
diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.h b/WebKit/gtk/webkit/webkitwebpolicydecision.h
index f1ec963..2b61837 100644
--- a/WebKit/gtk/webkit/webkitwebpolicydecision.h
+++ b/WebKit/gtk/webkit/webkitwebpolicydecision.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_POLICY_DECISION_H
-#define WEBKIT_WEB_POLICY_DECISION_H
+#ifndef webkitwebpolicydecision_h
+#define webkitwebpolicydecision_h
#include <glib-object.h>
#include <stdint.h>
diff --git a/WebKit/gtk/webkit/webkitwebresource.cpp b/WebKit/gtk/webkit/webkitwebresource.cpp
new file mode 100644
index 0000000..e995e08
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebresource.cpp
@@ -0,0 +1,401 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "webkitwebresource.h"
+#include "webkitprivate.h"
+
+#include "ArchiveResource.h"
+#include "CString.h"
+#include "KURL.h"
+#include "PlatformString.h"
+#include "SharedBuffer.h"
+#include "webkitenumtypes.h"
+#include "webkitmarshal.h"
+#include "wtf/Assertions.h"
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION:webkitwebresource
+ * @short_description: Represents a downloaded URI.
+ * @see_also: #WebKitWebDataSource
+ *
+ * A web resource encapsulates the data of the download as well as the URI,
+ * MIME type and frame name of the resource.
+ */
+
+using namespace WebCore;
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_MIME_TYPE,
+ PROP_ENCODING,
+ PROP_FRAME_NAME
+};
+
+G_DEFINE_TYPE(WebKitWebResource, webkit_web_resource, G_TYPE_OBJECT);
+
+static void webkit_web_resource_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
+static void webkit_web_resource_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
+
+static void webkit_web_resource_cleanup(WebKitWebResource* webResource)
+{
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ g_free(priv->uri);
+ priv->uri = NULL;
+
+ g_free(priv->mimeType);
+ priv->mimeType = NULL;
+
+ g_free(priv->textEncoding);
+ priv->textEncoding = NULL;
+
+ g_free(priv->frameName);
+ priv->frameName = NULL;
+
+ if (priv->data)
+ g_string_free(priv->data, TRUE);
+ priv->data = NULL;
+}
+
+static void webkit_web_resource_dispose(GObject* object)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (priv->resource) {
+ priv->resource->deref();
+ priv->resource = 0;
+ }
+
+ G_OBJECT_CLASS(webkit_web_resource_parent_class)->dispose(object);
+}
+
+static void webkit_web_resource_finalize(GObject* object)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ webkit_web_resource_cleanup(webResource);
+
+ G_OBJECT_CLASS(webkit_web_resource_parent_class)->finalize(object);
+}
+
+static void webkit_web_resource_class_init(WebKitWebResourceClass* klass)
+{
+ GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = webkit_web_resource_dispose;
+ gobject_class->finalize = webkit_web_resource_finalize;
+ gobject_class->get_property = webkit_web_resource_get_property;
+ gobject_class->set_property = webkit_web_resource_set_property;
+
+ /**
+ * WebKitWebResource:uri:
+ *
+ * The URI of the web resource
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_URI,
+ g_param_spec_string(
+ "uri",
+ _("URI"),
+ _("The uri of the resource"),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
+ /**
+ * WebKitWebResource:mime-type:
+ *
+ * The MIME type of the web resource.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_MIME_TYPE,
+ g_param_spec_string(
+ "mime-type",
+ _("MIME Type"),
+ _("The MIME type of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebResource:encoding:
+ *
+ * The encoding name to which the web resource was encoded in.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENCODING,
+ g_param_spec_string(
+ "encoding",
+ _("Encoding"),
+ _("The text encoding name of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebResource:frame-name:
+ *
+ * The frame name for the web resource.
+ *
+ * Since: 1.1.14
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_FRAME_NAME,
+ g_param_spec_string(
+ "frame-name",
+ _("Frame Name"),
+ _("The frame name of the resource"),
+ NULL,
+ WEBKIT_PARAM_READABLE));
+
+ g_type_class_add_private(gobject_class, sizeof(WebKitWebResourcePrivate));
+}
+
+static void webkit_web_resource_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ switch (prop_id) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_web_resource_get_uri(webResource));
+ break;
+ case PROP_MIME_TYPE:
+ g_value_set_string(value, webkit_web_resource_get_mime_type(webResource));
+ break;
+ case PROP_ENCODING:
+ g_value_set_string(value, webkit_web_resource_get_encoding(webResource));
+ break;
+ case PROP_FRAME_NAME:
+ g_value_set_string(value, webkit_web_resource_get_frame_name(webResource));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void webkit_web_resource_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(object);
+
+ switch (prop_id) {
+ case PROP_URI:
+ g_free(webResource->priv->uri);
+ webResource->priv->uri = g_value_dup_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void webkit_web_resource_init(WebKitWebResource* webResource)
+{
+ webResource->priv = WEBKIT_WEB_RESOURCE_GET_PRIVATE(webResource);
+}
+
+// internal use only
+WebKitWebResource* webkit_web_resource_new_with_core_resource(PassRefPtr<ArchiveResource> resource)
+{
+ WebKitWebResource* webResource = WEBKIT_WEB_RESOURCE(g_object_new(WEBKIT_TYPE_WEB_RESOURCE, NULL));
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ priv->resource = resource.releaseRef();
+
+ return webResource;
+}
+
+void webkit_web_resource_init_with_core_resource(WebKitWebResource* webResource, PassRefPtr<ArchiveResource> resource)
+{
+ ASSERT(resource);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (priv->resource)
+ priv->resource->deref();
+
+ priv->resource = resource.releaseRef();
+}
+
+/**
+ * webkit_web_resource_new:
+ * @data: the data to initialize the #WebKitWebResource
+ * @length: the length of @data
+ * @uri: the uri of the #WebKitWebResource
+ * @mime_type: the MIME type of the #WebKitWebResource
+ * @text_encoding_name: the text encoding name of the #WebKitWebResource
+ * @frame_name: the frame name of the #WebKitWebResource
+ *
+ * Returns a new #WebKitWebResource. The @text_encoding_name can be %NULL. The
+ * @frame_name argument can be used if the resource represents contents of an
+ * entire HTML frame, otherwise pass %NULL.
+ *
+ * Return value: a new #WebKitWebResource
+ *
+ * Since: 1.1.14
+ */
+WebKitWebResource* webkit_web_resource_new(const gchar* data,
+ gssize size,
+ const gchar* uri,
+ const gchar* mimeType,
+ const gchar* encoding,
+ const gchar* frameName)
+{
+ g_return_val_if_fail(data, NULL);
+ g_return_val_if_fail(uri, NULL);
+ g_return_val_if_fail(mimeType, NULL);
+
+ if (size < 0)
+ size = strlen(data);
+
+ RefPtr<SharedBuffer> buffer = SharedBuffer::create(data, size);
+ WebKitWebResource* webResource = webkit_web_resource_new_with_core_resource(ArchiveResource::create(buffer, KURL(KURL(), String::fromUTF8(uri)), String::fromUTF8(mimeType), String::fromUTF8(encoding), String::fromUTF8(frameName)));
+
+ return webResource;
+}
+
+/**
+ * webkit_web_resource_get_data:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Returns the data of the @webResource.
+ *
+ * Return value: a #GString containing the character data of the @webResource.
+ * The string is owned by WebKit and should not be freed or destroyed.
+ *
+ * Since: 1.1.14
+ */
+GString* webkit_web_resource_get_data(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->data)
+ priv->data = g_string_new_len(priv->resource->data()->data(), priv->resource->data()->size());
+
+ return priv->data;
+}
+
+/**
+ * webkit_web_resource_get_uri:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the URI of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_uri(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+
+
+ // We may have an URI without having a resource assigned to us (e.g., if the
+ // FrameLoaderClient only had a ResourceRequest when we got created
+ if (priv->uri)
+ return priv->uri;
+
+ if (!priv->resource)
+ return NULL;
+
+ priv->uri = g_strdup(priv->resource->url().string().utf8().data());
+
+ return priv->uri;
+}
+
+/**
+ * webkit_web_resource_get_mime_type:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the MIME type of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_mime_type(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->mimeType)
+ priv->mimeType = g_strdup(priv->resource->mimeType().utf8().data());
+
+ return priv->mimeType;
+}
+
+/**
+ * webkit_web_resource_get_encoding:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the encoding name of the resource
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_encoding(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->textEncoding)
+ priv->textEncoding = g_strdup(priv->resource->textEncoding().utf8().data());
+
+ return priv->textEncoding;
+}
+
+/**
+ * webkit_web_resource_get_frame_name:
+ * @web_resource: a #WebKitWebResource
+ *
+ * Return value: the frame name of the resource.
+ *
+ * Since: 1.1.14
+ */
+G_CONST_RETURN gchar* webkit_web_resource_get_frame_name(WebKitWebResource* webResource)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(webResource), NULL);
+
+ WebKitWebResourcePrivate* priv = webResource->priv;
+ if (!priv->resource)
+ return NULL;
+
+ if (!priv->frameName)
+ priv->frameName = g_strdup(priv->resource->frameName().utf8().data());
+
+ return priv->frameName;
+}
+
diff --git a/WebKit/gtk/webkit/webkitwebresource.h b/WebKit/gtk/webkit/webkitwebresource.h
new file mode 100644
index 0000000..05f6066
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitwebresource.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2009 Jan Michael C. Alonzo
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef webkitwebresource_h
+#define webkitwebresource_h
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_RESOURCE (webkit_web_resource_get_type())
+#define WEBKIT_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResource))
+#define WEBKIT_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass))
+#define WEBKIT_IS_WEB_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_RESOURCE))
+#define WEBKIT_IS_WEB_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_RESOURCE))
+#define WEBKIT_WEB_RESOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourceClass))
+
+typedef struct _WebKitWebResourcePrivate WebKitWebResourcePrivate;
+
+struct _WebKitWebResource {
+ GObject parent_instance;
+
+ /*< private >*/
+ WebKitWebResourcePrivate *priv;
+};
+
+struct _WebKitWebResourceClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_resource_get_type (void);
+
+WEBKIT_API WebKitWebResource *
+webkit_web_resource_new (const gchar *data,
+ gssize size,
+ const gchar *uri,
+ const gchar *mime_type,
+ const gchar *encoding,
+ const gchar *frame_name);
+
+WEBKIT_API GString *
+webkit_web_resource_get_data (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_uri (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_mime_type (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_encoding (WebKitWebResource *web_resource);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_resource_get_frame_name (WebKitWebResource *web_resource);
+
+G_END_DECLS
+
+#endif /* webkitwebresource_h */
diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp
index 061d3e2..588d5bd 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.cpp
+++ b/WebKit/gtk/webkit/webkitwebsettings.cpp
@@ -24,6 +24,7 @@
#include "config.h"
#include "webkitwebsettings.h"
+#include "webkitenumtypes.h"
#include "webkitprivate.h"
#include "webkitversion.h"
@@ -93,6 +94,8 @@ struct _WebKitWebSettingsPrivate {
gchar* user_agent;
gboolean javascript_can_open_windows_automatically;
gboolean enable_offline_web_application_cache;
+ WebKitEditingBehavior editing_behavior;
+ gboolean enable_universal_access_from_file_uris;
};
#define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -130,7 +133,9 @@ enum {
PROP_ENABLE_XSS_AUDITOR,
PROP_USER_AGENT,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
- PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
+ PROP_EDITING_BEHAVIOR,
+ PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS
};
// Create a default user agent string
@@ -433,7 +438,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* This is currently experimental for WebKitGtk.
*
- * Since 1.1.2
+ * Since: 1.1.2
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_PRIVATE_BROWSING,
@@ -449,7 +454,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* Whether to enable spell checking while typing.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_SPELL_CHECKING,
@@ -473,7 +478,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* If no value is specified then the value returned by
* gtk_get_default_language will be used.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_SPELL_CHECKING_LANGUAGES,
@@ -489,7 +494,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
*
* Whether to enable caret browsing mode.
*
- * Since 1.1.6
+ * Since: 1.1.6
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_CARET_BROWSING,
@@ -505,7 +510,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* SQL database allows web pages to store structured data and be able to
* use SQL to manipulate that data asynchronously.
*
- * Since 1.1.8
+ * Since: 1.1.8
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_HTML5_DATABASE,
@@ -521,7 +526,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether to enable HTML5 localStorage support. localStorage provides
* simple synchronous storage access.
*
- * Since 1.1.8
+ * Since: 1.1.8
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_HTML5_LOCAL_STORAGE,
@@ -536,7 +541,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether to enable the XSS Auditor. This feature filters some kinds of
* reflective XSS attacks on vulnerable web sites.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_XSS_AUDITOR,
@@ -571,7 +576,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Whether JavaScript can open popup windows automatically without user
* intervention.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
g_object_class_install_property(gobject_class,
PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
@@ -587,7 +592,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
* Web Application Cache ensures web applications are available even when
* the user is not connected to the network.
*
- * Since 1.1.13
+ * Since: 1.1.13
*/
g_object_class_install_property(gobject_class,
PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
@@ -597,7 +602,50 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
TRUE,
flags));
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_MAC) == static_cast<int>(WebCore::EditingMacBehavior), editing_behavior_type_mac_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_EDITING_BEHAVIOR_WINDOWS) == static_cast<int>(WebCore::EditingWindowsBehavior), editing_behavior_type_windows_match);
+ /**
+ * WebKitWebSettings:editing-behavior
+ *
+ * This setting controls various editing behaviors that differ
+ * between platforms and that have been combined in two groups,
+ * 'Mac' and 'Windows'. Some examples:
+ *
+ * 1) Clicking below the last line of an editable area puts the
+ * caret at the end of the last line on Mac, but in the middle of
+ * the last line on Windows.
+ *
+ * 2) Pushing down the arrow key on the last line puts the caret
+ * at the end of the last line on Mac, but does nothing on
+ * Windows. A similar case exists on the top line.
+ *
+ * Since: 1.1.13
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_EDITING_BEHAVIOR,
+ g_param_spec_enum("editing-behavior",
+ _("Editing behavior"),
+ _("The behavior mode to use in editing mode"),
+ WEBKIT_TYPE_EDITING_BEHAVIOR,
+ WEBKIT_EDITING_BEHAVIOR_MAC,
+ flags));
+
+ /**
+ * WebKitWebSettings:enable-universal-access-from-file-uris
+ *
+ * Whether to allow files loaded through file:// URIs universal access to
+ * all pages.
+ *
+ * Since: 1.1.13
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
+ g_param_spec_boolean("enable-universal-access-from-file-uris",
+ _("Enable universal access from file URIs"),
+ _("Whether to allow universal access from file URIs"),
+ FALSE,
+ flags));
g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
}
@@ -779,6 +827,12 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
priv->enable_offline_web_application_cache = g_value_get_boolean(value);
break;
+ case PROP_EDITING_BEHAVIOR:
+ priv->editing_behavior = static_cast<WebKitEditingBehavior>(g_value_get_enum(value));
+ break;
+ case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
+ priv->enable_universal_access_from_file_uris = g_value_get_boolean(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -884,7 +938,13 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
g_value_set_boolean(value, priv->enable_offline_web_application_cache);
break;
- default:
+ case PROP_EDITING_BEHAVIOR:
+ g_value_set_enum(value, priv->editing_behavior);
+ break;
+ case PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS:
+ g_value_set_boolean(value, priv->enable_universal_access_from_file_uris);
+ break;
+ default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
@@ -946,6 +1006,8 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
"user-agent", webkit_web_settings_get_user_agent(web_settings),
"javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically,
"enable-offline-web-application-cache", priv->enable_offline_web_application_cache,
+ "editing-behavior", priv->editing_behavior,
+ "enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
NULL));
return copy;
diff --git a/WebKit/gtk/webkit/webkitwebsettings.h b/WebKit/gtk/webkit/webkitwebsettings.h
index 9eac321..d8dafd9 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.h
+++ b/WebKit/gtk/webkit/webkitwebsettings.h
@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef __WEBKIT_WEB_SETTINGS_H__
-#define __WEBKIT_WEB_SETTINGS_H__
+#ifndef webkitwebsettings_h
+#define webkitwebsettings_h
#include <glib-object.h>
@@ -34,6 +34,11 @@ G_BEGIN_DECLS
#define WEBKIT_IS_WEB_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_SETTINGS))
#define WEBKIT_WEB_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsClass))
+typedef enum {
+ WEBKIT_EDITING_BEHAVIOR_MAC,
+ WEBKIT_EDITING_BEHAVIOR_WINDOWS
+} WebKitEditingBehavior;
+
typedef struct _WebKitWebSettingsPrivate WebKitWebSettingsPrivate;
struct _WebKitWebSettings {
@@ -67,4 +72,4 @@ webkit_web_settings_get_user_agent (WebKitWebSettings *web_settings);
G_END_DECLS
-#endif /* __WEBKIT_WEB_SETTINGS_H__ */
+#endif /* webkitwebsettings_h */
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index ec59e60..47d7d98 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -6,7 +6,7 @@
* Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com>
* Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org>
* Copyright (C) 2008 Nuanti Ltd.
- * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2008, 2009 Collabora Ltd.
* Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
@@ -25,11 +25,13 @@
*/
#include "config.h"
+#include "webkitwebview.h"
#include "webkitdownload.h"
-#include "webkitwebview.h"
#include "webkitenumtypes.h"
#include "webkitmarshal.h"
+#include "webkitnetworkrequest.h"
+#include "webkitnetworkresponse.h"
#include "webkitprivate.h"
#include "webkitwebinspector.h"
#include "webkitwebbackforwardlist.h"
@@ -60,11 +62,13 @@
#include "InspectorClientGtk.h"
#include "FrameLoader.h"
#include "FrameView.h"
+#include "MouseEventWithHitTestResults.h"
#include "PasteboardHelper.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
#include "ProgressTracker.h"
#include "ResourceHandle.h"
+#include "RenderView.h"
#include "ScriptValue.h"
#include "Scrollbar.h"
#include <wtf/GOwnPtr.h>
@@ -96,7 +100,7 @@
* gtk_container_add (GTK_CONTAINER (main_window), scrolled_window);
*
* /<!-- -->* Open a webpage *<!-- -->/
- * webkit_web_view_open (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
+ * webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "http://www.gnome.org");
*
* /<!-- -->* Show the result *<!-- -->/
* gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600);
@@ -142,6 +146,10 @@ enum {
PRINT_REQUESTED,
PLUGIN_WIDGET,
CLOSE_WEB_VIEW,
+ UNDO,
+ REDO,
+ DATABASE_QUOTA_EXCEEDED,
+ RESOURCE_REQUEST_STARTING,
LAST_SIGNAL
};
@@ -172,6 +180,15 @@ G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
+static void destroy_menu_cb(GtkObject* object, gpointer data)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(data);
+ WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
+
+ g_object_unref(priv->currentMenu);
+ priv->currentMenu = NULL;
+}
+
static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
{
Page* page = core(webView);
@@ -203,8 +220,14 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
return FALSE;
WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView);
+ priv->currentMenu = GTK_MENU(g_object_ref(menu));
priv->lastPopupXPosition = event.globalX();
priv->lastPopupYPosition = event.globalY();
+
+ g_signal_connect(menu, "destroy",
+ G_CALLBACK(destroy_menu_cb),
+ NULL);
+
gtk_menu_popup(menu, NULL, NULL,
NULL,
priv, event.button() + 1, gtk_get_current_event_time());
@@ -268,7 +291,7 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
}
int x, y;
- gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformWindow())->window, &x, &y);
+ gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformPageClient())->window, &x, &y);
// FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element.
// Ideally we'd have the position of a context menu event be separate from its target node.
@@ -649,7 +672,7 @@ static void webkit_web_view_realize(GtkWidget* widget)
gdk_window_set_user_data(widget->window, widget);
widget->style = gtk_style_attach(widget->style, widget->window);
- gdk_window_set_background(widget->window, &widget->style->base[GTK_WIDGET_STATE(widget)]);
+ gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
WebKitWebViewPrivate* priv = webView->priv;
@@ -690,8 +713,6 @@ static void webkit_web_view_container_add(GtkContainer* container, GtkWidget* wi
WebKitWebViewPrivate* priv = webView->priv;
priv->children.add(widget);
- if (GTK_WIDGET_REALIZED(container))
- gtk_widget_set_parent_window(widget, GTK_WIDGET(webView)->window);
gtk_widget_set_parent(widget, GTK_WIDGET(container));
}
@@ -866,6 +887,18 @@ static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
frame->editor()->command("Copy").execute();
}
+static void webkit_web_view_real_undo(WebKitWebView* webView)
+{
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ frame->editor()->command("Undo").execute();
+}
+
+static void webkit_web_view_real_redo(WebKitWebView* webView)
+{
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ frame->editor()->command("Redo").execute();
+}
+
static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
@@ -976,6 +1009,16 @@ static void webkit_web_view_dispose(GObject* object)
priv->paste_target_list = NULL;
}
+ if (priv->mainResource) {
+ g_object_unref(priv->mainResource);
+ priv->mainResource = NULL;
+ }
+
+ if (priv->subResources) {
+ g_hash_table_unref(priv->subResources);
+ priv->subResources = NULL;
+ }
+
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
}
@@ -984,6 +1027,7 @@ static void webkit_web_view_finalize(GObject* object)
WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
WebKitWebViewPrivate* priv = webView->priv;
+ g_free(priv->mainResourceIdentifier);
g_free(priv->encoding);
g_free(priv->customEncoding);
@@ -1081,6 +1125,130 @@ static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previou
settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
}
+static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context)
+{
+ g_object_unref(context);
+}
+
+struct DNDContentsRequest
+{
+ gint info;
+ GtkSelectionData* dnd_selection_data;
+
+ gboolean is_url_label_request;
+ gchar* url;
+};
+
+void clipboard_contents_received(GtkClipboard* clipboard, GtkSelectionData* selection_data, gpointer data)
+{
+ DNDContentsRequest* contents_request = reinterpret_cast<DNDContentsRequest*>(data);
+
+ if (contents_request->is_url_label_request) {
+ // We have received contents of the label clipboard. Use them to form
+ // required structures. When formed, enhance the dnd's selection data
+ // with them and return.
+
+ // If the label is empty, use the url itself.
+ gchar* url_label = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+ if (!url_label)
+ url_label = g_strdup(contents_request->url);
+
+ gchar* data = 0;
+ switch (contents_request->info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ data = g_strdup_printf("%s\r\n%s\r\n", contents_request->url, url_label);
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ data = g_strdup_printf("%s\n%s", contents_request->url, url_label);
+ break;
+ }
+
+ if (data) {
+ gtk_selection_data_set(contents_request->dnd_selection_data,
+ contents_request->dnd_selection_data->target, 8,
+ reinterpret_cast<const guchar*>(data), strlen(data));
+ g_free(data);
+ }
+
+ g_free(url_label);
+ g_free(contents_request->url);
+ g_free(contents_request);
+
+ return;
+ }
+
+ switch (contents_request->info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_HTML:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT:
+ {
+ gchar* data = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+ if (data) {
+ gtk_selection_data_set(contents_request->dnd_selection_data,
+ contents_request->dnd_selection_data->target, 8,
+ reinterpret_cast<const guchar*>(data),
+ strlen(data));
+ g_free(data);
+ }
+ break;
+ }
+ case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE:
+ {
+ GdkPixbuf* pixbuf = gtk_selection_data_get_pixbuf(selection_data);
+ if (pixbuf) {
+ gtk_selection_data_set_pixbuf(contents_request->dnd_selection_data, pixbuf);
+ g_object_unref(pixbuf);
+ }
+ break;
+ }
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ // URL's label is stored in another clipboard, so we store URL into
+ // contents request, mark the latter as an url label request
+ // and request for contents of the label clipboard.
+ contents_request->is_url_label_request = TRUE;
+ contents_request->url = reinterpret_cast<gchar*>(gtk_selection_data_get_text(selection_data));
+
+ gtk_clipboard_request_contents(gtk_clipboard_get(gdk_atom_intern_static_string("WebKitClipboardUrlLabel")),
+ selection_data->target, clipboard_contents_received, contents_request);
+ break;
+ }
+}
+
+static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selection_data, guint info, guint time_)
+{
+ GdkAtom selection_atom = GDK_NONE;
+ GdkAtom target_atom = selection_data->target;
+
+ switch (info) {
+ case WEBKIT_WEB_VIEW_TARGET_INFO_HTML:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardHtml");
+ // HTML markup data is set as text, therefor, we need a text-like target atom
+ target_atom = gdk_atom_intern_static_string("UTF8_STRING");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_TEXT:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardText");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardImage");
+ break;
+ case WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST:
+ case WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL:
+ selection_atom = gdk_atom_intern_static_string("WebKitClipboardUrl");
+ // We require URL and label, which are both stored in text format
+ // and are needed to be retrieved as such.
+ target_atom = gdk_atom_intern_static_string("UTF8_STRING");
+ break;
+ }
+
+ DNDContentsRequest* contents_request = g_new(DNDContentsRequest, 1);
+ contents_request->info = info;
+ contents_request->is_url_label_request = FALSE;
+ contents_request->dnd_selection_data = selection_data;
+
+ gtk_clipboard_request_contents(gtk_clipboard_get(selection_atom), target_atom,
+ clipboard_contents_received, contents_request);
+}
+
static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
{
GtkBindingSet* binding_set;
@@ -1104,11 +1272,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* The new #WebKitWebView should not be displayed to the user
* until the #WebKitWebView::web-view-ready signal is emitted.
*
- * The signal handlers should not try to deal with the reference
- * count for the new #WebKitWebView. The widget to which the
- * widget is added will handle that.
+ * The signal handlers should not try to deal with the reference count for
+ * the new #WebKitWebView. The widget to which the widget is added will
+ * handle that.
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1137,7 +1305,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* time of the window, so you may want to connect to the ::notify
* signal of the #WebKitWebWindowFeatures object to handle those.
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1154,10 +1322,12 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @return: %TRUE to stop handlers from being invoked for the event or
* %FALSE to propagate the event furter
*
- * Emitted when closing a WebView is requested. This occurs when a call
- * is made from JavaScript's window.close function.
+ * Emitted when closing a #WebKitWebView is requested. This occurs when a
+ * call is made from JavaScript's window.close function. The default
+ * signal handler does not do anything. It is the owner's responsibility
+ * to hide or delete the web view, if necessary.
*
- * Since 1.1.11
+ * Since: 1.1.11
*/
webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1727,6 +1897,44 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 0);
/**
+ * WebKitWebView::undo
+ * @web_view: the object which received the signal
+ *
+ * The #WebKitWebView::undo signal is a keybinding signal which gets emitted to
+ * undo the last editing command.
+ *
+ * The default binding for this signal is Ctrl-z
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[UNDO] = g_signal_new("undo",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, undo),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::redo
+ * @web_view: the object which received the signal
+ *
+ * The #WebKitWebView::redo signal is a keybinding signal which gets emitted to
+ * redo the last editing command.
+ *
+ * The default binding for this signal is Ctrl-Shift-z
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[REDO] = g_signal_new("redo",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, redo),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
* WebKitWebView::move-cursor:
* @web_view: the object which received the signal
* @step: the type of movement, one of #GtkMovementStep
@@ -1774,6 +1982,69 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
GTK_TYPE_WIDGET, 3,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
+ /**
+ * WebKitWebView::database-quota-exceeded
+ * @web_view: the object which received the signal
+ * @frame: the relevant frame
+ * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin
+ *
+ * The #WebKitWebView::database-exceeded-quota signal will be emitted when
+ * a Web Database exceeds the quota of its security origin. This signal
+ * may be used to increase the size of the quota before the originating
+ * operation fails.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[DATABASE_QUOTA_EXCEEDED] = g_signal_new("database-quota-exceeded",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ NULL, NULL,
+ webkit_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ G_TYPE_OBJECT, G_TYPE_OBJECT);
+
+ /**
+ * WebKitWebView::resource-request-starting:
+ * @web_view: the object which received the signal
+ * @web_frame: the #WebKitWebFrame whose load dispatched this request
+ * @web_resource: an empty #WebKitWebResource object
+ * @request: the #WebKitNetworkRequest that will be dispatched
+ * @response: the #WebKitNetworkResponse representing the redirect
+ * response, if any
+ *
+ * Emitted when a request is about to be sent. You can modify the
+ * request while handling this signal. You can set the URI in the
+ * #WebKitNetworkRequest object itself, and add/remove/replace
+ * headers using the #SoupMessage object it carries, if it is
+ * present. See webkit_network_request_get_message(). Setting the
+ * request URI to "about:blank" will effectively cause the request
+ * to load nothing, and can be used to disable the loading of
+ * specific resources.
+ *
+ * Notice that information about an eventual redirect is available
+ * in @response's #SoupMessage, not in the #SoupMessage carried by
+ * the @request. If @response is %NULL, then this is not a
+ * redirected request.
+ *
+ * The #WebKitWebResource object will be the same throughout all
+ * the lifetime of the resource, but the contents may change from
+ * inbetween signal emissions.
+ *
+ * Since: 1.1.14
+ */
+ webkit_web_view_signals[RESOURCE_REQUEST_STARTING] = g_signal_new("resource-request-starting",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ NULL, NULL,
+ webkit_marshal_VOID__OBJECT_OBJECT_OBJECT_OBJECT,
+ G_TYPE_NONE, 4,
+ WEBKIT_TYPE_WEB_FRAME,
+ WEBKIT_TYPE_WEB_RESOURCE,
+ WEBKIT_TYPE_NETWORK_REQUEST,
+ WEBKIT_TYPE_NETWORK_RESPONSE);
+
/*
* implementations of virtual methods
*/
@@ -1791,6 +2062,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
+ webViewClass->undo = webkit_web_view_real_undo;
+ webViewClass->redo = webkit_web_view_real_redo;
webViewClass->move_cursor = webkit_web_view_real_move_cursor;
GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
@@ -1816,6 +2089,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->focus_out_event = webkit_web_view_focus_out_event;
widgetClass->get_accessible = webkit_web_view_get_accessible;
widgetClass->screen_changed = webkit_web_view_screen_changed;
+ widgetClass->drag_end = webkit_web_view_drag_end;
+ widgetClass->drag_data_get = webkit_web_view_drag_data_get;
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -1852,6 +2127,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
"copy_clipboard", 0);
gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK,
"paste_clipboard", 0);
+ gtk_binding_entry_add_signal(binding_set, GDK_z, GDK_CONTROL_MASK,
+ "undo", 0);
+ gtk_binding_entry_add_signal(binding_set, GDK_z, static_cast<GdkModifierType>(GDK_CONTROL_MASK | GDK_SHIFT_MASK),
+ "redo", 0);
gtk_binding_entry_add_signal(binding_set, GDK_Delete, GDK_SHIFT_MASK,
"cut_clipboard", 0);
@@ -2112,7 +2391,10 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
gboolean autoLoadImages, autoShrinkImages, printBackgrounds,
enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
- enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache;
+ enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache,
+ enableUniversalAccessFromFileURI;
+
+ WebKitEditingBehavior editingBehavior;
g_object_get(webSettings,
"default-encoding", &defaultEncoding,
@@ -2137,6 +2419,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
"enable-xss-auditor", &enableXSSAuditor,
"javascript-can-open-windows-automatically", &javascriptCanOpenWindows,
"enable-offline-web-application-cache", &enableOfflineWebAppCache,
+ "editing-behavior", &editingBehavior,
+ "enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI,
NULL);
settings->setDefaultTextEncodingName(defaultEncoding);
@@ -2161,6 +2445,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setXSSAuditorEnabled(enableXSSAuditor);
settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
+ settings->setEditingBehavior(core(editingBehavior));
+ settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI);
g_free(defaultEncoding);
g_free(cursiveFontFamily);
@@ -2243,6 +2529,10 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value));
else if (name == g_intern_string("enable-offline-web-application-cache"))
settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
+ else if (name == g_intern_string("editing-behavior"))
+ settings->setEditingBehavior(core(static_cast<WebKitEditingBehavior>(g_value_get_enum(&value))));
+ else if (name == g_intern_string("enable-universal-access-from-file-uris"))
+ settings->setAllowUniversalAccessFromFileURLs(g_value_get_boolean(&value));
else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name))
g_warning("Unexpected setting '%s'", name);
g_value_unset(&value);
@@ -2256,7 +2546,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->imContext = gtk_im_multicontext_new();
WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView);
- priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient, inspectorClient);
+ priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient(webView), inspectorClient, 0);
// We also add a simple wrapper class to provide the public
// interface for the Web Inspector.
@@ -2294,6 +2584,8 @@ static void webkit_web_view_init(WebKitWebView* webView)
g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
priv->webWindowFeatures = webkit_web_window_features_new();
+
+ priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
}
GtkWidget* webkit_web_view_new(void)
@@ -2312,14 +2604,16 @@ void webkit_web_view_notify_ready(WebKitWebView* webView)
g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled);
}
-void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response)
+void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response, ResourceHandle* handle)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- WebKitDownload* download = webkit_download_new(request);
+ WebKitDownload* download;
- if (!response.isNull() && !response.suggestedFilename().isEmpty())
- webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
+ if (handle)
+ download = webkit_download_new_with_handle(request, handle, response);
+ else
+ download = webkit_download_new(request);
gboolean handled;
g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled);
@@ -2535,8 +2829,7 @@ void webkit_web_view_go_back_or_forward(WebKitWebView* webView, gint steps)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- Frame* frame = core(webView)->mainFrame();
- frame->loader()->goBackOrForward(steps);
+ core(webView)->goBackOrForward(steps);
}
/**
@@ -2585,8 +2878,7 @@ gboolean webkit_web_view_can_go_back_or_forward(WebKitWebView* webView, gint ste
{
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
- Frame* frame = core(webView)->mainFrame();
- return frame->loader()->canGoBackOrForward(steps);
+ return core(webView)->canGoBackOrForward(steps);
}
/**
@@ -2740,6 +3032,12 @@ void webkit_web_view_load_request(WebKitWebView* webView, WebKitNetworkRequest*
webkit_web_frame_load_request(frame, request);
}
+/**
+ * webkit_web_view_stop_loading:
+ * @webView: a #WebKitWebView
+ *
+ * Stops any ongoing load in the @webView.
+ **/
void webkit_web_view_stop_loading(WebKitWebView* webView)
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
@@ -2747,7 +3045,7 @@ void webkit_web_view_stop_loading(WebKitWebView* webView)
Frame* frame = core(webView)->mainFrame();
if (FrameLoader* loader = frame->loader())
- loader->stopAllLoaders();
+ loader->stopForUserCancel();
}
/**
@@ -2805,7 +3103,11 @@ void webkit_web_view_set_highlight_text_matches(WebKitWebView* webView, gboolean
{
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
- core(webView)->mainFrame()->setMarkedTextMatchesAreHighlighted(shouldHighlight);
+ Frame *frame = core(webView)->mainFrame();
+ do {
+ frame->setMarkedTextMatchesAreHighlighted(shouldHighlight);
+ frame = frame->tree()->traverseNextWithWrap(false);
+ } while (frame);
}
/**
@@ -3462,3 +3764,205 @@ void webkit_web_view_set_group_name(WebKitWebView* webView, const gchar* groupNa
priv->corePage->setGroupName(String::fromUTF8(groupName));
}
+
+/**
+ * webkit_web_view_can_undo:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether or not it is currently possible to undo the last
+ * editing command in the view.
+ *
+ * Return value: %TRUE if a undo can be done, %FALSE if not
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_can_undo(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ return frame->editor()->canUndo();
+}
+
+/**
+ * webkit_web_view_undo:
+ * @web_view: a #WebKitWebView
+ *
+ * Undoes the last editing command in the view, if possible.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_undo(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (webkit_web_view_can_undo(webView))
+ g_signal_emit(webView, webkit_web_view_signals[UNDO], 0);
+}
+
+/**
+ * webkit_web_view_can_redo:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether or not it is currently possible to redo the last
+ * editing command in the view.
+ *
+ * Return value: %TRUE if a redo can be done, %FALSE if not
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_can_redo(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ return frame->editor()->canRedo();
+}
+
+/**
+ * webkit_web_view_redo:
+ * @web_view: a #WebKitWebView
+ *
+ * Redoes the last editing command in the view, if possible.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_redo(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (webkit_web_view_can_redo(webView))
+ g_signal_emit(webView, webkit_web_view_signals[REDO], 0);
+}
+
+
+/**
+ * webkit_web_view_set_view_source_mode:
+ * @web_view: a #WebKitWebView
+ * @view_source_mode: the mode to turn on or off view source mode
+ *
+ * Set whether the view should be in view source mode. Setting this mode to
+ * %TRUE before loading a URI will display the source of the web page in a
+ * nice and readable format.
+ *
+ * Since: 1.1.14
+ */
+void webkit_web_view_set_view_source_mode (WebKitWebView* webView, gboolean mode)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ if (Frame* mainFrame = core(webView)->mainFrame())
+ mainFrame->setInViewSourceMode(mode);
+}
+
+/**
+ * webkit_web_view_get_view_source_mode:
+ * @web_view: a #WebKitWebView
+ *
+ * Return value: %TRUE if @web_view is in view source mode, %FALSE otherwise.
+ *
+ * Since: 1.1.14
+ */
+gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ if (Frame* mainFrame = core(webView)->mainFrame())
+ return mainFrame->inViewSourceMode();
+
+ return FALSE;
+}
+
+// Internal subresource management
+void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebKitWebResource* webResource)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (!priv->mainResource) {
+ priv->mainResource = webResource;
+ priv->mainResourceIdentifier = g_strdup(identifier);
+ return;
+ }
+
+ g_hash_table_insert(priv->subResources, identifier, webResource);
+}
+
+WebKitWebResource* webkit_web_view_get_resource(WebKitWebView* webView, char* identifier)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ gpointer webResource = NULL;
+
+ gboolean resourceFound = g_hash_table_lookup_extended(priv->subResources, identifier, NULL, &webResource);
+
+ // The only resource we do not store in this hash table is the main!
+ g_return_val_if_fail(resourceFound || g_str_equal(identifier, priv->mainResourceIdentifier), NULL);
+
+ if (!webResource)
+ return webkit_web_view_get_main_resource(webView);
+
+ return WEBKIT_WEB_RESOURCE(webResource);
+}
+
+WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView)
+{
+ return webView->priv->mainResource;
+}
+
+void webkit_web_view_clear_resources(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ g_free(priv->mainResourceIdentifier);
+ priv->mainResourceIdentifier = NULL;
+
+ if (priv->mainResource) {
+ g_object_unref(priv->mainResource);
+ priv->mainResource = NULL;
+ }
+
+ if (priv->subResources)
+ g_hash_table_remove_all(priv->subResources);
+}
+
+GList* webkit_web_view_get_subresources(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ GList* subResources = g_hash_table_get_values(priv->subResources);
+ return g_list_remove(subResources, priv->mainResource);
+}
+
+/* From EventHandler.cpp */
+static IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& windowPoint)
+{
+ FrameView* view = frame->view();
+ // FIXME: Is it really OK to use the wrong coordinates here when view is 0?
+ // Historically the code would just crash; this is clearly no worse than that.
+ return view ? view->windowToContents(windowPoint) : windowPoint;
+}
+
+/**
+ * webkit_web_view_get_hit_test_result:
+ * @webView: a #WebKitWebView
+ * @event: a #GdkEventButton
+ *
+ * Does a 'hit test' in the coordinates specified by @event to figure
+ * out context information about that position in the @webView.
+ *
+ * Returns: a newly created #WebKitHitTestResult with the context of the
+ * specified position.
+ *
+ * Since: 1.1.15
+ **/
+WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, GdkEventButton* event)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL);
+ g_return_val_if_fail(event, NULL);
+
+ PlatformMouseEvent mouseEvent = PlatformMouseEvent(event);
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ HitTestRequest request(HitTestRequest::Active);
+ IntPoint documentPoint = documentPointForWindowPoint(frame, mouseEvent.pos());
+ MouseEventWithHitTestResults mev = frame->document()->prepareMouseEvent(request, documentPoint, mouseEvent);
+
+ return kit(mev.hitTestResult());
+}
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index fbdefa8..1297695 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -19,8 +19,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_VIEW_H
-#define WEBKIT_WEB_VIEW_H
+#ifndef webkitwebview_h
+#define webkitwebview_h
#include <gtk/gtk.h>
#include <libsoup/soup.h>
@@ -52,7 +52,10 @@ typedef enum {
typedef enum
{
WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
- WEBKIT_WEB_VIEW_TARGET_INFO_TEXT
+ WEBKIT_WEB_VIEW_TARGET_INFO_TEXT,
+ WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE,
+ WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST,
+ WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL
} WebKitWebViewTargetInfo;
struct _WebKitWebView {
@@ -116,13 +119,15 @@ struct _WebKitWebViewClass {
void (* set_scroll_adjustments) (WebKitWebView *web_view,
GtkAdjustment *hadjustment,
GtkAdjustment *vadjustment);
+
+ void (* undo) (WebKitWebView *web_view);
+ void (* redo) (WebKitWebView *web_view);
+
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
void (*_webkit_reserved1) (void);
void (*_webkit_reserved2) (void);
void (*_webkit_reserved3) (void);
- void (*_webkit_reserved4) (void);
- void (*_webkit_reserved5) (void);
};
WEBKIT_API GType
@@ -339,6 +344,28 @@ webkit_web_view_get_load_status (WebKitWebView *web_view)
WEBKIT_API gdouble
webkit_web_view_get_progress (WebKitWebView *web_view);
+WEBKIT_API void
+webkit_web_view_undo (WebKitWebView *webView);
+
+WEBKIT_API gboolean
+webkit_web_view_can_undo (WebKitWebView *webView);
+
+WEBKIT_API void
+webkit_web_view_redo (WebKitWebView *webView);
+
+WEBKIT_API gboolean
+webkit_web_view_can_redo (WebKitWebView *webView);
+
+WEBKIT_API void
+webkit_web_view_set_view_source_mode (WebKitWebView *web_view,
+ gboolean view_source_mode);
+
+WEBKIT_API gboolean
+webkit_web_view_get_view_source_mode (WebKitWebView *web_view);
+
+WEBKIT_API WebKitHitTestResult*
+webkit_web_view_get_hit_test_result (WebKitWebView *webView,
+ GdkEventButton *event);
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
index 47610d3..cdb6858 100644
--- a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
+++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
@@ -371,7 +371,7 @@ static void webkit_web_window_features_get_property(GObject* object, guint prop_
*
* Returns: a new #WebKitWebWindowFeatures instance
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
WebKitWebWindowFeatures* webkit_web_window_features_new()
{
@@ -418,7 +418,7 @@ WebKitWebWindowFeatures* webkit_web_window_features_new_from_core_features(const
* Returns: %TRUE if the instances have the same values, %FALSE
* otherwise
*
- * Since 1.0.3
+ * Since: 1.0.3
*/
gboolean webkit_web_window_features_equal(WebKitWebWindowFeatures* features1, WebKitWebWindowFeatures* features2)
{
diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.h b/WebKit/gtk/webkit/webkitwebwindowfeatures.h
index cd28988..a79119d 100644
--- a/WebKit/gtk/webkit/webkitwebwindowfeatures.h
+++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.h
@@ -17,8 +17,8 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WEBKIT_WEB_WINDOW_FEATURES_H
-#define WEBKIT_WEB_WINDOW_FEATURES_H
+#ifndef webkitwebwindowfeatures_h
+#define webkitwebwindowfeatures_h
#include <glib-object.h>
@@ -65,4 +65,4 @@ webkit_web_window_features_equal (WebKitWebWindowFeatures* feature
G_END_DECLS
-#endif /* WEBKIT_WEB_WINDOW_FEATURES_H */
+#endif /* webkitwebwindowfeatures_h */
diff --git a/WebKit/gtk/webkit/webkitworkers.cpp b/WebKit/gtk/webkit/webkitworkers.cpp
new file mode 100644
index 0000000..255863c
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitworkers.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "webkitprivate.h"
+
+#include "WorkerThread.h"
+
+unsigned int webkit_worker_thread_count(void)
+{
+#if ENABLE(WORKERS)
+ return WebCore::WorkerThread::workerThreadCount();
+#else
+ return 0;
+#endif
+}
+
+
diff --git a/WebKit/gtk/webkitmarshal.list b/WebKit/gtk/webkitmarshal.list
index aa0d40c..fefdff3 100644
--- a/WebKit/gtk/webkitmarshal.list
+++ b/WebKit/gtk/webkitmarshal.list
@@ -13,6 +13,7 @@ OBJECT:OBJECT
OBJECT:STRING,STRING,POINTER
OBJECT:VOID
VOID:OBJECT,OBJECT
+VOID:OBJECT,OBJECT,OBJECT,OBJECT
VOID:OBJECT,POINTER,POINTER
VOID:OBJECT,STRING
VOID:STRING