diff options
Diffstat (limited to 'WebKit/gtk')
35 files changed, 3643 insertions, 616 deletions
diff --git a/WebKit/gtk/ChangeLog b/WebKit/gtk/ChangeLog index 42f717d..166be63 100644 --- a/WebKit/gtk/ChangeLog +++ b/WebKit/gtk/ChangeLog @@ -1,3 +1,1377 @@ +2008-11-03 Cameron Zwarich <zwarich@apple.com> + + Rubber-stamped by Maciej Stachowiak. + + Move more files into the runtime subdirectory of JavaScriptCore. + + * webkit/webkitprivate.cpp: + +2008-11-03 Alp Toker <alp@nuanti.com> + + Reviewed by Holger Freyther. + + Deprecate flawed webkit_web_frame_new() function. This would never + have worked properly when used outside WebCore since Frame::create() + can only be called without an owner element once in the lifetime of a + Page and would result in assertions, leaks and an unusable WebView + instance. + + Frame creation may be exposed in API some time later via the DOM + binding but probably not in the WebKit GTK+ core API. + + * webkit/webkitwebframe.cpp: + * webkit/webkitwebframe.h: + +2008-11-03 Alp Toker <alp@nuanti.com> + + Reviewed by Holger Freyther. + + Redundant scrollbars appear in frames where they shouldn't be visible + eg. embedded Google adverts. + + Call setCanHaveScrollbars() when necessary. The Mac and Win ports + already have this but it was missing in FrameLoaderClientGtk. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + +2008-11-03 Alp Toker <alp@nuanti.com> + + Rubber-stamped by Holger Freyther. + + Sync WebKit GTK+ default UA version string to 528.5+. (We're still + doing this manually!) + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::composeUserAgent): + +2008-10-31 Christian Dywan <christian@twotoasts.de> + + Reviewed by Mark Rowe. + + http://bugs.webkit.org/show_bug.cgi?id=22018 + enable-developer-extras doesn't toggle WebInspector + + * webkit/webkitwebview.cpp: + Add missing 'if' in notification for 'enable-developer-extras'. + +2008-10-30 Alp Toker <alp@nuanti.com> + + Reviewed by Dave Hyatt. + + Fix GIF animations. WebCore will not update animated GIFs if + the WebView is marked offscreen so we need to call + frameView->setParentVisible() when necessary like the Mac and Win + ports do. Regression was introduced around r37155 during the + HostWindow refactor. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + +2008-10-30 Alp Toker <alp@nuanti.com> + + Rubber-stamped by Holger Freyther. + + Fix typo in recently added web inspector signal. dettach -> detach. + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::detachWindow): + * webkit/webkitwebinspector.cpp: + (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init): + +2008-10-30 Alp Toker <alp@nuanti.com> + + Fix version comments for the web inspector added in r37982. Available + since 1.0.3, not 1.0.2. + + * webkit/webkitwebinspector.cpp: + (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init): + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + * webkit/webkitwebview.cpp: + +2008-10-29 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed and slightly changed by Holger Freyther. + + Implemented a new WebKitWebInspector class to provide a GObject + API for the Web Inspector. Also implemented InspectorClient. + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::notifyWebViewDestroyed): + (WebKit::InspectorClient::InspectorClient): + (WebKit::InspectorClient::inspectorDestroyed): + (WebKit::InspectorClient::webViewDestroyed): + (WebKit::InspectorClient::createPage): + (WebKit::InspectorClient::showWindow): + (WebKit::InspectorClient::closeWindow): + (WebKit::InspectorClient::attachWindow): + (WebKit::InspectorClient::detachWindow): + (WebKit::InspectorClient::inspectedURLChanged): + * WebCoreSupport/InspectorClientGtk.h: + * webkit/webkit.h: + * webkit/webkit-marshal.list: + * webkit/webkitdefines.h: + * webkit/webkitprivate.h: + * webkit/webkitwebinspector.cpp: Added. + (_WebKitWebInspectorPrivate::webkit_inspect_web_view_request_handled): + (_WebKitWebInspectorPrivate::webkit_web_inspector_class_init): + (_WebKitWebInspectorPrivate::webkit_web_inspector_init): + (_WebKitWebInspectorPrivate::webkit_web_inspector_finalize): + (_WebKitWebInspectorPrivate::webkit_web_inspector_set_property): + (_WebKitWebInspectorPrivate::webkit_web_inspector_get_property): + (_WebKitWebInspectorPrivate::webkit_web_inspector_set_web_view): + * webkit/webkitwebinspector.h: Added. + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::): + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + (_WebKitWebSettingsPrivate::webkit_web_settings_set_property): + (_WebKitWebSettingsPrivate::webkit_web_settings_get_property): + (_WebKitWebSettingsPrivate::webkit_web_settings_copy): + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-10-27 Michael Tross <michael@tross.org> + + Reviewed by Alp Toker. Landed by Jan Alonzo. + + https://bugs.webkit.org/show_bug.cgi?id=21827 + [GTK] Fix memory leak in webkit_web_view_load_string + + * webkit/webkitwebview.cpp: + +2008-10-24 Sam Weinig <sam@webkit.org> + + Fix the Gtk build. + + * WebCoreSupport/ChromeClientGtk.cpp: + +2008-10-24 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix https://bugs.webkit.org/show_bug.cgi?id=21759 + Layering violation: FileChooser should not depend on Document/Frame/Page + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::runOpenPanel): + * WebCoreSupport/ChromeClientGtk.h: + +2008-10-24 Timothy Hatcher <timothy@apple.com> + + Stub out new InspectorClient methods. + + https://bugs.webkit.org/show_bug.cgi?id=21856 + + Reviewed by Darin Adler. + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::populateSetting): Not implemented. + (WebKit::InspectorClient::storeSetting): Ditto. + (WebKit::InspectorClient::removeSetting): Ditto. + * WebCoreSupport/InspectorClientGtk.h: + +2008-10-22 Alp Toker <alp@nuanti.com> + + Build fix for older GTK+ versions where GTK_TYPE_TARGET_LIST isn't + defined. + + * webkit/webkitwebview.cpp: + +2008-10-22 Alp Toker <alp@nuanti.com> + + Reviewed by Adam Roben. + + Avoid critical warnings on older GTK+ versions (2.8) by not checking + for GTK+ setting properties when we know they don't exist. + + * WebCoreSupport/ContextMenuClientGtk.cpp: + (WebKit::inputMethodsMenuItem): + (WebKit::unicodeMenuItem): + +2008-10-20 Sam Weinig <sam@webkit.org> + + Reviewed by Anders Carlsson. + + Remove FrameLoaderClient::detachedFromParent4. It is no longer used by any port. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-10-20 Alp Toker <alp@nuanti.com> + + Reviewed by Dave Hyatt. + + https://bugs.webkit.org/show_bug.cgi?id=21303 + [GTK] Scrolling glitches + + Implement a buffering scheme to avoid full repaints when scrolling + views or subframes significantly improving scrolling performance. + + Improve rendering performance by coalescing large numbers of small + repaints. + + Also fixes long-running issues with scrollbar positioning and frame + invalidation. + + Rendering in the GTK+ port should be more similar to other ports after + these changes. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::repaint): + (WebKit::ChromeClient::scroll): + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::forceLayout): + * webkit/webkitwebview.cpp: + +2008-10-17 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + + Reviewed by Mark Rowe. Landed by Jan Alonzo. + + https://bugs.webkit.org/show_bug.cgi?id=20403 + [Gtk] Segfault after a table with an iframe is attempted to be added twice to DOM model with javascript + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::frameLoaderDestroyed): + (WebKit::FrameLoaderClient::detachedFromParent4): + +2008-10-06 David Hyatt <hyatt@apple.com> + + Enable viewless Mac WebKit to paint some basic pages. + + Reviewed by Sam Weinig + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-10-03 David Hyatt <hyatt@apple.com> + + Fix Gtk bustage from use of containingWindow() over on the WebKit side. Replace with HostWindow use. + + * webkit/webkitwebview.cpp: + +2008-10-03 David Hyatt <hyatt@apple.com> + + https://bugs.webkit.org/show_bug.cgi?id=21340 + + Remove "containingWindow()/setContainingWindow()" from Widget. HostWindow covers this now. + + Reviewed by Dan Bernstein & Darin Adler + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + +2008-10-03 Alp Toker <alp@nuanti.com> + + Remove some left-over GTK+ includes. No change in functionality. + + * webkit/webkitwebhistoryitem.h: + +2008-10-03 Alp Toker <alp@nuanti.com> + + Build fix following r37234. Remove addToDirtyRegion from the header + too. + + * WebCoreSupport/ChromeClientGtk.h: + +2008-10-03 David Hyatt <hyatt@apple.com> + + Remove addToDirtyRegion. + + Reviewed by Oliver Hunt + + * WebCoreSupport/ChromeClientGtk.cpp: + +2008-10-02 David Hyatt <hyatt@apple.com> + + https://bugs.webkit.org/show_bug.cgi?id=21314 + + Make scrollBackingStore cross-platform. + + Reviewed by Sam Weinig + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::repaint): + (WebKit::ChromeClient::scroll): + * WebCoreSupport/ChromeClientGtk.h: + +2008-10-01 David Hyatt <hyatt@apple.com> + + https://bugs.webkit.org/show_bug.cgi?id=21282 + + Make contentsToScreen/screenToContents cross-platform. Only implemented by Mac/Win right now. + + Reviewed by Adam Roben + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::windowToScreen): + (WebKit::ChromeClient::screenToWindow): + * WebCoreSupport/ChromeClientGtk.h: + +2008-09-30 Dave Hyatt <hyatt@apple.com> + + http://bugs.webkit.org/show_bug.cgi?id=21250 + + Rename updateContents to repaintContentRectangle and make it cross-platform by always sending + repaints up through the ChromeClient. + + Reviewed by Darin Adler + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::repaint): + * WebCoreSupport/ChromeClientGtk.h: + +2008-09-16 Alp Toker <alp@nuanti.com> + + Suggested by Dave Hyatt. + + Build fix and cleanup. Rename ScrollBar to Scrollbar. + + * webkit/webkitwebview.cpp: + +2008-09-13 Adrien Nader <camaradetux@gmail.com> + + Gtk build fix, not reviewed. + + * webkit/webkitwebview.cpp: + +2008-09-10 Alp Toker <alp@nuanti.com> + + Reviewed by Mark Rowe. + + https://bugs.webkit.org/show_bug.cgi?id=17267 + [GTK] Primary selection/clipboard support + + Implement primary selection support (copying only, no paste yet). + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::clipboard_get_contents_cb): + (WebKit::clipboard_clear_contents_cb): + (WebKit::EditorClient::respondToChangedSelection): + +2008-09-07 Cameron Zwarich <cwzwarich@uwaterloo.ca> + + Reviewed by Maciej Stachowiak. + + Bug 20704: Replace the KJS namespace + <https://bugs.webkit.org/show_bug.cgi?id=20704> + + Rename the KJS namespace to JSC. + + * webkit/webkitprivate.cpp: + (webkit_init): + +2008-09-05 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=18346 + [GTK] Remove build warnings + + Removed/commented code that is not (yet) used, and reordered + member variables initialization for FrameLoaderClient, so that the + compiler is happy and prints less warnings when building. + + * WebCoreSupport/ContextMenuClientGtk.cpp: + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::FrameLoaderClient): + +2008-09-03 Alp Toker <alp@nuanti.com> + + Build fix following r36073. Include config.h where necessary. + + * WebCoreSupport/PasteboardHelperGtk.cpp: + * webkit/webkitversion.cpp: + +2008-09-01 Alp Toker <alp@nuanti.com> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=19939 + [GTK] webkit_web_history_item_get_title() fails with assertion + + Make sure newly constructed WebHistoryItem objects wrap a WebCore + history item when necessary. Avoid G_PARAM_CONSTRUCT since it destroys + history data -- use WEBKIT_PARAM flags instead as they do the right + thing. This restores history functionality. + + Also use CString to simplify UTF-8 string management. + + * webkit/webkitwebbackforwardlist.cpp: + (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_forward_list_with_limit): + (_WebKitWebBackForwardListPrivate::webkit_web_back_forward_list_get_back_list_with_limit): + No need to initialize the vector with a size since it's cleared by the + callee. + * webkit/webkitwebhistoryitem.cpp: + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_finalize): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_class_init): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_title): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_alternate_title): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_set_alternate_title): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_uri): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_original_uri): + +2008-08-27 Adrien Nader <camaradetux@gmail.com> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=20099 + [GTK] SHIFT+PAGE_UP/DOWN doesn't extend selection + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::EditorClient::handleKeyboardEvent): + +2008-08-27 Brady Eidson <beidson@apple.com> + + Reviewed by Anders + + <rdar://problem/6134133> - Crash when loading large movie as a standalone document + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::pluginWillHandleLoadError): Stubbed for now + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-08-18 Alp Toker <alp@nuanti.com> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=20350 + [GTK] Get DumpRenderTree working + + Add a private function to WebFrame to dump the render tree as required + for the DumpRenderTree testing tool. + + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + +2008-08-12 Timothy Hatcher <timothy@apple.com> + + Add a stub for InspectorClient::setAttachedWindowHeight. + + * WebCoreSupport/InspectorClientGtk.cpp: + (WebKit::InspectorClient::setAttachedWindowHeight): + Call notImplemented(). + * WebCoreSupport/InspectorClientGtk.h: + +2008-08-10 Alp Toker <alp@nuanti.com> + + Remove leftover qmake/GTK+ build files. + + * webkit/headers.pri: Removed. + +2008-08-02 Christian Dywan <christian@twotoasts.de> + + Reviewed by Eric Seidel. + + Remove webkit-marshal.list, which was made obsolete in #19742 + + * webkit/webkit-marshal.list: Removed. + +2008-08-01 Wouter Bolsterlee <uws@xs4all.nl> + + Reviewed by Eric Seidel. + + https://bugs.webkit.org/show_bug.cgi?id=20035 + [GTK] Fix return value for webkit_web_view_go_to_back_forward_item() + + * webkit/webkitwebview.cpp: + +2008-07-30 Marco Barisione <marco.barisione@collabora.co.uk> + + Reviewed by Holger. + + http://bugs.webkit.org/show_bug.cgi?id=19742 + [GTK] Auto generate webkitmarshal.list + + Auto generate webkitmarshal.list from source files to reduce the + number of conflicts when merging git branches or when applying + patches. + Also rename webkit-marshal.* to webkitmarshal.* for consistency. + + * webkit/webkitwebframe.cpp: Include webkitmarshal.h instead of + webkit-marshal.h. + * webkit/webkitwebview.cpp: Ditto. + +2008-07-30 Gustavo Noronha Silva <gns@gnome.org> + + Reviewed by Sam. + + https://bugs.webkit.org/show_bug.cgi?id=20205 + Typo in comment for bracer ending block + + * webkit/webkitprivate.cpp: Typo fix in comment for the brace + that ends the WebKit namespace; WebCore -> WebKit + +2008-07-26 Mark Rowe <mrowe@apple.com> + + Build fix. Changes to accommodate newly named/signatured loading methods in WebCore. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::createFrame): + +2008-07-17 Christian Dywan <christian@twotoasts.de> + + Reviewed by Holger Freyther. + + https://bugs.webkit.org/show_bug.cgi?id=19813 + [GTK] WebKit crashes on invalid settings notify callback + + * webkit/webkitwebview.cpp: Disconnect in webkit_web_view_finalize + +2008-07-08 Jan Michael Alonzo <jmalonzo@webkit.org> + + Reviewed by Christian Dywan. + + Replace 'const' with G_CONST_RETURN macro to make it flexible to + disable constness + + * webkit/webkitnetworkrequest.cpp: + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebframe.cpp: + * webkit/webkitwebframe.h: + * webkit/webkitwebhistoryitem.cpp: + * webkit/webkitwebhistoryitem.h: + +2008-06-18 Marco Barisione <marco.barisione@collabora.co.uk> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=19171 + [GTK] GTypes for enumerations + + Generate GTypes for public enumerations so they can be used as + properties. + + * GNUmakefile.am: Generate webkit-enum-types.cpp and + webkit-enum-types.h. + +2008-06-17 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp. + + [GTK] WebKitWebHistoryItem needs properties + https://bugs.webkit.org/show_bug.cgi?id=19558 + + Implement properties matching the existing accessors. + + * webkit/webkitwebhistoryitem.cpp: + (_WebKitWebHistoryItemPrivate::): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_class_init): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_set_property): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_get_property): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_set_alternate_title): + +2008-06-15 Darin Adler <darin@apple.com> + + - give Frame object functions shorter names: scriptProxy() -> script(), + selectionController() -> selection(), animationController() -> animation() + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::EditorClient::handleKeyboardEvent): + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::windowObjectCleared): + * webkit/webkitwebframe.cpp: + * webkit/webkitwebview.cpp: + +2008-06-15 Darin Adler <darin@apple.com> + + - undo bogus renaming done by the script + + * WebCoreSupport/ContextMenuClientGtk.cpp: + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebbackforwardlist.h: + * webkit/webkitwebframe.h: + * webkit/webkitwebhistoryitem.h: + * webkit/webkitwebsettings.h: + +2008-06-15 Darin Adler <darin@apple.com> + + - new names for a few key JavaScriptCore files + + * WebCoreSupport/ContextMenuClientGtk.cpp: + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebbackforwardlist.h: + * webkit/webkitwebframe.h: + * webkit/webkitwebhistoryitem.h: + * webkit/webkitwebsettings.h: + +2008-06-15 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker. + + [GTK] Property setters do not call g_object_notify() + https://bugs.webkit.org/show_bug.cgi?id=18405 + + * webkit/webkitwebview.cpp: + +2008-06-15 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker. + + Tiny documentation fix, s/capacity/limit + + * webkit/webkitwebbackforwardlist.cpp: + +2008-06-14 Darin Adler <darin@apple.com> + + Rubber stamped by Sam. + + - new names for kjs_binding.h and kjs_proxy.h + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + * webkit/webkitwebframe.cpp: + +2008-06-14 Darin Adler <darin@apple.com> + + - fix build + + * webkit/webkitwebframe.cpp: Remove a bogus release() call. + +2008-06-14 Darin Adler <darin@apple.com> + + Reviewed by Sam. + + - more https://bugs.webkit.org/show_bug.cgi?id=17257 + start ref counts at 1 instead of 0 for speed + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::createDocumentLoader): Use create instead of new. + * webkit/webkitwebframe.cpp: + (webkit_web_frame_new): Ditto. + (webkit_web_frame_init_with_web_view): Ditto. + +2008-06-13 Darin Adler <darin@apple.com> + + - try to fix build + + * WebCoreSupport/FrameLoaderClientGtk.h: Add missing argument. + +2008-06-13 Darin Adler <darin@apple.com> + + Reviewed by John Sullivan. + + - updated for addition of FormState argument to action policy functions + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNewWindowAction): + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): + +2008-06-10 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker and Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=16676 + Apply GTK coding style to WebKit Gtk public headers + + * webkit/webkitnetworkrequest.h: + * webkit/webkitwebbackforwardlist.h: + * webkit/webkitwebframe.h: + * webkit/webkitwebhistoryitem.h: + * webkit/webkitwebsettings.h: + * webkit/webkitwebview.h: + +2008-06-07 Jan Michael Alonzo <jmalonzo@webkit.org> + + Confirmed by Christian Dywan. + + Gtk build fix for r34432 + + * webkit/webkitwebhistoryitem.cpp: + (_WebKitWebHistoryItemPrivate::webkit_history_item_add): + (_WebKitWebHistoryItemPrivate::webkit_history_item_remove): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_dispose): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new): + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data): + (WebKit::core): + +2008-06-07 Darin Adler <darin@apple.com> + + - try to fix build after HistoryItem changes + + * webkit/webkitwebhistoryitem.cpp: + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new): Use HistoryItem::create. + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_data): Ditto. I also + believe this fixes a memory leak in the old version. + +2008-06-07 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=17324 + Remove PLATFORM ifdefs from ContextMenu.cpp + + * WebCoreSupport/ContextMenuClientGtk.cpp: + (WebKit::ContextMenuClient::ContextMenuClient): + (WebKit::ContextMenuClient::contextMenuDestroyed): + (WebKit::inputMethodsMenuItem): + (WebKit::): + (WebKit::insertControlCharacter): + (WebKit::unicodeMenuItem): + (WebKit::ContextMenuClient::getCustomMenuFromDefaultItems): + * WebCoreSupport/ContextMenuClientGtk.h: + * webkit/webkitwebview.cpp: + +2008-06-05 Alp Toker <alp@nuanti.com> + + Add 'Since' documentation for API versioning functions. + + * webkit/webkitversion.cpp: + +2008-06-05 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=14141 + Please add a version to the Gtk port + + * webkit/webkit.h: + * webkit/webkitversion.cpp: Added. + * webkit/webkitversion.h.in: Added. + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + * webkit/webkitwebview.cpp: + +2008-06-01 Alp Toker <alp@nuanti.com> + + Suggested by Christian Dywan. + + Use float literals for zoom values and improve documentation wording. + + * webkit/webkitwebsettings.cpp: + (_WebKitWebSettingsPrivate::webkit_web_settings_class_init): + * webkit/webkitwebview.cpp: + +2008-06-01 Alp Toker <alp@nuanti.com> + + Reviewed by Oliver. + + Remove webkit_web_view_go_backward(), + webkit_web_view_can_go_backward(). These have been obsoleted by + the back() versions for quite a while. + + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-05-31 Alp Toker <alp@nuanti.com> + + Fix inconsistent zoom docs and enum name landed in r34249. Issue + noticed by Marco Barisione. + + * webkit/webkitwebview.cpp: + +2008-05-30 Carlos MartÃn Nieto <carlos@cmartin.tk> + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=18383 + [GTK] The "hovering-over-link" signal arguments aren't documented. + + * webkit/webkitwebview.cpp: + +2008-05-29 Marco Barisione <marco@collabora.co.uk> + + Reviewed (and tweaked) by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=18281 + [GTK] add functions to set/get the zoom level + + * 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: Add functions to get and set the zoom + level. + * webkit/webkitwebview.h: Ditto. + * webkit/webkitprivate.h: + +2008-05-28 Alp Toker <alp@nuanti.com> + + Reviewed by Alexey Proskuryakov. + + http://bugs.webkit.org/show_bug.cgi?id=18704 + [gtk] cannot type letters with dead keys in textarea + + http://bugs.webkit.org/show_bug.cgi?id=14120 + [GDK] Support input methods + + Add support for input method composition. + + Remove some old hacks so we handle input method events more + consistently. + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::imContextCommitted): + (WebKit::imContextPreeditChanged): + (WebKit::EditorClient::setInputMethodState): + (WebKit::EditorClient::respondToChangedSelection): + (WebKit::EditorClient::handleInputMethodKeydown): + (WebKit::EditorClient::EditorClient): + (WebKit::EditorClient::~EditorClient): + (WebKit::EditorClient::textFieldDidBeginEditing): + (WebKit::EditorClient::textFieldDidEndEditing): + (WebKit::EditorClient::textDidChangeInTextField): + (WebKit::EditorClient::doTextFieldCommandFromEvent): + * webkit/webkitwebview.cpp: + +2008-05-25 Alp Toker <alp@nuanti.com> + + Reviewed by Niko. + + Drop WebView focus when the widget is focused out. + + * webkit/webkitwebview.cpp: + +2008-05-25 Sriram Neelakandan <sriram.neelakandan@gmail.com> + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=18935 + [Gtk] Plugin Load crashes with NP_FULL mode + + Fix crash due to uninitialized variable. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::FrameLoaderClient): + +2008-05-24 Alp Toker <alp@nuanti.com> + + https://bugs.webkit.org/show_bug.cgi?id=18825 + webkitgtk fails to build from source: "Database Tracker" has not been declared + + GTK+ fix for building without database support. + exceededDatabaseQuota() still needs to be present, just a no-op. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::exceededDatabaseQuota): + +2008-05-23 Alp Toker <alp@nuanti.com> + + GTK+ fixes for building without database support. + + * WebCoreSupport/ChromeClientGtk.cpp: + +2008-05-19 Alp Toker <alp@nuanti.com> + + Reviewed by Anders and Beth. + + http://bugs.webkit.org/show_bug.cgi?id=16495 + [GTK] Accessibility support with ATK/AT-SPI + + Initial ATK/AT-SPI accessibility support for the GTK+ port. + + * webkit/webkitwebview.cpp: + +2008-05-06 Christian Dywan <christian@twotoasts.de> + + Rubber stamped by Alp. + + Back out 17626. It wasn't ready for commit. + + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-05-01 Marc Ordinas i Llopis <marc.ordinasillopis@collabora.co.uk> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=14750 + Added support for NPAPI plugins on Gtk and Qt-x11 ports. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::FrameLoaderClient): + (WebKit::FrameLoaderClient::committedLoad): + (WebKit::FrameLoaderClient::createPlugin): + (WebKit::FrameLoaderClient::redirectDataToPlugin): + (WebKit::FrameLoaderClient::finishedLoading): + (WebKit::FrameLoaderClient::setMainDocumentError): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-04-30 Sean Egan <seanegan@gmail.com> + + Reviewed and modified by Holger. + + https://bugs.webkit.org/show_bug.cgi?id=17626 + Support setting background color and a 16-bit alpha channel. + + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-04-24 Dan Bernstein <mitz@apple.com> + + - build fix + + * webkit/webkitwebview.cpp: + +2008-04-24 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam. + + Change some String arguments to be const references instead. + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::EditorClient::shouldInsertText): + * WebCoreSupport/EditorClientGtk.h: + +2008-04-23 Christian Dywan <christian@twotoasts.de> + + Reviewed by Alp Toker. + + Emit a warning about an unknown setting only if it is + not a valid property. Otherwise applications can't + subclass WebKitWebSettings to add new properties. + + * webkit/webkitwebview.cpp: + +2008-04-20 Simon Hausmann <hausmann@webkit.org> + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=18578 + Share the printing code between the Gtk and the Qt port + + Share the printing code between the Gtk and the Qt port + and added printing to the Qt WebKit API. + + * webkit/webkitwebframe.cpp: Removed PrintContext in favour of + page/Printcontext.cpp/h + +2008-04-19 Alp Toker <alp@nuanti.com> + + Reviewed by Maciej. + + Enable visited link tracking by default at startup. + + With this patch, the GTK+ port rendering of Acid3 now matches the + reference page. + + * webkit/webkitprivate.cpp: + (WebKit::core): + (webkit_init): + +2008-04-11 Mark Rowe <mrowe@apple.com> + + Gtk build fix after r32231. + + * webkit/webkitwebview.cpp: Update to use contentRenderer. + +2008-04-18 Alp Toker <alp@atoker.com> + + Rubber-stamped by Holger Freyther. + + http://bugs.webkit.org/show_bug.cgi?id=18218 + [Gtk] segfault when clicking on a disabled button + + Always use the main frame for mouse events (not the focused frame) + since it knows best how to get the event through to the right target. + + This also fixes a null crasher. + + * webkit/webkitwebview.cpp: + +2008-04-17 Alp Toker <alp@atoker.com> + + Rubber-stamped by Holger Freyther. + + Reduce hard-coded page-cache count to 3 based on research done for the + Mac port on value / page. + + We will need to make this more dynamic or configurable at some point + but for now it's best to keep closer to the behaviour before page + caching was enabled. + + Issue spotted by Mark Rowe. + + * webkit/webkitprivate.cpp: + (webkit_init): + +2008-04-17 Daniele Metilli <daniele.metilli@gmail.com> + + Reviewed by Eric. + + Fixed a typo in the copyright header. + + * webkit/webkitprivate.h: + +2008-04-14 Holger Freyther <zecke@selfish.org> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=18411 + Enable Page caching and create FrameViews on the fly + + Create the FrameView on the fly and cache pages + + - Keep a copy of the GtkAdjustment to be able to reuse it for the + FrameViews + - Do not initially create a FrameView and update the WebKit code to + cope with not having a view. + - Cache seven pages by default. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::createFrame): + (WebKit::FrameLoaderClient::canCachePage): + (WebKit::FrameLoaderClient::savePlatformDataToCachedPage): + (WebKit::FrameLoaderClient::transitionToCommittedFromCachedPage): + (WebKit::FrameLoaderClient::transitionToCommittedForNewPage): + * webkit/webkitprivate.cpp: + (webkit_init): + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + * webkit/webkitwebview.cpp: + +2008-04-10 Mario Bensi <mbensi@pleyo.com> + + Reviewed by Alp Toker. + + https://bugs.webkit.org/show_bug.cgi?id=18400 + Database example doesn't work on Gtk port + + Fix quota in ChromeClient + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::exceededDatabaseQuota): + +2008-04-08 Adam Roben <aroben@apple.com> + + Move callOnMainThread to WTF + + Reviewed by Alexey Proskuryakov. + + * webkit/webkitprivate.cpp: Updated #include. + (webkit_init): Changed to call KJS::initializeThreading. + +2008-04-06 Luca Bruno <lethalman88@gmail.com> + + Reviewed by Alp Toker. + + Fix webkit_web_view_get_transparent() return value. + + * webkit/webkitwebview.cpp: + +2008-03-31 Jasper Bryant-Greene <jasper@unix.geek.nz> + + Reviewed by Darin Adler. + + Resolves http://bugs.webkit.org/show_bug.cgi?id=18010 + "WebKitNetworkRequestPrivate is defined in two places unnecessarily" + + Removed unnecessary definition of WebKitNetworkRequestPrivate in + webkitprivate.h + + * webkit/webkitprivate.h: + +2008-03-25 Brady Eidson <beidson@apple.com> + + Reviewed by Darin + + Remove newly obsolete FrameLoaderClient methods + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-03-20 Alp Toker <alp@atoker.com> + + GTK+ build fix. Back out r31183. This patch also introduced API style + issues. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): + * webkit/headers.pri: + * webkit/webkit-marshal.list: + * webkit/webkitdefines.h: + * webkit/webkitnavigationaction.cpp: Removed. + * webkit/webkitnavigationaction.h: Removed. + * webkit/webkitprivate.cpp: + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-03-20 Jasper Bryant-Greene <jasper@unix.geek.nz> + + Reviewed and tweaked by Anders. + + Resolves http://bugs.webkit.org/show_bug.cgi?id=16092 + "[GTK] Middle-mouse click should allow opening a URL in a new tab" + + Created WebKitNavigationAction object exported through the API. The + navigation-requested signal provides this object as context for the + requested navigation, allowing the application to decide what to do + with the navigation based on which mouse button was used, which + modifier keys were held down, etc. This allows, for example, the + application to open links in a new tab when either middle-click or + control-click are used to initiate the navigation. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::dispatchDecidePolicyForNavigationAction): + * webkit/headers.pri: + * webkit/webkit-marshal.list: + * webkit/webkitdefines.h: + * webkit/webkitnavigationaction.cpp: Added. + (webkit_navigation_action_finalize): + (webkit_navigation_action_class_init): + (webkit_navigation_action_init): + (webkit_navigation_action_get_button): + (webkit_navigation_action_get_modifier_flags): + (webkit_navigation_action_get_navigation_type): + (webkit_navigation_action_get_original_url): + * webkit/webkitnavigationaction.h: Added. + * webkit/webkitprivate.cpp: + (WebKit::kit): + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-03-18 Rodney Dawes <dobey@wayofthemonkey.com> + + Reviewed and landed by jhoneycutt. + + Update to check if the MIME type is supported by a plugin. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (FrameLoaderClient::objectContentType): + +2008-03-18 Rodney Dawes <dobey@wayofthemonkey.com> + + Reviewed by Jon Honeycutt. + + Update setContainingWindow() calls to pass a GtkWidget. + + * webkit/webkitwebframe.cpp: + (webkit_web_frame_new): + (webkit_web_frame_init_with_web_view): + +2008-03-13 Rodney Dawes <dobey@wayofthemonkey.com> + + Fix GTK+ build for SharedBuffer changes. + + * webkit/webkitwebview.cpp: + (webkit_web_view_load_string): + +2008-03-12 Tommi Komulainen <tommi.komulainen@iki.fi> + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=17799 + WebView signals should use more specific types + + * webkit/webkitwebview.cpp: Use WEBKIT_TYPE_WEB_FRAME argument + type in "script-alert", "script-confirm", "script-script-prompt" + signals so that it gets more clearly documented rather than just + plain GObject. + +2008-03-10 Xan Lopez <xan@gnome.org> + + Reviewed by Alp Toker. + + Fix "missing braces" compiler warning. + + * webkit/webkitwebview.cpp: + +2008-03-04 Sam Weinig <sam@webkit.org> + + Reviewed by Mark Rowe. + + - Remove all unnecessary includes of JSDOMWindowBase.h, we prefer including + JSDOMWindow.h + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + * webkit/webkitwebframe.cpp: + +2008-03-03 Sam Weinig <sam@webkit.org> + + GTK+ build fix. + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::windowObjectCleared): + +2008-03-03 Alp Toker <alp@atoker.com> + + Fix the GTK+ build following breakage introduced in r30712. + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::imContextCommitted): + +2008-03-02 Alp Toker <alp@atoker.com> + + Reviewed by Mark Rowe. + + Split the WebKit GTK+ build out of the WebCore build and change the + shared object name to match the package name. + + * webkit.pc.in: + +2008-02-27 Adam Roben <aroben@apple.com> + + Attempt to fix the GTK+ build + + * webkit/webkitwebframe.cpp: + +2008-02-24 Darin Adler <darin@apple.com> + + Reviewed by Sam. + + - remove separate client calls for "standard" and "reload' history + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::updateGlobalHistory): + * WebCoreSupport/FrameLoaderClientGtk.h: + +2008-02-23 Alexey Proskuryakov <ap@webkit.org> + + Build fix. + + * webkit/webkitprivate.cpp: + (webkit_init): Renamed initializeThreading to initializeThreadingAndMainThread. + +2008-02-18 Alp Toker <alp@atoker.com> + + Reviewed by Mark Rowe. + + http://bugs.webkit.org/show_bug.cgi?id=17312 + [GTK] Webview Transparent Background + + Add support for WebView background transparency. + + * webkit/webkitprivate.h: + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-02-18 Alp Toker <alp@atoker.com> + + Reviewed by Mark Rowe. + + Implement webkit_web_view_get_focused_frame() + + Equivalent to selectedFrame in the Mac API. + + * webkit/webkitwebview.cpp: + * webkit/webkitwebview.h: + +2008-02-17 Jan Michael Alonzo <jmalonzo@unpluggable.com> + + Reviewed by Mark Rowe. + + Fix a crash introduced in changeset #29985 by moving the dereference to after + the null check. + + * webkit/webkitwebhistoryitem.cpp: + (_WebKitWebHistoryItemPrivate::webkit_web_history_item_new_with_core_item): + +2008-02-15 Alp Toker <alp@atoker.com> + + Fix the GTK+ build following breakage introduced in r30243. + + * WebCoreSupport/ChromeClientGtk.cpp: + (WebKit::ChromeClient::mouseDidMoveOverElement): + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::objectContentType): + +2008-02-15 Darin Adler <darin@apple.com> + + - another try at fixing the build + + * webkit/webkitwebview.cpp: Added some explicit conversions to KURL. + +2008-02-14 Darin Adler <darin@apple.com> + + * webkit/webkitwebframe.cpp: Removed DeprecatedString use to try to keep it building. + * webkit/webkitwebview.cpp: Ditto. + +2008-02-14 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Alp. + + * Make the handling of the coreFrame consistent. We construct the coreFrame + at the beginning and it will live until the end. Change the g_return_(val_)if + to ASSERTs as having a 0 coreFrame can never happen. + + * webkit/webkitwebframe.cpp: + (PrintContext::webkit_web_frame_print): + +2008-02-14 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Alp. + + * Make sure that the WebCore::Frame is living as long as the WebKitWebFrame + wrapped around it. All current calls to WebCore::Frame from within the + WebKitWebFrame are safe, even in the case where the WebCore::Frame is already + detached from the WebCore::Page. + * For the mainFrame the WebKitWebView is holding the initial reference and + will unref on destruction. + * For sub-frames the FramerLoaderClientGtk.cpp will do the unrefing when the + frame gets detached from the parent. + * Make sure FrameLoader::detachFromParent gets called by calling FrameLoader::detachChildren + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + (WebKit::FrameLoaderClient::detachedFromParent4): + * webkit/webkitprivate.cpp: + (WebKit::core): + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + * webkit/webkitwebview.cpp: + +2008-02-14 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Alp. + + WebCore::Frame is RefCounted, do not manually delete it! + + * webkit/webkitwebframe.cpp: + +2008-02-14 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Alp. + + * Plug a leak + + * webkit/webkitwebframe.cpp: + +2008-02-14 Holger Hans Peter Freyther <zecke@selfish.org> + + Reviewed by Alp. + + * Update the Copyright Information + + * WebCoreSupport/FrameLoaderClientGtk.cpp: + * webkit/webkitprivate.h: + * webkit/webkitwebframe.cpp: + +2008-02-13 Alp Toker <alp@atoker.com> + + Reviewed by Adam Roben. + + Fix very small, upside down, inside out text on GTK+/DirectFB. + + Based on an initial patch by Sriram Neelakandan <sriram.neelakandan@gmail.com> + + Test the result of gdk_screen_get_resolution() and use a default + fallback in case of failure. + + Also remove an unhelpful runtime warning. + + * webkit/webkitwebview.cpp: + +2008-02-08 Pierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk> + + Reviewed by Alp Toker. + + http://bugs.webkit.org/show_bug.cgi?id=17009 + [Gtk] Webkit strips accents from some dead-key combinations + + KeyEvents have to go through the gtk input method. + + * WebCoreSupport/EditorClientGtk.cpp: + (WebKit::imContextCommitted): + (WebKit::EditorClient::doTextFieldCommandFromEvent): + 2008-02-05 Mark Rowe <mrowe@apple.com> Reviewed by Alp Toker. @@ -357,7 +1731,7 @@ 2008-01-02 Holger Hans Peter Freyther <zecke@selfish.org> - Rubber stamped by Darin. + Rubber stamped by Darin Adler. Coding Style fix. Do not use an else because we use a return in the if branch. @@ -755,7 +2129,7 @@ 2007-12-07 Alexey Proskuryakov <ap@webkit.org> - Reviewed by Darin. + Reviewed by Darin Adler. <rdar://problem/5535636> Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp index 118639b..18ca5b3 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com> + * Copyright (C) 2008 Nuanti Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,6 +21,8 @@ #include "config.h" #include "ChromeClientGtk.h" +#include "FileSystem.h" +#include "FileChooser.h" #include "FloatRect.h" #include "IntRect.h" #include "PlatformString.h" @@ -30,10 +33,18 @@ #include "webkitprivate.h" #include "NotImplemented.h" #include "WindowFeatures.h" +#if ENABLE(DATABASE) +#include "DatabaseTracker.h" +#endif + +#include <glib.h> +#include <glib/gi18n.h> +#include <gtk/gtk.h> using namespace WebCore; namespace WebKit { + ChromeClient::ChromeClient(WebKitWebView* webView) : m_webView(webView) { @@ -256,19 +267,68 @@ IntRect ChromeClient::windowResizerRect() const return IntRect(); } -void ChromeClient::addToDirtyRegion(const IntRect&) +void ChromeClient::repaint(const IntRect& windowRect, bool contentChanged, bool immediate, bool repaintContentOnly) { - notImplemented(); + if (!m_webView) + return; + + GdkRectangle rect = windowRect; + GdkWindow* window = GTK_WIDGET(m_webView)->window; + + if (window) { + if (contentChanged) + gdk_window_invalidate_rect(window, &rect, FALSE); + // We don't currently do immediate updates since they delay other UI elements. + //if (immediate) + // gdk_window_process_updates(window, FALSE); + } +} + +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; + + GdkRectangle area = clipRect; + GdkRectangle moveRect; + + GdkRectangle sourceRect = area; + sourceRect.x -= delta.width(); + sourceRect.y -= delta.height(); + + GdkRegion* invalidRegion = gdk_region_rectangle(&area); + + if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) { + GdkRegion* moveRegion = gdk_region_rectangle(&moveRect); + gdk_window_move_region(window, moveRegion, delta.width(), delta.height()); + gdk_region_offset(moveRegion, delta.width(), delta.height()); + gdk_region_subtract(invalidRegion, moveRegion); + gdk_region_destroy(moveRegion); + } + + gdk_window_invalidate_region(window, invalidRegion, FALSE); + gdk_region_destroy(invalidRegion); } -void ChromeClient::scrollBackingStore(int dx, int dy, const IntRect& scrollViewRect, const IntRect& clipRect) +IntRect ChromeClient::windowToScreen(const IntRect& rect) const { notImplemented(); + return rect; } -void ChromeClient::updateBackingStore() +IntPoint ChromeClient::screenToWindow(const IntPoint& point) const { notImplemented(); + return point; +} + +PlatformWidget ChromeClient::platformWindow() const +{ + return m_webView ? GTK_WIDGET(m_webView) : 0; } void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned modifierFlags) @@ -279,7 +339,7 @@ void ChromeClient::mouseDidMoveOverElement(const HitTestResult& hit, unsigned mo KURL url = hit.absoluteLinkURL(); if (!url.isEmpty() && url != m_hoveredLinkURL) { CString titleString = hit.title().utf8(); - DeprecatedCString urlString = url.prettyURL().utf8(); + CString urlString = url.prettyURL().utf8(); g_signal_emit_by_name(m_webView, "hovering-over-link", titleString.data(), urlString.data()); m_hoveredLinkURL = url; } @@ -308,9 +368,37 @@ void ChromeClient::print(Frame* frame) webkit_web_frame_print(kit(frame)); } -void ChromeClient::exceededDatabaseQuota(Frame*, const String&) +void ChromeClient::exceededDatabaseQuota(Frame* frame, const String&) { +#if ENABLE(DATABASE) + // Set to 5M for testing + // FIXME: Make this configurable notImplemented(); + const unsigned long long defaultQuota = 5 * 1024 * 1024; + DatabaseTracker::tracker().setQuota(frame->document()->securityOrigin(), defaultQuota); +#endif +} + +void ChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> prpFileChooser) +{ + // FIXME: Support multiple files. + + RefPtr<FileChooser> fileChooser = prpFileChooser; + + GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"), + GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(platformWindow()))), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + 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); + } + gtk_widget_destroy(dialog); } } diff --git a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h index 465dc9f..04b3a26 100644 --- a/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h @@ -83,9 +83,12 @@ namespace WebKit { virtual bool tabsToLinks() const; virtual WebCore::IntRect windowResizerRect() const; - virtual void addToDirtyRegion(const WebCore::IntRect&); - virtual void scrollBackingStore(int dx, int dy, const WebCore::IntRect& scrollViewRect, const WebCore::IntRect& clipRect); - virtual void updateBackingStore(); + + virtual void repaint(const WebCore::IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false); + virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; + virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; + virtual PlatformWidget platformWindow() const; virtual void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags); @@ -95,6 +98,8 @@ namespace WebKit { virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&); + virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); + private: WebKitWebView* m_webView; WebCore::KURL m_hoveredLinkURL; diff --git a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp index 6a2feb2..490370c 100644 --- a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.cpp @@ -1,4 +1,6 @@ /* + * Copyright (C) 2008 Nuanti Ltd. + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -22,18 +24,136 @@ #include "KURL.h" #include "NotImplemented.h" +#include <glib-object.h> +#include <glib/gi18n.h> +#include <gtk/gtk.h> +#include "webkitprivate.h" + using namespace WebCore; namespace WebKit { +ContextMenuClient::ContextMenuClient(WebKitWebView *webView) + : m_webView(webView) +{ +} + void ContextMenuClient::contextMenuDestroyed() { delete this; } +static GtkWidget* inputMethodsMenuItem (WebKitWebView* webView) +{ + if (gtk_major_version > 2 || (gtk_major_version == 2 && gtk_minor_version >= 10)) { + GtkSettings* settings = webView ? gtk_widget_get_settings(GTK_WIDGET(webView)) : gtk_settings_get_default(); + + gboolean showMenu = TRUE; + if (settings) + g_object_get(settings, "gtk-show-input-method-menu", &showMenu, NULL); + if (!showMenu) + return 0; + } + + GtkWidget* menuitem = gtk_image_menu_item_new_with_mnemonic( + _("Input _Methods")); + + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + GtkWidget* imContextMenu = gtk_menu_new(); + gtk_im_multicontext_append_menuitems(GTK_IM_MULTICONTEXT(priv->imContext), GTK_MENU_SHELL(imContextMenu)); + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), imContextMenu); + + return menuitem; +} + +// Values taken from gtktextutil.c +typedef struct { + const char *label; + gunichar ch; +} GtkUnicodeMenuEntry; +static const GtkUnicodeMenuEntry bidi_menu_entries[] = { + { N_("LRM _Left-to-right mark"), 0x200E }, + { N_("RLM _Right-to-left mark"), 0x200F }, + { N_("LRE Left-to-right _embedding"), 0x202A }, + { N_("RLE Right-to-left e_mbedding"), 0x202B }, + { N_("LRO Left-to-right _override"), 0x202D }, + { N_("RLO Right-to-left o_verride"), 0x202E }, + { N_("PDF _Pop directional formatting"), 0x202C }, + { N_("ZWS _Zero width space"), 0x200B }, + { N_("ZWJ Zero width _joiner"), 0x200D }, + { N_("ZWNJ Zero width _non-joiner"), 0x200C } +}; + +static void insertControlCharacter(GtkWidget* widget) +{ + // GtkUnicodeMenuEntry* entry = (GtkUnicodeMenuEntry*)g_object_get_data(G_OBJECT(widget), "gtk-unicode-menu-entry"); + notImplemented(); +} + +static GtkWidget* unicodeMenuItem(WebKitWebView* webView) +{ + if (gtk_major_version > 2 || (gtk_major_version == 2 && gtk_minor_version >= 10)) { + GtkSettings* settings = webView ? gtk_widget_get_settings(GTK_WIDGET(webView)) : gtk_settings_get_default(); + + gboolean showMenu = TRUE; + if (settings) + g_object_get(settings, "gtk-show-unicode-menu", &showMenu, NULL); + if (!showMenu) + return 0; + } + + GtkWidget* menuitem = gtk_image_menu_item_new_with_mnemonic( + _("_Insert Unicode Control Character")); + + GtkWidget* unicodeContextMenu = gtk_menu_new(); + unsigned i; + for (i = 0; i < G_N_ELEMENTS(bidi_menu_entries); i++) { + GtkWidget* menuitem = gtk_menu_item_new_with_mnemonic(_(bidi_menu_entries[i].label)); + g_object_set_data(G_OBJECT(menuitem), "gtk-unicode-menu-entry", (gpointer)&bidi_menu_entries[i]); + g_signal_connect(menuitem, "activate", G_CALLBACK(insertControlCharacter), 0); + gtk_widget_show(menuitem); + gtk_menu_shell_append(GTK_MENU_SHELL(unicodeContextMenu), menuitem); + // FIXME: Make the item sensitive as insertControlCharacter() is implemented + gtk_widget_set_sensitive(menuitem, FALSE); + } + + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), unicodeContextMenu); + + return menuitem; +} + PlatformMenuDescription ContextMenuClient::getCustomMenuFromDefaultItems(ContextMenu* menu) { - return menu->releasePlatformDescription(); + GtkMenu* gtkmenu = menu->releasePlatformDescription(); + + HitTestResult result = menu->hitTestResult(); + WebKitWebView* webView = m_webView; + + if (result.isContentEditable()) { + + GtkWidget* imContextMenu = inputMethodsMenuItem(webView); + GtkWidget* unicodeContextMenu = unicodeMenuItem(webView); + + if (imContextMenu || unicodeContextMenu) { + GtkWidget* separator = gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(gtkmenu), separator); + gtk_widget_show(separator); + } + + if (imContextMenu) { + gtk_menu_shell_append(GTK_MENU_SHELL(gtkmenu), imContextMenu); + gtk_widget_show(imContextMenu); + } + + if (unicodeContextMenu) { + gtk_menu_shell_append(GTK_MENU_SHELL(gtkmenu), unicodeContextMenu); + gtk_widget_show(unicodeContextMenu); + } + + } + + return gtkmenu; } void ContextMenuClient::contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) diff --git a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h index c0e8069..52f7ad7 100644 --- a/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/ContextMenuClientGtk.h @@ -28,6 +28,8 @@ #include "ContextMenuClient.h" +typedef struct _WebKitWebView WebKitWebView; + namespace WebCore { class ContextMenu; } @@ -37,6 +39,8 @@ namespace WebKit { class ContextMenuClient : public WebCore::ContextMenuClient { public: + ContextMenuClient(WebKitWebView*); + virtual void contextMenuDestroyed(); virtual WebCore::PlatformMenuDescription getCustomMenuFromDefaultItems(WebCore::ContextMenu*); @@ -48,6 +52,9 @@ namespace WebKit { virtual void lookUpInDictionary(WebCore::Frame*); virtual void speak(const WebCore::String&); virtual void stopSpeaking(); + + private: + WebKitWebView* m_webView; }; } diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp index 663e2b1..62f1f27 100644 --- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * Copyright (C) 2008 Nuanti Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,6 +20,7 @@ #include "config.h" #include "EditorClientGtk.h" +#include "CString.h" #include "EditCommand.h" #include "Editor.h" #include "FocusController.h" @@ -28,16 +30,63 @@ #include "NotImplemented.h" #include "Page.h" #include "PlatformKeyboardEvent.h" +#include "markup.h" #include "webkitprivate.h" using namespace WebCore; namespace WebKit { -static void imContextCommitted(GtkIMContext* context, const char* str, EditorClient* client) +static void imContextCommitted(GtkIMContext* context, const gchar* str, EditorClient* client) +{ + Frame* targetFrame = core(client->m_webView)->focusController()->focusedOrMainFrame(); + + if (!targetFrame || !targetFrame->editor()->canEdit()) + return; + + Editor* editor = targetFrame->editor(); + + String commitString = String::fromUTF8(str); + editor->confirmComposition(commitString); +} + +static void imContextPreeditChanged(GtkIMContext* context, EditorClient* client) { Frame* frame = core(client->m_webView)->focusController()->focusedOrMainFrame(); - frame->editor()->insertTextWithoutSendingTextEvent(str, false); + Editor* editor = frame->editor(); + + gchar* preedit = NULL; + gint cursorPos = 0; + // We ignore the provided PangoAttrList for now. + gtk_im_context_get_preedit_string(context, &preedit, NULL, &cursorPos); + String preeditString = String::fromUTF8(preedit); + g_free(preedit); + + // setComposition() will replace the user selection if passed an empty + // preedit. We don't want this to happen. + if (preeditString.isEmpty() && !editor->hasComposition()) + return; + + Vector<CompositionUnderline> underlines; + underlines.append(CompositionUnderline(0, preeditString.length(), Color(0, 0, 0), false)); + editor->setComposition(preeditString, underlines, cursorPos, 0); +} + +void EditorClient::setInputMethodState(bool active) +{ + WebKitWebViewPrivate* priv = m_webView->priv; + + if (active) + gtk_im_context_focus_in(priv->imContext); + else + gtk_im_context_focus_out(priv->imContext); + +#ifdef MAEMO_CHANGES + if (active) + hildon_gtk_im_context_show(priv->imContext); + else + hildon_gtk_im_context_hide(priv->imContext); +#endif } bool EditorClient::shouldDeleteRange(Range*) @@ -81,7 +130,7 @@ bool EditorClient::shouldEndEditing(WebCore::Range*) return true; } -bool EditorClient::shouldInsertText(String, Range*, EditorInsertAction) +bool EditorClient::shouldInsertText(const String&, Range*, EditorInsertAction) { notImplemented(); return true; @@ -93,8 +142,7 @@ bool EditorClient::shouldChangeSelectedRange(Range*, Range*, EAffinity, bool) return true; } -bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration*, - WebCore::Range*) +bool EditorClient::shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*) { notImplemented(); return true; @@ -116,9 +164,67 @@ void EditorClient::respondToChangedContents() notImplemented(); } +#if GTK_CHECK_VERSION(2,10,0) +static void clipboard_get_contents_cb(GtkClipboard* clipboard, GtkSelectionData* selection_data, guint info, gpointer data) +{ + WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); + Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); + PassRefPtr<Range> selectedRange = frame->selection()->toRange(); + + if (static_cast<gint>(info) == WEBKIT_WEB_VIEW_TARGET_INFO_HTML) { + String markup = createMarkup(selectedRange.get(), 0, AnnotateForInterchange); + gtk_selection_data_set(selection_data, selection_data->target, 8, + reinterpret_cast<const guchar*>(markup.utf8().data()), markup.utf8().length()); + } else { + String text = selectedRange->text(); + gtk_selection_data_set_text(selection_data, text.utf8().data(), text.utf8().length()); + } +} + +static void clipboard_clear_contents_cb(GtkClipboard* clipboard, gpointer data) +{ + WebKitWebView* webView = reinterpret_cast<WebKitWebView*>(data); + Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); + + // Collapse the selection without clearing it + frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity()); +} +#endif + void EditorClient::respondToChangedSelection() { - notImplemented(); + WebKitWebViewPrivate* priv = m_webView->priv; + Frame* targetFrame = core(m_webView)->focusController()->focusedOrMainFrame(); + + if (!targetFrame) + return; + + if (targetFrame->editor()->ignoreCompositionSelectionChange()) + return; + +#if GTK_CHECK_VERSION(2,10,0) + GtkClipboard* clipboard = gtk_widget_get_clipboard(GTK_WIDGET(m_webView), GDK_SELECTION_PRIMARY); + if (targetFrame->selection()->isRange()) { + GtkTargetList* targetList = webkit_web_view_get_copy_target_list(m_webView); + gint targetCount; + GtkTargetEntry* targets = gtk_target_table_new_from_list(targetList, &targetCount); + gtk_clipboard_set_with_owner(clipboard, targets, targetCount, + clipboard_get_contents_cb, clipboard_clear_contents_cb, G_OBJECT(m_webView)); + gtk_target_table_free(targets, targetCount); + } else if (gtk_clipboard_get_owner(clipboard) == G_OBJECT(m_webView)) + gtk_clipboard_clear(clipboard); +#endif + + if (!targetFrame->editor()->hasComposition()) + return; + + unsigned start; + unsigned end; + if (!targetFrame->editor()->getCompositionSelection(start, end)) { + // gtk_im_context_reset() clears the composition for us. + gtk_im_context_reset(priv->imContext); + targetFrame->editor()->confirmCompositionWithoutDisturbingSelection(); + } } void EditorClient::didEndEditing() @@ -214,7 +320,7 @@ void EditorClient::handleKeyboardEvent(KeyboardEvent* event) if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) return; - Node* start = frame->selectionController()->start().node(); + Node* start = frame->selection()->start().node(); if (!start) return; @@ -232,34 +338,34 @@ void EditorClient::handleKeyboardEvent(KeyboardEvent* event) kevent->ctrlKey() ? WordGranularity : CharacterGranularity, false, true); break; case VK_LEFT: - frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::LEFT, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, true); break; case VK_RIGHT: - frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::RIGHT, kevent->ctrlKey() ? WordGranularity : CharacterGranularity, true); break; case VK_UP: - frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::BACKWARD, kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, true); break; case VK_DOWN: - frame->selectionController()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, + frame->selection()->modify(kevent->shiftKey() ? SelectionController::EXTEND : SelectionController::MOVE, SelectionController::FORWARD, kevent->ctrlKey() ? ParagraphGranularity : LineGranularity, true); break; case VK_PRIOR: // PageUp - frame->editor()->command("MovePageUp").execute(); + frame->editor()->command(kevent->shiftKey() ? "MovePageUpAndModifySelection" : "MovePageUp").execute(); break; case VK_NEXT: // PageDown - frame->editor()->command("MovePageDown").execute(); + frame->editor()->command(kevent->shiftKey() ? "MovePageDownAndModifySelection" : "MovePageDown").execute(); break; case VK_HOME: if (kevent->ctrlKey() && kevent->shiftKey()) @@ -343,10 +449,13 @@ void EditorClient::handleKeyboardEvent(KeyboardEvent* event) event->setDefaultHandled(); } - -void EditorClient::handleInputMethodKeydown(KeyboardEvent*) +void EditorClient::handleInputMethodKeydown(KeyboardEvent* event) { - notImplemented(); + WebKitWebViewPrivate* priv = m_webView->priv; + + // TODO: Dispatch IE-compatible text input events for IM events. + if (gtk_im_context_filter_keypress(priv->imContext, event->keyEvent()->gdkEventKey())) + event->setDefaultHandled(); } EditorClient::EditorClient(WebKitWebView* webView) @@ -354,37 +463,30 @@ EditorClient::EditorClient(WebKitWebView* webView) { WebKitWebViewPrivate* priv = m_webView->priv; g_signal_connect(priv->imContext, "commit", G_CALLBACK(imContextCommitted), this); + g_signal_connect(priv->imContext, "preedit-changed", G_CALLBACK(imContextPreeditChanged), this); } EditorClient::~EditorClient() { WebKitWebViewPrivate* priv = m_webView->priv; g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextCommitted, this); + g_signal_handlers_disconnect_by_func(priv->imContext, (gpointer)imContextPreeditChanged, this); } void EditorClient::textFieldDidBeginEditing(Element*) { - gtk_im_context_focus_in(WEBKIT_WEB_VIEW_GET_PRIVATE(m_webView)->imContext); } void EditorClient::textFieldDidEndEditing(Element*) { - WebKitWebViewPrivate* priv = m_webView->priv; - - gtk_im_context_focus_out(priv->imContext); -#ifdef MAEMO_CHANGES - hildon_gtk_im_context_hide(priv->imContext); -#endif } void EditorClient::textDidChangeInTextField(Element*) { - notImplemented(); } bool EditorClient::doTextFieldCommandFromEvent(Element*, KeyboardEvent*) { - notImplemented(); return false; } @@ -444,8 +546,4 @@ void EditorClient::getGuessesForWord(const String&, Vector<String>&) notImplemented(); } -void EditorClient::setInputMethodState(bool) -{ -} - } diff --git a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h index f2bc194..de31842 100644 --- a/WebKit/gtk/WebCoreSupport/EditorClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/EditorClientGtk.h @@ -64,7 +64,7 @@ namespace WebKit { virtual bool shouldBeginEditing(WebCore::Range*); virtual bool shouldEndEditing(WebCore::Range*); virtual bool shouldInsertNode(WebCore::Node*, WebCore::Range*, WebCore::EditorInsertAction); - virtual bool shouldInsertText(WebCore::String, WebCore::Range*, WebCore::EditorInsertAction); + virtual bool shouldInsertText(const WebCore::String&, WebCore::Range*, WebCore::EditorInsertAction); virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting); virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp index 0e561d1..8cea58f 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp @@ -1,7 +1,8 @@ /* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * Copyright (C) 2007 Christian Dywan <christian@twotoasts.de> + * Copyright (C) 2008 Collabora Ltd. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,16 +30,18 @@ #include "HTMLFrameElement.h" #include "HTMLFrameOwnerElement.h" #include "HTMLNames.h" +#include "JSDOMWindow.h" #include "Language.h" #include "MIMETypeRegistry.h" #include "NotImplemented.h" #include "PlatformString.h" +#include "PluginDatabase.h" +#include "RenderPart.h" #include "ResourceRequest.h" #include "CString.h" #include "ProgressTracker.h" -#include "kjs_binding.h" -#include "kjs_proxy.h" -#include "kjs_window.h" +#include "JSDOMBinding.h" +#include "ScriptController.h" #include "webkitwebview.h" #include "webkitwebframe.h" #include "webkitprivate.h" @@ -56,6 +59,8 @@ namespace WebKit { FrameLoaderClient::FrameLoaderClient(WebKitWebFrame* frame) : m_frame(frame) , m_userAgent("") + , m_pluginView(0) + , m_hasSentResponseToPlugin(false) { ASSERT(m_frame); } @@ -120,7 +125,7 @@ static String composeUserAgent() // WebKit Product // FIXME: The WebKit version is hardcoded - static const String webKitVersion = "525.1+"; + static const String webKitVersion = "528.5+"; ua += "AppleWebKit/" + webKitVersion; ua += " (KHTML, like Gecko, "; // We mention Safari since many broken sites check for it (OmniWeb does this too) @@ -144,11 +149,10 @@ String FrameLoaderClient::userAgent(const KURL&) WTF::PassRefPtr<WebCore::DocumentLoader> FrameLoaderClient::createDocumentLoader(const WebCore::ResourceRequest& request, const SubstituteData& substituteData) { - RefPtr<DocumentLoader> loader = new DocumentLoader(request, substituteData); - return loader.release(); + return DocumentLoader::create(request, substituteData); } -void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunction, PassRefPtr<FormState>) +void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunction, PassRefPtr<FormState>) { // FIXME: This is surely too simple ASSERT(policyFunction); @@ -160,9 +164,28 @@ void FrameLoaderClient::dispatchWillSubmitForm(FramePolicyFunction policyFunctio void FrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length) { - FrameLoader *fl = loader->frameLoader(); - fl->setEncoding(m_response.textEncodingName(), false); - fl->addData(data, length); + if (!m_pluginView) { + ASSERT(loader->frame()); + // Setting the encoding on the frame loader is our way to get work done that is normally done + // when the first bit of data is received, even for the case of a document with no data (like about:blank). + String encoding = loader->overrideEncoding(); + bool userChosen = !encoding.isNull(); + if (!userChosen) + encoding = loader->response().textEncodingName(); + + FrameLoader* frameLoader = loader->frameLoader(); + frameLoader->setEncoding(encoding, userChosen); + if (data) + frameLoader->addData(data, length); + } + + if (m_pluginView) { + if (!m_hasSentResponseToPlugin) { + m_pluginView->didReceiveResponse(loader->response()); + m_hasSentResponseToPlugin = true; + } + m_pluginView->didReceiveData(data, length); + } } void FrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long identifier, const AuthenticationChallenge&) @@ -208,6 +231,7 @@ void FrameLoaderClient::postProgressFinishedNotification() void FrameLoaderClient::frameLoaderDestroyed() { + g_object_unref(m_frame); m_frame = 0; delete this; } @@ -226,7 +250,7 @@ void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction poli (core(m_frame)->loader()->*policyFunction)(PolicyUse); } -void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, const String&) +void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction policyFunction, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>, const String&) { ASSERT(policyFunction); if (!policyFunction) @@ -236,7 +260,7 @@ void FrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFuncti (core(m_frame)->loader()->*policyFunction)(PolicyIgnore); } -void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest) +void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction policyFunction, const NavigationAction& action, const ResourceRequest& resourceRequest, PassRefPtr<FormState>) { ASSERT(policyFunction); if (!policyFunction) @@ -258,9 +282,13 @@ void FrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunct (core(m_frame)->loader()->*policyFunction)(PolicyUse); } -Widget* FrameLoaderClient::createPlugin(const IntSize&, Element*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) +Widget* FrameLoaderClient::createPlugin(const IntSize& pluginSize, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { - notImplemented(); + PluginView* pluginView = PluginView::create(core(m_frame), pluginSize, element, url, paramNames, paramValues, mimeType, loadManually); + + if (pluginView->status() == PluginStatusLoadedSuccessfully) + return pluginView; + return 0; } @@ -277,32 +305,20 @@ PassRefPtr<Frame> FrameLoaderClient::createFrame(const KURL& url, const String& childFrame->tree()->setName(name); childFrame->init(); - childFrame->loader()->load(url, referrer, FrameLoadTypeRedirectWithLockedHistory, String(), 0, 0); + childFrame->loader()->loadURL(url, referrer, String(), FrameLoadTypeRedirectWithLockedHistory, 0, 0); // The frame's onload handler may have removed it from the document. if (!childFrame->tree()->parent()) return 0; - // Propagate the marginwidth/height and scrolling modes to the view. - if (ownerElement->hasTagName(HTMLNames::frameTag) || ownerElement->hasTagName(HTMLNames::iframeTag)) { - HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement); - if (frameElt->scrollingMode() == ScrollbarAlwaysOff) - childFrame->view()->setScrollbarsMode(ScrollbarAlwaysOff); - int marginWidth = frameElt->getMarginWidth(); - int marginHeight = frameElt->getMarginHeight(); - if (marginWidth != -1) - childFrame->view()->setMarginWidth(marginWidth); - if (marginHeight != -1) - childFrame->view()->setMarginHeight(marginHeight); - } - return childFrame.release(); } void FrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) { - notImplemented(); - return; + ASSERT(!m_pluginView); + m_pluginView = static_cast<PluginView*>(pluginWidget); + m_hasSentResponseToPlugin = false; } Widget* FrameLoaderClient::createJavaAppletWidget(const IntSize&, Element*, const KURL& baseURL, @@ -315,8 +331,9 @@ Widget* FrameLoaderClient::createJavaAppletWidget(const IntSize&, Element*, cons ObjectContentType FrameLoaderClient::objectContentType(const KURL& url, const String& mimeType) { String type = mimeType; + // We don't use MIMETypeRegistry::getMIMETypeForPath() because it returns "application/octet-stream" upon failure if (type.isEmpty()) - type = MIMETypeRegistry::getMIMETypeForExtension(url.path().mid(url.path().findRev('.') + 1)); + type = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1)); if (type.isEmpty()) return WebCore::ObjectContentFrame; @@ -324,6 +341,9 @@ ObjectContentType FrameLoaderClient::objectContentType(const KURL& url, const St if (MIMETypeRegistry::isSupportedImageMIMEType(type)) return WebCore::ObjectContentImage; + if (PluginDatabase::installedPlugins()->isMIMETypeRegistered(mimeType)) + return WebCore::ObjectContentNetscapePlugin; + if (MIMETypeRegistry::isSupportedNonImageMIMEType(type)) return WebCore::ObjectContentFrame; @@ -350,8 +370,8 @@ void FrameLoaderClient::windowObjectCleared() // TODO: Consider using g_signal_has_handler_pending() to avoid the overhead // when there are no handlers. - JSGlobalContextRef context = toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec()); - JSObjectRef windowObject = toRef(KJS::Window::retrieve(coreFrame)->getObject()); + JSGlobalContextRef context = toGlobalRef(coreFrame->script()->globalObject()->globalExec()); + JSObjectRef windowObject = toRef(coreFrame->script()->globalObject()); ASSERT(windowObject); WebKitWebView* webView = getViewFromFrame(m_frame); @@ -381,12 +401,6 @@ bool FrameLoaderClient::hasWebView() const return true; } -bool FrameLoaderClient::hasFrameView() const -{ - notImplemented(); - return true; -} - void FrameLoaderClient::dispatchDidFinishLoad() { g_signal_emit_by_name(m_frame, "load-done", true); @@ -422,7 +436,7 @@ void FrameLoaderClient::makeRepresentation(DocumentLoader*) void FrameLoaderClient::forceLayout() { - notImplemented(); + core(m_frame)->forceLayout(true); } void FrameLoaderClient::forceLayoutForNonHTML() @@ -435,11 +449,6 @@ void FrameLoaderClient::setCopiesOnScroll() notImplemented(); } -void FrameLoaderClient::detachedFromParent1() -{ - notImplemented(); -} - void FrameLoaderClient::detachedFromParent2() { notImplemented(); @@ -450,11 +459,6 @@ void FrameLoaderClient::detachedFromParent3() notImplemented(); } -void FrameLoaderClient::detachedFromParent4() -{ - notImplemented(); -} - void FrameLoaderClient::loadedFromCachedPage() { notImplemented(); @@ -556,11 +560,6 @@ void FrameLoaderClient::revertToProvisionalState(DocumentLoader*) notImplemented(); } -void FrameLoaderClient::clearUnarchivingState(DocumentLoader*) -{ - notImplemented(); -} - void FrameLoaderClient::willChangeTitle(DocumentLoader*) { notImplemented(); @@ -571,32 +570,6 @@ void FrameLoaderClient::didChangeTitle(DocumentLoader *l) setTitle(l->title(), l->url()); } -void FrameLoaderClient::finalSetupForReplace(DocumentLoader*) -{ - notImplemented(); -} - -void FrameLoaderClient::setDefersLoading(bool) -{ - notImplemented(); -} - -bool FrameLoaderClient::isArchiveLoadPending(ResourceLoader*) const -{ - notImplemented(); - return false; -} - -void FrameLoaderClient::cancelPendingArchiveLoad(ResourceLoader*) -{ - notImplemented(); -} - -void FrameLoaderClient::clearArchivedResources() -{ - notImplemented(); -} - bool FrameLoaderClient::canHandleRequest(const ResourceRequest&) const { notImplemented(); @@ -623,14 +596,13 @@ String FrameLoaderClient::generatedMIMETypeForURLScheme(const String&) const void FrameLoaderClient::finishedLoading(DocumentLoader* documentLoader) { - ASSERT(documentLoader->frame()); - // Setting the encoding on the frame loader is our way to get work done that is normally done - // when the first bit of data is received, even for the case of a document with no data (like about:blank). - String encoding = documentLoader->overrideEncoding(); - bool userChosen = !encoding.isNull(); - if (encoding.isNull()) - encoding = documentLoader->response().textEncodingName(); - documentLoader->frameLoader()->setEncoding(encoding, userChosen); + if (!m_pluginView) + committedLoad(documentLoader, 0, 0); + else { + m_pluginView->didFinishLoading(); + m_pluginView = 0; + m_hasSentResponseToPlugin = false; + } } @@ -724,13 +696,13 @@ ResourceError FrameLoaderClient::fileDoesNotExistError(const ResourceResponse&) return ResourceError(); } -bool FrameLoaderClient::shouldFallBack(const ResourceError&) +ResourceError FrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse&) { notImplemented(); - return false; + return ResourceError(); } -bool FrameLoaderClient::willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL& originalURL) const +bool FrameLoaderClient::shouldFallBack(const ResourceError&) { notImplemented(); return false; @@ -738,8 +710,7 @@ bool FrameLoaderClient::willUseArchive(ResourceLoader*, const ResourceRequest&, bool FrameLoaderClient::canCachePage() const { - notImplemented(); - return false; + return true; } Frame* FrameLoaderClient::dispatchCreatePage() @@ -753,9 +724,13 @@ void FrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&) notImplemented(); } -void FrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError&) +void FrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceError& error) { - notImplemented(); + if (m_pluginView) { + m_pluginView->didFail(error); + m_pluginView = 0; + m_hasSentResponseToPlugin = false; + } } void FrameLoaderClient::startDownload(const ResourceRequest&) @@ -763,29 +738,57 @@ void FrameLoaderClient::startDownload(const ResourceRequest&) notImplemented(); } -void FrameLoaderClient::updateGlobalHistoryForStandardLoad(const KURL&) -{ - notImplemented(); -} - -void FrameLoaderClient::updateGlobalHistoryForReload(const KURL&) +void FrameLoaderClient::updateGlobalHistory(const KURL&) { notImplemented(); } void FrameLoaderClient::savePlatformDataToCachedPage(CachedPage*) { - notImplemented(); } void FrameLoaderClient::transitionToCommittedFromCachedPage(CachedPage*) { - notImplemented(); } void FrameLoaderClient::transitionToCommittedForNewPage() { - notImplemented(); + Frame* frame = core(m_frame); + ASSERT(frame); + + Page* page = frame->page(); + ASSERT(page); + + 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); + + if (HTMLFrameOwnerElement* owner = frame->ownerElement()) + frame->view()->setCanHaveScrollbars(owner->scrollingMode() != ScrollbarAlwaysOff); } } diff --git a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h index 26b4ef2..8f63b53 100644 --- a/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h @@ -1,6 +1,7 @@ /* * Copyright (C) 2006 Zack Rusin <zack@kde.org> * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Collabora Ltd. All rights reserved. * * All rights reserved. * @@ -31,6 +32,7 @@ #include "FrameLoaderClient.h" #include "ResourceResponse.h" +#include "PluginView.h" typedef struct _WebKitWebFrame WebKitWebFrame; @@ -45,7 +47,6 @@ namespace WebKit { WebKitWebFrame* webFrame() const { return m_frame; } virtual bool hasWebView() const; - virtual bool hasFrameView() const; virtual void makeRepresentation(WebCore::DocumentLoader*); virtual void forceLayout(); @@ -53,10 +54,8 @@ namespace WebKit { virtual void setCopiesOnScroll(); - virtual void detachedFromParent1(); virtual void detachedFromParent2(); virtual void detachedFromParent3(); - virtual void detachedFromParent4(); virtual void loadedFromCachedPage(); @@ -91,8 +90,8 @@ namespace WebKit { virtual void dispatchShow(); virtual void dispatchDecidePolicyForMIMEType(WebCore::FramePolicyFunction, const WebCore::String& MIMEType, const WebCore::ResourceRequest&); - virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, const WebCore::String& frameName); - virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&); + virtual void dispatchDecidePolicyForNewWindowAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WTF::PassRefPtr<WebCore::FormState>, const WebCore::String& frameName); + virtual void dispatchDecidePolicyForNavigationAction(WebCore::FramePolicyFunction, const WebCore::NavigationAction&, const WebCore::ResourceRequest&, WTF::PassRefPtr<WebCore::FormState>); virtual void cancelPolicyCheck(); virtual void dispatchUnableToImplementPolicy(const WebCore::ResourceError&); @@ -102,7 +101,6 @@ namespace WebKit { virtual void dispatchDidLoadMainResource(WebCore::DocumentLoader*); virtual void revertToProvisionalState(WebCore::DocumentLoader*); virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); - virtual void clearUnarchivingState(WebCore::DocumentLoader*); virtual void postProgressStartedNotification(); virtual void postProgressEstimateChangedNotification(); @@ -130,10 +128,8 @@ namespace WebKit { virtual void committedLoad(WebCore::DocumentLoader*, const char*, int); virtual void finishedLoading(WebCore::DocumentLoader*); - virtual void finalSetupForReplace(WebCore::DocumentLoader*); - virtual void updateGlobalHistoryForStandardLoad(const WebCore::KURL&); - virtual void updateGlobalHistoryForReload(const WebCore::KURL&); + virtual void updateGlobalHistory(const WebCore::KURL&); virtual bool shouldGoToHistoryItem(WebCore::HistoryItem*) const; virtual WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&); @@ -143,16 +139,10 @@ namespace WebKit { virtual WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&); virtual WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&); + virtual WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&); virtual bool shouldFallBack(const WebCore::ResourceError&); - virtual void setDefersLoading(bool); - - virtual bool willUseArchive(WebCore::ResourceLoader*, const WebCore::ResourceRequest&, const WebCore::KURL& originalURL) const; - virtual bool isArchiveLoadPending(WebCore::ResourceLoader*) const; - virtual void cancelPendingArchiveLoad(WebCore::ResourceLoader*); - virtual void clearArchivedResources(); - virtual bool canHandleRequest(const WebCore::ResourceRequest&) const; virtual bool canShowMIMEType(const WebCore::String&) const; virtual bool representationExistsForURLScheme(const WebCore::String&) const; @@ -180,6 +170,10 @@ namespace WebKit { WebKitWebFrame* m_frame; WebCore::ResourceResponse m_response; WebCore::String m_userAgent; + + // Plugin view to redirect data to + WebCore::PluginView* m_pluginView; + bool m_hasSentResponseToPlugin; }; } diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp index a54b6a0..210995a 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.cpp @@ -1,4 +1,6 @@ /* + * Copyright (C) 2008 Gustavo Noronha Silva + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -17,6 +19,11 @@ #include "config.h" #include "InspectorClientGtk.h" +#include "webkitwebview.h" +#include "webkitwebinspector.h" +#include "webkitprivate.h" +#include "CString.h" +#include "InspectorController.h" #include "NotImplemented.h" #include "PlatformString.h" @@ -24,15 +31,71 @@ using namespace WebCore; namespace WebKit { +static void notifyWebViewDestroyed(WebKitWebView* webView, InspectorClient* inspectorClient) +{ + inspectorClient->webViewDestroyed(); +} + +InspectorClient::InspectorClient(WebKitWebView* webView) + : m_webView(0) + , m_inspectedWebView(webView) + , m_webInspector(0) +{} + void InspectorClient::inspectorDestroyed() { + if (m_webView) { + gboolean handled = FALSE; + g_signal_emit_by_name(m_webInspector, "destroy", &handled); + + /* we can now dispose our own reference */ + g_object_unref(m_webInspector); + } + delete this; } +void InspectorClient::webViewDestroyed() +{ + m_webView = 0; + core(m_inspectedWebView)->inspectorController()->pageDestroyed(); + + // createPage will be called again, if the user chooses to inspect + // something else, and the inspector will be referenced again, + // there. + g_object_unref(m_webInspector); +} + Page* InspectorClient::createPage() { - notImplemented(); - return 0; + if (m_webView) + return core(m_webView); + + // This g_object_get will ref the inspector. We're not doing an + // unref if this method succeeds because the inspector object must + // be alive even after the inspected WebView is destroyed - the + // close-window and destroy signals still need to be + // emitted. + WebKitWebInspector* webInspector; + g_object_get(G_OBJECT(m_inspectedWebView), "web-inspector", &webInspector, NULL); + m_webInspector = webInspector; + + g_signal_emit_by_name(m_webInspector, "inspect-web-view", m_inspectedWebView, &m_webView); + + if (!m_webView) { + g_object_unref(m_webInspector); + return 0; + } + + webkit_web_inspector_set_web_view(m_webInspector, m_webView); + + g_signal_connect(G_OBJECT(m_webView), "destroy", + G_CALLBACK(notifyWebViewDestroyed), (gpointer)this); + + webkit_web_view_open(m_webView, "file://"DATA_DIR"/webkit-1.0/webinspector/inspector.html"); + gtk_widget_show(GTK_WIDGET(m_webView)); + + return core(m_webView); } String InspectorClient::localizedStringsURL() @@ -43,21 +106,46 @@ String InspectorClient::localizedStringsURL() void InspectorClient::showWindow() { - notImplemented(); + if (!m_webView) + return; + + gboolean handled = FALSE; + g_signal_emit_by_name(m_webInspector, "show-window", &handled); + + core(m_inspectedWebView)->inspectorController()->setWindowVisible(true); } void InspectorClient::closeWindow() { - notImplemented(); + if (!m_webView) + return; + + gboolean handled = FALSE; + g_signal_emit_by_name(m_webInspector, "close-window", &handled); + + core(m_inspectedWebView)->inspectorController()->setWindowVisible(false); } void InspectorClient::attachWindow() { - notImplemented(); + if (!m_webView) + return; + + gboolean handled = FALSE; + g_signal_emit_by_name(m_webInspector, "attach-window", &handled); } void InspectorClient::detachWindow() { + if (!m_webView) + return; + + gboolean handled = FALSE; + g_signal_emit_by_name(m_webInspector, "detach-window", &handled); +} + +void InspectorClient::setAttachedWindowHeight(unsigned height) +{ notImplemented(); } @@ -71,7 +159,25 @@ void InspectorClient::hideHighlight() notImplemented(); } -void InspectorClient::inspectedURLChanged(const String&) +void InspectorClient::inspectedURLChanged(const String& newURL) +{ + if (!m_webView) + return; + + webkit_web_inspector_set_inspected_uri(m_webInspector, newURL.utf8().data()); +} + +void InspectorClient::populateSetting(const String& key, InspectorController::Setting& setting) +{ + notImplemented(); +} + +void InspectorClient::storeSetting(const String& key, const InspectorController::Setting& setting) +{ + notImplemented(); +} + +void InspectorClient::removeSetting(const String& key) { notImplemented(); } diff --git a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h index 9afd42b..4fba55d 100644 --- a/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h +++ b/WebKit/gtk/WebCoreSupport/InspectorClientGtk.h @@ -30,6 +30,8 @@ #define InspectorClientGtk_h #include "InspectorClient.h" +#include "webkitwebview.h" +#include "webkitwebinspector.h" namespace WebCore { class Node; @@ -41,7 +43,10 @@ namespace WebKit { class InspectorClient : public WebCore::InspectorClient { public: + InspectorClient(WebKitWebView* webView); + virtual void inspectorDestroyed(); + void webViewDestroyed(); virtual WebCore::Page* createPage(); @@ -53,9 +58,20 @@ namespace WebKit { virtual void attachWindow(); virtual void detachWindow(); + virtual void setAttachedWindowHeight(unsigned height); + virtual void highlight(WebCore::Node*); virtual void hideHighlight(); virtual void inspectedURLChanged(const WebCore::String& newURL); + + virtual void populateSetting(const WebCore::String& key, WebCore::InspectorController::Setting&); + virtual void storeSetting(const WebCore::String& key, const WebCore::InspectorController::Setting&); + virtual void removeSetting(const WebCore::String& key); + + private: + WebKitWebView* m_webView; + WebKitWebView* m_inspectedWebView; + WebKitWebInspector* m_webInspector; }; } diff --git a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp index 9ef366d..ad8b077 100644 --- a/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp +++ b/WebKit/gtk/WebCoreSupport/PasteboardHelperGtk.cpp @@ -16,9 +16,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "Frame.h" +#include "config.h" #include "PasteboardHelperGtk.h" +#include "Frame.h" #include "webkitwebframe.h" #include "webkitwebview.h" #include "webkitprivate.h" diff --git a/WebKit/gtk/webkit.pc.in b/WebKit/gtk/webkit.pc.in index 43a1337..0ce6f71 100644 --- a/WebKit/gtk/webkit.pc.in +++ b/WebKit/gtk/webkit.pc.in @@ -4,8 +4,8 @@ libdir=@libdir@ includedir=@includedir@ Name: WebKit -Description: Web content engine for GTK+ applications +Description: Web content engine for GTK+ Version: @VERSION@ Requires: gtk+-2.0 -Libs: -L${libdir} -lWebKitGtk -Cflags: -I${includedir}/WebKit +Libs: -L${libdir} -lwebkit-1.0 +Cflags: -I${includedir}/webkit-1.0 diff --git a/WebKit/gtk/webkit/headers.pri b/WebKit/gtk/webkit/headers.pri deleted file mode 100644 index d53d825..0000000 --- a/WebKit/gtk/webkit/headers.pri +++ /dev/null @@ -1,8 +0,0 @@ -WEBKIT_API_HEADERS = $$PWD/webkit.h \ - $$PWD/webkitdefines.h \ - $$PWD/webkitnetworkrequest.h \ - $$PWD/webkitwebbackforwardlist.h \ - $$PWD/webkitwebframe.h \ - $$PWD/webkitwebhistoryitem.h \ - $$PWD/webkitwebsettings.h \ - $$PWD/webkitwebview.h diff --git a/WebKit/gtk/webkit/webkit-marshal.list b/WebKit/gtk/webkit/webkit-marshal.list deleted file mode 100644 index a8f2453..0000000 --- a/WebKit/gtk/webkit/webkit-marshal.list +++ /dev/null @@ -1,12 +0,0 @@ -VOID:OBJECT -VOID:STRING -VOID:STRING,STRING -VOID:OBJECT,BOOLEAN -VOID:OBJECT,STRING -VOID:OBJECT,OBJECT -VOID:OBJECT,POINTER,POINTER -BOOLEAN:STRING,INT,STRING -BOOLEAN:OBJECT,STRING -BOOLEAN:OBJECT,STRING,BOOLEAN -BOOLEAN:OBJECT,STRING,STRING,STRING -INT:OBJECT,OBJECT diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h index babd50a..e19cbc7 100644 --- a/WebKit/gtk/webkit/webkit.h +++ b/WebKit/gtk/webkit/webkit.h @@ -20,12 +20,15 @@ #ifndef __WEBKIT_H__ #define __WEBKIT_H__ +#include <webkit/webkitversion.h> #include <webkit/webkitdefines.h> #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitwebframe.h> #include <webkit/webkitwebsettings.h> +#include <webkit/webkitwebinspector.h> #include <webkit/webkitwebview.h> #include <webkit/webkitwebbackforwardlist.h> #include <webkit/webkitwebhistoryitem.h> +#include <webkit/webkitenumtypes.h> #endif /* __WEBKIT_H__ */ diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h index 386c3e1..0c080f4 100644 --- a/WebKit/gtk/webkit/webkitdefines.h +++ b/WebKit/gtk/webkit/webkitdefines.h @@ -55,6 +55,9 @@ typedef struct _WebKitWebFrameClass WebKitWebFrameClass; typedef struct _WebKitWebSettings WebKitWebSettings; typedef struct _WebKitWebSettingsClass WebKitWebSettingsClass; +typedef struct _WebKitWebInspector WebKitWebInspector; +typedef struct _WebKitWebInspectorClass WebKitWebInspectorClass; + typedef struct _WebKitWebView WebKitWebView; typedef struct _WebKitWebViewClass WebKitWebViewClass; diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp index b8711db..fab0f88 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp +++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp @@ -77,7 +77,7 @@ void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar* priv->uri = g_strdup(uri); } -const gchar* webkit_network_request_get_uri(WebKitNetworkRequest* request) +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 645144a..dfb4d6c 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.h +++ b/WebKit/gtk/webkit/webkitnetworkrequest.h @@ -38,7 +38,7 @@ typedef struct _WebKitNetworkRequestPrivate WebKitNetworkRequestPrivate; struct _WebKitNetworkRequest { GObject parent_instance; - WebKitNetworkRequestPrivate* priv; + WebKitNetworkRequestPrivate *priv; }; struct _WebKitNetworkRequestClass { @@ -48,14 +48,15 @@ struct _WebKitNetworkRequestClass { WEBKIT_API GType webkit_network_request_get_type (void); -WEBKIT_API WebKitNetworkRequest* -webkit_network_request_new (const gchar* uri); +WEBKIT_API WebKitNetworkRequest * +webkit_network_request_new (const gchar *uri); WEBKIT_API void -webkit_network_request_set_uri (WebKitNetworkRequest* request, const gchar* uri); +webkit_network_request_set_uri (WebKitNetworkRequest *request, + const gchar* uri); -WEBKIT_API const gchar* -webkit_network_request_get_uri (WebKitNetworkRequest* request); +WEBKIT_API G_CONST_RETURN gchar * +webkit_network_request_get_uri (WebKitNetworkRequest *request); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index 88be6c8..07c8174 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -25,9 +25,11 @@ #include "FrameLoaderClientGtk.h" #include "Logging.h" #include "NotImplemented.h" +#include "PageCache.h" +#include "PageGroup.h" #include "Pasteboard.h" #include "PasteboardHelperGtk.h" -#include "Threading.h" +#include <runtime/InitializeThreading.h> #if ENABLE(DATABASE) #include "DatabaseTracker.h" @@ -49,7 +51,7 @@ WebCore::Frame* core(WebKitWebFrame* frame) return 0; WebKitWebFramePrivate* priv = frame->priv; - return priv ? priv->coreFrame : 0; + return priv ? priv->coreFrame.get() : 0; } WebKitWebFrame* kit(WebCore::Frame* coreFrame) @@ -81,7 +83,7 @@ WebKitWebView* kit(WebCore::Page* corePage) return client ? client->webView() : 0; } -} /** end namespace WebCore */ +} /** end namespace WebKit */ void webkit_init() { @@ -90,9 +92,14 @@ void webkit_init() return; isInitialized = true; - WebCore::initializeThreading(); + JSC::initializeThreading(); WebCore::InitializeLoggingChannelsIfNecessary(); + // Page cache capacity (in pages). Comment from Mac port: + // (Research indicates that value / page drops substantially after 3 pages.) + // FIXME: Expose this with an API and/or calculate based on available resources + WebCore::pageCache()->setCapacity(3); + #if ENABLE(DATABASE) // FIXME: It should be possible for client applications to override this default location gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL); @@ -100,5 +107,7 @@ void webkit_init() g_free(databaseDirectory); #endif + PageGroup::setShouldTrackVisitedLinks(true); + Pasteboard::generalPasteboard()->setHelper(new WebKit::PasteboardHelperGtk()); } diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index 2dda422..3047af4 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -1,6 +1,6 @@ /* - * Copyright (C) 2007 Holger Hans Peter Freyther - * Copyrifht (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -30,7 +30,6 @@ #include <webkit/webkitwebview.h> #include <webkit/webkitwebframe.h> #include <webkit/webkitwebsettings.h> -#include <webkit/webkitnetworkrequest.h> #include <webkit/webkitwebbackforwardlist.h> #include "BackForwardList.h" @@ -38,6 +37,7 @@ #include "Settings.h" #include "Page.h" #include "Frame.h" +#include "InspectorClientGtk.h" #include "FrameLoaderClient.h" #include <glib.h> @@ -68,6 +68,7 @@ extern "C" { struct _WebKitWebViewPrivate { WebCore::Page* corePage; WebKitWebSettings* webSettings; + WebKitWebInspector* webInspector; WebKitWebFrame* mainFrame; WebCore::String applicationNameForUserAgent; @@ -84,12 +85,19 @@ extern "C" { GtkTargetList* copy_target_list; GtkTargetList* paste_target_list; + + gboolean transparent; + + GtkAdjustment* horizontalAdjustment; + GtkAdjustment* verticalAdjustment; + + gboolean zoomFullContent; }; #define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate)) typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; struct _WebKitWebFramePrivate { - WebCore::Frame* coreFrame; + WTF::RefPtr<WebCore::Frame> coreFrame; WebCore::FrameLoaderClient* client; WebKitWebView* webView; @@ -98,18 +106,21 @@ extern "C" { gchar* uri; }; - #define WEBKIT_NETWORK_REQUEST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_REQUEST, WebKitNetworkRequestPrivate)) - typedef struct _WebKitNetworkRequestPrivate WebKitNetworkRequestPrivate; - struct _WebKitNetworkRequestPrivate { - gchar* uri; - }; - WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView*, WebCore::HTMLFrameOwnerElement*); WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem*); + void + webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebKit::InspectorClient*); + + void + webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view); + + void + webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri); + // FIXME: Move these to webkitwebframe.h once their API has been discussed. WEBKIT_API GSList* @@ -122,6 +133,9 @@ extern "C" { webkit_web_frame_print (WebKitWebFrame* frame); WEBKIT_API gchar* + webkit_web_frame_dump_render_tree (WebKitWebFrame* frame); + + WEBKIT_API gchar* webkit_web_view_get_selected_text (WebKitWebView* web_view); } diff --git a/WebKit/gtk/webkit/webkitversion.cpp b/WebKit/gtk/webkit/webkitversion.cpp new file mode 100644 index 0000000..3f35750 --- /dev/null +++ b/WebKit/gtk/webkit/webkitversion.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008 Christian Dywan <christian@imendio.com> + * + * 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 "webkitversion.h" + +extern "C" { + +/** + * webkit_major_version: + * + * The major version number of the WebKit that is linked against. + * + * Return value: The major version + * + * Since: 1.0.1 + */ +guint webkit_major_version() +{ + return WEBKIT_MAJOR_VERSION; +} + +/** + * webkit_minor_version: + * + * The minor version number of the WebKit that is linked against. + * + * Return value: The minor version + * + * Since: 1.0.1 + */ +guint webkit_minor_version() +{ + return WEBKIT_MINOR_VERSION; +} + +/** + * webkit_micro_version: + * + * The micro version number of the WebKit that is linked against. + * + * Return value: The micro version + * + * Since: 1.0.1 + */ +guint webkit_micro_version() +{ + return WEBKIT_MICRO_VERSION; +} + +} diff --git a/WebKit/gtk/webkit/webkitversion.h.in b/WebKit/gtk/webkit/webkitversion.h.in new file mode 100644 index 0000000..f70800d --- /dev/null +++ b/WebKit/gtk/webkit/webkitversion.h.in @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2008 Christian Dywan <christian@imendio.com> + * + * 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_VERSION_H +#define WEBKIT_VERSION_H + +#include <glib.h> +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_MAJOR_VERSION (@WEBKIT_MAJOR_VERSION@) +#define WEBKIT_MINOR_VERSION (@WEBKIT_MINOR_VERSION@) +#define WEBKIT_MICRO_VERSION (@WEBKIT_MICRO_VERSION@) + +#define WEBKIT_CHECK_VERSION(major, minor, micro) \ + (WEBKIT_MAJOR_VERSION > (major) || \ + (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION > (minor)) || \ + (WEBKIT_MAJOR_VERSION == (major) && WEBKIT_MINOR_VERSION == (minor) && \ + WEBKIT_MICRO_VERSION >= (micro))) + +WEBKIT_API guint +webkit_major_version (void); + +WEBKIT_API guint +webkit_minor_version (void); + +WEBKIT_API guint +webkit_micro_version (void); + +WEBKIT_API gboolean +webkit_check_version (guint major, guint minor, guint micro); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp index c409557..ff68dad 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp @@ -163,7 +163,7 @@ GList* webkit_web_back_forward_list_get_forward_list_with_limit(WebKitWebBackFor if (!backForwardList || !backForwardList->enabled()) return NULL; - WebCore::HistoryItemVector items(limit); + WebCore::HistoryItemVector items; GList* forwardItems = { 0 }; backForwardList->forwardListWithLimit(limit, items); @@ -193,7 +193,7 @@ GList* webkit_web_back_forward_list_get_back_list_with_limit(WebKitWebBackForwar if (!backForwardList || !backForwardList->enabled()) return NULL; - WebCore::HistoryItemVector items(limit); + WebCore::HistoryItemVector items; GList* backItems = { 0 }; backForwardList->backListWithLimit(limit, items); @@ -333,7 +333,7 @@ gint webkit_web_back_forward_list_get_forward_length(WebKitWebBackForwardList* w } /** - * webkit_web_back_forward_list_get_capacity: + * webkit_web_back_forward_list_get_limit: * @webBackForwardList: a #WebKitWebBackForwardList * * Returns the maximum limit of the back forward list. diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.h b/WebKit/gtk/webkit/webkitwebbackforwardlist.h index e63505d..68e18eb 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.h +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.h @@ -40,7 +40,7 @@ typedef struct _WebKitWebBackForwardListPrivate WebKitWebBackForwardListPrivate; struct _WebKitWebBackForwardList { GObject parent_instance; - WebKitWebBackForwardListPrivate* priv; + WebKitWebBackForwardListPrivate *priv; }; struct _WebKitWebBackForwardListClass { @@ -50,50 +50,56 @@ struct _WebKitWebBackForwardListClass { WEBKIT_API GType webkit_web_back_forward_list_get_type (void); -WEBKIT_API WebKitWebBackForwardList* -webkit_web_back_forward_list_new_with_web_view (WebKitWebView* web_view); +WEBKIT_API WebKitWebBackForwardList * +webkit_web_back_forward_list_new_with_web_view (WebKitWebView *web_view); WEBKIT_API void -webkit_web_back_forward_list_go_forward (WebKitWebBackForwardList* web_back_forward_list); +webkit_web_back_forward_list_go_forward (WebKitWebBackForwardList *web_back_forward_list); WEBKIT_API void -webkit_web_back_forward_list_go_back (WebKitWebBackForwardList* web_back_forward_list); +webkit_web_back_forward_list_go_back (WebKitWebBackForwardList *web_back_forward_list); WEBKIT_API gboolean -webkit_web_back_forward_list_contains_item (WebKitWebBackForwardList* web_back_forward_list, WebKitWebHistoryItem* history_item); +webkit_web_back_forward_list_contains_item (WebKitWebBackForwardList *web_back_forward_list, + WebKitWebHistoryItem *history_item); WEBKIT_API void -webkit_web_back_forward_list_go_to_item (WebKitWebBackForwardList* web_back_forward_list, WebKitWebHistoryItem* history_item); +webkit_web_back_forward_list_go_to_item (WebKitWebBackForwardList *web_back_forward_list, + WebKitWebHistoryItem *history_item); -WEBKIT_API GList* -webkit_web_back_forward_list_get_forward_list_with_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit); +WEBKIT_API GList * +webkit_web_back_forward_list_get_forward_list_with_limit (WebKitWebBackForwardList *web_back_forward_list, + gint limit); -WEBKIT_API GList* -webkit_web_back_forward_list_get_back_list_with_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit); +WEBKIT_API GList * +webkit_web_back_forward_list_get_back_list_with_limit (WebKitWebBackForwardList *web_back_forward_list, + gint limit); -WEBKIT_API WebKitWebHistoryItem* -webkit_web_back_forward_list_get_back_item (WebKitWebBackForwardList* web_back_forward_list); +WEBKIT_API WebKitWebHistoryItem * +webkit_web_back_forward_list_get_back_item (WebKitWebBackForwardList *web_back_forward_list); -WEBKIT_API WebKitWebHistoryItem* -webkit_web_back_forward_list_get_current_item (WebKitWebBackForwardList* web_back_forward_list); +WEBKIT_API WebKitWebHistoryItem * +webkit_web_back_forward_list_get_current_item (WebKitWebBackForwardList *web_back_forward_list); -WEBKIT_API WebKitWebHistoryItem* -webkit_web_back_forward_list_get_forward_item (WebKitWebBackForwardList* web_back_forward_list); +WEBKIT_API WebKitWebHistoryItem * +webkit_web_back_forward_list_get_forward_item (WebKitWebBackForwardList *web_back_forward_list); -WEBKIT_API WebKitWebHistoryItem* -webkit_web_back_forward_list_get_nth_item (WebKitWebBackForwardList* web_back_forward_list, gint index); +WEBKIT_API WebKitWebHistoryItem * +webkit_web_back_forward_list_get_nth_item (WebKitWebBackForwardList *web_back_forward_list, + gint index); WEBKIT_API gint -webkit_web_back_forward_list_get_back_length (WebKitWebBackForwardList* web_back_forward_list); +webkit_web_back_forward_list_get_back_length (WebKitWebBackForwardList *web_back_forward_list); WEBKIT_API gint -webkit_web_back_forward_list_get_forward_length (WebKitWebBackForwardList* web_back_forward_list); +webkit_web_back_forward_list_get_forward_length (WebKitWebBackForwardList *web_back_forward_list); WEBKIT_API gint -webkit_web_back_forward_list_get_limit (WebKitWebBackForwardList* web_back_forward_list); +webkit_web_back_forward_list_get_limit (WebKitWebBackForwardList *web_back_forward_list); WEBKIT_API void -webkit_web_back_forward_list_set_limit (WebKitWebBackForwardList* web_back_forward_list, gint limit); +webkit_web_back_forward_list_set_limit (WebKitWebBackForwardList *web_back_forward_list, + gint limit); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp index 4ae0def..6a4c4d5 100644 --- a/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/WebKit/gtk/webkit/webkitwebframe.cpp @@ -1,8 +1,10 @@ /* - * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Holger Hans Peter Freyther * Copyright (C) 2007 Alp Toker <alp@atoker.com> * Copyright (C) 2007 Apple Inc. * Copyright (C) 2008 Christian Dywan <christian@imendio.com> + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2008 Nuanti Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,7 +26,7 @@ #include "webkitwebframe.h" #include "webkitwebview.h" -#include "webkit-marshal.h" +#include "webkitmarshal.h" #include "webkitprivate.h" #include "CString.h" @@ -34,15 +36,18 @@ #include "FrameView.h" #include "GraphicsContext.h" #include "HTMLFrameOwnerElement.h" +#include "JSDOMWindow.h" +#include "PrintContext.h" #include "RenderView.h" -#include "kjs_binding.h" -#include "kjs_proxy.h" -#include "kjs_window.h" +#include "RenderTreeAsText.h" +#include "JSDOMBinding.h" +#include "ScriptController.h" #include <JavaScriptCore/APICast.h> using namespace WebKit; using namespace WebCore; +using namespace std; extern "C" { @@ -93,10 +98,11 @@ static void webkit_web_frame_finalize(GObject* object) WebKitWebFramePrivate* priv = frame->priv; priv->coreFrame->loader()->cancelAndClear(); + priv->coreFrame = 0; + g_free(priv->name); g_free(priv->title); g_free(priv->uri); - delete priv->coreFrame; G_OBJECT_CLASS(webkit_web_frame_parent_class)->finalize(object); } @@ -205,6 +211,9 @@ static void webkit_web_frame_init(WebKitWebFrame* frame) * Creates a new #WebKitWebFrame initialized with a controlling #WebKitWebView. * * Returns: a new #WebKitWebFrame + * + * Deprecated: 1.0.2: #WebKitWebFrame can only be used to inspect existing + * frames. **/ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView) { @@ -214,16 +223,10 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView) WebKitWebFramePrivate* priv = frame->priv; WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + priv->webView = webView; priv->client = new WebKit::FrameLoaderClient(frame); - priv->coreFrame = new Frame(viewPriv->corePage, 0, priv->client); - - FrameView* frameView = new FrameView(priv->coreFrame); - frameView->setContainingWindow(GTK_CONTAINER(webView)); - frameView->setGtkAdjustments(GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)), - GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0))); - priv->coreFrame->setView(frameView); + priv->coreFrame = Frame::create(viewPriv->corePage, 0, priv->client).get(); priv->coreFrame->init(); - priv->webView = webView; return frame; } @@ -234,15 +237,10 @@ WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTML WebKitWebFramePrivate* priv = frame->priv; WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + priv->webView = webView; priv->client = new WebKit::FrameLoaderClient(frame); - priv->coreFrame = new Frame(viewPriv->corePage, element, priv->client); - - FrameView* frameView = new FrameView(priv->coreFrame); - frameView->setContainingWindow(GTK_CONTAINER(webView)); - priv->coreFrame->setView(frameView); - frameView->deref(); + priv->coreFrame = Frame::create(viewPriv->corePage, element, priv->client).releaseRef(); priv->coreFrame->init(); - priv->webView = webView; return frame; } @@ -255,7 +253,7 @@ WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTML * * Return value: the title of @frame */ -const gchar* webkit_web_frame_get_title(WebKitWebFrame* frame) +G_CONST_RETURN gchar* webkit_web_frame_get_title(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); @@ -271,7 +269,7 @@ const gchar* webkit_web_frame_get_title(WebKitWebFrame* frame) * * Return value: the URI of @frame */ -const gchar* webkit_web_frame_get_uri(WebKitWebFrame* frame) +G_CONST_RETURN gchar* webkit_web_frame_get_uri(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); @@ -306,7 +304,7 @@ WebKitWebView* webkit_web_frame_get_web_view(WebKitWebFrame* frame) * * Return value: the name of @frame */ -const gchar* webkit_web_frame_get_name(WebKitWebFrame* frame) +G_CONST_RETURN gchar* webkit_web_frame_get_name(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); @@ -316,7 +314,7 @@ const gchar* webkit_web_frame_get_name(WebKitWebFrame* frame) return priv->name; Frame* coreFrame = core(frame); - g_return_val_if_fail(coreFrame, NULL); + ASSERT(coreFrame); String string = coreFrame->tree()->name(); priv->name = g_strdup(string.utf8().data()); @@ -336,7 +334,7 @@ WebKitWebFrame* webkit_web_frame_get_parent(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - g_return_val_if_fail(coreFrame, NULL); + ASSERT(coreFrame); return kit(coreFrame->tree()->parent()); } @@ -358,10 +356,10 @@ void webkit_web_frame_load_request(WebKitWebFrame* frame, WebKitNetworkRequest* g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request)); Frame* coreFrame = core(frame); - g_return_if_fail(coreFrame); + ASSERT(coreFrame); // TODO: Use the ResourceRequest carried by WebKitNetworkRequest when it is implemented. - DeprecatedString string = DeprecatedString::fromUtf8(webkit_network_request_get_uri(request)); + String string = String::fromUTF8(webkit_network_request_get_uri(request)); coreFrame->loader()->load(ResourceRequest(KURL(string))); } @@ -376,7 +374,7 @@ void webkit_web_frame_stop_loading(WebKitWebFrame* frame) g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); Frame* coreFrame = core(frame); - g_return_if_fail(coreFrame); + ASSERT(coreFrame); coreFrame->loader()->stopAllLoaders(); } @@ -392,7 +390,7 @@ void webkit_web_frame_reload(WebKitWebFrame* frame) g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); Frame* coreFrame = core(frame); - g_return_if_fail(coreFrame); + ASSERT(coreFrame); coreFrame->loader()->reload(); } @@ -420,7 +418,7 @@ WebKitWebFrame* webkit_web_frame_find_frame(WebKitWebFrame* frame, const gchar* g_return_val_if_fail(name, NULL); Frame* coreFrame = core(frame); - g_return_val_if_fail(coreFrame, NULL); + ASSERT(coreFrame); String nameString = String::fromUTF8(name); return kit(coreFrame->tree()->find(AtomicString(nameString))); @@ -440,9 +438,9 @@ JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame) g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); Frame* coreFrame = core(frame); - g_return_val_if_fail(coreFrame, NULL); + ASSERT(coreFrame); - return toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec()); + return toGlobalRef(coreFrame->script()->globalObject()->globalExec()); } /** @@ -455,9 +453,10 @@ GSList* webkit_web_frame_get_children(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - GSList* children = NULL; Frame* coreFrame = core(frame); + ASSERT(coreFrame); + GSList* children = NULL; for (Frame* child = coreFrame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { FrameLoader* loader = child->loader(); WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(loader->client()); @@ -479,9 +478,11 @@ 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); + FrameView* view = coreFrame->view(); - if (view->layoutPending()) + if (view && view->layoutPending()) view->layout(); Element* documentElement = coreFrame->document()->documentElement(); @@ -489,122 +490,29 @@ gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame) return g_strdup(string.utf8().data()); } -#if GTK_CHECK_VERSION(2,10,0) - -// This could be shared between ports once it's complete -class PrintContext +/** + * webkit_web_frame_dump_render_tree: + * @frame: a #WebKitWebFrame + * + * Return value: Non-recursive render tree dump of @frame + */ +gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame) { -public: - PrintContext(Frame* frame) - : m_frame(frame) - { - } - - ~PrintContext() - { - m_pageRects.clear(); - } - - int pageCount() - { - return m_pageRects.size(); - } - - void computePageRects(const FloatRect& printRect, float headerHeight, float footerHeight, float userScaleFactor, float& outPageHeight) - { - m_pageRects.clear(); - outPageHeight = 0; - - if (!m_frame->document() || !m_frame->view() || !m_frame->document()->renderer()) - return; - - RenderView* root = static_cast<RenderView*>(m_frame->document()->renderer()); - - if (!root) { - LOG_ERROR("document to be printed has no renderer"); - return; - } - - if (userScaleFactor <= 0) { - LOG_ERROR("userScaleFactor has bad value %.2f", userScaleFactor); - return; - } - - float ratio = printRect.height() / printRect.width(); - - float pageWidth = (float)root->docWidth(); - float pageHeight = pageWidth * ratio; - outPageHeight = pageHeight; // this is the height of the page adjusted by margins - pageHeight -= headerHeight + footerHeight; - - if (pageHeight <= 0) { - LOG_ERROR("pageHeight has bad value %.2f", pageHeight); - return; - } - - float currPageHeight = pageHeight / userScaleFactor; - float docHeight = root->layer()->height(); - float currPageWidth = pageWidth / userScaleFactor; - - // always return at least one page, since empty files should print a blank page - float printedPagesHeight = 0.0; - do { - float proposedBottom = min(docHeight, printedPagesHeight + pageHeight); - m_frame->adjustPageHeight(&proposedBottom, printedPagesHeight, proposedBottom, printedPagesHeight); - currPageHeight = max(1.0f, proposedBottom - printedPagesHeight); + g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - m_pageRects.append(IntRect(0, (int)printedPagesHeight, (int)currPageWidth, (int)currPageHeight)); - printedPagesHeight += currPageHeight; - } while (printedPagesHeight < docHeight); - } + Frame* coreFrame = core(frame); + ASSERT(coreFrame); - // TODO: eliminate width param - void begin(float width) - { - // By imaging to a width a little wider than the available pixels, - // thin pages will be scaled down a little, matching the way they - // print in IE and Camino. This lets them use fewer sheets than they - // would otherwise, which is presumably why other browsers do this. - // Wide pages will be scaled down more than this. - const float PrintingMinimumShrinkFactor = 1.25f; - - // This number determines how small we are willing to reduce the page content - // in order to accommodate the widest line. If the page would have to be - // reduced smaller to make the widest line fit, we just clip instead (this - // behavior matches MacIE and Mozilla, at least) - const float PrintingMaximumShrinkFactor = 2.0f; - - float minLayoutWidth = width * PrintingMinimumShrinkFactor; - float maxLayoutWidth = width * PrintingMaximumShrinkFactor; - - // FIXME: This will modify the rendering of the on-screen frame. - // Could lead to flicker during printing. - m_frame->setPrinting(true, minLayoutWidth, maxLayoutWidth, true); - } + FrameView* view = coreFrame->view(); - // TODO: eliminate width param - void spoolPage(GraphicsContext& ctx, int pageNumber, float width) - { - IntRect pageRect = m_pageRects[pageNumber]; - float scale = width / pageRect.width(); - - ctx.save(); - ctx.scale(FloatSize(scale, scale)); - ctx.translate(-pageRect.x(), -pageRect.y()); - ctx.clip(pageRect); - m_frame->paint(&ctx, pageRect); - ctx.restore(); - } + if (view && view->layoutPending()) + view->layout(); - void end() - { - m_frame->setPrinting(false, 0, 0, true); - } + String string = externalRepresentation(coreFrame->contentRenderer()); + return g_strdup(string.utf8().data()); +} -protected: - Frame* m_frame; - Vector<IntRect> m_pageRects; -}; +#if GTK_CHECK_VERSION(2,10,0) static void begin_print(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) { @@ -647,6 +555,8 @@ void webkit_web_frame_print(WebKitWebFrame* frame) topLevel = NULL; Frame* coreFrame = core(frame); + ASSERT(coreFrame); + PrintContext printContext(coreFrame); GtkPrintOperation* op = gtk_print_operation_new(); diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h index a89da46..827e4b9 100644 --- a/WebKit/gtk/webkit/webkitwebframe.h +++ b/WebKit/gtk/webkit/webkitwebframe.h @@ -41,7 +41,7 @@ typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; struct _WebKitWebFrame { GObject parent_instance; - WebKitWebFramePrivate* priv; + WebKitWebFramePrivate *priv; }; struct _WebKitWebFrameClass { @@ -56,40 +56,44 @@ struct _WebKitWebFrameClass { }; WEBKIT_API GType -webkit_web_frame_get_type (void); +webkit_web_frame_get_type (void); -WEBKIT_API WebKitWebFrame* -webkit_web_frame_new (WebKitWebView* web_view); +#ifndef WEBKIT_DISABLE_DEPRECATED +WEBKIT_API WebKitWebFrame * +webkit_web_frame_new (WebKitWebView *web_view); +#endif -WEBKIT_API WebKitWebView* -webkit_web_frame_get_web_view (WebKitWebFrame* frame); +WEBKIT_API WebKitWebView * +webkit_web_frame_get_web_view (WebKitWebFrame *frame); -WEBKIT_API const gchar* -webkit_web_frame_get_name (WebKitWebFrame* frame); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_frame_get_name (WebKitWebFrame *frame); -WEBKIT_API const gchar* -webkit_web_frame_get_title (WebKitWebFrame* frame); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_frame_get_title (WebKitWebFrame *frame); -WEBKIT_API const gchar* -webkit_web_frame_get_uri (WebKitWebFrame* frame); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_frame_get_uri (WebKitWebFrame *frame); WEBKIT_API WebKitWebFrame* -webkit_web_frame_get_parent (WebKitWebFrame* frame); +webkit_web_frame_get_parent (WebKitWebFrame *frame); WEBKIT_API void -webkit_web_frame_load_request (WebKitWebFrame* frame, WebKitNetworkRequest* request); +webkit_web_frame_load_request (WebKitWebFrame *frame, + WebKitNetworkRequest *request); WEBKIT_API void -webkit_web_frame_stop_loading (WebKitWebFrame* frame); +webkit_web_frame_stop_loading (WebKitWebFrame *frame); WEBKIT_API void -webkit_web_frame_reload (WebKitWebFrame* frame); +webkit_web_frame_reload (WebKitWebFrame *frame); -WEBKIT_API WebKitWebFrame* -webkit_web_frame_find_frame (WebKitWebFrame* frame, const gchar* name); +WEBKIT_API WebKitWebFrame * +webkit_web_frame_find_frame (WebKitWebFrame *frame, + const gchar *name); WEBKIT_API JSGlobalContextRef -webkit_web_frame_get_global_context (WebKitWebFrame* frame); +webkit_web_frame_get_global_context (WebKitWebFrame *frame); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp index 5fbf8c1..150df68 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp @@ -34,18 +34,31 @@ using namespace WebKit; extern "C" { struct _WebKitWebHistoryItemPrivate { - WebCore::HistoryItem* historyItem; + WTF::RefPtr<WebCore::HistoryItem> historyItem; - gchar* title; - gchar* alternateTitle; - gchar* uri; - gchar* originalUri; + WebCore::CString title; + WebCore::CString alternateTitle; + WebCore::CString uri; + WebCore::CString originalUri; }; #define WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemPrivate)) +enum { + PROP_0, + + PROP_TITLE, + PROP_ALTERNATE_TITLE, + PROP_URI, + PROP_ORIGINAL_URI, + PROP_LAST_VISITED_TIME +}; + G_DEFINE_TYPE(WebKitWebHistoryItem, webkit_web_history_item, G_TYPE_OBJECT); +static void webkit_web_history_item_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec); + +static void webkit_web_history_item_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec); static GHashTable* webkit_history_items() { @@ -59,7 +72,6 @@ static void webkit_history_item_add(WebKitWebHistoryItem* webHistoryItem, WebCor GHashTable* table = webkit_history_items(); - historyItem->ref(); g_hash_table_insert(table, historyItem, g_object_ref(webHistoryItem)); } @@ -71,17 +83,14 @@ static void webkit_history_item_remove(WebCore::HistoryItem* historyItem) g_return_if_fail(webHistoryItem != NULL); g_hash_table_remove(table, historyItem); - historyItem->deref(); g_object_unref(webHistoryItem); } static void webkit_web_history_item_dispose(GObject* object) { WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); - WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - webkit_history_item_remove(priv->historyItem); - delete priv->historyItem; + webkit_history_item_remove(core(webHistoryItem)); /* destroy table if empty */ GHashTable* table = webkit_history_items(); @@ -96,10 +105,10 @@ static void webkit_web_history_item_finalize(GObject* object) WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - g_free(priv->title); - g_free(priv->alternateTitle); - g_free(priv->uri); - g_free(priv->originalUri); + priv->title = WebCore::CString(); + priv->alternateTitle = WebCore::CString(); + priv->uri = WebCore::CString(); + priv->originalUri = WebCore::CString(); G_OBJECT_CLASS(webkit_web_history_item_parent_class)->finalize(object); } @@ -110,6 +119,88 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass) gobject_class->dispose = webkit_web_history_item_dispose; gobject_class->finalize = webkit_web_history_item_finalize; + gobject_class->set_property = webkit_web_history_item_set_property; + gobject_class->get_property = webkit_web_history_item_get_property; + + /** + * WebKitWebHistoryItem:title: + * + * The title of the history item. + * + * Since: 1.0.2 + */ + g_object_class_install_property(gobject_class, + PROP_TITLE, + g_param_spec_string( + "title", + "Title", + "The title of the history item", + NULL, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitWebHistoryItem:alternate-title: + * + * The alternate title of the history item. + * + * Since: 1.0.2 + */ + g_object_class_install_property(gobject_class, + PROP_ALTERNATE_TITLE, + g_param_spec_string( + "alternate-title", + "Alternate Title", + "The alternate title of the history item", + NULL, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitWebHistoryItem:uri: + * + * The URI of the history item. + * + * Since: 1.0.2 + */ + g_object_class_install_property(gobject_class, + PROP_URI, + g_param_spec_string( + "uri", + "URI", + "The URI of the history item", + NULL, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitWebHistoryItem:original-uri: + * + * The original URI of the history item. + * + * Since: 1.0.2 + */ + g_object_class_install_property(gobject_class, + PROP_ORIGINAL_URI, + g_param_spec_string( + "original-uri", + "Original URI", + "The original URI of the history item", + NULL, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitWebHistoryItem:last-visited-time: + * + * The time at which the history item was last visited. + * + * Since: 1.0.2 + */ + g_object_class_install_property(gobject_class, + PROP_LAST_VISITED_TIME, + g_param_spec_double( + "last-visited-time", + "Last visited Time", + "The time at which the history item was last visited", + 0, G_MAXDOUBLE, 0, + WEBKIT_PARAM_READABLE)); g_type_class_add_private(gobject_class, sizeof(WebKitWebHistoryItemPrivate)); } @@ -119,16 +210,59 @@ static void webkit_web_history_item_init(WebKitWebHistoryItem* webHistoryItem) webHistoryItem->priv = WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(webHistoryItem); } +static void webkit_web_history_item_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); + + switch(prop_id) { + case PROP_ALTERNATE_TITLE: + webkit_web_history_item_set_alternate_title(webHistoryItem, g_value_get_string(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void webkit_web_history_item_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); + + switch (prop_id) { + case PROP_TITLE: + g_value_set_string(value, webkit_web_history_item_get_title(webHistoryItem)); + break; + case PROP_ALTERNATE_TITLE: + g_value_set_string(value, webkit_web_history_item_get_alternate_title(webHistoryItem)); + break; + case PROP_URI: + g_value_set_string(value, webkit_web_history_item_get_uri(webHistoryItem)); + break; + case PROP_ORIGINAL_URI: + g_value_set_string(value, webkit_web_history_item_get_original_uri(webHistoryItem)); + break; + case PROP_LAST_VISITED_TIME: + g_value_set_double(value, webkit_web_history_item_get_last_visited_time(webHistoryItem)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + /* Helper function to create a new WebHistoryItem instance when needed */ WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::HistoryItem* item) { WebKitWebHistoryItem* webHistoryItem = kit(item); - WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - if (!webHistoryItem) { + if (webHistoryItem) + g_object_ref(webHistoryItem); + else { webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL)); + WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; + priv->historyItem = item; - webkit_history_item_add(webHistoryItem, priv->historyItem); + webkit_history_item_add(webHistoryItem, priv->historyItem.get()); } return webHistoryItem; @@ -142,13 +276,13 @@ WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(WebCore::Histor * * Return value: the new #WebKitWebHistoryItem */ -WebKitWebHistoryItem* webkit_web_history_item_new(void) +WebKitWebHistoryItem* webkit_web_history_item_new() { WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL)); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - priv->historyItem = new WebCore::HistoryItem(); - webkit_history_item_add(webHistoryItem, priv->historyItem); + priv->historyItem = WebCore::HistoryItem::create(); + webkit_history_item_add(webHistoryItem, priv->historyItem.get()); return webHistoryItem; } @@ -165,13 +299,13 @@ WebKitWebHistoryItem* webkit_web_history_item_new(void) WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, const gchar* title) { WebCore::KURL historyUri(uri); - WebCore::String historyTitle(title); + WebCore::String historyTitle = WebCore::String::fromUTF8(title); - WebKitWebHistoryItem* webHistoryItem = webkit_web_history_item_new(); + WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL)); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - priv->historyItem = new WebCore::HistoryItem(historyUri, historyTitle); - webkit_history_item_add(webHistoryItem, priv->historyItem); + priv->historyItem = WebCore::HistoryItem::create(historyUri, historyTitle, 0); + webkit_history_item_add(webHistoryItem, priv->historyItem.get()); return webHistoryItem; } @@ -182,7 +316,7 @@ WebKitWebHistoryItem* webkit_web_history_item_new_with_data(const gchar* uri, co * * Returns the page title of @webHistoryItem */ -const gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryItem) +G_CONST_RETURN gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryItem) { g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); @@ -191,11 +325,9 @@ const gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryI g_return_val_if_fail(item != NULL, NULL); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - WebCore::String title = item->title(); - g_free(priv->title); - priv->title = g_strdup(title.utf8().data()); + priv->title = item->title().utf8(); - return priv->title; + return priv->title.data(); } /** @@ -206,7 +338,7 @@ const gchar* webkit_web_history_item_get_title(WebKitWebHistoryItem* webHistoryI * * Return value: the alternate title of @webHistoryItem */ -const gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* webHistoryItem) +G_CONST_RETURN gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* webHistoryItem) { g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); @@ -215,11 +347,9 @@ const gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* w g_return_val_if_fail(item != NULL, NULL); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - WebCore::String alternateTitle = item->alternateTitle(); - g_free(priv->alternateTitle); - priv->alternateTitle = g_strdup(alternateTitle.utf8().data()); + priv->alternateTitle = item->alternateTitle().utf8(); - return priv->alternateTitle; + return priv->alternateTitle.data(); } /** @@ -232,10 +362,12 @@ const gchar* webkit_web_history_item_get_alternate_title(WebKitWebHistoryItem* w void webkit_web_history_item_set_alternate_title(WebKitWebHistoryItem* webHistoryItem, const gchar* title) { g_return_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem)); + g_return_if_fail(title); WebCore::HistoryItem* item = core(webHistoryItem); item->setAlternateTitle(WebCore::String::fromUTF8(title)); + g_object_notify(G_OBJECT(webHistoryItem), "alternate-title"); } /** @@ -246,7 +378,7 @@ void webkit_web_history_item_set_alternate_title(WebKitWebHistoryItem* webHistor * * Return value: the URI of @webHistoryItem */ -const gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryItem) +G_CONST_RETURN gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryItem) { g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); @@ -254,12 +386,10 @@ const gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryIte g_return_val_if_fail(item != NULL, NULL); - WebCore::String uri = item->urlString(); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - g_free(priv->uri); - priv->uri = g_strdup(uri.utf8().data()); + priv->uri = item->urlString().utf8(); - return priv->uri; + return priv->uri.data(); } /** @@ -270,7 +400,7 @@ const gchar* webkit_web_history_item_get_uri(WebKitWebHistoryItem* webHistoryIte * * Return value: the original URI of @webHistoryITem */ -const gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webHistoryItem) +G_CONST_RETURN gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webHistoryItem) { g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); @@ -278,12 +408,10 @@ const gchar* webkit_web_history_item_get_original_uri(WebKitWebHistoryItem* webH g_return_val_if_fail(item != NULL, NULL); - WebCore::String originalUri = item->originalURLString(); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - g_free(priv->originalUri); - priv->originalUri = g_strdup(originalUri.utf8().data()); + priv->originalUri = item->originalURLString().utf8(); - return webHistoryItem->priv->originalUri; + return webHistoryItem->priv->originalUri.data(); } /** @@ -312,9 +440,9 @@ WebCore::HistoryItem* WebKit::core(WebKitWebHistoryItem* webHistoryItem) g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - WebCore::HistoryItem* historyItem = priv->historyItem; + WTF::RefPtr<WebCore::HistoryItem> historyItem = priv->historyItem; - return historyItem ? historyItem : 0; + return historyItem ? historyItem.get() : 0; } WebKitWebHistoryItem* WebKit::kit(WebCore::HistoryItem* historyItem) diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.h b/WebKit/gtk/webkit/webkitwebhistoryitem.h index 267ffb5..dd63f9d 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.h +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.h @@ -22,7 +22,6 @@ #include <glib.h> #include <glib-object.h> -#include <gdk/gdk.h> #include <webkit/webkitdefines.h> @@ -40,7 +39,7 @@ typedef struct _WebKitWebHistoryItemPrivate WebKitWebHistoryItemPrivate; struct _WebKitWebHistoryItem { GObject parent_instance; - WebKitWebHistoryItemPrivate* priv; + WebKitWebHistoryItemPrivate *priv; }; struct _WebKitWebHistoryItemClass { @@ -50,29 +49,31 @@ struct _WebKitWebHistoryItemClass { WEBKIT_API GType webkit_web_history_item_get_type (void); -WEBKIT_API WebKitWebHistoryItem* +WEBKIT_API WebKitWebHistoryItem * webkit_web_history_item_new (void); -WEBKIT_API WebKitWebHistoryItem* -webkit_web_history_item_new_with_data (const gchar* uri, const gchar* title); +WEBKIT_API WebKitWebHistoryItem * +webkit_web_history_item_new_with_data (const gchar *uri, + const gchar *title); -WEBKIT_API const gchar* -webkit_web_history_item_get_title (WebKitWebHistoryItem* web_history_item); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_history_item_get_title (WebKitWebHistoryItem *web_history_item); -WEBKIT_API const gchar* -webkit_web_history_item_get_alternate_title (WebKitWebHistoryItem* web_history_item); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_history_item_get_alternate_title (WebKitWebHistoryItem *web_history_item); WEBKIT_API void -webkit_web_history_item_set_alternate_title (WebKitWebHistoryItem* web_history_item, const gchar* title); +webkit_web_history_item_set_alternate_title (WebKitWebHistoryItem *web_history_item, + const gchar *title); -WEBKIT_API const gchar* -webkit_web_history_item_get_uri (WebKitWebHistoryItem* web_history_item); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_history_item_get_uri (WebKitWebHistoryItem *web_history_item); -WEBKIT_API const gchar* -webkit_web_history_item_get_original_uri (WebKitWebHistoryItem* web_history_item); +WEBKIT_API G_CONST_RETURN gchar * +webkit_web_history_item_get_original_uri (WebKitWebHistoryItem *web_history_item); WEBKIT_API gdouble -webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem* web_history_item); +webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem *web_history_item); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp new file mode 100644 index 0000000..437fe2b --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebinspector.cpp @@ -0,0 +1,368 @@ +/* + * Copyright (C) 2008 Gustavo Noronha Silva + * + * 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 "webkitwebinspector.h" +#include "webkitmarshal.h" +#include "InspectorClientGtk.h" +#include "webkitprivate.h" + +using namespace WebKit; + +extern "C" { + +enum { + INSPECT_WEB_VIEW, + SHOW_WINDOW, + ATTACH_WINDOW, + DETACH_WINDOW, + CLOSE_WINDOW, + FINISHED, + LAST_SIGNAL +}; + +static guint webkit_web_inspector_signals[LAST_SIGNAL] = { 0, }; + +enum { + PROP_0, + + PROP_WEB_VIEW, + PROP_INSPECTED_URI, +}; + +G_DEFINE_TYPE(WebKitWebInspector, webkit_web_inspector, G_TYPE_OBJECT) + +struct _WebKitWebInspectorPrivate { + InspectorClient* inspectorClient; + WebKitWebView* inspector_view; + gchar* inspected_uri; +}; + +#define WEBKIT_WEB_INSPECTOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorPrivate)) + +static void webkit_web_inspector_finalize(GObject* object); + +static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec); + +static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec); + +static gboolean webkit_inspect_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy) +{ + gboolean continueEmission = TRUE; + gpointer newWebView = g_value_get_object(handlerReturn); + g_value_set_object(returnAccu, newWebView); + + if (newWebView) + continueEmission = FALSE; + + return continueEmission; +} + +static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) +{ + GObjectClass* gobject_class = G_OBJECT_CLASS(klass); + gobject_class->finalize = webkit_web_inspector_finalize; + gobject_class->set_property = webkit_web_inspector_set_property; + gobject_class->get_property = webkit_web_inspector_get_property; + + /** + * WebKitWebInspector::inspect-web-view: + * @web_inspector: the object on which the signal is emitted + * @web_view: the #WebKitWeb which will be inspected + * @return: a newly allocated #WebKitWebView or %NULL + * + * Emitted when the user activates the 'inspect' context menu item + * to inspect a web view. The application which is interested in + * the inspector should create a window, or otherwise add the + * #WebKitWebView it creates to an existing window. + * + * You don't need to handle the reference count of the + * #WebKitWebView instance you create; the widget to which you add + * it will do that. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[INSPECT_WEB_VIEW] = g_signal_new("inspect-web-view", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + webkit_inspect_web_view_request_handled, + NULL, + webkit_marshal_OBJECT__OBJECT, + WEBKIT_TYPE_WEB_VIEW , 1, + WEBKIT_TYPE_WEB_VIEW); + + /** + * WebKitWebInspector::show-window: + * @web_inspector: the object on which the signal is emitted + * @return: %TRUE if the signal has been handled + * + * Emitted when the inspector window should be displayed. Notice + * that the window must have been created already by handling + * ::inspect-web-view. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[SHOW_WINDOW] = g_signal_new("show-window", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN , 0); + + /** + * WebKitWebInspector::attach-window: + * @web_inspector: the object on which the signal is emitted + * @return: %TRUE if the signal has been handled + * + * Emitted when the inspector should appear at the same window as + * the #WebKitWebView being inspected. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[ATTACH_WINDOW] = g_signal_new("attach-window", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN , 0); + + /** + * WebKitWebInspector::detach-window: + * @web_inspector: the object on which the signal is emitted + * @return: %TRUE if the signal has been handled + * + * Emitted when the inspector should appear in a separate window. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[DETACH_WINDOW] = g_signal_new("detach-window", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN , 0); + + /** + * WebKitWebInspector::close-window: + * @web_inspector: the object on which the signal is emitted + * @return: %TRUE if the signal has been handled + * + * 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. + * + * 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 + * inspects an element. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[CLOSE_WINDOW] = g_signal_new("close-window", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + g_signal_accumulator_true_handled, + NULL, + webkit_marshal_BOOLEAN__VOID, + G_TYPE_BOOLEAN , 0); + + /** + * WebKitWebInspector::finished: + * @web_inspector: the object on which the signal is emitted + * + * Emitted when the inspection is done. You should release your + * references on the inspector at this time. The inspected + * #WebKitWebView may no longer exist when this signal is emitted. + * + * Since: 1.0.3 + */ + webkit_web_inspector_signals[FINISHED] = g_signal_new("finished", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE , 0); + + /* + * properties + */ + + /** + * WebKitWebInspector:web-view: + * + * The Web View that renders the Web Inspector itself. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, PROP_WEB_VIEW, + g_param_spec_object("web-view", + "Web View", + "The Web View that renders the Web Inspector itself", + WEBKIT_TYPE_WEB_VIEW, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitWebInspector:inspected-uri: + * + * The URI that is currently being inspected. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, PROP_INSPECTED_URI, + g_param_spec_string("inspected-uri", + "Inspected URI", + "The URI that is currently being inspected", + NULL, + WEBKIT_PARAM_READABLE)); + + g_type_class_add_private(klass, sizeof(WebKitWebInspectorPrivate)); +} + +static void webkit_web_inspector_init(WebKitWebInspector* web_inspector) +{ + web_inspector->priv = WEBKIT_WEB_INSPECTOR_GET_PRIVATE(web_inspector); +} + +static void webkit_web_inspector_finalize(GObject* object) +{ + WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object); + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + if (priv->inspector_view) + g_object_unref(priv->inspector_view); + + if (priv->inspected_uri) + g_free(priv->inspected_uri); + + G_OBJECT_CLASS(webkit_web_inspector_parent_class)->finalize(object); +} + +static void webkit_web_inspector_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch(prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +static void webkit_web_inspector_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebKitWebInspector* web_inspector = WEBKIT_WEB_INSPECTOR(object); + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + switch (prop_id) { + case PROP_WEB_VIEW: + g_value_set_object(value, priv->inspector_view); + break; + case PROP_INSPECTED_URI: + g_value_set_string(value, priv->inspected_uri); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + +// internal use only +void webkit_web_inspector_set_web_view(WebKitWebInspector *web_inspector, WebKitWebView *web_view) +{ + g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector)); + g_return_if_fail(WEBKIT_IS_WEB_VIEW(web_view)); + + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + if (priv->inspector_view) + g_object_unref(priv->inspector_view); + + g_object_ref(web_view); + priv->inspector_view = web_view; +} + +/** + * webkit_web_inspector_get_web_view: + * + * 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 + * that this method may return %NULL if the user hasn't inspected + * anything. + * + * Returns: the #WebKitWebView instance that is used to render the + * inspector or %NULL if it is not yet created. + * + * Since: 1.0.3 + **/ +WebKitWebView* webkit_web_inspector_get_web_view(WebKitWebInspector *web_inspector) +{ + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + return priv->inspector_view; +} + +// internal use only +void webkit_web_inspector_set_inspected_uri(WebKitWebInspector* web_inspector, const gchar* inspected_uri) +{ + g_return_if_fail(WEBKIT_IS_WEB_INSPECTOR(web_inspector)); + + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + g_free(priv->inspected_uri); + priv->inspected_uri = g_strdup(inspected_uri); +} + +/** + * webkit_web_inspector_get_inspected_uri: + * + * Obtains the URI that is currently being inspected. + * + * Returns: a pointer to the URI as an internally allocated string; it + * should not be freed, modified or stored. + * + * Since: 1.0.3 + **/ +const gchar* webkit_web_inspector_get_inspected_uri(WebKitWebInspector *web_inspector) +{ + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + return priv->inspected_uri; +} + +void +webkit_web_inspector_set_inspector_client(WebKitWebInspector* web_inspector, WebKit::InspectorClient* inspectorClient) +{ + WebKitWebInspectorPrivate* priv = web_inspector->priv; + + priv->inspectorClient = inspectorClient; +} + +} diff --git a/WebKit/gtk/webkit/webkitwebinspector.h b/WebKit/gtk/webkit/webkitwebinspector.h new file mode 100644 index 0000000..41ccf92 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebinspector.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2008 Gustavo Noronha Silva + * + * 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_INSPECTOR_H__ +#define __WEBKIT_WEB_INSPECTOR_H__ + +#include <glib-object.h> + +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_WEB_INSPECTOR (webkit_web_inspector_get_type()) +#define WEBKIT_WEB_INSPECTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspector)) +#define WEBKIT_WEB_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass)) +#define WEBKIT_IS_WEB_INSPECTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_INSPECTOR)) +#define WEBKIT_IS_WEB_INSPECTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_INSPECTOR)) +#define WEBKIT_WEB_INSPECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorClass)) + +typedef struct _WebKitWebInspectorPrivate WebKitWebInspectorPrivate; + +struct _WebKitWebInspector { + GObject parent_instance; + + WebKitWebInspectorPrivate* priv; +}; + +struct _WebKitWebInspectorClass { + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_webkit_reserved1) (void); + void (*_webkit_reserved2) (void); + void (*_webkit_reserved3) (void); + void (*_webkit_reserved4) (void); +}; + +WEBKIT_API GType +webkit_web_inspector_get_type (void); + +WEBKIT_API WebKitWebView* +webkit_web_inspector_get_web_view(WebKitWebInspector* web_inspector); + +WEBKIT_API const gchar* +webkit_web_inspector_get_inspected_uri(WebKitWebInspector* web_inspector); + +G_END_DECLS + +#endif /* __WEBKIT_WEB_INSPECTOR_H__ */ diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 43b2209..49ab4c6 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -1,5 +1,7 @@ /* * Copyright (C) 2008 Christian Dywan <christian@imendio.com> + * Copyright (C) 2008 Nuanti Ltd. + * 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 @@ -45,6 +47,8 @@ struct _WebKitWebSettingsPrivate { gboolean enable_plugins; gboolean resizable_text_areas; gchar* user_stylesheet_uri; + gfloat zoom_step; + gboolean enable_developer_extras; }; #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate)) @@ -69,7 +73,9 @@ enum { PROP_ENABLE_SCRIPTS, PROP_ENABLE_PLUGINS, PROP_RESIZABLE_TEXT_AREAS, - PROP_USER_STYLESHEET_URI + PROP_USER_STYLESHEET_URI, + PROP_ZOOM_STEP, + PROP_ENABLE_DEVELOPER_EXTRAS }; static void webkit_web_settings_finalize(GObject* object); @@ -248,6 +254,41 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) 0, flags)); + /** + * WebKitWebSettings:zoom-step: + * + * The value by which the zoom level is changed when zooming in or out. + * + * Since: 1.0.1 + */ + g_object_class_install_property(gobject_class, + PROP_ZOOM_STEP, + g_param_spec_float( + "zoom-step", + "Zoom Stepping Value", + "The value by which the zoom level is changed when zooming in or out.", + 0.0f, G_MAXFLOAT, 0.1f, + flags)); + + /** + * WebKitWebSettings:enable-developer-extras: + * + * Whether developer extensions should be enabled. This enables, + * for now, the Web Inspector, which can be controlled using the + * #WebKitWebInspector instance held by the #WebKitWebView this + * setting is enabled for. + * + * Since: 1.0.3 + */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_DEVELOPER_EXTRAS, + g_param_spec_boolean( + "enable-developer-extras", + "Enable Developer Extras", + "Enables special extensions that help developers", + FALSE, + flags)); + g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate)); } @@ -341,6 +382,12 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con g_free(priv->user_stylesheet_uri); priv->user_stylesheet_uri = g_strdup(g_value_get_string(value)); break; + case PROP_ZOOM_STEP: + priv->zoom_step = g_value_get_float(value); + break; + case PROP_ENABLE_DEVELOPER_EXTRAS: + priv->enable_developer_extras = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -407,6 +454,12 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_USER_STYLESHEET_URI: g_value_set_string(value, priv->user_stylesheet_uri); break; + case PROP_ZOOM_STEP: + g_value_set_float(value, priv->zoom_step); + break; + case PROP_ENABLE_DEVELOPER_EXTRAS: + g_value_set_boolean(value, priv->enable_developer_extras); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -456,6 +509,8 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "enable-plugins", priv->enable_plugins, "resizable-text-areas", priv->resizable_text_areas, "user-stylesheet-uri", priv->user_stylesheet_uri, + "zoom-step", priv->zoom_step, + "enable-developer-extras", priv->enable_developer_extras, NULL)); return copy; diff --git a/WebKit/gtk/webkit/webkitwebsettings.h b/WebKit/gtk/webkit/webkitwebsettings.h index a21ccf4..33fa54a 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.h +++ b/WebKit/gtk/webkit/webkitwebsettings.h @@ -38,7 +38,7 @@ typedef struct _WebKitWebSettingsPrivate WebKitWebSettingsPrivate; struct _WebKitWebSettings { GObject parent_instance; - WebKitWebSettingsPrivate* priv; + WebKitWebSettingsPrivate *priv; }; struct _WebKitWebSettingsClass { @@ -52,13 +52,13 @@ struct _WebKitWebSettingsClass { }; WEBKIT_API GType -webkit_web_settings_get_type(void); +webkit_web_settings_get_type (void); -WEBKIT_API WebKitWebSettings* -webkit_web_settings_new(void); +WEBKIT_API WebKitWebSettings * +webkit_web_settings_new (void); -WEBKIT_API WebKitWebSettings* -webkit_web_settings_copy(WebKitWebSettings* web_settings); +WEBKIT_API WebKitWebSettings * +webkit_web_settings_copy (WebKitWebSettings *web_settings); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index d5834db..2c90b4e 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -2,8 +2,10 @@ * Copyright (C) 2007 Holger Hans Peter Freyther * Copyright (C) 2007, 2008 Christian Dywan <christian@imendio.com> * Copyright (C) 2007 Xan Lopez <xan@gnome.org> - * Copyright (C) 2007 Alp Toker <alp@atoker.com> + * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com> + * Copyright (C) 2008 Nuanti Ltd. + * Copyright (C) 2008 Collabora Ltd. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,11 +25,13 @@ #include "config.h" #include "webkitwebview.h" -#include "webkit-marshal.h" +#include "webkitmarshal.h" #include "webkitprivate.h" +#include "webkitwebinspector.h" #include "webkitwebbackforwardlist.h" #include "webkitwebhistoryitem.h" +#include "AXObjectCache.h" #include "NotImplemented.h" #include "BackForwardList.h" #include "CString.h" @@ -36,6 +40,7 @@ #include "ContextMenuClientGtk.h" #include "ContextMenuController.h" #include "Cursor.h" +#include "Document.h" #include "DragClientGtk.h" #include "Editor.h" #include "EditorClientGtk.h" @@ -52,10 +57,14 @@ #include "PasteboardHelper.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" +#include "Scrollbar.h" #include "SubstituteData.h" +#include <wtf/GOwnPtr.h> #include <gdk/gdkkeysyms.h> +static const double defaultDPI = 96.0; + using namespace WebKit; using namespace WebCore; @@ -92,13 +101,19 @@ enum { PROP_COPY_TARGET_LIST, PROP_PASTE_TARGET_LIST, PROP_EDITABLE, - PROP_SETTINGS + PROP_SETTINGS, + PROP_WEB_INSPECTOR, + PROP_TRANSPARENT, + PROP_ZOOM_LEVEL, + PROP_FULL_CONTENT_ZOOM }; 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_context_menu_position_func(GtkMenu*, gint* x, gint* y, gboolean* pushIn, WebKitWebViewPrivate* data) { *pushIn = FALSE; @@ -111,6 +126,10 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie Page* page = core(webView); page->contextMenuController()->clearContextMenu(); Frame* focusedFrame = page->focusController()->focusedOrMainFrame(); + + if (!focusedFrame->view()) + return FALSE; + focusedFrame->view()->setCursor(pointerCursor()); bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event); if (!handledEvent) @@ -148,8 +167,11 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) // The context menu event was generated from the keyboard, so show the context menu by the current selection. Page* page = core(WEBKIT_WEB_VIEW(widget)); FrameView* view = page->mainFrame()->view(); - Position start = page->mainFrame()->selectionController()->selection().start(); - Position end = page->mainFrame()->selectionController()->selection().end(); + if (!view) + return FALSE; + + Position start = page->mainFrame()->selection()->selection().start(); + Position end = page->mainFrame()->selection()->selection().end(); int rightAligned = FALSE; IntPoint location; @@ -163,8 +185,16 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) // Calculate the rect of the first line of the selection (cribbed from -[WebCoreFrameBridge firstRectForDOMRange:]). int extraWidthToEndOfLine = 0; - IntRect startCaretRect = renderer->caretRect(start.offset(), DOWNSTREAM, &extraWidthToEndOfLine); - IntRect endCaretRect = renderer->caretRect(end.offset(), UPSTREAM); + + InlineBox* startInlineBox; + int startCaretOffset; + start.getInlineBoxAndOffset(DOWNSTREAM, startInlineBox, startCaretOffset); + IntRect startCaretRect = renderer->caretRect(startInlineBox, startCaretOffset, &extraWidthToEndOfLine); + + InlineBox* endInlineBox; + int endCaretOffset; + end.getInlineBoxAndOffset(UPSTREAM, endInlineBox, endCaretOffset); + IntRect endCaretRect = renderer->caretRect(endInlineBox, endCaretOffset); IntRect firstRect; if (startCaretRect.y() == endCaretRect.y()) @@ -182,7 +212,7 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) } int x, y; - gdk_window_get_origin(GTK_WIDGET(view->containingWindow())->window, &x, &y); + gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformWindow())->window, &x, &y); // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element. // Ideally we'd have the position of a context menu event be separate from its target node. @@ -198,18 +228,32 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* WebKitWebView* webView = WEBKIT_WEB_VIEW(object); switch(prop_id) { +#if GTK_CHECK_VERSION(2,10,0) case PROP_COPY_TARGET_LIST: g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView)); break; case PROP_PASTE_TARGET_LIST: g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView)); break; +#endif case PROP_EDITABLE: g_value_set_boolean(value, webkit_web_view_get_editable(webView)); break; case PROP_SETTINGS: g_value_set_object(value, webkit_web_view_get_settings(webView)); break; + case PROP_WEB_INSPECTOR: + g_value_set_object(value, webkit_web_view_get_inspector(webView)); + break; + case PROP_TRANSPARENT: + g_value_set_boolean(value, webkit_web_view_get_transparent(webView)); + break; + case PROP_ZOOM_LEVEL: + g_value_set_float(value, webkit_web_view_get_zoom_level(webView)); + break; + case PROP_FULL_CONTENT_ZOOM: + g_value_set_boolean(value, webkit_web_view_get_full_content_zoom(webView)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } @@ -226,26 +270,79 @@ 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_TRANSPARENT: + webkit_web_view_set_transparent(webView, g_value_get_boolean(value)); + break; + case PROP_ZOOM_LEVEL: + webkit_web_view_set_zoom_level(webView, g_value_get_float(value)); + break; + case PROP_FULL_CONTENT_ZOOM: + webkit_web_view_set_full_content_zoom(webView, g_value_get_boolean(value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); } } +static bool shouldCoalesce(GdkRectangle rect, GdkRectangle* rects, int count) +{ + const int cRectThreshold = 10; + const float cWastedSpaceThreshold = 0.75f; + bool useUnionedRect = (count <= 1) || (count > cRectThreshold); + if (!useUnionedRect) { + // Attempt to guess whether or not we should use the unioned rect or the individual rects. + // We do this by computing the percentage of "wasted space" in the union. If that wasted space + // is too large, then we will do individual rect painting instead. + float unionPixels = (rect.width * rect.height); + float singlePixels = 0; + for (int i = 0; i < count; ++i) + singlePixels += rects[i].width * rects[i].height; + float wastedSpace = 1 - (singlePixels / unionPixels); + if (wastedSpace <= cWastedSpaceThreshold) + useUnionedRect = true; + } + return useUnionedRect; +} + static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + WebKitWebViewPrivate* priv = webView->priv; Frame* frame = core(webView)->mainFrame(); - GdkRectangle clip; - gdk_region_get_clipbox(event->region, &clip); - cairo_t* cr = gdk_cairo_create(event->window); - GraphicsContext ctx(cr); - ctx.setGdkExposeEvent(event); - if (frame->renderer()) { + if (frame->contentRenderer() && frame->view()) { frame->view()->layoutIfNeededRecursive(); - frame->view()->paint(&ctx, clip); + + cairo_t* cr = gdk_cairo_create(event->window); + GraphicsContext ctx(cr); + cairo_destroy(cr); + ctx.setGdkExposeEvent(event); + + GOwnPtr<GdkRectangle> rects; + int rectCount; + gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount); + + // Avoid recursing into the render tree excessively + bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount); + + if (coalesce) { + IntRect rect = event->area; + ctx.clip(rect); + if (priv->transparent) + ctx.clearRect(rect); + frame->view()->paint(&ctx, rect); + } else { + for (int i = 0; i < rectCount; i++) { + IntRect rect = rects.get()[i]; + ctx.save(); + ctx.clip(rect); + if (priv->transparent) + ctx.clearRect(rect); + frame->view()->paint(&ctx, rect); + ctx.restore(); + } + } } - cairo_destroy(cr); return FALSE; } @@ -257,6 +354,9 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); PlatformKeyboardEvent keyboardEvent(event); + if (!frame->view()) + return FALSE; + if (frame->eventHandler()->keyEvent(keyboardEvent)) return TRUE; @@ -271,22 +371,22 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey* // approach more like the Win and Mac ports for key handling. switch (event->keyval) { case GDK_Down: - view->scrollBy(0, LINE_STEP); + view->scrollBy(IntSize(0, cScrollbarPixelsPerLineStep)); return TRUE; case GDK_Up: - view->scrollBy(0, -LINE_STEP); + view->scrollBy(IntSize(0, -cScrollbarPixelsPerLineStep)); return TRUE; case GDK_Right: - view->scrollBy(LINE_STEP, 0); + view->scrollBy(IntSize(cScrollbarPixelsPerLineStep, 0)); return TRUE; case GDK_Left: - view->scrollBy(-LINE_STEP, 0); + view->scrollBy(IntSize(-cScrollbarPixelsPerLineStep, 0)); return TRUE; case GDK_Home: - frame->selectionController()->modify(alteration, SelectionController::BACKWARD, DocumentBoundary, true); + frame->selection()->modify(alteration, SelectionController::BACKWARD, DocumentBoundary, true); return TRUE; case GDK_End: - frame->selectionController()->modify(alteration, SelectionController::FORWARD, DocumentBoundary, true); + frame->selection()->modify(alteration, SelectionController::FORWARD, DocumentBoundary, true); return TRUE; } @@ -299,6 +399,9 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); + if (!frame->view()) + return FALSE; + PlatformKeyboardEvent keyboardEvent(event); if (frame->eventHandler()->keyEvent(keyboardEvent)) @@ -312,33 +415,37 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); - Frame* frame = core(webView)->mainFrame(); - // FIXME: need to keep track of subframe focus for key events gtk_widget_grab_focus(widget); if (event->button == 3) return webkit_web_view_forward_context_menu_event(webView, PlatformMouseEvent(event)); + Frame* frame = core(webView)->mainFrame(); + if (!frame->view()) + return FALSE; + return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event)); } static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); - WebKitWebViewPrivate* priv = webView->priv; + Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); if (focusedFrame && focusedFrame->editor()->canEdit()) { - GdkWindow* window = gtk_widget_get_parent_window(widget); - gtk_im_context_set_client_window(priv->imContext, window); #ifdef MAEMO_CHANGES + WebKitWebViewPrivate* priv = webView->priv; hildon_gtk_im_context_filter_event(priv->imContext, (GdkEvent*)event); - hildon_gtk_im_context_show(priv->imContext); #endif } - return focusedFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); + Frame* mainFrame = core(webView)->mainFrame(); + if (!mainFrame->view()) + return FALSE; + + return mainFrame->eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event)); } static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* event) @@ -346,6 +453,9 @@ static gboolean webkit_web_view_motion_event(GtkWidget* widget, GdkEventMotion* WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); Frame* frame = core(webView)->mainFrame(); + if (!frame->view()) + return FALSE; + return frame->eventHandler()->mouseMoved(PlatformMouseEvent(event)); } @@ -354,6 +464,9 @@ static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll* WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); Frame* frame = core(webView)->mainFrame(); + if (!frame->view()) + return FALSE; + PlatformWheelEvent wheelEvent(event); return frame->eventHandler()->handleWheelEvent(wheelEvent); } @@ -365,6 +478,9 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); Frame* frame = core(webView)->mainFrame(); + if (!frame->view()) + return; + frame->view()->resize(allocation->width, allocation->height); frame->forceLayout(); frame->view()->adjustViewSize(); @@ -384,6 +500,15 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event); } +static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus* event) +{ + WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + + core(webView)->focusController()->setActive(false); + + return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event); +} + static void webkit_web_view_realize(GtkWidget* widget) { GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); @@ -415,11 +540,34 @@ static void webkit_web_view_realize(GtkWidget* widget) widget->style = gtk_style_attach(widget->style, widget->window); gdk_window_set_background(widget->window, &widget->style->base[GTK_WIDGET_STATE(widget)]); + + WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + WebKitWebViewPrivate* priv = webView->priv; + gtk_im_context_set_client_window(priv->imContext, widget->window); } static void webkit_web_view_set_scroll_adjustments(WebKitWebView* webView, GtkAdjustment* hadj, GtkAdjustment* vadj) { FrameView* view = core(webkit_web_view_get_main_frame(webView))->view(); + + if (hadj) + g_object_ref(hadj); + if (vadj) + g_object_ref(vadj); + + WebKitWebViewPrivate* priv = webView->priv; + + if (priv->horizontalAdjustment) + g_object_unref(priv->horizontalAdjustment); + if (priv->verticalAdjustment) + g_object_unref(priv->verticalAdjustment); + + priv->horizontalAdjustment = hadj; + priv->verticalAdjustment = vadj; + + if (!view) + return; + view->setGtkAdjustments(hadj, vadj); } @@ -610,10 +758,17 @@ static void webkit_web_view_finalize(GObject* object) webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object)); + core(priv->mainFrame)->loader()->detachChildren(); delete priv->corePage; + if (priv->horizontalAdjustment) + g_object_unref(priv->horizontalAdjustment); + 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); @@ -635,6 +790,26 @@ static gboolean webkit_navigation_request_handled(GSignalInvocationHint* ihint, return continueEmission; } +static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget) +{ + WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + AXObjectCache::enableAccessibility(); + + Frame* coreFrame = core(webView)->mainFrame(); + if (!coreFrame) + return NULL; + + Document* doc = coreFrame->document(); + if (!doc) + return NULL; + + AccessibilityObject* coreAccessible = doc->axObjectCache()->get(doc->renderer()); + if (!coreAccessible || !coreAccessible->wrapper()) + return NULL; + + return coreAccessible->wrapper(); +} + static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) { GtkBindingSet* binding_set; @@ -762,6 +937,14 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING); + /** + * WebKitWebView::hovering-over-link: + * @web_view: the object on which the signal is emitted + * @title: the link's title + * @uri: the URI the link points to + * + * When the cursor is over a link, this signal is emitted. + */ webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link", G_TYPE_FROM_CLASS(webViewClass), (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), @@ -857,7 +1040,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) NULL, webkit_marshal_BOOLEAN__OBJECT_STRING, G_TYPE_BOOLEAN, 2, - G_TYPE_OBJECT, G_TYPE_STRING); + WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING); /** * WebKitWebView::script-confirm: @@ -877,7 +1060,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) NULL, webkit_marshal_BOOLEAN__OBJECT_STRING_BOOLEAN, G_TYPE_BOOLEAN, 3, - G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_BOOLEAN); + WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_BOOLEAN); /** * WebKitWebView::script-prompt: @@ -898,7 +1081,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) NULL, webkit_marshal_BOOLEAN__OBJECT_STRING_STRING_STRING, G_TYPE_BOOLEAN, 4, - G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); + WEBKIT_TYPE_WEB_FRAME, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); /** * WebKitWebView::select-all: @@ -1001,6 +1184,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) widgetClass->size_allocate = webkit_web_view_size_allocate; widgetClass->popup_menu = webkit_web_view_popup_menu_handler; widgetClass->focus_in_event = webkit_web_view_focus_in_event; + widgetClass->focus_out_event = webkit_web_view_focus_out_event; + widgetClass->get_accessible = webkit_web_view_get_accessible; GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass); containerClass->add = webkit_web_view_container_add; @@ -1048,19 +1233,36 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) /* * properties */ + +#if GTK_CHECK_VERSION(2,10,0) + /** + * WebKitWebView:copy-target-list: + * + * The list of targets this web view supports for clipboard copying. + * + * Since: 1.0.2 + */ g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST, g_param_spec_boxed("copy-target-list", - "Target list", - "The list of targets this Web view supports for copying to the clipboard", + "Copy target list", + "The list of targets this web view supports for clipboard copying", GTK_TYPE_TARGET_LIST, WEBKIT_PARAM_READABLE)); + /** + * WebKitWebView:paste-target-list: + * + * The list of targets this web view supports for clipboard pasting. + * + * Since: 1.0.2 + */ g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST, g_param_spec_boxed("paste-target-list", - "Target list", - "The list of targets this Web view supports for pasting to the clipboard", + "Paste target list", + "The list of targets this web view supports for clipboard pasting", GTK_TYPE_TARGET_LIST, WEBKIT_PARAM_READABLE)); +#endif g_object_class_install_property(objectClass, PROP_SETTINGS, g_param_spec_object("settings", @@ -1069,6 +1271,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_SETTINGS, WEBKIT_PARAM_READWRITE)); + /** + * WebKitWebView:web-inspector: + * + * The associated WebKitWebInspector instance. + * + * Since: 1.0.3 + */ + g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR, + g_param_spec_object("web-inspector", + "Web Inspector", + "The associated WebKitWebInspector instance", + WEBKIT_TYPE_WEB_INSPECTOR, + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(objectClass, PROP_EDITABLE, g_param_spec_boolean("editable", "Editable", @@ -1076,6 +1292,43 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) FALSE, WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(objectClass, PROP_TRANSPARENT, + g_param_spec_boolean("transparent", + "Transparent", + "Whether content has a transparent background", + FALSE, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitWebView:zoom-level: + * + * The level of zoom of the content. + * + * Since: 1.0.1 + */ + g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL, + g_param_spec_float("zoom-level", + "Zoom level", + "The level of zoom of the content", + G_MINFLOAT, + G_MAXFLOAT, + 1.0f, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitWebView:full-content-zoom: + * + * Whether the full content is scaled when zooming. + * + * Since: 1.0.1 + */ + g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM, + g_param_spec_boolean("full-content-zoom", + "Full content zoom", + "Whether the full content is scaled when zooming", + FALSE, + WEBKIT_PARAM_READWRITE)); + g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate)); } @@ -1094,13 +1347,17 @@ static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* pr "minimum-logical-font-size", &minimumLogicalFontSize, NULL); -#if GTK_CHECK_VERSION(2, 10, 0) + gdouble DPI = defaultDPI; +#if GTK_CHECK_VERSION(2,10,0) GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default(); - gdouble DPI = gdk_screen_get_resolution(screen); -#else - gdouble DPI = 96; - g_warning("Cannot retrieve resolution, falling back to 96 DPI"); + if (screen) { + DPI = gdk_screen_get_resolution(screen); + // gdk_screen_get_resolution() returns -1 when no DPI is set. + if (DPI == -1) + DPI = defaultDPI; + } #endif + ASSERT(DPI > 0); settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI); settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI); settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI); @@ -1114,7 +1371,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) Settings* settings = core(webView)->settings(); gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri; - gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, resizableTextAreas; + gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas; g_object_get(G_OBJECT(webSettings), "default-encoding", &defaultEncoding, @@ -1131,6 +1388,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "enable-plugins", &enablePlugins, "resizable-text-areas", &resizableTextAreas, "user-stylesheet-uri", &userStylesheetUri, + "enable-developer-extras", &enableDeveloperExtras, NULL); settings->setDefaultTextEncodingName(defaultEncoding); @@ -1146,7 +1404,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) settings->setJavaScriptEnabled(enableScripts); settings->setPluginsEnabled(enablePlugins); settings->setTextAreasAreResizable(resizableTextAreas); - settings->setUserStyleSheetLocation(userStylesheetUri); + settings->setUserStyleSheetLocation(KURL(userStylesheetUri)); + settings->setDeveloperExtrasEnabled(enableDeveloperExtras); g_free(defaultEncoding); g_free(cursiveFontFamily); @@ -1165,7 +1424,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar Settings* settings = core(webView)->settings(); const gchar* name = g_intern_string(pspec->name); - GValue value = {0, 0}; + GValue value = { 0, { { 0 } } }; g_value_init(&value, pspec->value_type); g_object_get_property(G_OBJECT(webSettings), name, &value); @@ -1204,8 +1463,10 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar else if (name == g_intern_string("resizable-text-areas")) settings->setTextAreasAreResizable(g_value_get_boolean(&value)); else if (name == g_intern_string("user-stylesheet-uri")) - settings->setUserStyleSheetLocation(g_value_get_string(&value)); - else + settings->setUserStyleSheetLocation(KURL(g_value_get_string(&value))); + else if (name == g_intern_string("enable-developer-extras")) + settings->setDeveloperExtrasEnabled(g_value_get_boolean(&value)); + else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name)) g_warning("Unexpected setting '%s'", name); g_value_unset(&value); } @@ -1216,7 +1477,27 @@ static void webkit_web_view_init(WebKitWebView* webView) webView->priv = priv; priv->imContext = gtk_im_multicontext_new(); - priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient, new WebKit::EditorClient(webView), new WebKit::DragClient, new WebKit::InspectorClient); + + WebKit::InspectorClient* inspectorClient = new WebKit::InspectorClient(webView); + priv->corePage = new Page(new WebKit::ChromeClient(webView), new WebKit::ContextMenuClient(webView), new WebKit::EditorClient(webView), new WebKit::DragClient, inspectorClient); + + // We also add a simple wrapper class to provide the public + // interface for the Web Inspector. + priv->webInspector = WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL)); + webkit_web_inspector_set_inspector_client(priv->webInspector, inspectorClient); + + priv->horizontalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); + priv->verticalAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 0.0, 0.0, 0.0, 0.0)); + +#if GLIB_CHECK_VERSION(2,10,0) + g_object_ref_sink(priv->horizontalAdjustment); + g_object_ref_sink(priv->verticalAdjustment); +#else + g_object_ref(priv->horizontalAdjustment); + gtk_object_sink(GTK_OBJECT(priv->horizontalAdjustment)); + g_object_ref(priv->verticalAdjustment); + gtk_object_sink(GTK_OBJECT(priv->verticalAdjustment)); +#endif GTK_WIDGET_SET_FLAGS(webView, GTK_CAN_FOCUS); priv->mainFrame = WEBKIT_WEB_FRAME(webkit_web_frame_new(webView)); @@ -1225,6 +1506,8 @@ static void webkit_web_view_init(WebKitWebView* webView) priv->backForwardList = webkit_web_back_forward_list_new_with_web_view(webView); + priv->zoomFullContent = FALSE; + #if GTK_CHECK_VERSION(2,10,0) GdkAtom textHtml = gdk_atom_intern_static_string("text/html"); #else @@ -1265,6 +1548,7 @@ void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* web priv->webSettings = webSettings; webkit_web_view_update_settings(webView); g_signal_connect(webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView); + g_object_notify(G_OBJECT(webView), "settings"); } WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) @@ -1276,6 +1560,30 @@ WebKitWebSettings* webkit_web_view_get_settings(WebKitWebView* webView) } /** + * webkit_web_view_get_inspector: + * @webView: a #WebKitWebView + * + * Obtains the #WebKitWebInspector associated with the + * #WebKitWebView. Every #WebKitWebView object has a + * #WebKitWebInspector object attached to it as soon as it is created, + * so this function will only return NULL if the argument is not a + * valid #WebKitWebView. + * + * Returns: the #WebKitWebInspector instance associated with the + * #WebKitWebView; %NULL is only returned if the argument is not a + * valid #WebKitWebView. + * + * Since: 1.0.3 + */ +WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); + + WebKitWebViewPrivate* priv = webView->priv; + return priv->webInspector; +} + +/** * webkit_web_view_set_maintains_back_forward_list: * @webView: a #WebKitWebView * @flag: to tell the view to maintain a back or forward list @@ -1323,26 +1631,15 @@ gboolean webkit_web_view_go_to_back_forward_item(WebKitWebView* webView, WebKitW g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(item), FALSE); - // FIXME: This always returns TRUE + WebKitWebBackForwardList* backForwardList = webkit_web_view_get_back_forward_list(webView); + if (!webkit_web_back_forward_list_contains_item(backForwardList, item)) + return FALSE; + core(webView)->goToItem(core(item), FrameLoadTypeIndexedBackForward); return TRUE; } /** - * webkit_web_view_go_backward: - * @webView: the #WebKitWebView - * - * @Deprecated: Use webkit_web_view_go_back() instead. - * - * Go to the previous page, if there's any. - */ -void webkit_web_view_go_backward(WebKitWebView* webView) -{ - g_warning("webkit_web_view_go_backward() is obsolete; use webkit_web_view_go_back()"); - webkit_web_view_go_back(webView); -} - -/** * webkit_web_view_go_back: * @web_view: a #WebKitWebView * @@ -1386,22 +1683,6 @@ void webkit_web_view_go_forward(WebKitWebView* webView) } /** - * webkit_web_view_can_go_backward: - * @webView: the #WebKitWebView - * - * Checks whether the view can go back to the previous page - * - * @Deprecated: Use webkit_web_view_can_go_back() instead. - * - * Return value: %TRUE if the page can go back, otherwise returns %FALSE - */ -gboolean webkit_web_view_can_go_backward(WebKitWebView* webView) -{ - g_warning("webkit_web_view_can_go_backward() is obsolete; use webkit_web_view_can_go_back()"); - return webkit_web_view_can_go_back(webView); -} - -/** * webkit_web_view_can_go_back: * @web_view: a #WebKitWebView * @@ -1467,8 +1748,7 @@ void webkit_web_view_open(WebKitWebView* webView, const gchar* uri) g_return_if_fail(uri); Frame* frame = core(webView)->mainFrame(); - DeprecatedString string = DeprecatedString::fromUtf8(uri); - frame->loader()->load(ResourceRequest(KURL(string))); + frame->loader()->load(ResourceRequest(KURL(String::fromUTF8(uri)))); } void webkit_web_view_reload(WebKitWebView* webView) @@ -1485,8 +1765,8 @@ void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, c Frame* frame = core(webView)->mainFrame(); - KURL url(baseUri ? DeprecatedString::fromUtf8(baseUri) : ""); - RefPtr<SharedBuffer> sharedBuffer = new SharedBuffer(strdup(content), strlen(content)); + KURL url(baseUri ? String::fromUTF8(baseUri) : ""); + RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(content, strlen(content)); SubstituteData substituteData(sharedBuffer.release(), contentMimeType ? String(contentMimeType) : "text/html", contentEncoding ? String(contentEncoding) : "UTF-8", KURL("about:blank"), url); frame->loader()->load(ResourceRequest(url), substituteData); @@ -1589,6 +1869,22 @@ WebKitWebFrame* webkit_web_view_get_main_frame(WebKitWebView* webView) return priv->mainFrame; } +/** + * webkit_web_view_get_focused_frame: + * @web_view: a #WebKitWebView + * + * Returns the frame that has focus or an active text selection. + * + * Return value: The focused #WebKitWebFrame or %NULL if no frame is focused + */ +WebKitWebFrame* webkit_web_view_get_focused_frame(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); + + Frame* focusedFrame = core(webView)->focusController()->focusedFrame(); + return kit(focusedFrame); +} + void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script) { g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); @@ -1808,6 +2104,7 @@ void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) // mainFrame->setSelectionFromNone(); } else frame->removeEditingStyleFromBodyElement(); + g_object_notify(G_OBJECT(webView), "editable"); } /** @@ -1850,4 +2147,186 @@ GtkTargetList* webkit_web_view_get_paste_target_list(WebKitWebView* webView) return priv->paste_target_list; } +/** + * webkit_web_view_get_transparent: + * @web_view: a #WebKitWebView + * + * Returns whether the #WebKitWebView has a transparent background. + * + * Return value: %FALSE when the #WebKitWebView draws a solid background + * (the default), otherwise %TRUE. + */ +gboolean webkit_web_view_get_transparent(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); + + WebKitWebViewPrivate* priv = webView->priv; + return priv->transparent; +} + +/** + * webkit_web_view_set_transparent: + * @web_view: a #WebKitWebView + * + * Sets whether the #WebKitWebView has a transparent background. + * + * Pass %FALSE to have the #WebKitWebView draw a solid background + * (the default), otherwise %TRUE. + */ +void webkit_web_view_set_transparent(WebKitWebView* webView, gboolean flag) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + WebKitWebViewPrivate* priv = webView->priv; + priv->transparent = flag; + + // TODO: This needs to be made persistent or it could become a problem when + // the main frame is replaced. + Frame* frame = core(webView)->mainFrame(); + g_return_if_fail(frame); + frame->view()->setTransparent(flag); + g_object_notify(G_OBJECT(webView), "transparent"); +} + +/** + * webkit_web_view_get_zoom_level: + * @web_view: a #WebKitWebView + * + * Returns the zoom level of @web_view, i.e. the factor by which elements in + * the page are scaled with respect to their original size. + * If the "full-content-zoom" property is set to %FALSE (the default) + * the zoom level changes the text size, or if %TRUE, scales all + * elements in the page. + * + * Return value: the zoom level of @web_view + * + * Since: 1.0.1 + */ +gfloat webkit_web_view_get_zoom_level(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0f); + + Frame* frame = core(webView)->mainFrame(); + if (!frame) + return 1.0f; + + return frame->zoomFactor(); +} + +static void webkit_web_view_apply_zoom_level(WebKitWebView* webView, gfloat zoomLevel) +{ + Frame* frame = core(webView)->mainFrame(); + if (!frame) + return; + + WebKitWebViewPrivate* priv = webView->priv; + frame->setZoomFactor(zoomLevel, !priv->zoomFullContent); +} + +/** + * webkit_web_view_set_zoom_level: + * @web_view: a #WebKitWebView + * @zoom_level: the new zoom level + * + * Sets the zoom level of @web_view, i.e. the factor by which elements in + * the page are scaled with respect to their original size. + * If the "full-content-zoom" property is set to %FALSE (the default) + * the zoom level changes the text size, or if %TRUE, scales all + * elements in the page. + * + * Since: 1.0.1 + */ +void webkit_web_view_set_zoom_level(WebKitWebView* webView, gfloat zoomLevel) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + webkit_web_view_apply_zoom_level(webView, zoomLevel); + g_object_notify(G_OBJECT(webView), "zoom-level"); +} + +/** + * webkit_web_view_zoom_in: + * @web_view: a #WebKitWebView + * + * Increases the zoom level of @web_view. The current zoom + * level is incremented by the value of the "zoom-step" + * property of the #WebKitWebSettings associated with @web_view. + * + * Since: 1.0.1 + */ +void webkit_web_view_zoom_in(WebKitWebView* webView) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + WebKitWebViewPrivate* priv = webView->priv; + gfloat zoomMultiplierRatio; + g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL); + + webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) + zoomMultiplierRatio); +} + +/** + * webkit_web_view_zoom_out: + * @web_view: a #WebKitWebView + * + * Decreases the zoom level of @web_view. The current zoom + * level is decremented by the value of the "zoom-step" + * property of the #WebKitWebSettings associated with @web_view. + * + * Since: 1.0.1 + */ +void webkit_web_view_zoom_out(WebKitWebView* webView) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + WebKitWebViewPrivate* priv = webView->priv; + gfloat zoomMultiplierRatio; + g_object_get(priv->webSettings, "zoom-step", &zoomMultiplierRatio, NULL); + + webkit_web_view_set_zoom_level(webView, webkit_web_view_get_zoom_level(webView) - zoomMultiplierRatio); +} + +/** + * webkit_web_view_get_full_content_zoom: + * @web_view: a #WebKitWebView + * + * Returns whether the zoom level affects only text or all elements. + * + * Return value: %FALSE if only text should be scaled (the default), + * %TRUE if the full content of the view should be scaled. + * + * Since: 1.0.1 + */ +gboolean webkit_web_view_get_full_content_zoom(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); + + WebKitWebViewPrivate* priv = webView->priv; + return priv->zoomFullContent; +} + +/** + * webkit_web_view_set_full_content_zoom: + * @web_view: a #WebKitWebView + * @full_content_zoom: %FALSE if only text should be scaled (the default), + * %TRUE if the full content of the view should be scaled. + * + * Sets whether the zoom level affects only text or all elements. + * + * Since: 1.0.1 + */ +void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoomFullContent) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + + WebKitWebViewPrivate* priv = webView->priv; + if (priv->zoomFullContent == zoomFullContent) + return; + + priv->zoomFullContent = zoomFullContent; + webkit_web_view_apply_zoom_level(webView, webkit_web_view_get_zoom_level(webView)); + + g_object_notify(G_OBJECT(webView), "full-content-zoom"); +} + } diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h index 816b5e2..7371959 100644 --- a/WebKit/gtk/webkit/webkitwebview.h +++ b/WebKit/gtk/webkit/webkitwebview.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -54,7 +55,7 @@ typedef enum struct _WebKitWebView { GtkContainer parent_instance; - WebKitWebViewPrivate* priv; + WebKitWebViewPrivate *priv; }; struct _WebKitWebViewClass { @@ -66,146 +67,215 @@ struct _WebKitWebViewClass { * 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); /* * TODO: FIXME: Create something like WebPolicyDecisionListener_Protocol instead */ - WebKitNavigationResponse (*navigation_requested) (WebKitWebView* web_view, WebKitWebFrame* frame, WebKitNetworkRequest* request); - - void (*window_object_cleared) (WebKitWebView* web_view, WebKitWebFrame* frame, JSGlobalContextRef context, JSObjectRef window_object); - gchar* (*choose_file) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* old_file); - gboolean (*script_alert) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* alert_message); - gboolean (*script_confirm) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* confirm_message, gboolean* did_confirm); - gboolean (*script_prompt) (WebKitWebView* web_view, WebKitWebFrame* frame, const gchar* message, const gchar* default_value, gchar** value); - gboolean (*console_message) (WebKitWebView* web_view, const gchar* message, unsigned int line_number, const gchar* source_id); - void (*select_all) (WebKitWebView* web_view); - void (*cut_clipboard) (WebKitWebView* web_view); - void (*copy_clipboard) (WebKitWebView* web_view); - void (*paste_clipboard) (WebKitWebView* web_view); + WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view, + WebKitWebFrame *frame, + WebKitNetworkRequest *request); + void (* window_object_cleared) (WebKitWebView *web_view, + WebKitWebFrame *frame, + JSGlobalContextRef context, + JSObjectRef window_object); + gchar * (* choose_file) (WebKitWebView *web_view, + WebKitWebFrame *frame, + const gchar *old_file); + gboolean (* script_alert) (WebKitWebView *web_view, + WebKitWebFrame *frame, + const gchar *alert_message); + gboolean (* script_confirm) (WebKitWebView *web_view, + WebKitWebFrame *frame, + const gchar *confirm_message, + gboolean *did_confirm); + gboolean (* script_prompt) (WebKitWebView *web_view, + WebKitWebFrame *frame, + const gchar *message, + const gchar *default_value, + gchar* *value); + gboolean (* console_message) (WebKitWebView *web_view, + const gchar *message, + guint line_number, + const gchar* source_id); + void (* select_all) (WebKitWebView *web_view); + void (* cut_clipboard) (WebKitWebView *web_view); + void (* copy_clipboard) (WebKitWebView *web_view); + void (* paste_clipboard) (WebKitWebView *web_view); /* * internal */ - void (*set_scroll_adjustments) (WebKitWebView*, GtkAdjustment*, GtkAdjustment*); + void (* set_scroll_adjustments) (WebKitWebView *web_view, + GtkAdjustment *hadjustment, + GtkAdjustment *vadjustment); }; WEBKIT_API GType webkit_web_view_get_type (void); -WEBKIT_API GtkWidget* +WEBKIT_API GtkWidget * webkit_web_view_new (void); WEBKIT_API void -webkit_web_view_set_maintains_back_forward_list (WebKitWebView* web_view, gboolean flag); +webkit_web_view_set_maintains_back_forward_list (WebKitWebView *web_view, + gboolean flag); -WEBKIT_API WebKitWebBackForwardList* -webkit_web_view_get_back_forward_list (WebKitWebView* web_view); +WEBKIT_API WebKitWebBackForwardList * +webkit_web_view_get_back_forward_list (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_go_to_back_forward_item (WebKitWebView *web_view, WebKitWebHistoryItem* item); +webkit_web_view_go_to_back_forward_item (WebKitWebView *web_view, + WebKitWebHistoryItem *item); WEBKIT_API gboolean -webkit_web_view_can_go_back (WebKitWebView* web_view); +webkit_web_view_can_go_back (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_go_back_or_forward (WebKitWebView* web_view, gint steps); +webkit_web_view_can_go_back_or_forward (WebKitWebView *web_view, + gint steps); WEBKIT_API gboolean -webkit_web_view_can_go_forward (WebKitWebView* web_view); +webkit_web_view_can_go_forward (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_back (WebKitWebView* web_view); +webkit_web_view_go_back (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_back_or_forward (WebKitWebView* web_view, gint steps); +webkit_web_view_go_back_or_forward (WebKitWebView *web_view, + gint steps); WEBKIT_API void -webkit_web_view_go_forward (WebKitWebView* web_view); +webkit_web_view_go_forward (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_stop_loading (WebKitWebView* web_view); +webkit_web_view_stop_loading (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_open (WebKitWebView* web_view, const gchar* uri); +webkit_web_view_open (WebKitWebView *web_view, + const gchar *uri); WEBKIT_API void -webkit_web_view_reload (WebKitWebView *web_view); +webkit_web_view_reload (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_load_string (WebKitWebView* web_view, const gchar* content, const gchar* content_mime_type, const gchar* content_encoding, const gchar* base_uri); +webkit_web_view_load_string (WebKitWebView *web_view, + const gchar *content, + const gchar *content_mime_type, + const gchar *content_encoding, + const gchar *base_uri); WEBKIT_API void -webkit_web_view_load_html_string (WebKitWebView* web_view, const gchar* content, const gchar* base_uri); +webkit_web_view_load_html_string (WebKitWebView *web_view, + const gchar *content, + const gchar *base_uri); WEBKIT_API gboolean -webkit_web_view_search_text (WebKitWebView* web_view, const gchar* string, gboolean case_sensitive, gboolean forward, gboolean wrap); +webkit_web_view_search_text (WebKitWebView *web_view, + const gchar *string, + gboolean case_sensitive, + gboolean forward, + gboolean wrap); WEBKIT_API guint -webkit_web_view_mark_text_matches (WebKitWebView* web_view, const gchar* string, gboolean case_sensitive, guint limit); +webkit_web_view_mark_text_matches (WebKitWebView *web_view, + const gchar *string, + gboolean case_sensitive, + guint limit); WEBKIT_API void -webkit_web_view_set_highlight_text_matches (WebKitWebView* web_view, gboolean highlight); +webkit_web_view_set_highlight_text_matches (WebKitWebView *web_view, + gboolean highlight); WEBKIT_API void -webkit_web_view_unmark_text_matches (WebKitWebView* web_view); +webkit_web_view_unmark_text_matches (WebKitWebView *web_view); -WEBKIT_API WebKitWebFrame* -webkit_web_view_get_main_frame (WebKitWebView* web_view); +WEBKIT_API WebKitWebFrame * +webkit_web_view_get_main_frame (WebKitWebView *web_view); + +WEBKIT_API WebKitWebFrame * +webkit_web_view_get_focused_frame (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_execute_script (WebKitWebView* web_view, const gchar* script); +webkit_web_view_execute_script (WebKitWebView *web_view, + const gchar *script); WEBKIT_API gboolean -webkit_web_view_can_cut_clipboard (WebKitWebView* web_view); +webkit_web_view_can_cut_clipboard (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_copy_clipboard (WebKitWebView* web_view); +webkit_web_view_can_copy_clipboard (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_paste_clipboard (WebKitWebView* web_view); +webkit_web_view_can_paste_clipboard (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_cut_clipboard (WebKitWebView* web_view); +webkit_web_view_cut_clipboard (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_copy_clipboard (WebKitWebView* web_view); +webkit_web_view_copy_clipboard (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_paste_clipboard (WebKitWebView* web_view); +webkit_web_view_paste_clipboard (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_delete_selection (WebKitWebView* web_view); +webkit_web_view_delete_selection (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_has_selection (WebKitWebView* web_view); +webkit_web_view_has_selection (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_select_all (WebKitWebView* web_view); +webkit_web_view_select_all (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_get_editable (WebKitWebView* web_view); +webkit_web_view_get_editable (WebKitWebView *web_view); + +WEBKIT_API void +webkit_web_view_set_editable (WebKitWebView *web_view, + gboolean flag); + +WEBKIT_API GtkTargetList * +webkit_web_view_get_copy_target_list (WebKitWebView *web_view); + +WEBKIT_API GtkTargetList * +webkit_web_view_get_paste_target_list (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_editable (WebKitWebView* web_view, gboolean flag); +webkit_web_view_set_settings (WebKitWebView *web_view, + WebKitWebSettings *settings); + +WEBKIT_API WebKitWebSettings * +webkit_web_view_get_settings (WebKitWebView *web_view); -WEBKIT_API GtkTargetList* -webkit_web_view_get_copy_target_list (WebKitWebView* web_view); +WEBKIT_API WebKitWebInspector * +webkit_web_view_get_inspector (WebKitWebView *web_view); -WEBKIT_API GtkTargetList* -webkit_web_view_get_paste_target_list (WebKitWebView* web_view); +WEBKIT_API gboolean +webkit_web_view_get_transparent (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_settings (WebKitWebView* web_view, WebKitWebSettings* settings); +webkit_web_view_set_transparent (WebKitWebView *web_view, + gboolean flag); -WEBKIT_API WebKitWebSettings* -webkit_web_view_get_settings (WebKitWebView* web_view); +WEBKIT_API gfloat +webkit_web_view_get_zoom_level (WebKitWebView *web_view); -WEBKIT_OBSOLETE_API gboolean -webkit_web_view_can_go_backward (WebKitWebView* web_view); +WEBKIT_API void +webkit_web_view_set_zoom_level (WebKitWebView *web_view, + gfloat zoom_level); -WEBKIT_OBSOLETE_API void -webkit_web_view_go_backward (WebKitWebView* web_view); +WEBKIT_API void +webkit_web_view_zoom_in (WebKitWebView *web_view); + +WEBKIT_API void +webkit_web_view_zoom_out (WebKitWebView *web_view); + +WEBKIT_API gboolean +webkit_web_view_get_full_content_zoom (WebKitWebView *web_view); + +WEBKIT_API void +webkit_web_view_set_full_content_zoom (WebKitWebView *web_view, + gboolean full_content_zoom); G_END_DECLS |