diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-05 14:34:32 -0800 |
commit | 635860845790a19bf50bbc51ba8fb66a96dde068 (patch) | |
tree | ef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebKit/gtk | |
parent | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff) | |
download | external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2 |
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebKit/gtk')
31 files changed, 2876 insertions, 261 deletions
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 166be63..e6dc216 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,695 @@ +2009-02-03 Mark Rowe <mrowe@apple.com> + + Merge r40508. + + 2009-02-02 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Sam Weinig. + + Track redirects in global history. + + Keep GTK building. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::createFrame): + (WebKit::FrameLoaderClient::updateGlobalHistoryForRedirectWithoutHistoryItem): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2009-02-03 Mark Rowe <mrowe@apple.com> + + Merge r40436. + + 2009-01-30 Geoffrey Garen <ggaren@apple.com> + + Build fix. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::createFrame): + +2009-01-27 Brady Eidson <beidson@apple.com> + + Reviewed by Dan Bernstein + + Rework FrameLoaderClient to work on a CachedFrame basis instead of CachedPage + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::savePlatformDataToCachedFrame): + (WebKit::FrameLoaderClient::transitionToCommittedFromCachedFrame): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2009-01-25 Darin Adler <darin@apple.com> + + Try to fix GTK build. + + * webkit/webkitwebview.cpp: Added include of FloatQuad.h. + +2009-01-13 Alexander V. Butenko <alex@digiqube.com> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=23279 + + Fix crash on WebView dispose stage. + + Add null checks to webkit_web_view_set_scroll_adjustments and + webkit_web_view_get_accessible as they get called from within + the dispose. + + * webkit/webkitwebview.cpp: + +2009-01-11 Xan Lopez <xan@gnome.org> + + Reviewed by Holger Freyther. + + Use NULL instead of 0 when dealing with pointers, as agreed for + the coding style of the WebKit GTK port for its GTK+ specific + files. + + * webkit/webkitwebview.cpp: + +2009-01-11 Xan Lopez <xan@gnome.org> + + Reviewed by Holger Freyther. + + Add padding to the class structs to avoid breaking ABI each time + we add stuff there. + + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebbackforwardlist.h: + * webkit/webkitwebhistoryitem.h: + * webkit/webkitwebnavigationaction.h: + * webkit/webkitwebpolicydecision.h: + * webkit/webkitwebview.h: + +2009-01-09 Benjamin Otte <otte@gnome.org> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=23194 + + make the finalize function the dispose function. Not releasing held + objects in dispose can cause crashers later. + + * webkit/webkitwebview.cpp: + +2009-01-09 Benjamin Otte <otte@gnome.org> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=23194 + + Remove broken code that uses a fallback. The previous code did 2 + policy decisions which caused crashes. + Download is still notImplemented(); + + * webkit/webkitwebpolicydecision.cpp: + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_download): + +2009-01-03 Xan Lopez <xan@gnome.org> + + Reviewed by Holger Freyther. + + [GTK] Need a public method to reload view bypassing cache + https://bugs.webkit.org/show_bug.cgi?id=19815 + + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + + Add webkit_web_view_reload_bypass_cache. + +2009-01-07 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Maciej Stachowiak. + + Add private API to get the number of active animations of + a frame. This is required by the DumpRenderTree utility. + + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + +2009-01-05 Adam Treat <adam.treat@torchmobile.com> + + Fix build + + * WebCoreSupport/ChromeClientGtk.h: + +2009-01-05 Adam Treat <adam.treat@torchmobile.com> + + Reviewed by George Staikos. + + Build fix for contentsSizeChanged + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::contentsSizeChanged): + * WebCoreSupport/ChromeClientGtk.h: + +2009-01-04 Adam Treat <adam.treat@torchmobile.com> + + Reviewed by George Staikos. + + Make the gtk port build with the new fixedLayoutSize feature + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + +2009-01-03 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Darin Adler. + + [GTK] Fix the reference counting of WebKitWebFrames + + The ownership is the following: WebKitWebView owns a WebCore::Page. + WebKitWebView is creating one WebKitWebFrame which will be the + mainFrame of the WebCore::Page (having the reference on the Frame). + + The FrameLoaderClient has the reference of the WebKitWebFrame for + the main frame and also any other frame. This means when the + WebCore::Frame goes away the FrameLoaderClient will go away which + will normally remove the last reference of the WebKitWebFrame. Because + an API user might have g_object_ref'ed the WebKitWebFrame null + checks had to be added to WebKitWebFrame. + + For WebCore::Frames created by the FrameLoaderClient the ownership + will be passed down to the FrameTree, the WebKitWebFrame is not holding + a reference to the WebCore::Frame. + + Do not g_object_unref the mainFrame in the destructor of the + WebKitWebFrame as this will happen from within the WebCore::Page + destruction. Do not hold a reference to the WebCore::Frame (circle) in + WebKitWebFrame, add null checks as the WebCore::Frame might have gone + away. Do not keep track of the FrameLoaderClient in the private + structures as it was mostly unusued. + + https://bugs.webkit.org/show_bug.cgi?id=21837 + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::frameLoaderDestroyed): + (WebKit::FrameLoaderClient::createFrame): + * tests/main.c: Add test case. + (test_webkit_web_frame_create_destroy): + (test_webkit_web_frame_lifetime): + (main): + * webkit/webkitprivate.cpp: + (WebKit::core): + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + * webkit/webkitwebview.cpp: + +2009-01-02 Holger Hans Peter Freyther <zecke@selfish.org> + + Unreviewed build fix. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + +2008-12-31 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Nikolas Zimmermann. + + https://bugs.webkit.org/show_bug.cgi?id=17045 + + Add section information for View, Frame, Settings, HistoryItem, BackForwardList, WindowFeatures and Inspector + + Add section information and informal examples for WebKitWebView, + WebKitWebFrame, WebKitWebSettings, WebKitWebNetworkRequest, + WebKitWebWindowFeatures, WebKitWebHistoryItem, + WebKitWebBackForwardList and WebKitWebInspector. + + * docs/webkitgtk-sections.txt: Decide to not document some bits + * webkit/webkitnetworkrequest.cpp: + * webkit/webkitwebbackforwardlist.cpp: + * webkit/webkitwebframe.cpp: + * webkit/webkitwebhistoryitem.cpp: + * webkit/webkitwebhistoryitem.h: + * webkit/webkitwebinspector.cpp: + * webkit/webkitwebsettings.cpp: + * webkit/webkitwebsettings.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebwindowfeatures.cpp: + +2008-12-21 Xan Lopez <xan@gnome.org> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=16092 + [GTK] Middle-mouse click should allow opening a URL in a new tab + + Add mouse button and keyboard state modifiers info to navigation action. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): + * webkit/webkitwebnavigationaction.cpp: + (_WebKitWebNavigationActionPrivate::): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_property): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_property): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_class_init): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_button): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_modifier_state): + * webkit/webkitwebnavigationaction.h: + +2008-12-19 Marco Barisione <marco.barisione@collabora.co.uk> + + Reviewed by Holger Freyther. + + http://bugs.webkit.org/show_bug.cgi?id=16562 + [gtk] Implement WebPolicyDelegate methods + + Original work by Pierre-Luc Beaudoin. Final touches by Gustavo + Noronha. + + This implements the delegates methods of WebPolicyDelegate. + Since Gtk+/C doesn't have delegate methods, they are replaced with + signals. + + A new object WebKitWebPolicyDecision allows the browser to delay its + response in certain cases. WebKitWebNavigationAction contains the + information about what caused a navigation request. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::FrameLoaderClient): + (WebKit::FrameLoaderClient::~FrameLoaderClient): + (WebKit::FrameLoaderClient::dispatchDecidePolicyForMIMEType): + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNewWindowAction): + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): + (WebKit::FrameLoaderClient::cancelPolicyCheck): + (WebKit::FrameLoaderClient::canShowMIMEType): + * WebCoreSupport/FrameLoaderClientGtk.h: + * webkit/webkit.h: + * webkit/webkitdefines.h: + * webkit/webkitprivate.cpp: + (WebKit::kit): + (WebKit::core): + * webkit/webkitprivate.h: + * webkit/webkitwebnavigationaction.cpp: Added. + (_WebKitWebNavigationActionPrivate::): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_property): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_property): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_init): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_finalize): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_class_init): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_reason): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_reason): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_get_original_uri): + (_WebKitWebNavigationActionPrivate::webkit_web_navigation_action_set_original_uri): + * webkit/webkitwebnavigationaction.h: Added. + * webkit/webkitwebpolicydecision.cpp: Added. + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_class_init): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_init): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_new): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_use): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_ignore): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_download): + (_WebKitWebPolicyDecisionPrivate::webkit_web_policy_decision_cancel): + * webkit/webkitwebpolicydecision.h: Added. + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-12-18 Dan Bernstein <mitz@apple.com> + + Reviewed by Sam Weinig. + + - stub out FrameLoaderClient::shouldUseCredentialStorage(). + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::shouldUseCredentialStorage): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-12-18 Sam Weinig <sam@webkit.org> + + Reviewed by John Sullivan. + + Stub out FrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-12-13 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Cameron Zwarich. + + [GTK] Fix crash with LayoutTests/fast/loader/frame-creation-removal.html + + Call WebCore::Frame::init after the frame has been given + a name and been added to the FrameTree of the parent. + + Removing the call to init is fine as FrameLoaderClientGtk::createFrame + is the only user of webkit_web_frame_init_with_web_view and is already + calling WebCore::Frame::init. + + * webkit/webkitwebframe.cpp: + +2008-12-13 Adam Bergkvist <adam.bergkvist@ericsson.com> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=22779 + + Check for GTK version >= 2.14.0 before using gtk_test_init. + + * tests/main.c: + (main): + +2008-12-13 Zan Dobersek <zandobersek@gmail.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=22039 + + Implement animation and transition pausing as needed by DumpRenderTree. + + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + +2008-11-29 Holger Hans Peter Freyther <zecke@selfish.org> + + Rubber-stamped by Simon Hausmann. + + https://bugs.webkit.org/show_bug.cgi?id=22574 + + Make webkit_web_view_set_window_features internal + + Calling this method will not result in a notify::window-features + signal being emitted. This would allow replacing a + WebKitWebWindowFeature on a WebKitWebView without anyone noticing + and the client code would monitor the wrong object. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::createWindow): + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-12-09 Brett Wilson <brettw@chromium.org> + + Reviewed by Dave Hyatt. + + https://bugs.webkit.org/show_bug.cgi?id=22177 + + Add a callback on ChromeClient that the state of form elements on + the page has changed. This is to allow clients implementing session + saving to know when the current state is dirty. + + * WebCoreSupport/ChromeClientGtk.h: + (WebKit::ChromeClient::formStateDidChange): + +2008-12-07 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Eric Seidel. + + [Gtk+] Use glib's unit test facilities to test the WebKit/Gtk+ API + + https://bugs.webkit.org/show_bug.cgi?id=22491 + + Add the skeleton to WebKit/gtk/tests and integrate that into the + buildsystem. Testing support was added in glib 2.16. For versions + using glib < 2.16 we compile an empty application. + + * tests/main.c: Added. https://bugs.webkit.org/show_bug.cgi?id=21837 + will be the first consumer. + (main): + +2008-12-06 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Dave Hyatt + + https://bugs.webkit.org/show_bug.cgi?id=15671 + + Renderer::caretRect() is now localCaretRect(), which needs + converting to absolute coordinates (taking transforms into account). + + * webkit/webkitwebview.cpp: + +2008-12-01 Xan Lopez <xan@gnome.org> + + Reviewed by Holger Freyther. + + http://bugs.webkit.org/show_bug.cgi?id=22553 + Remove unneeded GObject casts. + + Remove unneeded casts to GObject in functions that take a gpointer + argument. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::setWindowRect): + (WebKit::ChromeClient::createWindow): + (WebKit::ChromeClient::setToolbarsVisible): + (WebKit::ChromeClient::toolbarsVisible): + (WebKit::ChromeClient::setStatusbarVisible): + (WebKit::ChromeClient::statusbarVisible): + (WebKit::ChromeClient::setScrollbarsVisible): + (WebKit::ChromeClient::scrollbarsVisible): + (WebKit::ChromeClient::setMenubarVisible): + (WebKit::ChromeClient::menubarVisible): + (WebKit::ChromeClient::setToolTip): + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::createPage): + * webkit/webkitwebframe.cpp: + * webkit/webkitwebview.cpp: + * webkit/webkitwebwindowfeatures.cpp: + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_new_from_core_features): + +2008-11-29 Christian Dywan <christian@twotoasts.de> + + Reviewed by Holger Freyther. + + http://bugs.webkit.org/show_bug.cgi?id=17122 + [GTK] Bad font default settings + + Implement a property "enforce-96-dpi" in WebKitWebSettings + that can be enabled to force the view to assume 96 DPI. + + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::): + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + (_WebKitWebSettingsPrivate::webkit_web_settings_set_property): + (_WebKitWebSettingsPrivate::webkit_web_settings_get_property): + * webkit/webkitwebview.cpp: + +2008-11-28 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Nikolas Zimmermann. + + Simplify the code. There is no reason to have code like + if (true) return false; which is using temporary variables. + + * webkit/webkitwebview.cpp: + +2008-11-28 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Nikolas Zimmermann. + + Remove bogus null checks. The WebKitWebView own's a WebCore::Page + which is owning a WebCore::ChromeClient. There is no way that a + WebCore::ChromeClient is still around when the WebKitWebView is gone. + + m_webView can only be null when a ChromeClient gets constructed with + a null WebKitWebView which is not allowed. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::ChromeClient): + (WebKit::ChromeClient::windowRect): + (WebKit::ChromeClient::setWindowRect): + (WebKit::ChromeClient::pageRect): + (WebKit::ChromeClient::focus): + (WebKit::ChromeClient::unfocus): + (WebKit::ChromeClient::show): + (WebKit::ChromeClient::setToolbarsVisible): + (WebKit::ChromeClient::toolbarsVisible): + (WebKit::ChromeClient::setStatusbarVisible): + (WebKit::ChromeClient::statusbarVisible): + (WebKit::ChromeClient::setScrollbarsVisible): + (WebKit::ChromeClient::setMenubarVisible): + (WebKit::ChromeClient::menubarVisible): + (WebKit::ChromeClient::canTakeFocus): + (WebKit::ChromeClient::repaint): + (WebKit::ChromeClient::scroll): + (WebKit::ChromeClient::platformWindow): + +2008-11-28 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed and slightly modified by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=19130 + + ChromeClient::createWindow and friends need to be implemented + + Code from Gustavo Noronha and Marco Barisione + <marco.barisione@collabora.co.uk> in this change set. + + Implemented all the ChromeClient interfaces needed to have new + window creation functioning and exposed to client code. We + implemented a mirror GObject to the WindowFeatures object provided + by WebCore. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::windowRect): + (WebKit::ChromeClient::setWindowRect): + (WebKit::ChromeClient::unfocus): + (WebKit::ChromeClient::createWindow): + (WebKit::ChromeClient::show): + (WebKit::ChromeClient::setToolbarsVisible): + (WebKit::ChromeClient::toolbarsVisible): + (WebKit::ChromeClient::setStatusbarVisible): + (WebKit::ChromeClient::statusbarVisible): + (WebKit::ChromeClient::setScrollbarsVisible): + (WebKit::ChromeClient::scrollbarsVisible): + (WebKit::ChromeClient::setMenubarVisible): + (WebKit::ChromeClient::menubarVisible): + (WebKit::ChromeClient::setResizable): + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNewWindowAction): + (WebKit::FrameLoaderClient::dispatchShow): + (WebKit::FrameLoaderClient::dispatchCreatePage): + * webkit/webkit.h: + * webkit/webkitdefines.h: + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + * webkit/webkitwebwindowfeatures.cpp: Added. + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_class_init): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_init): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_finalize): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_set_property): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_get_property): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_new): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_new_from_core_features): + (_WebKitWebWindowFeaturesPrivate::webkit_web_window_features_equal): + * webkit/webkitwebwindowfeatures.h: Added. + +2008-11-24 Darin Fisher <darin@chromium.org> + + Fix bustage. + + http://bugs.webkit.org/show_bug.cgi?id=15643 + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::EditorClient::isSelectTrailingWhitespaceEnabled): + * WebCoreSupport/EditorClientGtk.h: + +2008-11-24 Darin Adler <darin@apple.com> + + Reviewed by Dan Bernstein. + + - https://bugs.webkit.org/show_bug.cgi?id=22470 + remove unneeded URL argument from FrameLoaderClient::updateGlobalHistory + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::updateGlobalHistory): Remove argument. + * WebCoreSupport/FrameLoaderClientGtk.h: Ditto. + +2008-11-24 Christian Dywan <christian@twotoasts.de> + + Reviewed by Holger Freyther. + + http://bugs.webkit.org/show_bug.cgi?id=17122 + [GTK] Bad font default settings + + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + Use default font size 12 instead of 10 + +2008-11-24 Zan Dobersek <zandobersek@gmail.com> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=22039 + + Implement a semi-private function for adding a directory to + PluginDatabase's paths. + + * webkit/webkitprivate.h: + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::webkit_web_settings_add_extra_plugin_directory): + +2008-11-23 Holger Hans Peter Freyther <zecke@selfish.org> + + Rubber-stamped by Sam Weinig. + + Add gtk-doc configuration/source for the WebKit/Gtk+ Reference Manual + + These files will be used by gtk-doc to generate the documentation. They + contain information how to group the symbols of our API, which objects + to inspect during the generation of the manual and how to display the + manual. + + * docs/webkitgtk-docs.sgml: Added. + * docs/webkitgtk-overrides.txt: Added. + * docs/webkitgtk-sections.txt: Added. + * docs/webkitgtk.types: Added. + +2008-11-23 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Sam Weinig. + + Make gtk-doc happy with the existing API documentation + + - Mark the *Private pointers in the struct private + - Use Returns: where gtk-doc wants us to + - Fix the parameters to make gtk-doc happy + - Fix signal references + + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebbackforwardlist.cpp: + * webkit/webkitwebbackforwardlist.h: + * webkit/webkitwebframe.h: + * webkit/webkitwebhistoryitem.cpp: + * webkit/webkitwebinspector.cpp: + (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init): + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-11-19 Darin Fisher <darin@chromium.org> + + Bustage fix. + + https://bugs.webkit.org/show_bug.cgi?id=22373 + Ports busted by addition of ScriptValue.{h,cpp} + + * webkit/webkitwebview.cpp: + +2008-11-18 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Simon Hausmann. + + Attempt to share transitionToCommittedForNewPage of FrameLoaderClient with the different ports + + After Hyatt's work on Widget and ScrollView there is little difference + between the implementation of Qt, Gtk+ and Win. In fact any kind of + difference is mostly a bug. Alp has fixed two of such errors for the Gtk+ + port and the Qt port has at least one of them left. + + The only difference between the implementations is in getting the the + IntSize for the new FrameView, the background color to be applied and + eventually some post processing. + + Unify the implementations by providing a static helper function that + takes a Frame, IntSize, color and transparency bit and calling it from + the Gtk+, the Qt and the Windows port. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + +2008-11-16 Christian Dywan <christian@twoasts.de> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=22207 + [Gtk] Font sizes are not handled properly when updated at runtime + + * webkit/webkitwebview.cpp: Move the DPI/ conversion into a + helper function and apply the logic in the notification callback. + +2008-11-06 Alp Toker <alp@nuanti.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=22047 + GTK: Add support for multiple file selection in the file upload control + + Implemented with GtkFileChooser. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::runOpenPanel): + 2008-11-03 Cameron Zwarich <zwarich@apple.com> Rubber-stamped by Maciej Stachowiak. diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp index 18ca5b3..3557a3f 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -1,7 +1,9 @@ /* - * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2008 Nuanti Ltd. + * Copyright (C) 2008 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,12 +26,14 @@ #include "FileSystem.h" #include "FileChooser.h" #include "FloatRect.h" +#include "FrameLoadRequest.h" #include "IntRect.h" #include "PlatformString.h" #include "CString.h" #include "HitTestResult.h" #include "KURL.h" #include "webkitwebview.h" +#include "webkitnetworkrequest.h" #include "webkitprivate.h" #include "NotImplemented.h" #include "WindowFeatures.h" @@ -48,6 +52,7 @@ namespace WebKit { ChromeClient::ChromeClient(WebKitWebView* webView) : m_webView(webView) { + ASSERT(m_webView); } void ChromeClient::chromeDestroyed() @@ -57,10 +62,8 @@ void ChromeClient::chromeDestroyed() FloatRect ChromeClient::windowRect() { - if (!m_webView) - return FloatRect(); GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); - if (window) { + if (GTK_WIDGET_TOPLEVEL(window)) { gint left, top, width, height; gtk_window_get_position(GTK_WINDOW(window), &left, &top); gtk_window_get_size(GTK_WINDOW(window), &width, &height); @@ -69,15 +72,21 @@ FloatRect ChromeClient::windowRect() return FloatRect(); } -void ChromeClient::setWindowRect(const FloatRect& r) +void ChromeClient::setWindowRect(const FloatRect& rect) { - notImplemented(); + IntRect intrect = IntRect(rect); + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + + g_object_set(webWindowFeatures, + "x", intrect.x(), + "y", intrect.y(), + "width", intrect.width(), + "height", intrect.height(), + NULL); } FloatRect ChromeClient::pageRect() { - if (!m_webView) - return FloatRect(); GtkAllocation allocation = GTK_WIDGET(m_webView)->allocation; return IntRect(allocation.x, allocation.y, allocation.width, allocation.height); } @@ -90,39 +99,38 @@ float ChromeClient::scaleFactor() void ChromeClient::focus() { - if (!m_webView) - return; gtk_widget_grab_focus(GTK_WIDGET(m_webView)); } void ChromeClient::unfocus() { - if (!m_webView) - return; GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(m_webView)); - if (window) + if (GTK_WIDGET_TOPLEVEL(window)) gtk_window_set_focus(GTK_WINDOW(window), NULL); } -Page* ChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& features) +Page* ChromeClient::createWindow(Frame* frame, const FrameLoadRequest& frameLoadRequest, const WindowFeatures& coreFeatures) { - if (features.dialog) { - notImplemented(); + WebKitWebView* webView = 0; + + g_signal_emit_by_name(m_webView, "create-web-view", kit(frame), &webView); + + if (!webView) return 0; - } else { - /* TODO: FrameLoadRequest is not used */ - WebKitWebView* webView = WEBKIT_WEB_VIEW_GET_CLASS(m_webView)->create_web_view(m_webView); - if (!webView) - return 0; - - WebKitWebViewPrivate* privateData = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); - return privateData->corePage; - } + + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_window_features_new_from_core_features(coreFeatures); + g_object_set(webView, "window-features", webWindowFeatures, NULL); + g_object_unref(webWindowFeatures); + + if (!frameLoadRequest.isEmpty()) + webkit_web_view_open(webView, frameLoadRequest.resourceRequest().url().string().utf8().data()); + + return core(webView); } void ChromeClient::show() { - notImplemented(); + webkit_web_view_notify_ready(m_webView); } bool ChromeClient::canRunModal() @@ -136,52 +144,72 @@ void ChromeClient::runModal() notImplemented(); } -void ChromeClient::setToolbarsVisible(bool) +void ChromeClient::setToolbarsVisible(bool visible) { - notImplemented(); + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + + g_object_set(webWindowFeatures, "toolbar-visible", visible, NULL); } bool ChromeClient::toolbarsVisible() { - notImplemented(); - return false; + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + gboolean visible; + + g_object_get(webWindowFeatures, "toolbar-visible", &visible, NULL); + return visible; } -void ChromeClient::setStatusbarVisible(bool) +void ChromeClient::setStatusbarVisible(bool visible) { - notImplemented(); + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + + g_object_set(webWindowFeatures, "statusbar-visible", visible, NULL); } bool ChromeClient::statusbarVisible() { - notImplemented(); - return false; + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + gboolean visible; + + g_object_get(webWindowFeatures, "statusbar-visible", &visible, NULL); + return visible; } -void ChromeClient::setScrollbarsVisible(bool) +void ChromeClient::setScrollbarsVisible(bool visible) { - notImplemented(); + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + + g_object_set(webWindowFeatures, "scrollbar-visible", visible, NULL); } bool ChromeClient::scrollbarsVisible() { - notImplemented(); - return false; + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + gboolean visible; + + g_object_get(webWindowFeatures, "scrollbar-visible", &visible, NULL); + return visible; } -void ChromeClient::setMenubarVisible(bool) +void ChromeClient::setMenubarVisible(bool visible) { - notImplemented(); + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + + g_object_set(webWindowFeatures, "menubar-visible", visible, NULL); } bool ChromeClient::menubarVisible() { - notImplemented(); - return false; + WebKitWebWindowFeatures* webWindowFeatures = webkit_web_view_get_window_features(m_webView); + gboolean visible; + + g_object_get(webWindowFeatures, "menubar-visible", &visible, NULL); + return visible; } void ChromeClient::setResizable(bool) { - notImplemented(); + // Ignored for now } void ChromeClient::closeWindowSoon() @@ -191,8 +219,6 @@ void ChromeClient::closeWindowSoon() bool ChromeClient::canTakeFocus(FocusDirection) { - if (!m_webView) - return false; return GTK_WIDGET_CAN_FOCUS(m_webView); } @@ -269,9 +295,6 @@ IntRect ChromeClient::windowResizerRect() const void ChromeClient::repaint(const IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly) { - if (!m_webView) - return; - GdkRectangle rect = windowRect; GdkWindow* window = GTK_WIDGET(m_webView)->window; @@ -286,9 +309,6 @@ void ChromeClient::repaint(const IntRect& windowRect, bool contentChanged, bool void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, const IntRect& clipRect) { - if (!m_webView) - return; - GdkWindow* window = GTK_WIDGET(m_webView)->window; if (!window) return; @@ -328,7 +348,12 @@ IntPoint ChromeClient::screenToWindow(const IntPoint& point) const PlatformWidget ChromeClient::platformWindow() const { - return m_webView ? GTK_WIDGET(m_webView) : 0; + return GTK_WIDGET(m_webView); +} + +void ChromeClient::contentsSizeChanged(Frame*, const IntSize&) const +{ + notImplemented(); } void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags) @@ -353,7 +378,7 @@ void ChromeClient::setToolTip(const String& toolTip) { #if GTK_CHECK_VERSION(2,12,0) if (toolTip.isEmpty()) - g_object_set(G_OBJECT(m_webView), "has-tooltip", FALSE, NULL); + g_object_set(m_webView, "has-tooltip", FALSE, NULL); else gtk_widget_set_tooltip_text(GTK_WIDGET(m_webView), toolTip.utf8().data()); #else @@ -381,9 +406,7 @@ void ChromeClient::exceededDatabaseQuota(Frame* frame, const String&) void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser) { - // FIXME: Support multiple files. - - RefPtr<FileChooser> fileChooser = prpFileChooser; + RefPtr<FileChooser> chooser = prpFileChooser; GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"), GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformWindow()))), @@ -392,11 +415,26 @@ void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser) GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), chooser->allowsMultipleFiles()); + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { - gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); - if (filename) - fileChooser->chooseFile(filenameToString(filename)); - g_free(filename); + if (gtk_file_chooser_get_select_multiple(GTK_FILE_CHOOSER(dialog))) { + GSList* filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); + Vector<String> names; + for (GSList* item = filenames ; item ; item = item->next) { + if (!item->data) + continue; + names.append(filenameToString(static_cast<char*>(item->data))); + g_free(item->data); + } + g_slist_free(filenames); + chooser->chooseFiles(names); + } else { + gchar* filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (filename) + chooser->chooseFile(filenameToString(filename)); + g_free(filename); + } } gtk_widget_destroy(dialog); } diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h index 04b3a26..299d023 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -89,6 +89,7 @@ namespace WebKit { virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; virtual PlatformWidget platformWindow() const; + virtual void contentsSizeChanged(WebCore::Frame*, const WebCore::IntSize&) const; virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); @@ -100,6 +101,8 @@ namespace WebKit { virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); + virtual void formStateDidChange(const WebCore::Node*) { } + private: WebKitWebView* m_webView; WebCore::KURL m_hoveredLinkURL; diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp index 62f1f27..e09178e 100644 --- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp @@ -301,6 +301,12 @@ bool EditorClient::smartInsertDeleteEnabled() return false; } +bool EditorClient::isSelectTrailingWhitespaceEnabled() +{ + notImplemented(); + return false; +} + void EditorClient::toggleContinuousSpellChecking() { notImplemented(); diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h index de31842..14514f5 100644 --- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h @@ -53,6 +53,7 @@ namespace WebKit { virtual bool shouldDeleteRange(WebCore::Range*); virtual bool shouldShowDeleteInterface(WebCore::HTMLElement*); virtual bool smartInsertDeleteEnabled(); + virtual bool isSelectTrailingWhitespaceEnabled(); virtual bool isContinuousSpellCheckingEnabled(); virtual void toggleContinuousSpellChecking(); virtual bool isGrammarCheckingEnabled(); diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp index 8cea58f..55d5024 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp @@ -22,7 +22,9 @@ #include "config.h" #include "FrameLoaderClientGtk.h" +#include "Color.h" #include "DocumentLoader.h" +#include "FormState.h" #include "FrameLoader.h" #include "FrameView.h" #include "FrameTree.h" @@ -33,6 +35,7 @@ #include "JSDOMWindow.h" #include "Language.h" #include "MIMETypeRegistry.h" +#include "MouseEvent.h" #include "NotImplemented.h" #include "PlatformString.h" #include "PluginDatabase.h" @@ -43,7 +46,10 @@ #include "JSDOMBinding.h" #include "ScriptController.h" #include "webkitwebview.h" +#include "webkitnetworkrequest.h" #include "webkitwebframe.h" +#include "webkitwebnavigationaction.h" +#include "webkitwebpolicydecision.h" #include "webkitprivate.h" #include <JavaScriptCore/APICast.h> @@ -59,12 +65,19 @@ namespace WebKit { FrameLoaderClient::FrameLoaderClient(WebKitWebFrame* frame) : m_frame(frame) , m_userAgent("") + , m_policyDecision(0) , m_pluginView(0) , m_hasSentResponseToPlugin(false) { ASSERT(m_frame); } +FrameLoaderClient::~FrameLoaderClient() +{ + if (m_policyDecision) + g_object_unref(m_policyDecision); +} + static String agentPlatform() { #ifdef GDK_WINDOWING_X11 @@ -188,6 +201,13 @@ void FrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, } } +bool +FrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned long identifier) +{ + notImplemented(); + return false; +} + void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) { notImplemented(); @@ -231,6 +251,7 @@ void FrameLoaderClient::postProgressFinishedNotification() void FrameLoaderClient::frameLoaderDestroyed() { + webkit_web_frame_core_frame_gone(m_frame); g_object_unref(m_frame); m_frame = 0; delete this; @@ -241,23 +262,42 @@ void FrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned lon m_response = response; } -void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String&, const ResourceRequest&) +void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String& mimeType, const ResourceRequest& resourceRequest) { - // FIXME: we need to call directly here (comment copied from Qt version) ASSERT(policyFunction); if (!policyFunction) return; - (core(m_frame)->loader()->*policyFunction)(PolicyUse); + + WebKitWebView* page = getViewFromFrame(m_frame); + WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data()); + + WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); + if (m_policyDecision) + g_object_unref(m_policyDecision); + m_policyDecision = policyDecision; + + gboolean isHandled = false; + g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request, mimeType.utf8().data(), policyDecision, &isHandled); + + g_object_unref(request); + + if (isHandled) + return; + + if (canShowMIMEType(mimeType)) + webkit_web_policy_decision_use (policyDecision); + else + webkit_web_policy_decision_download (policyDecision); } -void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&) +void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>, const String& s) { ASSERT(policyFunction); if (!policyFunction) return; // FIXME: I think Qt version marshals this to another thread so when we // have multi-threaded download, we might need to do the same - (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); + (core(m_frame)->loader()->*policyFunction)(PolicyUse); } void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>) @@ -269,17 +309,65 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct WebKitWebView* webView = getViewFromFrame(m_frame); WebKitNetworkRequest* request = webkit_network_request_new(resourceRequest.url().string().utf8().data()); WebKitNavigationResponse response; - + /* + * We still support the deprecated navigation-requested signal, if the + * application doesn't ignore the navigation then the new signal is + * emitted. + * navigation-policy-decision-requested must be emitted after + * navigation-requested as the policy decision can be async. + */ g_signal_emit_by_name(webView, "navigation-requested", m_frame, request, &response); - g_object_unref(request); - if (response == WEBKIT_NAVIGATION_RESPONSE_IGNORE) { (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); + g_object_unref(request); return; } - (core(m_frame)->loader()->*policyFunction)(PolicyUse); + WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); + if (m_policyDecision) + g_object_unref(m_policyDecision); + m_policyDecision = policyDecision; + + gint button = -1; + gint modifierFlags = 0; + + const Event* event = action.event(); + if (event && event->isMouseEvent()) { + const MouseEvent* mouseEvent = static_cast<const MouseEvent*>(event); + // DOM button values are 0, 1 and 2 for left, middle and right buttons. + // GTK+ uses 1, 2 and 3, so let's add 1 to remain consistent. + button = mouseEvent->button() + 1; + } + + UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(event)); + if (keyStateEvent) { + if (keyStateEvent->shiftKey()) + modifierFlags |= GDK_SHIFT_MASK; + if (keyStateEvent->ctrlKey()) + modifierFlags |= GDK_CONTROL_MASK; + if (keyStateEvent->altKey()) + modifierFlags |= GDK_MOD1_MASK; + if (keyStateEvent->metaKey()) + modifierFlags |= GDK_MOD2_MASK; + } + + GObject* navigationAction = G_OBJECT(g_object_new(WEBKIT_TYPE_WEB_NAVIGATION_ACTION, + "reason", kit(action.type()), + "original-uri", action.url().string().utf8().data(), + "button", button, + "modifier-state", modifierFlags, + NULL)); + + gboolean isHandled = false; + g_signal_emit_by_name(webView, "navigation-policy-decision-requested", m_frame, request, navigationAction, policyDecision, &isHandled); + + g_object_unref(navigationAction); + g_object_unref(request); + + // FIXME Implement default behavior when we can query the backend what protocols it supports + if (!isHandled) + webkit_web_policy_decision_use(m_policyDecision); } Widget* FrameLoaderClient::createPlugin(const IntSize& pluginSize, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) @@ -298,14 +386,14 @@ PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String& Frame* coreFrame = core(webFrame()); ASSERT(core(getViewFromFrame(webFrame())) == coreFrame->page()); - WebKitWebFrame* gtkFrame = WEBKIT_WEB_FRAME(webkit_web_frame_init_with_web_view(getViewFromFrame(webFrame()), ownerElement)); - RefPtr<Frame> childFrame(adoptRef(core(gtkFrame))); + + RefPtr<Frame> childFrame = webkit_web_frame_init_with_web_view(getViewFromFrame(webFrame()), ownerElement); coreFrame->tree()->appendChild(childFrame); childFrame->tree()->setName(name); childFrame->init(); - childFrame->loader()->loadURL(url, referrer, String(), FrameLoadTypeRedirectWithLockedHistory, 0, 0); + childFrame->loader()->loadURL(url, referrer, String(), FrameLoadTypeRedirectWithLockedBackForwardList, 0, 0); // The frame's onload handler may have removed it from the document. if (!childFrame->tree()->parent()) @@ -459,11 +547,6 @@ void FrameLoaderClient::detachedFromParent3() notImplemented(); } -void FrameLoaderClient::loadedFromCachedPage() -{ - notImplemented(); -} - void FrameLoaderClient::dispatchDidHandleOnloadEvents() { notImplemented(); @@ -540,14 +623,22 @@ void FrameLoaderClient::dispatchDidFirstLayout() notImplemented(); } -void FrameLoaderClient::dispatchShow() +void FrameLoaderClient::dispatchDidFirstVisuallyNonEmptyLayout() { notImplemented(); } +void FrameLoaderClient::dispatchShow() +{ + WebKitWebView* webView = getViewFromFrame(m_frame); + webkit_web_view_notify_ready(webView); +} + void FrameLoaderClient::cancelPolicyCheck() { - notImplemented(); + //FIXME Add support for more than one policy decision at once + if (m_policyDecision) + webkit_web_policy_decision_cancel(m_policyDecision); } void FrameLoaderClient::dispatchDidLoadMainResource(DocumentLoader*) @@ -576,10 +667,10 @@ bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const return true; } -bool FrameLoaderClient::canShowMIMEType(const String&) const +bool FrameLoaderClient::canShowMIMEType(const String& type) const { - notImplemented(); - return true; + return MIMETypeRegistry::isSupportedImageMIMEType(type) || MIMETypeRegistry::isSupportedNonImageMIMEType(type) || + PluginDatabase::installedPlugins()->isMIMETypeRegistered(type); } bool FrameLoaderClient::representationExistsForURLScheme(const String&) const @@ -715,8 +806,16 @@ bool FrameLoaderClient::canCachePage() const Frame* FrameLoaderClient::dispatchCreatePage() { - notImplemented(); - return 0; + WebKitWebView* webView = getViewFromFrame(m_frame); + WebKitWebView* newWebView = 0; + + g_signal_emit_by_name(webView, "create-web-view", m_frame, &newWebView); + + if (!newWebView) + return 0; + + WebKitWebViewPrivate* privateData = WEBKIT_WEB_VIEW_GET_PRIVATE(newWebView); + return core(privateData->mainFrame); } void FrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) @@ -738,57 +837,42 @@ void FrameLoaderClient::startDownload(const ResourceRequest&) notImplemented(); } -void FrameLoaderClient::updateGlobalHistory(const KURL&) +void FrameLoaderClient::updateGlobalHistory() { notImplemented(); } -void FrameLoaderClient::savePlatformDataToCachedPage(CachedPage*) +void FrameLoaderClient::updateGlobalHistoryForRedirectWithoutHistoryItem() { + notImplemented(); } -void FrameLoaderClient::transitionToCommittedFromCachedPage(CachedPage*) +void FrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*) +{ +} + +void FrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) { } void FrameLoaderClient::transitionToCommittedForNewPage() { + WebKitWebView* containingWindow = getViewFromFrame(m_frame); + IntSize size = IntSize(GTK_WIDGET(containingWindow)->allocation.width, + GTK_WIDGET(containingWindow)->allocation.height); + bool transparent = webkit_web_view_get_transparent(containingWindow); + Color backgroundColor = transparent ? WebCore::Color::transparent : WebCore::Color::white; Frame* frame = core(m_frame); ASSERT(frame); - Page* page = frame->page(); - ASSERT(page); + WebCore::FrameLoaderClient::transitionToCommittedForNewPage(frame, size, backgroundColor, transparent, IntSize(), false); - WebKitWebView* containingWindow = getViewFromFrame(m_frame); - bool isMainFrame = frame == page->mainFrame(); - - if (isMainFrame && frame->view()) - frame->view()->setParentVisible(false); - - frame->setView(0); - - FrameView* frameView; - if (isMainFrame) { - IntSize size = IntSize(GTK_WIDGET(containingWindow)->allocation.width, - GTK_WIDGET(containingWindow)->allocation.height); - frameView = new FrameView(frame, size); - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow); - frameView->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment); - } else - frameView = new FrameView(frame); - - frame->setView(frameView); - // FrameViews are created with a ref count of 1. Release this ref since we've assigned it to frame. - frameView->deref(); - - if (isMainFrame) - frameView->setParentVisible(true); - - if (frame->ownerRenderer()) - frame->ownerRenderer()->setWidget(frameView); + // We need to do further manipulation on the FrameView if it was the mainFrame + if (frame != frame->page()->mainFrame()) + return; - if (HTMLFrameOwnerElement* owner = frame->ownerElement()) - frame->view()->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOff); + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(containingWindow); + frame->view()->setGtkAdjustments(priv->horizontalAdjustment, priv->verticalAdjustment); } } diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h index 8f63b53..82286e8 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h @@ -33,6 +33,7 @@ #include "FrameLoaderClient.h" #include "ResourceResponse.h" #include "PluginView.h" +#include "webkitwebpolicydecision.h" typedef struct _WebKitWebFrame WebKitWebFrame; @@ -41,7 +42,7 @@ namespace WebKit { class FrameLoaderClient : public WebCore::FrameLoaderClient { public: FrameLoaderClient(WebKitWebFrame*); - virtual ~FrameLoaderClient() { } + virtual ~FrameLoaderClient(); virtual void frameLoaderDestroyed(); WebKitWebFrame* webFrame() const { return m_frame; } @@ -57,11 +58,10 @@ namespace WebKit { virtual void detachedFromParent2(); virtual void detachedFromParent3(); - virtual void loadedFromCachedPage(); - virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); virtual void dispatchWillSendRequest(WebCore::DocumentLoader*, unsigned long identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse); + virtual bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long identifier); virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&); virtual void dispatchDidReceiveResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&); @@ -85,6 +85,7 @@ namespace WebKit { virtual void dispatchDidFinishDocumentLoad(); virtual void dispatchDidFinishLoad(); virtual void dispatchDidFirstLayout(); + virtual void dispatchDidFirstVisuallyNonEmptyLayout(); virtual WebCore::Frame* dispatchCreatePage(); virtual void dispatchShow(); @@ -129,7 +130,8 @@ namespace WebKit { virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); virtual void finishedLoading(WebCore::DocumentLoader*); - virtual void updateGlobalHistory(const WebCore::KURL&); + virtual void updateGlobalHistory(); + virtual void updateGlobalHistoryForRedirectWithoutHistoryItem(); virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); @@ -160,8 +162,8 @@ namespace WebKit { virtual WebCore::String userAgent(const WebCore::KURL&); - virtual void savePlatformDataToCachedPage(WebCore::CachedPage*); - virtual void transitionToCommittedFromCachedPage(WebCore::CachedPage*); + virtual void savePlatformDataToCachedFrame(WebCore::CachedFrame*); + virtual void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*); virtual void transitionToCommittedForNewPage(); virtual bool canCachePage() const; @@ -170,6 +172,7 @@ namespace WebKit { WebKitWebFrame* m_frame; WebCore::ResourceResponse m_response; WebCore::String m_userAgent; + WebKitWebPolicyDecision* m_policyDecision; // Plugin view to redirect data to WebCore::PluginView* m_pluginView; diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp index 210995a..ba3721a 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -77,7 +77,7 @@ Page* InspectorClient::createPage() // close-window and destroy signals still need to be // emitted. WebKitWebInspector* webInspector; - g_object_get(G_OBJECT(m_inspectedWebView), "web-inspector", &webInspector, NULL); + g_object_get(m_inspectedWebView, "web-inspector", &webInspector, NULL); m_webInspector = webInspector; g_signal_emit_by_name(m_webInspector, "inspect-web-view", m_inspectedWebView, &m_webView); @@ -89,7 +89,7 @@ Page* InspectorClient::createPage() webkit_web_inspector_set_web_view(m_webInspector, m_webView); - g_signal_connect(G_OBJECT(m_webView), "destroy", + g_signal_connect(m_webView, "destroy", G_CALLBACK(notifyWebViewDestroyed), (gpointer)this); webkit_web_view_open(m_webView, "file://"DATA_DIR"/webkit-1.0/webinspector/inspector.html"); diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h index e19cbc7..8c868a2 100644 --- a/WebKit/gtk/webkit/webkit.h +++ b/WebKit/gtk/webkit/webkit.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -26,9 +27,12 @@ #include <webkit/webkitwebframe.h> #include <webkit/webkitwebsettings.h> #include <webkit/webkitwebinspector.h> +#include <webkit/webkitwebwindowfeatures.h> #include <webkit/webkitwebview.h> #include <webkit/webkitwebbackforwardlist.h> #include <webkit/webkitwebhistoryitem.h> +#include <webkit/webkitwebpolicydecision.h> +#include <webkit/webkitwebnavigationaction.h> #include <webkit/webkitenumtypes.h> #endif /* __WEBKIT_H__ */ diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h index 0c080f4..f94e710 100644 --- a/WebKit/gtk/webkit/webkitdefines.h +++ b/WebKit/gtk/webkit/webkitdefines.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -52,12 +53,18 @@ typedef struct _WebKitWebHistoryItemClass WebKitWebHistoryItemClass; typedef struct _WebKitWebFrame WebKitWebFrame; typedef struct _WebKitWebFrameClass WebKitWebFrameClass; +typedef struct _WebKitWebPolicyDecision WebKitWebPolicyDecision; +typedef struct _WebKitWebPolicyDecisionClass WebKitWebPolicyDecisionClass; + typedef struct _WebKitWebSettings WebKitWebSettings; typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass; typedef struct _WebKitWebInspector WebKitWebInspector; typedef struct _WebKitWebInspectorClass WebKitWebInspectorClass; +typedef struct _WebKitWebWindowFeatures WebKitWebWindowFeatures; +typedef struct _WebKitWebWindowFeaturesClass WebKitWebWindowFeaturesClass; + typedef struct _WebKitWebView WebKitWebView; typedef struct _WebKitWebViewClass WebKitWebViewClass; diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp index fab0f88..3ad8b5d 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp +++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -21,6 +21,19 @@ #include "webkitnetworkrequest.h" +/** + * SECTION:webkitnetworkrequest + * @short_description: The target of a navigation request + * @see_also: #WebKitWebView::navigation-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. + * + */ + extern "C" { G_DEFINE_TYPE(WebKitNetworkRequest, webkit_network_request, G_TYPE_OBJECT); @@ -77,6 +90,14 @@ void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar* priv->uri = g_strdup(uri); } +/** + * webkit_network_request_get_uri: + * @request: a #WebKitNetworkRequest + * + * Returns: the uri of the #WebKitNetworkRequest + * + * Since: 1.0.0 + */ G_CONST_RETURN gchar* webkit_network_request_get_uri(WebKitNetworkRequest* request) { g_return_val_if_fail(WEBKIT_IS_NETWORK_REQUEST(request), NULL); diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.h b/WebKit/gtk/webkit/webkitnetworkrequest.h index dfb4d6c..01ab8bb 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.h +++ b/WebKit/gtk/webkit/webkitnetworkrequest.h @@ -38,11 +38,18 @@ typedef struct _WebKitNetworkRequestPrivate WebKitNetworkRequestPrivate; struct _WebKitNetworkRequest { GObject parent_instance; + /*< private >*/ WebKitNetworkRequestPrivate *priv; }; struct _WebKitNetworkRequestClass { 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 diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index 07c8174..e801981 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -51,7 +52,7 @@ WebCore::Frame* core(WebKitWebFrame* frame) return 0; WebKitWebFramePrivate* priv = frame->priv; - return priv ? priv->coreFrame.get() : 0; + return priv ? priv->coreFrame : 0; } WebKitWebFrame* kit(WebCore::Frame* coreFrame) @@ -83,6 +84,16 @@ WebKitWebView* kit(WebCore::Page* corePage) return client ? client->webView() : 0; } +WebKitWebNavigationReason kit(WebCore::NavigationType type) +{ + return (WebKitWebNavigationReason)type; +} + +WebCore::NavigationType core(WebKitWebNavigationReason type) +{ + return (WebCore::NavigationType)type; +} + } /** end namespace WebKit */ void webkit_init() diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index 3047af4..ace996d 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -29,7 +30,10 @@ #include <webkit/webkitdefines.h> #include <webkit/webkitwebview.h> #include <webkit/webkitwebframe.h> +#include <webkit/webkitwebpolicydecision.h> +#include <webkit/webkitwebnavigationaction.h> #include <webkit/webkitwebsettings.h> +#include <webkit/webkitwebwindowfeatures.h> #include <webkit/webkitwebbackforwardlist.h> #include "BackForwardList.h" @@ -39,6 +43,7 @@ #include "Frame.h" #include "InspectorClientGtk.h" #include "FrameLoaderClient.h" +#include "WindowFeatures.h" #include <glib.h> @@ -55,6 +60,9 @@ namespace WebKit { WebKitWebHistoryItem* kit(WebCore::HistoryItem*); WebCore::BackForwardList* core(WebKitWebBackForwardList*); + + WebKitWebNavigationReason kit(WebCore::NavigationType type); + WebCore::NavigationType core(WebKitWebNavigationReason reason); } extern "C" { @@ -69,6 +77,7 @@ extern "C" { WebCore::Page* corePage; WebKitWebSettings* webSettings; WebKitWebInspector* webInspector; + WebKitWebWindowFeatures* webWindowFeatures; WebKitWebFrame* mainFrame; WebCore::String applicationNameForUserAgent; @@ -97,8 +106,7 @@ extern "C" { #define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate)) typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; struct _WebKitWebFramePrivate { - WTF::RefPtr<WebCore::Frame> coreFrame; - WebCore::FrameLoaderClient* client; + WebCore::Frame* coreFrame; WebKitWebView* webView; gchar* name; @@ -106,9 +114,12 @@ extern "C" { gchar* uri; }; - WebKitWebFrame* + PassRefPtr<WebCore::Frame> webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*); + void + webkit_web_frame_core_frame_gone(WebKitWebFrame*); + WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*); @@ -121,6 +132,18 @@ extern "C" { void webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri); + WebKitWebWindowFeatures* + webkit_web_window_features_new_from_core_features (const WebCore::WindowFeatures& features); + + void + webkit_web_view_notify_ready (WebKitWebView* web_view); + + WebKitWebPolicyDecision* + webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction); + + void + webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision); + // FIXME: Move these to webkitwebframe.h once their API has been discussed. WEBKIT_API GSList* @@ -135,8 +158,20 @@ extern "C" { WEBKIT_API gchar* webkit_web_frame_dump_render_tree (WebKitWebFrame* frame); + WEBKIT_API bool + webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); + + WEBKIT_API bool + webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); + + WEBKIT_API unsigned int + webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); + WEBKIT_API gchar* webkit_web_view_get_selected_text (WebKitWebView* web_view); + + WEBKIT_API void + webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory); } #endif diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp index ff68dad..3899f4b 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp @@ -29,6 +29,26 @@ #include "BackForwardList.h" #include "HistoryItem.h" +/** + * SECTION:webkitwebbackforwardlist + * @short_description: The history of a #WebKitWebView + * @see_also: #WebKitWebView, #WebKitWebHistoryItem + * + * <informalexample><programlisting> + * /<!-- -->* Get the WebKitWebBackForwardList from the WebKitWebView *<!-- -->/ + * WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list (my_web_view); + * WebKitWebHistoryItem *item = webkit_web_back_forward_list_get_current_item (back_forward_list); + * + * /<!-- -->* Do something with a WebKitWebHistoryItem *<!-- -->/ + * g_print("%p", item); + * + * /<!-- -->* Control some parameters *<!-- -->/ + * WebKitWebBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list (my_web_view); + * webkit_web_back_forward_list_set_limit (back_forward_list, 30); + * </programlisting></informalexample> + * + */ + using namespace WebKit; extern "C" { @@ -53,7 +73,7 @@ static void webkit_web_back_forward_list_init(WebKitWebBackForwardList* webBackF /** * webkit_web_back_forward_list_new_with_web_view: - * @webView: the back forward list's #WebKitWebView + * @web_view: the back forward list's #WebKitWebView * * Creates an instance of the back forward list with a controlling #WebKitWebView * @@ -76,7 +96,7 @@ WebKitWebBackForwardList* webkit_web_back_forward_list_new_with_web_view(WebKitW /** * webkit_web_back_forward_list_go_forward: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Steps forward in the back forward list */ @@ -91,7 +111,7 @@ void webkit_web_back_forward_list_go_forward(WebKitWebBackForwardList* webBackFo /** * webkit_web_back_forward_list_go_back: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Steps backward in the back forward list */ @@ -106,12 +126,12 @@ void webkit_web_back_forward_list_go_back(WebKitWebBackForwardList* webBackForwa /** * webkit_web_back_forward_list_contains_item: - * @webBackForwardList: a #WebKitWebBackForwardList - * @webHistoryItem: the #WebKitWebHistoryItem to check + * @web_back_forward_list: a #WebKitWebBackForwardList + * @history_item: the #WebKitWebHistoryItem to check * - * Checks if @webHistoryItem is in the back forward list + * Checks if @web_history_item is in the back forward list * - * Return: %TRUE if @webHistoryItem is in the back forward list, %FALSE if it doesn't + * Return: %TRUE if @web_history_item is in the back forward list, %FALSE if it doesn't */ gboolean webkit_web_back_forward_list_contains_item(WebKitWebBackForwardList* webBackForwardList, WebKitWebHistoryItem* webHistoryItem) { @@ -129,10 +149,10 @@ gboolean webkit_web_back_forward_list_contains_item(WebKitWebBackForwardList* we /** * webkit_web_back_forward_list_go_to_item: - * @webBackForwardList: a #WebKitWebBackForwardList - * @webHistoryItem: the #WebKitWebHistoryItem to go to + * @web_back_forward_list: a #WebKitWebBackForwardList + * @history_item: the #WebKitWebHistoryItem to go to * - * Go to the specified @webHistoryItem in the back forward list + * Go to the specified @web_history_item in the back forward list */ void webkit_web_back_forward_list_go_to_item(WebKitWebBackForwardList* webBackForwardList, WebKitWebHistoryItem* webHistoryItem) { @@ -148,7 +168,7 @@ void webkit_web_back_forward_list_go_to_item(WebKitWebBackForwardList* webBackFo /** * webkit_web_back_forward_list_get_forward_list_with_limit: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * @limit: the number of items to retrieve * * Returns a list of items that succeed the current item, limited by @limit @@ -178,7 +198,7 @@ GList* webkit_web_back_forward_list_get_forward_list_with_limit(WebKitWebBackFor /** * webkit_web_back_forward_list_get_back_list_with_limit: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * @limit: the number of items to retrieve * * Returns a list of items that precede the current item, limited by @limit @@ -207,7 +227,7 @@ GList* webkit_web_back_forward_list_get_back_list_with_limit(WebKitWebBackForwar } /** * webkit_web_back_forward_list_get_back_item: - * @webBackForwardList: a #WebBackForwardList + * @web_back_forward_list: a #WebBackForwardList * * Returns the item that precedes the current item * @@ -228,7 +248,7 @@ WebKitWebHistoryItem* webkit_web_back_forward_list_get_back_item(WebKitWebBackFo /** * webkit_web_back_forward_list_get_current_item: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the current item. * @@ -251,7 +271,7 @@ WebKitWebHistoryItem* webkit_web_back_forward_list_get_current_item(WebKitWebBac /** * webkit_web_back_forward_list_get_forward_item: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the item that succeeds the current item. * @@ -274,7 +294,7 @@ WebKitWebHistoryItem* webkit_web_back_forward_list_get_forward_item(WebKitWebBac /** * webkit_web_back_forward_list_get_nth_item: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * @index: the index of the item * * Returns the item at a given index relative to the current item. @@ -296,7 +316,7 @@ WebKitWebHistoryItem* webkit_web_back_forward_list_get_nth_item(WebKitWebBackFor /** * webkit_web_back_forward_list_get_back_length: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the number of items that preced the current item. * @@ -315,7 +335,7 @@ gint webkit_web_back_forward_list_get_back_length(WebKitWebBackForwardList* webB /** * webkit_web_back_forward_list_get_forward_length: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the number of items that succeed the current item. * @@ -334,7 +354,7 @@ gint webkit_web_back_forward_list_get_forward_length(WebKitWebBackForwardList* w /** * webkit_web_back_forward_list_get_limit: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the maximum limit of the back forward list. * @@ -353,7 +373,7 @@ gint webkit_web_back_forward_list_get_limit(WebKitWebBackForwardList* webBackFor /** * webkit_web_back_forward_list_set_limit: - * @webBackForwardList: a #WebKitWebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * @limit: the limit to set the back forward list to * * Sets the maximum limit of the back forward list. If the back forward list diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.h b/WebKit/gtk/webkit/webkitwebbackforwardlist.h index 68e18eb..fb641f0 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.h +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.h @@ -40,11 +40,18 @@ typedef struct _WebKitWebBackForwardListPrivate WebKitWebBackForwardListPrivate; struct _WebKitWebBackForwardList { GObject parent_instance; + /*< private >*/ WebKitWebBackForwardListPrivate *priv; }; struct _WebKitWebBackForwardListClass { 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 diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp index 6a4c4d5..38e23a4 100644 --- a/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/WebKit/gtk/webkit/webkitwebframe.cpp @@ -29,6 +29,7 @@ #include "webkitmarshal.h" #include "webkitprivate.h" +#include "AnimationController.h" #include "CString.h" #include "FrameLoader.h" #include "FrameLoaderClientGtk.h" @@ -45,6 +46,24 @@ #include <JavaScriptCore/APICast.h> +/** + * SECTION:webkitwebframe + * @short_description: The content of a #WebKitWebView + * + * A #WebKitWebView contains a main #WebKitWebFrame. A #WebKitWebFrame + * contains the content of one URI. The URI and name of the frame can + * be retrieved, the load status and progress can be observed using the + * signals and can be controlled using the methods of the #WebKitWebFrame. + * A #WebKitWebFrame can have any number of children and one child can + * be found by using #webkit_web_frame_find_frame. + * + * <informalexample><programlisting> + * /<!-- -->* Get the frame from the #WebKitWebView *<!-- -->/ + * WebKitWebFrame *frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW(my_view)); + * g_print("The URI of this frame is '%s'", webkit_web_frame_get_uri (frame)); + * </programlisting></informalexample> + */ + using namespace WebKit; using namespace WebCore; using namespace std; @@ -92,13 +111,24 @@ static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue } } +// Called from the FrameLoaderClient when it is destroyed. Normally +// the unref in the FrameLoaderClient is destroying this object as +// well but due reference counting a user might have added a reference... +void webkit_web_frame_core_frame_gone(WebKitWebFrame* frame) +{ + ASSERT(WEBKIT_IS_WEB_FRAME(frame)); + frame->priv->coreFrame = 0; +} + static void webkit_web_frame_finalize(GObject* object) { WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object); WebKitWebFramePrivate* priv = frame->priv; - priv->coreFrame->loader()->cancelAndClear(); - priv->coreFrame = 0; + if (priv->coreFrame) { + priv->coreFrame->loader()->cancelAndClear(); + priv->coreFrame = 0; + } g_free(priv->name); g_free(priv->title); @@ -224,25 +254,26 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView) WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); priv->webView = webView; - priv->client = new WebKit::FrameLoaderClient(frame); - priv->coreFrame = Frame::create(viewPriv->corePage, 0, priv->client).get(); + WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame); + priv->coreFrame = Frame::create(viewPriv->corePage, 0, client).get(); priv->coreFrame->init(); return frame; } -WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTMLFrameOwnerElement* element) +PassRefPtr<Frame> webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTMLFrameOwnerElement* element) { WebKitWebFrame* frame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL)); WebKitWebFramePrivate* priv = frame->priv; WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); priv->webView = webView; - priv->client = new WebKit::FrameLoaderClient(frame); - priv->coreFrame = Frame::create(viewPriv->corePage, element, priv->client).releaseRef(); - priv->coreFrame->init(); + WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame); - return frame; + RefPtr<Frame> coreFrame = Frame::create(viewPriv->corePage, element, client); + priv->coreFrame = coreFrame.get(); + + return coreFrame.release(); } /** @@ -314,7 +345,8 @@ G_CONST_RETURN gchar* webkit_web_frame_get_name(WebKitWebFrame* frame) return priv->name; Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return ""; String string = coreFrame->tree()->name(); priv->name = g_strdup(string.utf8().data()); @@ -334,7 +366,8 @@ WebKitWebFrame* webkit_web_frame_get_parent(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return NULL; return kit(coreFrame->tree()->parent()); } @@ -356,7 +389,8 @@ void webkit_web_frame_load_request(WebKitWebFrame* frame, WebKitNetworkRequest* g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request)); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return; // TODO: Use the ResourceRequest carried by WebKitNetworkRequest when it is implemented. String string = String::fromUTF8(webkit_network_request_get_uri(request)); @@ -374,7 +408,8 @@ void webkit_web_frame_stop_loading(WebKitWebFrame* frame) g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return; coreFrame->loader()->stopAllLoaders(); } @@ -390,7 +425,8 @@ void webkit_web_frame_reload(WebKitWebFrame* frame) g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return; coreFrame->loader()->reload(); } @@ -418,7 +454,8 @@ WebKitWebFrame* webkit_web_frame_find_frame(WebKitWebFrame* frame, const gchar* g_return_val_if_fail(name, NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return NULL; String nameString = String::fromUTF8(name); return kit(coreFrame->tree()->find(AtomicString(nameString))); @@ -438,7 +475,8 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return NULL; return toGlobalRef(coreFrame->script()->globalObject()->globalExec()); } @@ -454,7 +492,8 @@ GSList* webkit_web_frame_get_children(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return NULL; GSList* children = NULL; for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { @@ -478,7 +517,8 @@ gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return g_strdup(""); FrameView* view = coreFrame->view(); @@ -501,7 +541,8 @@ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return g_strdup(""); FrameView* view = coreFrame->view(); @@ -555,14 +596,15 @@ void webkit_web_frame_print(WebKitWebFrame* frame) topLevel = NULL; Frame* coreFrame = core(frame); - ASSERT(coreFrame); + if (!coreFrame) + return; PrintContext printContext(coreFrame); GtkPrintOperation* op = gtk_print_operation_new(); - g_signal_connect(G_OBJECT(op), "begin-print", G_CALLBACK(begin_print), &printContext); - g_signal_connect(G_OBJECT(op), "draw-page", G_CALLBACK(draw_page), &printContext); - g_signal_connect(G_OBJECT(op), "end-print", G_CALLBACK(end_print), &printContext); + g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), &printContext); + g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), &printContext); + g_signal_connect(op, "end-print", G_CALLBACK(end_print), &printContext); GError *error = NULL; gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(topLevel), &error); g_object_unref(op); @@ -589,4 +631,35 @@ void webkit_web_frame_print(WebKitWebFrame*) #endif +bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) +{ + ASSERT(core(frame)); + Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); + if (!coreElement || !coreElement->renderer()) + return false; + return core(frame)->animation()->pauseAnimationAtTime(coreElement->renderer(), AtomicString(name), time); +} + +bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) +{ + ASSERT(core(frame)); + Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); + if (!coreElement || !coreElement->renderer()) + return false; + return core(frame)->animation()->pauseTransitionAtTime(coreElement->renderer(), AtomicString(name), time); +} + +unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame) +{ + Frame* coreFrame = core(frame); + if (!coreFrame) + return 0; + + AnimationController* controller = coreFrame->animation(); + if (!controller) + return 0; + + return controller->numberOfActiveAnimations(); +} + } diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h index 827e4b9..fcdace6 100644 --- a/WebKit/gtk/webkit/webkitwebframe.h +++ b/WebKit/gtk/webkit/webkitwebframe.h @@ -41,12 +41,14 @@ typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; struct _WebKitWebFrame { GObject parent_instance; + /*< private >*/ WebKitWebFramePrivate *priv; }; struct _WebKitWebFrameClass { GObjectClass parent_class; + /*< public >*/ void (*_webkit_reserved1) (void); void (*_webkit_reserved2) (void); void (*_webkit_reserved3) (void); diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp index 150df68..8cdaa90 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp @@ -29,6 +29,25 @@ #include "HistoryItem.h" #include "PlatformString.h" +/** + * SECTION:webkitwebhistoryitem + * @short_description: One item of the #WebKitWebBackForwardList and or global history + * @see_also: #WebKitWebBackForwardList + * + * A history item consists out of a title and a uri. It can be part of the + * #WebKitWebBackForwardList and the global history. The global history is used + * for coloring the links of visited sites. #WebKitHistoryItem's constructed with + * #webkit_web_history_item_new and #webkit_web_history_item_new_with_data are + * automatically added to the global history. + * + * <informalexample><programlisting> + * /<!-- -->* Inject a visited page into the global history *<!-- -->/ + * webkit_web_history_item_new_with_data("http://www.gnome.org/", "GNOME: The Free Software Desktop Project"); + * webkit_web_history_item_new_with_data("http://www.webkit.org/", "The WebKit Open Source Project"); + * </programlisting></informalexample> + * + */ + using namespace WebKit; extern "C" { @@ -312,9 +331,9 @@ WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, co /** * webkit_web_history_item_get_title: - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * - * Returns the page title of @webHistoryItem + * Returns: the page title of @web_history_item */ G_CONST_RETURN gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryItem) { @@ -332,11 +351,11 @@ G_CONST_RETURN gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* we /** * webkit_web_history_item_get_alternate_title: - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * - * Returns the alternate title of @webHistoryItem + * Returns the alternate title of @web_history_item * - * Return value: the alternate title of @webHistoryItem + * Return value: the alternate title of @web_history_item */ G_CONST_RETURN gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* webHistoryItem) { @@ -354,10 +373,10 @@ G_CONST_RETURN gchar* webkit_web_history_item_get_alternate_title(WebKitWebHisto /** * webkit_web_history_item_set_alternate_title: - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * @title: the alternate title for @this history item * - * Sets an alternate title for @webHistoryItem + * Sets an alternate title for @web_history_item */ void webkit_web_history_item_set_alternate_title(WebKitWebHistoryItem* webHistoryItem, const gchar* title) { @@ -372,11 +391,11 @@ void webkit_web_history_item_set_alternate_title(WebKitWebHistoryItem* webHistor /** * webkit_web_history_item_get_uri: - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * * Returns the URI of @this * - * Return value: the URI of @webHistoryItem + * Return value: the URI of @web_history_item */ G_CONST_RETURN gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryItem) { @@ -394,11 +413,11 @@ G_CONST_RETURN gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webH /** * webkit_web_history_item_get_original_uri: - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * - * Returns the original URI of @webHistoryItem. + * Returns the original URI of @web_history_item. * - * Return value: the original URI of @webHistoryITem + * Return value: the original URI of @web_history_item */ G_CONST_RETURN gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webHistoryItem) { @@ -416,11 +435,11 @@ G_CONST_RETURN gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryI /** * webkit_web_history_item_get_last_visisted_time : - * @webHistoryItem: a #WebKitWebHistoryItem + * @web_history_item: a #WebKitWebHistoryItem * - * Returns the last time @webHistoryItem was visited + * Returns the last time @web_history_item was visited * - * Return value: the time in seconds this @webHistoryItem was last visited + * Return value: the time in seconds this @web_history_item was last visited */ gdouble webkit_web_history_item_get_last_visited_time(WebKitWebHistoryItem* webHistoryItem) { diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.h b/WebKit/gtk/webkit/webkitwebhistoryitem.h index dd63f9d..c8a754a 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.h +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.h @@ -39,11 +39,18 @@ typedef struct _WebKitWebHistoryItemPrivate WebKitWebHistoryItemPrivate; struct _WebKitWebHistoryItem { GObject parent_instance; + /*< private >*/ WebKitWebHistoryItemPrivate *priv; }; struct _WebKitWebHistoryItemClass { 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 diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp index 437fe2b..b8f8d9e 100644 --- a/WebKit/gtk/webkit/webkitwebinspector.cpp +++ b/WebKit/gtk/webkit/webkitwebinspector.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 Gustavo Noronha Silva + * Copyright (C) 2008 Holger Hans Peter Freyther * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,6 +25,35 @@ #include "InspectorClientGtk.h" #include "webkitprivate.h" +/** + * SECTION:webkitwebinspector + * @short_description: Access to the WebKit Inspector + * + * The WebKit Inspector is a graphical tool to inspect and change + * the content of a #WebKitWebView. It also includes an interactive + * JavaScriptDebugger. Using this class one can get a GtkWidget which + * can be embedded into an application to show the inspector. + * + * The inspector is available when the #WebKitWebSettings of the + * #WebKitWebView has set the #WebKitWebSettings:enable-developer-extras + * to true otherwise no inspector is available. + * + * <informalexample><programlisting> + * /<!-- -->* Enable the developer extras *<!-- -->/ + * WebKitWebSettings *setting = webkit_web_view_get_settings (WEBKIT_WEB_VIEW(my_webview)); + * g_object_set (G_OBJECT(settings), "enable-developer-extras", TRUE, NULL); + * + * /<!-- -->* load some data or reload to be able to inspect the page*<!-- -->/ + * webkit_web_view_open (WEBKIT_WEB_VIEW(my_webview), "http://www.gnome.org"); + * + * /<!-- -->* Embed the inspector somewhere *<!-- -->/ + * WebKitWebInspector *inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW(my_webview)); + * g_signal_connect (G_OBJECT (inspector), "inspect-web-view", G_CALLBACK(create_gtk_window_around_it), NULL); + * g_signal_connect (G_OBJECT (inspector), "show-window", G_CALLBACK(show_inpector_window), NULL)); + * g_signal_connect (G_OBJECT (inspector), "notify::inspected-uri", G_CALLBACK(inspected_uri_changed_do_stuff), NULL); + * </programlisting></informalexample> + */ + using namespace WebKit; extern "C" { @@ -116,7 +146,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) * * Emitted when the inspector window should be displayed. Notice * that the window must have been created already by handling - * ::inspect-web-view. + * #WebKitWebInspector::inspect-web-view. * * Since: 1.0.3 */ @@ -173,13 +203,13 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) * * Emitted when the inspector window should be closed. You can * destroy the window or hide it so that it can be displayed again - * by handling ::show-window later on. + * by handling #WebKitWebInspector::show-window later on. * * Notice that the inspected #WebKitWebView may no longer exist * when this signal is emitted. * * Notice, too, that if you decide to destroy the window, - * ::inspect-web-view will be emmited again, when the user + * #WebKitWebInspector::inspect-web-view will be emmited again, when the user * inspects an element. * * Since: 1.0.3 @@ -313,7 +343,7 @@ void webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKit * * Obtains the #WebKitWebView that is used to render the * inspector. The #WebKitWebView instance is created by the - * application, by handling the ::inspect-web-view signal. This means + * application, by handling the #WebKitWebInspector::inspect-web-view signal. This means * that this method may return %NULL if the user hasn't inspected * anything. * diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp new file mode 100644 index 0000000..48e36ac --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp @@ -0,0 +1,312 @@ +/* + * Copyright (C) 2008 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 <wtf/Assertions.h> +#include "FrameLoaderTypes.h" + +#include "webkitwebnavigationaction.h" +#include "webkitprivate.h" +#include "webkitenumtypes.h" + +#include <string.h> + +extern "C" { + +struct _WebKitWebNavigationActionPrivate { + WebKitWebNavigationReason reason; + gchar* originalUri; + gint button; + gint modifier_state; +}; + +#define WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionPrivate)) + +enum { + PROP_0, + + PROP_REASON, + PROP_ORIGINAL_URI, + PROP_BUTTON, + PROP_MODIFIER_STATE +}; + +G_DEFINE_TYPE(WebKitWebNavigationAction, webkit_web_navigation_action, G_TYPE_OBJECT) + + +static void webkit_web_navigation_action_get_property(GObject* object, guint propertyId, GValue* value, GParamSpec* pspec) +{ + WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(object); + + switch(propertyId) { + case PROP_REASON: + g_value_set_enum(value, webkit_web_navigation_action_get_reason(navigationAction)); + break; + case PROP_ORIGINAL_URI: + g_value_set_string(value, webkit_web_navigation_action_get_original_uri(navigationAction)); + break; + case PROP_BUTTON: + g_value_set_int(value, webkit_web_navigation_action_get_button(navigationAction)); + break; + case PROP_MODIFIER_STATE: + g_value_set_int(value, webkit_web_navigation_action_get_modifier_state(navigationAction)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + +static void webkit_web_navigation_action_set_property(GObject* object, guint propertyId, const GValue* value, GParamSpec* pspec) +{ + WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(object); + WebKitWebNavigationActionPrivate* priv = navigationAction->priv; + + switch(propertyId) { + case PROP_REASON: + webkit_web_navigation_action_set_reason(navigationAction, (WebKitWebNavigationReason)g_value_get_enum(value)); + break; + case PROP_ORIGINAL_URI: + webkit_web_navigation_action_set_original_uri(navigationAction, g_value_get_string(value)); + break; + case PROP_BUTTON: + priv->button = g_value_get_int(value); + break; + case PROP_MODIFIER_STATE: + priv->modifier_state = g_value_get_int(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec); + break; + } +} + +static void webkit_web_navigation_action_init(WebKitWebNavigationAction* navigationAction) +{ + navigationAction->priv = WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(navigationAction); + + WebKitWebNavigationActionPrivate* priv = navigationAction->priv; +} + +static void webkit_web_navigation_action_finalize(GObject* obj) +{ + WebKitWebNavigationAction* navigationAction = WEBKIT_WEB_NAVIGATION_ACTION(obj); + WebKitWebNavigationActionPrivate* priv = navigationAction->priv; + + g_free(priv->originalUri); + + G_OBJECT_CLASS(webkit_web_navigation_action_parent_class)->finalize(obj); +} + +static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionClass* requestClass) +{ + GObjectClass* objectClass = G_OBJECT_CLASS(requestClass); + + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED == WebCore::NavigationTypeLinkClicked, navigation_type_link_clicked_enum_match); + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED == WebCore::NavigationTypeFormSubmitted, navigation_type_form_submitted_enum_match); + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD == WebCore::NavigationTypeBackForward, navigation_type_back_forward_enum_match); + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_RELOAD == WebCore::NavigationTypeReload, navigation_type_reload_enum_match); + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED == WebCore::NavigationTypeFormResubmitted, navigation_type_form_resubmitted_enum_match); + COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_OTHER == WebCore::NavigationTypeOther, navigation_type_other_enum_match); + + objectClass->get_property = webkit_web_navigation_action_get_property; + objectClass->set_property = webkit_web_navigation_action_set_property; + objectClass->dispose = webkit_web_navigation_action_finalize; + + /** + * WebKitWebNavigationAction:reason: + * + * The reason why this navigation is occuring. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_REASON, + g_param_spec_enum("reason", + "Reason", + "The reason why this navigation is occurring", + WEBKIT_TYPE_WEB_NAVIGATION_REASON, + WEBKIT_WEB_NAVIGATION_REASON_OTHER, + (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT))); + + /** + * WebKitWebNavigationAction:original-uri: + * + * The URI that was requested as the target for the navigation. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_ORIGINAL_URI, + g_param_spec_string("original-uri", + "Original URI", + "The URI that was requested as the target for the navigation", + "", + (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT))); + /** + * WebKitWebNavigationAction:button: + * + * The button used to click if the action was a mouse event. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_BUTTON, + g_param_spec_int("button", + "Button", + "The button used to click", + -1, + G_MAXINT, + -1, + (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); + + /** + * WebKitWebNavigationAction:modifier-state: + * + * The state of the modifier keys when the action was requested. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_MODIFIER_STATE, + g_param_spec_int("modifier-state", + "Modifier state", + "A bitmask representing the state of the modifier keys", + 0, + G_MAXINT, + 0, + (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); + + + + g_type_class_add_private(requestClass, sizeof(WebKitWebNavigationActionPrivate)); +} + +/** + * webkit_web_navigation_action_get_reason: + * @navigationAction: a #WebKitWebNavigationAction + * + * Returns the reason why WebKit is requesting a navigation. + * + * Return value: a #WebKitWebNavigationReason + * + * Since: 1.0.3 + */ +WebKitWebNavigationReason webkit_web_navigation_action_get_reason(WebKitWebNavigationAction* navigationAction) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), WEBKIT_WEB_NAVIGATION_REASON_OTHER); + + return navigationAction->priv->reason; +} + +/** + * webkit_web_navigation_action_set_reason: + * @navigationAction: a #WebKitWebNavigationAction + * @reason: a #WebKitWebNavigationReason + * + * Sets the reason why WebKit is requesting a navigation. + * + * Since: 1.0.3 + */ +void webkit_web_navigation_action_set_reason(WebKitWebNavigationAction* navigationAction, WebKitWebNavigationReason reason) +{ + g_return_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction)); + + if (navigationAction->priv->reason == reason) + return; + + navigationAction->priv->reason = reason; + g_object_notify(G_OBJECT(navigationAction), "reason"); +} + +/** + * webkit_web_navigation_action_get_original_uri: + * @navigationAction: a #WebKitWebNavigationAction + * + * Returns the URI that was originally requested. This may differ from the + * navigation target, for instance because of a redirect. + * + * Return value: the originally requested URI + * + * Since: 1.0.3 + */ +const gchar* webkit_web_navigation_action_get_original_uri(WebKitWebNavigationAction* navigationAction) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), NULL); + + return navigationAction->priv->originalUri; +} + +/** + * webkit_web_navigation_action_set_original_uri: + * @navigationAction: a #WebKitWebNavigationAction + * @originalUri: a URI + * + * Sets the URI that was originally requested. This may differ from the + * navigation target, for instance because of a redirect. + * + * Since: 1.0.3 + */ +void webkit_web_navigation_action_set_original_uri(WebKitWebNavigationAction* navigationAction, const gchar* originalUri) +{ + g_return_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction)); + g_return_if_fail(originalUri); + + if (navigationAction->priv->originalUri && + (!strcmp(navigationAction->priv->originalUri, originalUri))) + return; + + g_free(navigationAction->priv->originalUri); + navigationAction->priv->originalUri = g_strdup(originalUri); + g_object_notify(G_OBJECT(navigationAction), "original-uri"); +} + +/** + * webkit_web_navigation_action_get_button: + * @navigationAction: a #WebKitWebNavigationAction + * + * Returns the mouse button used to click if the action was a mouse event. + * Otherwise returns -1. + * + * Return value: the mouse button used to click + * + * Since: 1.0.3 + */ +gint webkit_web_navigation_action_get_button(WebKitWebNavigationAction* navigationAction) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), -1); + + return navigationAction->priv->button; +} + +/** + * webkit_web_navigation_action_get_modifier_state: + * @navigationAction: a #WebKitWebNavigationAction + * + * Returns a bitmask with the the state of the modifier keys. + * + * Return value: a bitmask with the state of the modifier keys + * + * Since: 1.0.3 + */ +gint webkit_web_navigation_action_get_modifier_state(WebKitWebNavigationAction* navigationAction) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), 0); + + return navigationAction->priv->modifier_state; +} + +} diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.h b/WebKit/gtk/webkit/webkitwebnavigationaction.h new file mode 100644 index 0000000..d83e7a0 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebnavigationaction.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2008 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 WEBKIT_WEB_NAVIGATION_ACTION_H +#define WEBKIT_WEB_NAVIGATION_ACTION_H + +#include <glib-object.h> + +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +/* + * The order of this enum must be the same as NavigationType in + * FrameLoaderTypes.h + */ +typedef enum { + WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED, + WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED, + WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD, + WEBKIT_WEB_NAVIGATION_REASON_RELOAD, + WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED, + WEBKIT_WEB_NAVIGATION_REASON_OTHER, +} WebKitWebNavigationReason; + +#define WEBKIT_TYPE_WEB_NAVIGATION_ACTION (webkit_web_navigation_action_get_type()) +#define WEBKIT_WEB_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationAction)) +#define WEBKIT_WEB_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionClass)) +#define WEBKIT_IS_WEB_NAVIGATION_ACTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION)) +#define WEBKIT_IS_WEB_NAVIGATION_ACTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_NAVIGATION_ACTION)) +#define WEBKIT_WEB_NAVIGATION_ACTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionClass)) + +typedef struct _WebKitWebNavigationAction WebKitWebNavigationAction; +typedef struct _WebKitWebNavigationActionClass WebKitWebNavigationActionClass; +typedef struct _WebKitWebNavigationActionPrivate WebKitWebNavigationActionPrivate; + +struct _WebKitWebNavigationAction { + GObject parent_instance; + + /*< private >*/ + WebKitWebNavigationActionPrivate* priv; +}; + +struct _WebKitWebNavigationActionClass { + 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_navigation_action_get_type(void); + +WEBKIT_API WebKitWebNavigationReason +webkit_web_navigation_action_get_reason(WebKitWebNavigationAction* navigationAction); + +WEBKIT_API void +webkit_web_navigation_action_set_reason(WebKitWebNavigationAction* navigationAction, WebKitWebNavigationReason reason); + +WEBKIT_API const gchar* +webkit_web_navigation_action_get_original_uri(WebKitWebNavigationAction* navigationAction); + +WEBKIT_API void +webkit_web_navigation_action_set_original_uri(WebKitWebNavigationAction* navigationAction, const gchar* originalUri); + +WEBKIT_API gint +webkit_web_navigation_action_get_button(WebKitWebNavigationAction* navigationAction); + +WEBKIT_API gint +webkit_web_navigation_action_get_modifier_state(WebKitWebNavigationAction* navigationAction); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp new file mode 100644 index 0000000..db4d10f --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2008 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 "webkitwebpolicydecision.h" + +#include "FrameLoaderTypes.h" +#include "webkitprivate.h" + +using namespace WebKit; +using namespace WebCore; + +extern "C" { + +G_DEFINE_TYPE(WebKitWebPolicyDecision, webkit_web_policy_decision, G_TYPE_OBJECT); + +struct _WebKitWebPolicyDecisionPrivate { + WebKitWebFrame* frame; + FramePolicyFunction framePolicyFunction; + gboolean isCancelled; +}; + +#define WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionPrivate)) + +static void webkit_web_policy_decision_class_init(WebKitWebPolicyDecisionClass* decisionClass) +{ + g_type_class_add_private(decisionClass, sizeof(WebKitWebPolicyDecisionPrivate)); +} + +static void webkit_web_policy_decision_init(WebKitWebPolicyDecision* decision) +{ + decision->priv = WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(decision); +} + +WebKitWebPolicyDecision* webkit_web_policy_decision_new(WebKitWebFrame* frame, WebCore::FramePolicyFunction function) +{ + g_return_val_if_fail(frame, NULL); + + WebKitWebPolicyDecision* decision = WEBKIT_WEB_POLICY_DECISION(g_object_new(WEBKIT_TYPE_WEB_POLICY_DECISION, NULL)); + WebKitWebPolicyDecisionPrivate* priv = decision->priv; + + priv->frame = frame; + priv->framePolicyFunction = function; + priv->isCancelled = FALSE; + + return decision; +} + +/** + * webkit_web_policy_decision_use + * @decision: a #WebKitWebPolicyDecision + * + * Will send the USE decision to the policy implementer. + * + * Since: 1.0.3 + */ +void webkit_web_policy_decision_use(WebKitWebPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision)); + + WebKitWebPolicyDecisionPrivate* priv = decision->priv; + + if (!priv->isCancelled) + (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyUse); +} + +/** + * webkit_web_policy_decision_ignore + * @decision: a #WebKitWebPolicyDecision + * + * Will send the IGNORE decision to the policy implementer. + * + * Since: 1.0.3 + */ +void webkit_web_policy_decision_ignore(WebKitWebPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision)); + + WebKitWebPolicyDecisionPrivate* priv = decision->priv; + + if (!priv->isCancelled) + (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyIgnore); +} + +/** + * webkit_web_policy_decision_download + * @decision: a #WebKitWebPolicyDecision + * + * Will send the DOWNLOAD decision to the policy implementer. + * + * Since: 1.0.3 + */ +void webkit_web_policy_decision_download(WebKitWebPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision)); + + WebKitWebPolicyDecisionPrivate* priv = decision->priv; + + if (!priv->isCancelled) + (core(priv->frame)->loader()->*(priv->framePolicyFunction))(WebCore::PolicyDownload); +} + +void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_WEB_POLICY_DECISION(decision)); + + WebKitWebPolicyDecisionPrivate* priv = decision->priv; + + priv->isCancelled = TRUE; +} + +} diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.h b/WebKit/gtk/webkit/webkitwebpolicydecision.h new file mode 100644 index 0000000..f1ec963 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebpolicydecision.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2008 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 WEBKIT_WEB_POLICY_DECISION_H +#define WEBKIT_WEB_POLICY_DECISION_H + +#include <glib-object.h> +#include <stdint.h> +#include "webkitdefines.h" + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_WEB_POLICY_DECISION (webkit_web_policy_decision_get_type()) +#define WEBKIT_WEB_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecision)) +#define WEBKIT_WEB_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionClass)) +#define WEBKIT_IS_WEB_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_POLICY_DECISION)) +#define WEBKIT_IS_WEB_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_POLICY_DECISION)) +#define WEBKIT_WEB_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionClass)) + +typedef struct _WebKitWebPolicyDecisionPrivate WebKitWebPolicyDecisionPrivate; +struct _WebKitWebPolicyDecision { + GObject parent_instance; + + /*< private >*/ + WebKitWebPolicyDecisionPrivate* priv; +}; + +struct _WebKitWebPolicyDecisionClass { + 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_policy_decision_get_type (void); + +WEBKIT_API void +webkit_web_policy_decision_use (WebKitWebPolicyDecision* decision); + +WEBKIT_API void +webkit_web_policy_decision_ignore (WebKitWebPolicyDecision* decision); + +WEBKIT_API void +webkit_web_policy_decision_download (WebKitWebPolicyDecision* decision); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 49ab4c6..aa38c6c 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2008 Nuanti Ltd. * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2008 Holger Hans Peter Freyther * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,6 +25,29 @@ #include "webkitwebsettings.h" #include "webkitprivate.h" +#include "FileSystem.h" +#include "PluginDatabase.h" + +/** + * SECTION:webkitwebsettings + * @short_description: Control the behaviour of a #WebKitWebView + * + * #WebKitWebSettings can be applied to a #WebKitWebView to control + * the to be used text encoding, color, font sizes, printing mode, + * script support, loading of images and various other things. + * + * <informalexample><programlisting> + * /<!-- -->* Create a new websettings and disable java script *<!-- -->/ + * WebKitWebSettings *settings = webkit_web_settings_new (); + * g_object_set (G_OBJECT(settings), "enable-scripts", FALSE, NULL); + * + * /<!-- -->* Apply the result *<!-- -->/ + * webkit_web_view_set_settings (WEBKIT_WEB_VIEW(my_webview), settings); + * </programlisting></informalexample> + */ + +using namespace WebCore; + extern "C" { G_DEFINE_TYPE(WebKitWebSettings, webkit_web_settings, G_TYPE_OBJECT) @@ -40,6 +64,7 @@ struct _WebKitWebSettingsPrivate { guint default_monospace_font_size; guint minimum_font_size; guint minimum_logical_font_size; + gboolean enforce_96_dpi; gboolean auto_load_images; gboolean auto_shrink_images; gboolean print_backgrounds; @@ -67,6 +92,7 @@ enum { PROP_DEFAULT_MONOSPACE_FONT_SIZE, PROP_MINIMUM_FONT_SIZE, PROP_MINIMUM_LOGICAL_FONT_SIZE, + PROP_ENFORCE_96_DPI, PROP_AUTO_LOAD_IMAGES, PROP_AUTO_SHRINK_IMAGES, PROP_PRINT_BACKGROUNDS, @@ -162,7 +188,7 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) "default-font-size", "Default Font Size", "The default font size used to display text.", - 5, G_MAXINT, 10, + 5, G_MAXINT, 12, flags)); g_object_class_install_property(gobject_class, @@ -192,6 +218,26 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) 1, G_MAXINT, 5, flags)); + /** + * WebKitWebSettings:enforce-96-dpi: + * + * Enforce a resolution of 96 DPI. This is meant for compatibility + * with web pages which cope badly with different screen resolutions + * and for automated testing. + * Web browsers and applications that typically display arbitrary + * content from the web should provide a preference for this. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_ENFORCE_96_DPI, + g_param_spec_boolean( + "enforce-96-dpi", + "Enforce 96 DPI", + "Enforce a resolution of 96 DPI", + FALSE, + flags)); + g_object_class_install_property(gobject_class, PROP_AUTO_LOAD_IMAGES, g_param_spec_boolean( @@ -360,6 +406,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_MINIMUM_LOGICAL_FONT_SIZE: priv->minimum_logical_font_size = g_value_get_int(value); break; + case PROP_ENFORCE_96_DPI: + priv->enforce_96_dpi = g_value_get_boolean(value); + break; case PROP_AUTO_LOAD_IMAGES: priv->auto_load_images = g_value_get_boolean(value); break; @@ -433,6 +482,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_MINIMUM_LOGICAL_FONT_SIZE: g_value_set_int(value, priv->minimum_logical_font_size); break; + case PROP_ENFORCE_96_DPI: + g_value_set_boolean(value, priv->enforce_96_dpi); + break; case PROP_AUTO_LOAD_IMAGES: g_value_set_boolean(value, priv->auto_load_images); break; @@ -516,4 +568,20 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) return copy; } +/** + * webkit_web_settings_add_extra_plugin_directory: + * @web_view: a #WebKitWebView + * @directory: the directory to add + * + * Adds the @directory to paths where @web_view will search for plugins. + * + * Since: 1.0.3 + */ +void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* webView, const gchar* directory) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + PluginDatabase::installedPlugins()->addExtraPluginDirectory(filenameToString(directory)); +} + } diff --git a/WebKit/gtk/webkit/webkitwebsettings.h b/WebKit/gtk/webkit/webkitwebsettings.h index 33fa54a..5d25fee 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.h +++ b/WebKit/gtk/webkit/webkitwebsettings.h @@ -38,6 +38,7 @@ typedef struct _WebKitWebSettingsPrivate WebKitWebSettingsPrivate; struct _WebKitWebSettings { GObject parent_instance; + /*< private >*/ WebKitWebSettingsPrivate *priv; }; diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index 2c90b4e..0ea6ed5 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -1,9 +1,10 @@ /* - * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2007 Xan Lopez <xan@gnome.org> * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> * 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. * @@ -25,6 +26,7 @@ #include "config.h" #include "webkitwebview.h" +#include "webkitenumtypes.h" #include "webkitmarshal.h" #include "webkitprivate.h" #include "webkitwebinspector.h" @@ -45,6 +47,7 @@ #include "Editor.h" #include "EditorClientGtk.h" #include "EventHandler.h" +#include "FloatQuad.h" #include "FocusController.h" #include "FrameLoaderTypes.h" #include "HitTestRequest.h" @@ -57,12 +60,46 @@ #include "PasteboardHelper.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" +#include "ScriptValue.h" #include "Scrollbar.h" #include "SubstituteData.h" #include <wtf/GOwnPtr.h> #include <gdk/gdkkeysyms.h> +/** + * SECTION:webkitwebview + * @short_description: The central class of the WebKit/Gtk+ API + * @see_also: #WebKitWebSettings, #WebKitWebFrame + * + * #WebKitWebView is the central class of the WebKit/Gtk+ API. It is a + * #GtkWidget implementing the scrolling interface which means you can + * embed in a #GtkScrolledWindow. It is responsible for managing the + * drawing of the content, forwarding of events. You can load any URI + * into the #WebKitWebView or any kind of data string. With #WebKitWebSettings + * you can control various aspects of the rendering and loading of the content. + * Each #WebKitWebView has exactly one #WebKitWebFrame as main frame. A + * #WebKitWebFrame can have n children. + * + * <programlisting> + * /<!-- -->* Create the widgets *<!-- -->/ + * GtkWidget *main_window = gtk_window_new (GTK_WIDGET_TOPLEVEL); + * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); + * GtkWidget *web_view = webkit_web_view_new (); + * + * /<!-- -->* Place the WebKitWebView in the GtkScrolledWindow *<!-- -->/ + * gtk_container_add (GTK_CONTAINER (scrolled_window), web_view); + * 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"); + * + * /<!-- -->* Show the result *<!-- -->/ + * gtk_window_set_default_size (GTK_WINDOW (main_window), 800, 600); + * gtk_widget_show_all (main_window); + * </programlisting> + */ + static const double defaultDPI = 96.0; using namespace WebKit; @@ -73,6 +110,10 @@ extern "C" { enum { /* normal signals */ NAVIGATION_REQUESTED, + NAVIGATION_POLICY_DECISION_REQUESTED, + MIME_TYPE_POLICY_DECISION_REQUESTED, + CREATE_WEB_VIEW, + WEB_VIEW_READY, WINDOW_OBJECT_CLEARED, LOAD_STARTED, LOAD_COMMITTED, @@ -103,6 +144,7 @@ enum { PROP_EDITABLE, PROP_SETTINGS, PROP_WEB_INSPECTOR, + PROP_WINDOW_FEATURES, PROP_TRANSPARENT, PROP_ZOOM_LEVEL, PROP_FULL_CONTENT_ZOOM @@ -113,6 +155,7 @@ static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, }; 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 webkit_web_view_context_menu_position_func(GtkMenu*, gint* x, gint* y, gboolean* pushIn, WebKitWebViewPrivate* data) { @@ -183,18 +226,23 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) if (!renderer) return FALSE; - // Calculate the rect of the first line of the selection (cribbed from -[WebCoreFrameBridge firstRectForDOMRange:]). + // Calculate the rect of the first line of the selection (cribbed from -[WebCoreFrameBridge firstRectForDOMRange:], + // now Frame::firstRectForRange(), which perhaps this should call). int extraWidthToEndOfLine = 0; InlineBox* startInlineBox; int startCaretOffset; start.getInlineBoxAndOffset(DOWNSTREAM, startInlineBox, startCaretOffset); - IntRect startCaretRect = renderer->caretRect(startInlineBox, startCaretOffset, &extraWidthToEndOfLine); + IntRect startCaretRect = renderer->localCaretRect(startInlineBox, startCaretOffset, &extraWidthToEndOfLine); + if (startCaretRect != IntRect()) + startCaretRect = renderer->localToAbsoluteQuad(FloatRect(startCaretRect)).enclosingBoundingBox(); InlineBox* endInlineBox; int endCaretOffset; end.getInlineBoxAndOffset(UPSTREAM, endInlineBox, endCaretOffset); - IntRect endCaretRect = renderer->caretRect(endInlineBox, endCaretOffset); + IntRect endCaretRect = renderer->localCaretRect(endInlineBox, endCaretOffset); + if (endCaretRect != IntRect()) + endCaretRect = renderer->localToAbsoluteQuad(FloatRect(endCaretRect)).enclosingBoundingBox(); IntRect firstRect; if (startCaretRect.y() == endCaretRect.y()) @@ -245,6 +293,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* case PROP_WEB_INSPECTOR: g_value_set_object(value, webkit_web_view_get_inspector(webView)); break; + case PROP_WINDOW_FEATURES: + g_value_set_object(value, webkit_web_view_get_window_features(webView)); + break; case PROP_TRANSPARENT: g_value_set_boolean(value, webkit_web_view_get_transparent(webView)); break; @@ -270,6 +321,9 @@ static void webkit_web_view_set_property(GObject* object, guint prop_id, const G case PROP_SETTINGS: webkit_web_view_set_settings(webView, WEBKIT_WEB_SETTINGS(g_value_get_object(value))); break; + case PROP_WINDOW_FEATURES: + webkit_web_view_set_window_features(webView, WEBKIT_WEB_WINDOW_FEATURES(g_value_get_object(value))); + break; case PROP_TRANSPARENT: webkit_web_view_set_transparent(webView, g_value_get_boolean(value)); break; @@ -548,6 +602,9 @@ static void webkit_web_view_realize(GtkWidget* widget) static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj) { + if (!core(webView)) + return; + FrameView* view = core(webkit_web_view_get_main_frame(webView))->view(); if (hadj) @@ -604,15 +661,18 @@ static void webkit_web_view_container_forall(GtkContainer* container, gboolean, (*callback)(*current, callbackData); } -static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*) +static WebKitWebView* webkit_web_view_real_create_web_view(WebKitWebView*, WebKitWebFrame*) { - notImplemented(); return 0; } -static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame* frame, WebKitNetworkRequest*) +static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*) +{ + return FALSE; +} + +static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*) { - notImplemented(); return WEBKIT_NAVIGATION_RESPONSE_ACCEPT; } @@ -751,48 +811,85 @@ static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView) frame->editor()->command("Paste").execute(); } -static void webkit_web_view_finalize(GObject* object) +static void webkit_web_view_dispose(GObject* object) { WebKitWebView* webView = WEBKIT_WEB_VIEW(object); WebKitWebViewPrivate* priv = webView->priv; - webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object)); + if (priv->corePage) { + webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object)); - core(priv->mainFrame)->loader()->detachChildren(); - delete priv->corePage; + core(priv->mainFrame)->loader()->detachChildren(); + delete priv->corePage; + priv->corePage = NULL; + } - if (priv->horizontalAdjustment) + if (priv->horizontalAdjustment) { g_object_unref(priv->horizontalAdjustment); - if (priv->verticalAdjustment) + priv->horizontalAdjustment = NULL; + } + + if (priv->verticalAdjustment) { g_object_unref(priv->verticalAdjustment); - g_object_unref(priv->backForwardList); - g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView); - g_object_unref(priv->webSettings); - g_object_unref(priv->webInspector); - g_object_unref(priv->mainFrame); - g_object_unref(priv->imContext); - gtk_target_list_unref(priv->copy_target_list); - gtk_target_list_unref(priv->paste_target_list); - delete priv->userAgent; + priv->verticalAdjustment = NULL; + } + + if (priv->backForwardList) { + g_object_unref(priv->backForwardList); + priv->backForwardList = NULL; + + g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView); + g_object_unref(priv->webSettings); + priv->webSettings = NULL; + + g_object_unref(priv->webInspector); + priv->webInspector = NULL; - G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object); + g_object_unref(priv->webWindowFeatures); + priv->webWindowFeatures = NULL; + + g_object_unref(priv->imContext); + priv->imContext = NULL; + + gtk_target_list_unref(priv->copy_target_list); + priv->copy_target_list = NULL; + + gtk_target_list_unref(priv->paste_target_list); + priv->paste_target_list = NULL; + + delete priv->userAgent; + priv->userAgent = NULL; + } + + G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object); +} + +static gboolean webkit_create_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) +{ + gpointer newWebView = g_value_get_object(handlerReturn); + g_value_set_object(returnAccu, newWebView); + + // Continue if we don't have a newWebView + return !newWebView; } static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) { - gboolean continueEmission = TRUE; - int signalHandled = g_value_get_int(handlerReturn); - g_value_set_int(returnAccu, signalHandled); + WebKitNavigationResponse navigationResponse = (WebKitNavigationResponse)g_value_get_enum(handlerReturn); + g_value_set_enum(returnAccu, navigationResponse); - if (signalHandled != WEBKIT_NAVIGATION_RESPONSE_ACCEPT) - continueEmission = FALSE; + if (navigationResponse != WEBKIT_NAVIGATION_RESPONSE_ACCEPT) + return FALSE; - return continueEmission; + return TRUE; } static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + if (!core(webView)) + return NULL; + AXObjectCache::enableAccessibility(); Frame* coreFrame = core(webView)->mainFrame(); @@ -820,16 +917,145 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * Signals */ + /** + * WebKitWebView::create-web-view: + * @web_view: the object on which the signal is emitted + * @frame: the #WebKitWebFrame + * @return: a newly allocated #WebKitWebView or %NULL + * + * Emitted when the creation of a new window is requested. + * If this signal is handled the signal handler should return the + * newly created #WebKitWebView. + * + * 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. + * + * Since 1.0.3 + */ + webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view), + webkit_create_web_view_request_handled, + NULL, + webkit_marshal_OBJECT__OBJECT, + WEBKIT_TYPE_WEB_VIEW , 1, + WEBKIT_TYPE_WEB_FRAME); + + /** + * WebKitWebView::web-view-ready: + * @web_view: the object on which the signal is emitted + * @return: %TRUE to stop other handlers from being invoked for + * the event, %FALSE to propagate the event further + * + * Emitted after #WebKitWebView::create-web-view when the new #WebKitWebView + * should be displayed to the user. When this signal is emitted + * all the information about how the window should look, including + * size, position, whether the location, status and scroll bars + * should be displayed, is already set on the + * #WebKitWebWindowFeatures object contained by the #WebKitWebView. + * + * Notice that some of that information may change during the life + * 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 + */ + webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST), + G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready), + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN, 0); + + /** + * WebKitWebView::navigation-requested: + * @web_view: the object on which the signal is emitted + * @frame: the #WebKitWebFrame that required the navigation + * @request: a #WebKitNetworkRequest + * @return: a WebKitNavigationResponse + * + * Emitted when @frame requests a navigation to another page. + * + * Deprecated: Use WebKitWebView::navigation-policy-decision-requested + * instead + */ webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested", G_TYPE_FROM_CLASS(webViewClass), (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested), webkit_navigation_request_handled, NULL, - webkit_marshal_INT__OBJECT_OBJECT, - G_TYPE_INT, 2, - G_TYPE_OBJECT, - G_TYPE_OBJECT); + webkit_marshal_ENUM__OBJECT_OBJECT, + WEBKIT_TYPE_NAVIGATION_RESPONSE, 2, + WEBKIT_TYPE_WEB_FRAME, + WEBKIT_TYPE_NETWORK_REQUEST); + + /** + * WebKitWebView::navigation-policy-decision-requested: + * @web_view: the object on which the signal is emitted + * @frame: the #WebKitWebFrame that required the navigation + * @request: a #WebKitNetworkRequest + * @navigation_action: a #WebKitWebNavigation + * @policy_decision: a #WebKitWebPolicyDecision + * @return: TRUE if the signal will be handled, FALSE to have the + * default behavior apply + * + * Emitted when @frame requests a navigation to another page. + * If this signal is not handled, the default behavior is to allow the + * navigation. + * + * Since: 1.0.3 + */ + webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__OBJECT_OBJECT_OBJECT_OBJECT, + G_TYPE_BOOLEAN, 4, + WEBKIT_TYPE_WEB_FRAME, + WEBKIT_TYPE_NETWORK_REQUEST, + WEBKIT_TYPE_WEB_NAVIGATION_ACTION, + WEBKIT_TYPE_WEB_POLICY_DECISION); + + /** + * WebKitWebView::mime-type-policy-decision-requested: + * @web_view: the object on which the signal is emitted + * @frame: the #WebKitWebFrame that required the policy decision + * @request: a WebKitNetworkRequest + * @mimetype: the MIME type attempted to load + * @policy_decision: a #WebKitWebPolicyDecision + * @return: TRUE if the signal will be handled, FALSE to have the + * default behavior apply + * + * Decide whether or not to display the given MIME type. If this + * signal is not handled, the default behavior is to show the + * content of the requested URI if WebKit can show this MIME + * type; if WebKit is not able to show the MIME type nothing + * happens. + * + * Since: 1.0.3 + */ + webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__OBJECT_OBJECT_STRING_OBJECT, + G_TYPE_BOOLEAN, 4, + WEBKIT_TYPE_WEB_FRAME, + WEBKIT_TYPE_NETWORK_REQUEST, + G_TYPE_STRING, + WEBKIT_TYPE_WEB_POLICY_DECISION); /** * WebKitWebView::window-object-cleared: @@ -1087,7 +1313,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * WebKitWebView::select-all: * @web_view: the object which received the signal * - * The ::select-all signal is a keybinding signal which gets emitted to + * The #WebKitWebView::select-all signal is a keybinding signal which gets emitted to * select the complete contents of the text view. * * The default bindings for this signal is Ctrl-a. @@ -1104,7 +1330,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * WebKitWebView::cut-clipboard: * @web_view: the object which received the signal * - * The ::cut-clipboard signal is a keybinding signal which gets emitted to + * The #WebKitWebView::cut-clipboard signal is a keybinding signal which gets emitted to * cut the selection to the clipboard. * * The default bindings for this signal are Ctrl-x and Shift-Delete. @@ -1121,7 +1347,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * WebKitWebView::copy-clipboard: * @web_view: the object which received the signal * - * The ::copy-clipboard signal is a keybinding signal which gets emitted to + * The #WebKitWebView::copy-clipboard signal is a keybinding signal which gets emitted to * copy the selection to the clipboard. * * The default bindings for this signal are Ctrl-c and Ctrl-Insert. @@ -1138,7 +1364,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * WebKitWebView::paste-clipboard: * @web_view: the object which received the signal * - * The ::paste-clipboard signal is a keybinding signal which gets emitted to + * The #WebKitWebView::paste-clipboard signal is a keybinding signal which gets emitted to * paste the contents of the clipboard into the Web view. * * The default bindings for this signal are Ctrl-v and Shift-Insert. @@ -1155,6 +1381,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * implementations of virtual methods */ webViewClass->create_web_view = webkit_web_view_real_create_web_view; + webViewClass->web_view_ready = webkit_web_view_real_web_view_ready; webViewClass->navigation_requested = webkit_web_view_real_navigation_requested; webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared; webViewClass->choose_file = webkit_web_view_real_choose_file; @@ -1168,7 +1395,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard; GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass); - objectClass->finalize = webkit_web_view_finalize; + objectClass->dispose = webkit_web_view_dispose; objectClass->get_property = webkit_web_view_get_property; objectClass->set_property = webkit_web_view_set_property; @@ -1285,6 +1512,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_INSPECTOR, WEBKIT_PARAM_READABLE)); + /** + * WebKitWebView:window-features: + * + * An associated WebKitWebWindowFeatures instance. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_WINDOW_FEATURES, + g_param_spec_object("window-features", + "Window Features", + "An associated WebKitWebWindowFeatures instance", + WEBKIT_TYPE_WEB_WINDOW_FEATURES, + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(objectClass, PROP_EDITABLE, g_param_spec_boolean("editable", "Editable", @@ -1332,20 +1573,14 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); } -static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* previousScreen, gpointer userdata) +static gdouble webViewGetDPI(WebKitWebView* webView) { WebKitWebViewPrivate* priv = webView->priv; WebKitWebSettings* webSettings = priv->webSettings; - Settings* settings = core(webView)->settings(); - - guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize; - - g_object_get(G_OBJECT(webSettings), - "default-font-size", &defaultFontSize, - "default-monospace-font-size", &defaultMonospaceFontSize, - "minimum-font-size", &minimumFontSize, - "minimum-logical-font-size", &minimumLogicalFontSize, - NULL); + gboolean enforce96DPI; + g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL); + if (enforce96DPI) + return 96.0; gdouble DPI = defaultDPI; #if GTK_CHECK_VERSION(2,10,0) @@ -1358,6 +1593,25 @@ static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* pr } #endif ASSERT(DPI > 0); + return DPI; +} + +static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* previousScreen, gpointer userdata) +{ + WebKitWebViewPrivate* priv = webView->priv; + WebKitWebSettings* webSettings = priv->webSettings; + Settings* settings = core(webView)->settings(); + gdouble DPI = webViewGetDPI(webView); + + guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize; + + g_object_get(webSettings, + "default-font-size", &defaultFontSize, + "default-monospace-font-size", &defaultMonospaceFontSize, + "minimum-font-size", &minimumFontSize, + "minimum-logical-font-size", &minimumLogicalFontSize, + NULL); + settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI); settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI); settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI); @@ -1373,7 +1627,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri; gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas; - g_object_get(G_OBJECT(webSettings), + g_object_get(webSettings, "default-encoding", &defaultEncoding, "cursive-font-family", &cursiveFontFamily, "default-font-family", &defaultFontFamily, @@ -1419,6 +1673,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) webkit_web_view_screen_changed(webView, NULL, NULL); } +static inline gint pixelsFromSize(WebKitWebView* webView, gint size) +{ + gdouble DPI = webViewGetDPI(webView); + return size / 72.0 * DPI; +} + static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView) { Settings* settings = core(webView)->settings(); @@ -1443,13 +1703,15 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar else if (name == g_intern_string("serif-font-family")) settings->setSerifFontFamily(g_value_get_string(&value)); else if (name == g_intern_string("default-font-size")) - settings->setDefaultFontSize(g_value_get_int(&value)); + settings->setDefaultFontSize(pixelsFromSize(webView, g_value_get_int(&value))); else if (name == g_intern_string("default-monospace-font-size")) - settings->setDefaultFixedFontSize(g_value_get_int(&value)); + settings->setDefaultFixedFontSize(pixelsFromSize(webView, g_value_get_int(&value))); else if (name == g_intern_string("minimum-font-size")) - settings->setMinimumFontSize(g_value_get_int(&value)); + settings->setMinimumFontSize(pixelsFromSize(webView, g_value_get_int(&value))); else if (name == g_intern_string("minimum-logical-font-size")) - settings->setMinimumLogicalFontSize(g_value_get_int(&value)); + settings->setMinimumLogicalFontSize(pixelsFromSize(webView, g_value_get_int(&value))); + else if (name == g_intern_string("enforce-96-dpi")) + webkit_web_view_screen_changed(webView, NULL, NULL); else if (name == g_intern_string("auto-load-images")) settings->setLoadsImagesAutomatically(g_value_get_boolean(&value)); else if (name == g_intern_string("auto-shrink-images")) @@ -1527,6 +1789,8 @@ static void webkit_web_view_init(WebKitWebView* webView) webkit_web_view_update_settings(webView); g_signal_connect(webView, "screen-changed", G_CALLBACK(webkit_web_view_screen_changed), NULL); g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); + + priv->webWindowFeatures = webkit_web_window_features_new(); } GtkWidget* webkit_web_view_new(void) @@ -1536,6 +1800,16 @@ GtkWidget* webkit_web_view_new(void) return GTK_WIDGET(webView); } +// for internal use only +void webkit_web_view_notify_ready(WebKitWebView* webView) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + gboolean isHandled = FALSE; + g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled); +} + + void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings) { g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); @@ -1561,7 +1835,7 @@ WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) /** * webkit_web_view_get_inspector: - * @webView: a #WebKitWebView + * @web_view: a #WebKitWebView * * Obtains the #WebKitWebInspector associated with the * #WebKitWebView. Every #WebKitWebView object has a @@ -1583,9 +1857,41 @@ WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) return priv->webInspector; } +// internal +static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures) +{ + WebKitWebViewPrivate* priv = webView->priv; + + if(webkit_web_window_features_equal(priv->webWindowFeatures, webWindowFeatures)) + return; + + g_object_unref(priv->webWindowFeatures); + g_object_ref(webWindowFeatures); + priv->webWindowFeatures = webWindowFeatures; +} + +/** + * webkit_web_view_get_window_features + * @web_view: a #WebKitWebView + * + * Returns the instance of #WebKitWebWindowFeatures held by the given + * #WebKitWebView. + * + * Return value: the #WebKitWebWindowFeatures + * + * Since: 1.0.3 + */ +WebKitWebWindowFeatures* webkit_web_view_get_window_features(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); + + WebKitWebViewPrivate* priv = webView->priv; + return priv->webWindowFeatures; +} + /** * webkit_web_view_set_maintains_back_forward_list: - * @webView: a #WebKitWebView + * @web_view: a #WebKitWebView * @flag: to tell the view to maintain a back or forward list * * Set the view to maintain a back or forward list of history items. @@ -1599,7 +1905,7 @@ void webkit_web_view_set_maintains_back_forward_list(WebKitWebView* webView, gbo /** * webkit_web_view_get_back_forward_list: - * @webView: a #WebKitWebView + * @web_view: a #WebKitWebView * * Returns a #WebKitWebBackForwardList * @@ -1619,7 +1925,7 @@ WebKitWebBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* w /** * webkit_web_view_go_to_back_forward_item: - * @webView: a #WebKitWebView + * @web_view: a #WebKitWebView * @item: a #WebKitWebHistoryItem* * * Go to the specified #WebKitWebHistoryItem @@ -1758,6 +2064,21 @@ void webkit_web_view_reload(WebKitWebView* webView) core(webView)->mainFrame()->loader()->reload(); } +/** + * webkit_web_view_reload_bypass_cache: + * @web_view: a #WebKitWebView + * + * Reloads the @web_view without using any cached data. + * + * Since: 1.0.3 + */ +void webkit_web_view_reload_bypass_cache(WebKitWebView* webView) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + core(webView)->mainFrame()->loader()->reload(true); +} + void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, const gchar* contentMimeType, const gchar* contentEncoding, const gchar* baseUri) { g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); @@ -2148,6 +2469,29 @@ GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) } /** + * webkit_web_view_can_show_mime_type: + * @web_view: a #WebKitWebView + * @mime_type: a MIME type + * + * This functions returns whether or not a MIME type can be displayed using this view. + * + * Return value: a #gboolean indicating if the MIME type can be displayed + * + * Since: 1.0.3 + **/ + +gboolean webkit_web_view_can_show_mime_type(WebKitWebView* webView, const gchar* mimeType) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); + + Frame* frame = core(webkit_web_view_get_main_frame(webView)); + if (FrameLoader* loader = frame->loader()) + return loader->canShowMIMEType(String::fromUTF8(mimeType)); + else + return FALSE; +} + +/** * webkit_web_view_get_transparent: * @web_view: a #WebKitWebView * diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h index 7371959..2bb8c61 100644 --- a/WebKit/gtk/webkit/webkitwebview.h +++ b/WebKit/gtk/webkit/webkitwebview.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -55,23 +56,22 @@ typedef enum struct _WebKitWebView { GtkContainer parent_instance; + /*< private >*/ WebKitWebViewPrivate *priv; }; struct _WebKitWebViewClass { GtkContainerClass parent_class; + /*< public >*/ /* * default handler/virtual methods - * DISCUSS: create_web_view needs a request and should we make this a signal with default handler? this would - * require someone doing a g_signal_stop_emission_by_name - * WebUIDelegate has nothing for create_frame, WebPolicyDelegate as well... */ - WebKitWebView * (* create_web_view) (WebKitWebView* web_view); + WebKitWebView * (* create_web_view) (WebKitWebView *web_view, + WebKitWebFrame *web_frame); + + gboolean (* web_view_ready) (WebKitWebView* web_view); - /* - * TODO: FIXME: Create something like WebPolicyDecisionListener_Protocol instead - */ WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request); @@ -109,6 +109,15 @@ struct _WebKitWebViewClass { void (* set_scroll_adjustments) (WebKitWebView *web_view, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment); + /* 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); + void (*_webkit_reserved6) (void); + void (*_webkit_reserved7) (void); }; WEBKIT_API GType @@ -159,6 +168,9 @@ WEBKIT_API void webkit_web_view_reload (WebKitWebView *web_view); WEBKIT_API void +webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); + +WEBKIT_API void webkit_web_view_load_string (WebKitWebView *web_view, const gchar *content, const gchar *content_mime_type, @@ -172,7 +184,7 @@ webkit_web_view_load_html_string (WebKitWebView *web_view, WEBKIT_API gboolean webkit_web_view_search_text (WebKitWebView *web_view, - const gchar *string, + const gchar *text, gboolean case_sensitive, gboolean forward, gboolean wrap); @@ -250,6 +262,13 @@ webkit_web_view_get_settings (WebKitWebView *web_view) WEBKIT_API WebKitWebInspector * webkit_web_view_get_inspector (WebKitWebView *web_view); +WEBKIT_API WebKitWebWindowFeatures* +webkit_web_view_get_window_features (WebKitWebView *web_view); + +WEBKIT_API gboolean +webkit_web_view_can_show_mime_type (WebKitWebView *web_view, + const gchar *mime_type); + WEBKIT_API gboolean webkit_web_view_get_transparent (WebKitWebView *web_view); diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp new file mode 100644 index 0000000..7e61b59 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp @@ -0,0 +1,443 @@ +/* + * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> + * Copyright (C) 2008 Holger Hans Peter Freyther + * + * 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 "WindowFeatures.h" +#include "webkitwebwindowfeatures.h" +#include "webkitprivate.h" + +/** + * SECTION:webkitwebwindowfeatures + * @short_description: Window properties of a #WebKitWebView + * @see_also: #WebKitWebView::web-view-ready + * + * The content of a #WebKitWebView can request to change certain + * properties of a #WebKitWebView. This can include the x, y position + * of the window, the width and height but also if a toolbar, + * scrollbar, statusbar, locationbar should be visible to the user, + * the request to show the #WebKitWebView fullscreen. + * + * In the normal case one will use #webkit_web_view_get_window_features + * to get the #WebKitWebWindowFeatures and then monitor the property + * changes. Be aware that the #WebKitWebWindowFeatures might change + * change before #WebKitWebView::web-view-ready signal is emitted. + * To be safe listen to the notify::window-features signal of the #WebKitWebView + * and reconnect the signals whenever the #WebKitWebWindowFeatures of + * a #WebKitWebView changes. + * + * <informalexample><programlisting> + * /<!-- -->* Get the current WebKitWebWindowFeatures *<!-- -->/ + * WebKitWebWindowFeatures *features = webkit_web_view_get_window_features (my_webview); + * + * /<!-- -->* Connect to the property changes *<!-- -->/ + * g_signal_connect (G_OBJECT(features), "notify::menubar-visible", G_CALLBACK(make_menu_bar_visible), NULL); + * g_signal_connect (G_OBJECT(features), "notify::statusbar-visible", G_CALLBACK(make_status_bar_visible), NULL); + * + * </programlisting></informalexample> + */ + +extern "C" { + +enum { + PROP_0, + + PROP_X, + PROP_Y, + PROP_WIDTH, + PROP_HEIGHT, + PROP_TOOLBAR_VISIBLE, + PROP_STATUSBAR_VISIBLE, + PROP_SCROLLBAR_VISIBLE, + PROP_MENUBAR_VISIBLE, + PROP_LOCATIONBAR_VISIBLE, + PROP_FULLSCREEN, +}; + +G_DEFINE_TYPE(WebKitWebWindowFeatures, webkit_web_window_features, G_TYPE_OBJECT) + +struct _WebKitWebWindowFeaturesPrivate { + gint x; + gint y; + gint width; + gint height; + + gboolean toolbar_visible; + gboolean statusbar_visible; + gboolean scrollbar_visible; + gboolean menubar_visible; + gboolean locationbar_visible; + + gboolean fullscreen; +}; + +#define WEBKIT_WEB_WINDOW_FEATURES_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_WINDOW_FEATURES, WebKitWebWindowFeaturesPrivate)) + +static void webkit_web_window_features_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec); + +static void webkit_web_window_features_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec); + +static void webkit_web_window_features_class_init(WebKitWebWindowFeaturesClass* klass) +{ + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); + gobject_class->set_property = webkit_web_window_features_set_property; + gobject_class->get_property = webkit_web_window_features_get_property; + + GParamFlags flags = (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT); + + /** + * WebKitWebWindowFeatures:x: + * + * The starting x position of the window on the screen. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_X, + g_param_spec_int( + "x", + "x", + "The starting x position of the window on the screen.", + -1, + G_MAXINT, + -1, + flags)); + + /** + * WebKitWebWindowFeatures:y: + * + * The starting y position of the window on the screen. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_Y, + g_param_spec_int( + "y", + "y", + "The starting y position of the window on the screen.", + -1, + G_MAXINT, + -1, + flags)); + + /** + * WebKitWebWindowFeatures:width: + * + * The width of the window on the screen. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_WIDTH, + g_param_spec_int( + "width", + "Width", + "The width of the window on the screen.", + -1, + G_MAXINT, + -1, + flags)); + + /** + * WebKitWebWindowFeatures:height: + * + * The height of the window on the screen. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_HEIGHT, + g_param_spec_int( + "height", + "Height", + "The height of the window on the screen.", + -1, + G_MAXINT, + -1, + flags)); + + /** + * WebKitWebWindowFeatures:toolbar-visible: + * + * Controls whether the toolbar should be visible for the window. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_TOOLBAR_VISIBLE, + g_param_spec_boolean( + "toolbar-visible", + "Toolbar Visible", + "Controls whether the toolbar should be visible for the window.", + TRUE, + flags)); + + /** + * WebKitWebWindowFeatures:statusbar-visible: + * + * Controls whether the statusbar should be visible for the window. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_STATUSBAR_VISIBLE, + g_param_spec_boolean( + "statusbar-visible", + "Statusbar Visible", + "Controls whether the statusbar should be visible for the window.", + TRUE, + flags)); + + /** + * WebKitWebWindowFeatures:scrollbar-visible: + * + * Controls whether the scrollbars should be visible for the window. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_SCROLLBAR_VISIBLE, + g_param_spec_boolean( + "scrollbar-visible", + "Scrollbar Visible", + "Controls whether the scrollbars should be visible for the window.", + TRUE, + flags)); + + /** + * WebKitWebWindowFeatures:menubar-visible: + * + * Controls whether the menubar should be visible for the window. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_MENUBAR_VISIBLE, + g_param_spec_boolean( + "menubar-visible", + "Menubar Visible", + "Controls whether the menubar should be visible for the window.", + TRUE, + flags)); + + /** + * WebKitWebWindowFeatures:locationbar-visible: + * + * Controls whether the locationbar should be visible for the window. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_LOCATIONBAR_VISIBLE, + g_param_spec_boolean( + "locationbar-visible", + "Locationbar Visible", + "Controls whether the locationbar should be visible for the window.", + TRUE, + flags)); + + /** + * WebKitWebWindowFeatures:fullscreen: + * + * Controls whether window will be displayed fullscreen. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_FULLSCREEN, + g_param_spec_boolean( + "fullscreen", + "Fullscreen", + "Controls whether window will be displayed fullscreen.", + FALSE, + flags)); + + + g_type_class_add_private(klass, sizeof(WebKitWebWindowFeaturesPrivate)); +} + +static void webkit_web_window_features_init(WebKitWebWindowFeatures* web_window_features) +{ + web_window_features->priv = WEBKIT_WEB_WINDOW_FEATURES_GET_PRIVATE(web_window_features); +} + +static void webkit_web_window_features_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebKitWebWindowFeatures* web_window_features = WEBKIT_WEB_WINDOW_FEATURES(object); + WebKitWebWindowFeaturesPrivate* priv = web_window_features->priv; + + switch(prop_id) { + case PROP_X: + priv->x = g_value_get_int(value); + break; + case PROP_Y: + priv->y = g_value_get_int(value); + break; + case PROP_WIDTH: + priv->width = g_value_get_int(value); + break; + case PROP_HEIGHT: + priv->height = g_value_get_int(value); + break; + case PROP_TOOLBAR_VISIBLE: + priv->toolbar_visible = g_value_get_boolean(value); + break; + case PROP_STATUSBAR_VISIBLE: + priv->statusbar_visible = g_value_get_boolean(value); + break; + case PROP_SCROLLBAR_VISIBLE: + priv->scrollbar_visible = g_value_get_boolean(value); + break; + case PROP_MENUBAR_VISIBLE: + priv->menubar_visible = g_value_get_boolean(value); + break; + case PROP_LOCATIONBAR_VISIBLE: + priv->locationbar_visible = g_value_get_boolean(value); + break; + case PROP_FULLSCREEN: + priv->fullscreen = g_value_get_boolean(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void webkit_web_window_features_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebKitWebWindowFeatures* web_window_features = WEBKIT_WEB_WINDOW_FEATURES(object); + WebKitWebWindowFeaturesPrivate* priv = web_window_features->priv; + + switch (prop_id) { + case PROP_X: + g_value_set_int(value, priv->x); + break; + case PROP_Y: + g_value_set_int(value, priv->y); + break; + case PROP_WIDTH: + g_value_set_int(value, priv->width); + break; + case PROP_HEIGHT: + g_value_set_int(value, priv->height); + break; + case PROP_TOOLBAR_VISIBLE: + g_value_set_boolean(value, priv->toolbar_visible); + break; + case PROP_STATUSBAR_VISIBLE: + g_value_set_boolean(value, priv->statusbar_visible); + break; + case PROP_SCROLLBAR_VISIBLE: + g_value_set_boolean(value, priv->scrollbar_visible); + break; + case PROP_MENUBAR_VISIBLE: + g_value_set_boolean(value, priv->menubar_visible); + break; + case PROP_LOCATIONBAR_VISIBLE: + g_value_set_boolean(value, priv->locationbar_visible); + break; + case PROP_FULLSCREEN: + g_value_set_boolean(value, priv->fullscreen); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +/** + * webkit_web_window_features_new: + * + * Creates a new #WebKitWebWindowFeatures instance with default values. It must + * be manually attached to a WebView. + * + * Returns: a new #WebKitWebWindowFeatures instance + * + * Since 1.0.3 + */ +WebKitWebWindowFeatures* webkit_web_window_features_new() +{ + return WEBKIT_WEB_WINDOW_FEATURES(g_object_new(WEBKIT_TYPE_WEB_WINDOW_FEATURES, NULL)); +} + +// for internal use only +WebKitWebWindowFeatures* webkit_web_window_features_new_from_core_features(const WebCore::WindowFeatures& features) +{ + WebKitWebWindowFeatures *webWindowFeatures = webkit_web_window_features_new(); + + if(features.xSet) + g_object_set(webWindowFeatures, "x", static_cast<int>(features.x), NULL); + + if(features.ySet) + g_object_set(webWindowFeatures, "y", static_cast<int>(features.y), NULL); + + if(features.widthSet) + g_object_set(webWindowFeatures, "width", static_cast<int>(features.width), NULL); + + if(features.heightSet) + g_object_set(webWindowFeatures, "height", static_cast<int>(features.height), NULL); + + g_object_set(webWindowFeatures, + "toolbar-visible", features.toolBarVisible, + "statusbar-visible", features.statusBarVisible, + "scrollbar-visible", features.scrollbarsVisible, + "menubar-visible", features.menuBarVisible, + "locationbar-visible", features.locationBarVisible, + "fullscreen", features.fullscreen, + NULL); + + return webWindowFeatures; +} + +/** + * webkit_web_window_features_equal: + * @features1: a #WebKitWebWindowFeatures instance + * @features2: another #WebKitWebWindowFeatures instance + * + * Decides if a #WebKitWebWindowFeatures instance equals another, as + * in has the same values. + * + * Returns: %TRUE if the instances have the same values, %FALSE + * otherwise + * + * Since 1.0.3 + */ +gboolean webkit_web_window_features_equal(WebKitWebWindowFeatures* features1, WebKitWebWindowFeatures* features2) +{ + WebKitWebWindowFeaturesPrivate* priv1 = features1->priv; + WebKitWebWindowFeaturesPrivate* priv2 = features2->priv; + + if((priv1->x == priv2->x) && + (priv1->y == priv2->y) && + (priv1->width == priv2->width) && + (priv1->height == priv2->height) && + (priv1->toolbar_visible == priv2->toolbar_visible) && + (priv1->statusbar_visible == priv2->statusbar_visible) && + (priv1->scrollbar_visible == priv2->scrollbar_visible) && + (priv1->menubar_visible == priv2->menubar_visible) && + (priv1->locationbar_visible == priv2->locationbar_visible) && + (priv1->fullscreen == priv2->fullscreen)) + return TRUE; + return FALSE; +} + + +} diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.h b/WebKit/gtk/webkit/webkitwebwindowfeatures.h new file mode 100644 index 0000000..cd28988 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> + * + * 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 WEBKIT_WEB_WINDOW_FEATURES_H +#define WEBKIT_WEB_WINDOW_FEATURES_H + +#include <glib-object.h> + +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_WEB_WINDOW_FEATURES (webkit_web_window_features_get_type()) +#define WEBKIT_WEB_WINDOW_FEATURES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_WINDOW_FEATURES, WebKitWebWindowFeatures)) +#define WEBKIT_WEB_WINDOW_FEATURES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_WINDOW_FEATURES, WebKitWebWindowFeaturesClass)) +#define WEBKIT_IS_WEB_WINDOW_FEATURES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_WINDOW_FEATURES)) +#define WEBKIT_IS_WEB_WINDOW_FEATURES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_WINDOW_FEATURES)) +#define WEBKIT_WEB_WINDOW_FEATURES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_WINDOW_FEATURES, WebKitWebWindowFeaturesClass)) + +typedef struct _WebKitWebWindowFeaturesPrivate WebKitWebWindowFeaturesPrivate; + +struct _WebKitWebWindowFeatures { + GObject parent_instance; + + /*< private >*/ + WebKitWebWindowFeaturesPrivate* priv; +}; + +struct _WebKitWebWindowFeaturesClass { + GObjectClass parent_class; + + /*< private >*/ + /* 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_window_features_get_type (void); + +WEBKIT_API WebKitWebWindowFeatures* +webkit_web_window_features_new (void); + +WEBKIT_API gboolean +webkit_web_window_features_equal (WebKitWebWindowFeatures* features1, + WebKitWebWindowFeatures* features2); + +G_END_DECLS + +#endif /* WEBKIT_WEB_WINDOW_FEATURES_H */ |