diff options
author | Ben Murdoch <benm@google.com> | 2011-05-05 14:36:32 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-05-10 15:38:30 +0100 |
commit | f05b935882198ccf7d81675736e3aeb089c5113a (patch) | |
tree | 4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebKit/gtk/webkit | |
parent | 60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff) | |
download | external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2 |
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'WebKit/gtk/webkit')
47 files changed, 2576 insertions, 1065 deletions
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h index fc71c2c..c0d0e31 100644 --- a/WebKit/gtk/webkit/webkit.h +++ b/WebKit/gtk/webkit/webkit.h @@ -30,6 +30,7 @@ #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitnetworkresponse.h> #include <webkit/webkitsoupauthdialog.h> +#include <webkit/webkitviewportattributes.h> #include <webkit/webkitwebdatasource.h> #include <webkit/webkitwebframe.h> #include <webkit/webkitwebsettings.h> @@ -38,6 +39,8 @@ #include <webkit/webkitwebview.h> #include <webkit/webkitwebbackforwardlist.h> #include <webkit/webkitwebhistoryitem.h> +#include <webkit/webkitwebplugin.h> +#include <webkit/webkitwebplugindatabase.h> #include <webkit/webkitwebpolicydecision.h> #include <webkit/webkitwebnavigationaction.h> #include <webkit/webkitwebresource.h> diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h index b06a3bf..b0b607b 100644 --- a/WebKit/gtk/webkit/webkitdefines.h +++ b/WebKit/gtk/webkit/webkitdefines.h @@ -92,6 +92,15 @@ typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass; typedef struct _WebKitGeolocationPolicyDecision WebKitGeolocationPolicyDecision; typedef struct _WebKitGeolocationPolicyDecisionClass WebKitGeolocationPolicyDecisionClass; +typedef struct _WebKitViewportAttributes WebKitViewportAttributes; +typedef struct _WebKitViewportAttributesClass WebKitViewportAttributesClass; + +typedef struct _WebKitWebPluginDatabase WebKitWebPluginDatabase; +typedef struct _WebKitWebPluginDatabaseClass WebKitWebPluginDatabaseClass; + +typedef struct _WebKitWebPlugin WebKitWebPlugin; +typedef struct _WebKitWebPluginClass WebKitWebPluginClass; + G_END_DECLS #endif diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp index 18b64ab..6be591c 100644 --- a/WebKit/gtk/webkit/webkitdownload.cpp +++ b/WebKit/gtk/webkit/webkitdownload.cpp @@ -29,9 +29,12 @@ #include "ResourceRequest.h" #include "ResourceResponse.h" #include "webkitdownload.h" +#include "webkitdownloadprivate.h" #include "webkitenumtypes.h" #include "webkitmarshal.h" +#include "webkitnetworkrequestprivate.h" #include "webkitnetworkresponse.h" +#include "webkitnetworkresponseprivate.h" #include "webkitprivate.h" #include <wtf/text/CString.h> @@ -69,8 +72,6 @@ class DownloadClient : public Noncopyable, public ResourceHandleClient { WebKitDownload* m_download; }; -#define WEBKIT_DOWNLOAD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_DOWNLOAD, WebKitDownloadPrivate)) - struct _WebKitDownloadPrivate { gchar* destinationURI; gchar* suggestedFilename; @@ -387,7 +388,7 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass) static void webkit_download_init(WebKitDownload* download) { - WebKitDownloadPrivate* priv = WEBKIT_DOWNLOAD_GET_PRIVATE(download); + WebKitDownloadPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(download, WEBKIT_TYPE_DOWNLOAD, WebKitDownloadPrivate); download->priv = priv; priv->downloadClient = new DownloadClient(download); @@ -593,7 +594,7 @@ WebKitNetworkResponse* webkit_download_get_network_response(WebKitDownload* down static void webkit_download_set_response(WebKitDownload* download, const ResourceResponse& response) { WebKitDownloadPrivate* priv = download->priv; - priv->networkResponse = webkit_network_response_new_with_core_response(response); + priv->networkResponse = kitNew(response); if (!response.isNull() && !response.suggestedFilename().isEmpty()) webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data()); diff --git a/WebKit/gtk/webkit/webkitdownloadprivate.h b/WebKit/gtk/webkit/webkitdownloadprivate.h new file mode 100644 index 0000000..13cc2a4 --- /dev/null +++ b/WebKit/gtk/webkit/webkitdownloadprivate.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitdownloadprivate_h +#define webkitdownloadprivate_h + +#include "webkitdownload.h" + +extern "C" { + +WebKitDownload* webkit_download_new_with_handle(WebKitNetworkRequest*, WebCore::ResourceHandle*, const WebCore::ResourceResponse&); + +void webkit_download_set_suggested_filename(WebKitDownload*, const gchar* suggestedFilename); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp index 7afd8fa..cb023d6 100644 --- a/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp +++ b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp @@ -43,8 +43,6 @@ struct _WebKitGeolocationPolicyDecisionPrivate { Geolocation* geolocation; }; -#define WEBKIT_GEOLOCATION_POLICY_DECISION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionPrivate)) - static void webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolicyDecisionClass* decisionClass) { g_type_class_add_private(decisionClass, sizeof(WebKitGeolocationPolicyDecisionPrivate)); @@ -52,7 +50,7 @@ static void webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolic static void webkit_geolocation_policy_decision_init(WebKitGeolocationPolicyDecision* decision) { - decision->priv = WEBKIT_GEOLOCATION_POLICY_DECISION_GET_PRIVATE(decision); + decision->priv = G_TYPE_INSTANCE_GET_PRIVATE(decision, WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionPrivate); } WebKitGeolocationPolicyDecision* webkit_geolocation_policy_decision_new(WebKitWebFrame* frame, Geolocation* geolocation) diff --git a/WebKit/gtk/webkit/webkithittestresult.cpp b/WebKit/gtk/webkit/webkithittestresult.cpp index 931289e..fa0b40b 100644 --- a/WebKit/gtk/webkit/webkithittestresult.cpp +++ b/WebKit/gtk/webkit/webkithittestresult.cpp @@ -22,6 +22,8 @@ #include "webkithittestresult.h" #include "GOwnPtr.h" +#include "HitTestResult.h" +#include "WebKitDOMBinding.h" #include "WebKitDOMNode.h" #include "webkitenumtypes.h" #include "webkitprivate.h" @@ -47,8 +49,6 @@ struct _WebKitHitTestResultPrivate { WebKitDOMNode* innerNode; }; -#define WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate)) - enum { PROP_0, @@ -228,5 +228,50 @@ static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* webHitTe static void webkit_hit_test_result_init(WebKitHitTestResult* web_hit_test_result) { - web_hit_test_result->priv = WEBKIT_HIT_TEST_RESULT_GET_PRIVATE(web_hit_test_result); + web_hit_test_result->priv = G_TYPE_INSTANCE_GET_PRIVATE(web_hit_test_result, WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate); +} + +namespace WebKit { + +WebKitHitTestResult* kit(const WebCore::HitTestResult& result) +{ + guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; + GOwnPtr<char> linkURI(0); + GOwnPtr<char> imageURI(0); + GOwnPtr<char> mediaURI(0); + WebKitDOMNode* node = 0; + + if (!result.absoluteLinkURL().isEmpty()) { + context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; + linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data())); + } + + if (!result.absoluteImageURL().isEmpty()) { + context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; + imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data())); + } + + if (!result.absoluteMediaURL().isEmpty()) { + context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; + mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data())); + } + + if (result.isSelected()) + context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION; + + if (result.isContentEditable()) + context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; + + if (result.innerNonSharedNode()) + node = kit(result.innerNonSharedNode()); + + return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT, + "link-uri", linkURI.get(), + "image-uri", imageURI.get(), + "media-uri", mediaURI.get(), + "context", context, + "inner-node", node, + NULL)); +} + } diff --git a/WebKit/gtk/webkit/webkithittestresultprivate.h b/WebKit/gtk/webkit/webkithittestresultprivate.h new file mode 100644 index 0000000..237ac27 --- /dev/null +++ b/WebKit/gtk/webkit/webkithittestresultprivate.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkithittestresultprivate_h +#define webkithittestresultprivate_h + +#include "HitTestResult.h" +#include "webkithittestresult.h" + +namespace WebKit { + +WebKitHitTestResult* kit(const WebCore::HitTestResult&); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp index 6180efa..23f22a3 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp +++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp @@ -48,8 +48,6 @@ struct _WebKitNetworkRequestPrivate { SoupMessage* message; }; -#define WEBKIT_NETWORK_REQUEST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_REQUEST, WebKitNetworkRequestPrivate)) - enum { PROP_0, @@ -157,20 +155,10 @@ static void webkit_network_request_class_init(WebKitNetworkRequestClass* request static void webkit_network_request_init(WebKitNetworkRequest* request) { - WebKitNetworkRequestPrivate* priv = WEBKIT_NETWORK_REQUEST_GET_PRIVATE(request); + WebKitNetworkRequestPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_NETWORK_REQUEST, WebKitNetworkRequestPrivate); request->priv = priv; } -// for internal use only -WebKitNetworkRequest* webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest) -{ - PlatformRefPtr<SoupMessage> soupMessage(adoptPlatformRef(resourceRequest.toSoupMessage())); - if (soupMessage) - return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", soupMessage.get(), NULL)); - - return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "uri", resourceRequest.url().string().utf8().data(), NULL)); -} - /** * webkit_network_request_new: * @uri: an URI @@ -260,3 +248,26 @@ SoupMessage* webkit_network_request_get_message(WebKitNetworkRequest* request) return priv->message; } + +namespace WebKit { + +WebKitNetworkRequest* kitNew(const WebCore::ResourceRequest& resourceRequest) +{ + PlatformRefPtr<SoupMessage> soupMessage(adoptPlatformRef(resourceRequest.toSoupMessage())); + if (soupMessage) + return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", soupMessage.get(), NULL)); + + return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "uri", resourceRequest.url().string().utf8().data(), NULL)); +} + +WebCore::ResourceRequest core(WebKitNetworkRequest* request) +{ + SoupMessage* soupMessage = webkit_network_request_get_message(request); + if (soupMessage) + return WebCore::ResourceRequest(soupMessage); + + WebCore::KURL url = WebCore::KURL(WebCore::KURL(), String::fromUTF8(webkit_network_request_get_uri(request))); + return WebCore::ResourceRequest(url); +} + +} diff --git a/WebKit/gtk/webkit/webkitnetworkrequestprivate.h b/WebKit/gtk/webkit/webkitnetworkrequestprivate.h new file mode 100644 index 0000000..84b4593 --- /dev/null +++ b/WebKit/gtk/webkit/webkitnetworkrequestprivate.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitnetworkrequestprivate_h +#define webkitnetworkrequestprivate_h + +namespace WebKit { + +WebCore::ResourceRequest core(WebKitNetworkRequest*); +WebKitNetworkRequest* kitNew(const WebCore::ResourceRequest&); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitnetworkresponse.cpp b/WebKit/gtk/webkit/webkitnetworkresponse.cpp index 0aca6d8..da29212 100644 --- a/WebKit/gtk/webkit/webkitnetworkresponse.cpp +++ b/WebKit/gtk/webkit/webkitnetworkresponse.cpp @@ -158,16 +158,6 @@ static void webkit_network_response_init(WebKitNetworkResponse* response) response->priv = WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(response); } -// for internal use only -WebKitNetworkResponse* webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse) -{ - PlatformRefPtr<SoupMessage> soupMessage(adoptPlatformRef(resourceResponse.toSoupMessage())); - if (soupMessage) - return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL)); - - return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", resourceResponse.url().string().utf8().data(), NULL)); -} - /** * webkit_network_response_new: * @uri: an URI @@ -259,3 +249,25 @@ SoupMessage* webkit_network_response_get_message(WebKitNetworkResponse* response return priv->message; } + +namespace WebKit { + +WebCore::ResourceResponse core(WebKitNetworkResponse* response) +{ + SoupMessage* soupMessage = webkit_network_response_get_message(response); + if (soupMessage) + return WebCore::ResourceResponse(soupMessage); + + return WebCore::ResourceResponse(); +} + +WebKitNetworkResponse* kitNew(const WebCore::ResourceResponse& resourceResponse) +{ + PlatformRefPtr<SoupMessage> soupMessage(adoptPlatformRef(resourceResponse.toSoupMessage())); + if (soupMessage) + return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL)); + + return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", resourceResponse.url().string().utf8().data(), NULL)); +} + +} diff --git a/WebKit/gtk/webkit/webkitnetworkresponseprivate.h b/WebKit/gtk/webkit/webkitnetworkresponseprivate.h new file mode 100644 index 0000000..ab38a50 --- /dev/null +++ b/WebKit/gtk/webkit/webkitnetworkresponseprivate.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitnetworkresponseprivate_h +#define webkitnetworkresponseprivate_h + +#include "ResourceResponse.h" + +namespace WebKit { + +WebCore::ResourceResponse core(WebKitNetworkResponse*); +WebKitNetworkResponse* kitNew(const WebCore::ResourceResponse&); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index 4ec6362..4652031 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -43,9 +43,7 @@ #include "ResourceHandleClient.h" #include "ResourceHandleInternal.h" #include "ResourceResponse.h" -#include "SecurityOrigin.h" #include "TextEncodingRegistry.h" -#include "WebKitDOMBinding.h" #include "webkitnetworkresponse.h" #include "webkitsoupauthdialog.h" #include "webkitversion.h" @@ -66,125 +64,11 @@ using namespace WebCore; namespace WebKit { -WebKitWebView* getViewFromFrame(WebKitWebFrame* frame) -{ - WebKitWebFramePrivate* priv = frame->priv; - return priv->webView; -} - -WebCore::Frame* core(WebKitWebFrame* frame) -{ - if (!frame) - return 0; - - WebKitWebFramePrivate* priv = frame->priv; - return priv ? priv->coreFrame : 0; -} - -WebKitWebFrame* kit(WebCore::Frame* coreFrame) -{ - if (!coreFrame) - return 0; - - ASSERT(coreFrame->loader()); - WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(coreFrame->loader()->client()); - return client ? client->webFrame() : 0; -} - -WebCore::Page* core(WebKitWebView* webView) -{ - if (!webView) - return 0; - - WebKitWebViewPrivate* priv = webView->priv; - return priv ? priv->corePage : 0; -} - -WebKitWebView* kit(WebCore::Page* corePage) -{ - if (!corePage) - return 0; - - ASSERT(corePage->chrome()); - WebKit::ChromeClient* client = static_cast<WebKit::ChromeClient*>(corePage->chrome()->client()); - return client ? client->webView() : 0; -} - -WebKitWebNavigationReason kit(WebCore::NavigationType type) -{ - return (WebKitWebNavigationReason)type; -} - -WebCore::NavigationType core(WebKitWebNavigationReason type) -{ - return static_cast<WebCore::NavigationType>(type); -} - -WebCore::ResourceRequest core(WebKitNetworkRequest* request) -{ - SoupMessage* soupMessage = webkit_network_request_get_message(request); - if (soupMessage) - return ResourceRequest(soupMessage); - - KURL url = KURL(KURL(), String::fromUTF8(webkit_network_request_get_uri(request))); - return ResourceRequest(url); -} - -WebCore::ResourceResponse core(WebKitNetworkResponse* response) -{ - SoupMessage* soupMessage = webkit_network_response_get_message(response); - if (soupMessage) - return ResourceResponse(soupMessage); - - return ResourceResponse(); -} - WebCore::EditingBehaviorType core(WebKitEditingBehavior type) { return (WebCore::EditingBehaviorType)type; } -WebKitHitTestResult* kit(const WebCore::HitTestResult& result) -{ - guint context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT; - GOwnPtr<char> linkURI(0); - GOwnPtr<char> imageURI(0); - GOwnPtr<char> mediaURI(0); - WebKitDOMNode* node = 0; - - if (!result.absoluteLinkURL().isEmpty()) { - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK; - linkURI.set(g_strdup(result.absoluteLinkURL().string().utf8().data())); - } - - if (!result.absoluteImageURL().isEmpty()) { - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE; - imageURI.set(g_strdup(result.absoluteImageURL().string().utf8().data())); - } - - if (!result.absoluteMediaURL().isEmpty()) { - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA; - mediaURI.set(g_strdup(result.absoluteMediaURL().string().utf8().data())); - } - - if (result.isSelected()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION; - - if (result.isContentEditable()) - context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE; - - if (result.innerNonSharedNode()) - node = kit(result.innerNonSharedNode()); - - return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT, - "link-uri", linkURI.get(), - "image-uri", imageURI.get(), - "media-uri", mediaURI.get(), - "context", context, - "inner-node", node, - NULL)); -} - PasteboardHelperGtk* pasteboardHelperInstance() { static PasteboardHelperGtk* helper = new PasteboardHelperGtk(); @@ -226,45 +110,6 @@ static void closeIconDatabaseOnExit() iconDatabase()->close(); } -#ifdef HAVE_GSETTINGS -static bool isSchemaAvailable(const char* schemaID) -{ - const char* const* availableSchemas = g_settings_list_schemas(); - char* const* iter = const_cast<char* const*>(availableSchemas); - - while (*iter) { - if (g_str_equal(schemaID, *iter)) - return true; - iter++; - } - - return false; -} - -GSettings* inspectorGSettings() -{ - static GSettings* settings = 0; - - if (settings) - return settings; - - const gchar* schemaID = "org.webkitgtk-"WEBKITGTK_API_VERSION_STRING".inspector"; - - // Unfortunately GSettings will abort the process execution if the - // schema is not installed, which is the case for when running - // tests, or even the introspection dump at build time, so check - // if we have the schema before trying to initialize it. - if (!isSchemaAvailable(schemaID)) { - g_warning("GSettings schema not found - settings will not be used or saved."); - return 0; - } - - settings = g_settings_new(schemaID); - - return settings; -} -#endif - void webkit_init() { static bool isInitialized = false; @@ -284,11 +129,6 @@ void webkit_init() // that may only be done by the main thread. atomicCanonicalTextEncodingName("UTF-8"); - // 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 - webkit_set_cache_model(WEBKIT_CACHE_MODEL_WEB_BROWSER); - #if ENABLE(DATABASE) gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL); webkit_set_web_database_directory_path(databaseDirectory); @@ -322,43 +162,3 @@ void webkit_init() soup_session_add_feature_by_type(session, SOUP_TYPE_CONTENT_DECODER); } - -void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains) -{ - SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); -} - -void webkit_reset_origin_access_white_lists() -{ - SecurityOrigin::resetOriginAccessWhitelists(); -} - - -void webkitWebViewEnterFullscreen(WebKitWebView* webView, Node* node) -{ - if (!node->hasTagName(HTMLNames::videoTag)) - return; - -#if ENABLE(VIDEO) - HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node); - WebKitWebViewPrivate* priv = webView->priv; - - // First exit Fullscreen for the old mediaElement. - if (priv->fullscreenVideoController) - priv->fullscreenVideoController->exitFullscreen(); - - priv->fullscreenVideoController = new FullscreenVideoController; - priv->fullscreenVideoController->setMediaElement(videoElement); - priv->fullscreenVideoController->enterFullscreen(); -#endif -} - -void webkitWebViewExitFullscreen(WebKitWebView* webView) -{ -#if ENABLE(VIDEO) - WebKitWebViewPrivate* priv = webView->priv; - if (priv->fullscreenVideoController) - priv->fullscreenVideoController->exitFullscreen(); -#endif -} - diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index e090ed4..cf2e9d6 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -30,42 +30,29 @@ */ #include <webkit/webkitdefines.h> -#include <webkit/webkitdownload.h> -#include <webkit/webkithittestresult.h> #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitwebview.h> #include <webkit/webkitwebdatasource.h> #include <webkit/webkitwebframe.h> -#include <webkit/webkitwebpolicydecision.h> -#include <webkit/webkitwebnavigationaction.h> -#include <webkit/webkitwebresource.h> #include <webkit/webkitwebsettings.h> #include <webkit/webkitwebwindowfeatures.h> -#include <webkit/webkitwebbackforwardlist.h> #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitsecurityorigin.h> -#include "ArchiveResource.h" -#include "BackForwardListImpl.h" #include "DataObjectGtk.h" #include "DragActions.h" #include "Frame.h" #include "GOwnPtr.h" #include "Geolocation.h" -#include "HistoryItem.h" -#include "InspectorClientGtk.h" #include "IntPoint.h" #include "IntRect.h" #include "FrameLoaderClient.h" -#include "FullscreenVideoController.h" #include "Node.h" #include "Page.h" #include "PlatformString.h" #include "ResourceHandle.h" #include "ResourceRequest.h" -#include "ResourceResponse.h" #include "WindowFeatures.h" -#include "SecurityOrigin.h" #include "Settings.h" #include <enchant.h> #include <wtf/OwnPtr.h> @@ -75,365 +62,37 @@ #include <glib.h> #include <libsoup/soup.h> -class DownloadClient; - namespace WebKit { class DocumentLoader; class PasteboardHelperGtk; - WebKitWebView* getViewFromFrame(WebKitWebFrame*); - - WebCore::Frame* core(WebKitWebFrame*); - WebKitWebFrame* kit(WebCore::Frame*); - - WebCore::Page* core(WebKitWebView*); - WebKitWebView* kit(WebCore::Page*); - - WebCore::HistoryItem* core(WebKitWebHistoryItem*); - WebKitWebHistoryItem* kit(PassRefPtr<WebCore::HistoryItem>); - - WebCore::BackForwardListImpl* core(WebKitWebBackForwardList*); - - WebKitWebNavigationReason kit(WebCore::NavigationType type); - WebCore::NavigationType core(WebKitWebNavigationReason reason); - - WebCore::ResourceRequest core(WebKitNetworkRequest* request); - - WebCore::ResourceResponse core(WebKitNetworkResponse* response); - WebCore::EditingBehaviorType core(WebKitEditingBehavior type); - WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*); - WebCore::SecurityOrigin* core(WebKitSecurityOrigin*); - - WebKitHitTestResult* kit(const WebCore::HitTestResult&); - PasteboardHelperGtk* pasteboardHelperInstance(); - - typedef struct DroppingContext_ { - WebKitWebView* webView; - GdkDragContext* gdkContext; - RefPtr<WebCore::DataObjectGtk> dataObject; - WebCore::IntPoint lastMotionPosition; - int pendingDataRequests; - bool dropHappened; - } DroppingContext; } extern "C" { void webkit_init(); -#ifdef HAVE_GSETTINGS - GSettings* inspectorGSettings(); -#endif - #define WEBKIT_PARAM_READABLE ((GParamFlags)(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) #define WEBKIT_PARAM_READWRITE ((GParamFlags)(G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) - #define WEBKIT_WEB_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate)) - typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; - struct _WebKitWebViewPrivate { - WebCore::Page* corePage; - PlatformRefPtr<WebKitWebSettings> webSettings; - PlatformRefPtr<WebKitWebInspector> webInspector; - PlatformRefPtr<WebKitWebWindowFeatures> webWindowFeatures; - - WebKitWebFrame* mainFrame; - PlatformRefPtr<WebKitWebBackForwardList> backForwardList; - - PlatformRefPtr<GtkMenu> currentMenu; - gint lastPopupXPosition; - gint lastPopupYPosition; - - HashSet<GtkWidget*> children; - bool editable; - PlatformRefPtr<GtkIMContext> imContext; - - gboolean transparent; - - PlatformRefPtr<GtkAdjustment> horizontalAdjustment; - PlatformRefPtr<GtkAdjustment> verticalAdjustment; - -#ifndef GTK_API_VERSION_2 - // GtkScrollablePolicy needs to be checked when - // driving the scrollable adjustment values - GtkScrollablePolicy horizontalScrollingPolicy; - GtkScrollablePolicy verticalScrollingPolicy; -#endif - - gboolean zoomFullContent; - WebKitLoadStatus loadStatus; - CString encoding; - CString customEncoding; - - CString iconURI; - - gboolean disposing; - gboolean usePrimaryForPaste; - -#if ENABLE(VIDEO) - FullscreenVideoController* fullscreenVideoController; -#endif - - // These are hosted here because the DataSource object is - // created too late in the frame loading process. - PlatformRefPtr<WebKitWebResource> mainResource; - CString mainResourceIdentifier; - PlatformRefPtr<GHashTable> subResources; - CString tooltipText; - WebCore::IntRect tooltipArea; - - int currentClickCount; - WebCore::IntPoint previousClickPoint; - guint previousClickButton; - guint32 previousClickTime; - HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects; - HashMap<GdkDragContext*, WebKit::DroppingContext*> droppingContexts; - }; - - #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; - WebKitWebView* webView; - - gchar* name; - gchar* title; - gchar* uri; - WebKitLoadStatus loadStatus; - WebKitSecurityOrigin* origin; - }; - -#define WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginPrivate)) - struct _WebKitSecurityOriginPrivate { - RefPtr<WebCore::SecurityOrigin> coreOrigin; - gchar* protocol; - gchar* host; - GHashTable* webDatabases; - - gboolean disposed; - }; - WTF::String webkitUserAgent(); - void - webkit_web_frame_core_frame_gone(WebKitWebFrame*); - - // WebKitWebHistoryItem private - WebKitWebHistoryItem* - webkit_web_history_item_new_with_core_item(PassRefPtr<WebCore::HistoryItem> historyItem); - - WEBKIT_API G_CONST_RETURN gchar* - webkit_web_history_item_get_target(WebKitWebHistoryItem*); - - WEBKIT_API gboolean - webkit_web_history_item_is_target_item(WebKitWebHistoryItem*); - - WEBKIT_API GList* - webkit_web_history_item_get_children(WebKitWebHistoryItem*); - // end WebKitWebHistoryItem private - - // WebKitWebResource private - #define WEBKIT_WEB_RESOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourcePrivate)) - struct _WebKitWebResourcePrivate { - WebCore::ArchiveResource* resource; - - gchar* uri; - gchar* mimeType; - gchar* textEncoding; - gchar* frameName; - - GString* data; - }; - WebKitWebResource* - webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>); - - void - webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>); - - // end WebKitWebResource private - - void - webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebCore::Page*); - - 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); - - WEBKIT_API void - webkit_web_inspector_execute_script(WebKitWebInspector* inspector, long callId, const gchar* script); - - WebKitWebWindowFeatures* webkit_web_window_features_new_from_core_features (const WebCore::WindowFeatures& features); - void - webkit_web_view_notify_ready (WebKitWebView* web_view); - - void - webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse(), WebCore::ResourceHandle* handle = 0); - - void - webkit_web_view_add_resource(WebKitWebView*, const char*, WebKitWebResource*); - - void - webkit_web_view_remove_resource(WebKitWebView*, const char*); - - WebKitWebResource* - webkit_web_view_get_resource(WebKitWebView*, char*); - - WebKitWebResource* - webkit_web_view_get_main_resource(WebKitWebView*); - - void - webkit_web_view_clear_resources(WebKitWebView*); - - GList* - webkit_web_view_get_subresources(WebKitWebView*); - - void - webkit_web_view_set_tooltip_text(WebKitWebView*, const char*); - - GtkMenu* - webkit_web_view_get_context_menu(WebKitWebView*); - - WEBKIT_API void - webkit_web_view_execute_core_command_by_name(WebKitWebView* webView, const gchar* name, const gchar* value); - - WEBKIT_API gboolean - webkit_web_view_is_command_enabled(WebKitWebView* webView, const gchar* name); - - WebKitDownload* - webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response); - - void - webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename); - - WebKitWebPolicyDecision* - webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction); - - void - webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision); - - WebKitNetworkRequest* - webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest); - - WebKitNetworkResponse* - webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse); - WebKitGeolocationPolicyDecision* webkit_geolocation_policy_decision_new(WebKitWebFrame*, WebCore::Geolocation*); - // FIXME: move this to webkitnetworkrequest.h once the API is agreed upon. - WEBKIT_API SoupMessage* - webkit_network_request_get_message(WebKitNetworkRequest* request); - - // FIXME: move this functionality into a 'WebKitWebDataSource' once implemented - WEBKIT_API gchar* - webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame); - - // FIXME: Move these to webkitwebframe.h once their API has been discussed. - - WEBKIT_API GSList* - webkit_web_frame_get_children (WebKitWebFrame* frame); - - WEBKIT_API gchar* - webkit_web_frame_get_inner_text (WebKitWebFrame* frame); - - WEBKIT_API gchar* - webkit_web_frame_dump_render_tree (WebKitWebFrame* frame); - - WEBKIT_API gchar* - webkit_web_frame_counter_value_for_element_by_id (WebKitWebFrame* frame, const gchar* id); - - WEBKIT_API int - webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight); - - WEBKIT_API int - webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight); - - WEBKIT_API guint - webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame); - - WEBKIT_API bool - webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); - - WEBKIT_API bool - webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element); - - WEBKIT_API bool - webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId); - - WEBKIT_API gchar* - webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject); - - WEBKIT_API unsigned int - webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); - - WEBKIT_API void - webkit_web_frame_suspend_animations(WebKitWebFrame* frame); - - WEBKIT_API void - webkit_web_frame_resume_animations(WebKitWebFrame* frame); - - WEBKIT_API void - webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame); - - WEBKIT_API AtkObject* - webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame); - - WEBKIT_API gchar* - webkit_web_view_get_selected_text (WebKitWebView* web_view); - - WEBKIT_API void - webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory); - - GSList* - webkit_web_settings_get_enchant_dicts(WebKitWebView* web_view); - - bool - webkit_web_view_use_primary_for_paste(WebKitWebView* web_view); - - GHashTable* - webkit_history_items(void); - - WEBKIT_API void - webkit_gc_collect_javascript_objects(); - - WEBKIT_API void - webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone); - - WEBKIT_API gsize - webkit_gc_count_javascript_objects(); - WEBKIT_API void webkit_application_cache_set_maximum_size(unsigned long long size); - WEBKIT_API unsigned int - webkit_worker_thread_count(); - - WEBKIT_API void - webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains); - - WEBKIT_API void - webkit_reset_origin_access_white_lists(); - // WebKitWebDataSource private WebKitWebDataSource* webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader>); - - WEBKIT_API WebKitWebDatabase * - webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const char* databaseName); - - WEBKIT_API void - webkit_web_frame_layout(WebKitWebFrame* frame); - - void webkitWebViewEnterFullscreen(WebKitWebView* webView, WebCore::Node* node); - void webkitWebViewExitFullscreen(WebKitWebView* webView); } #endif diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.cpp b/WebKit/gtk/webkit/webkitsecurityorigin.cpp index 92d19e7..927b76d 100644 --- a/WebKit/gtk/webkit/webkitsecurityorigin.cpp +++ b/WebKit/gtk/webkit/webkitsecurityorigin.cpp @@ -18,15 +18,14 @@ */ #include "config.h" -#include "webkitwebdatabase.h" +#include "webkitsecurityorigin.h" -#include "webkitprivate.h" - -#include "PlatformString.h" #include "DatabaseTracker.h" -#include <wtf/text/CString.h> - +#include "PlatformString.h" +#include "webkitprivate.h" +#include "webkitsecurityoriginprivate.h" #include <glib/gi18n-lib.h> +#include <wtf/text/CString.h> /** * SECTION:webkitsecurityorigin @@ -213,7 +212,7 @@ static void webkit_security_origin_class_init(WebKitSecurityOriginClass* klass) static void webkit_security_origin_init(WebKitSecurityOrigin* securityOrigin) { - WebKitSecurityOriginPrivate* priv = WEBKIT_SECURITY_ORIGIN_GET_PRIVATE(securityOrigin); + WebKitSecurityOriginPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(securityOrigin, WEBKIT_TYPE_SECURITY_ORIGIN, WebKitSecurityOriginPrivate); priv->webDatabases = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); securityOrigin->priv = priv; } @@ -379,46 +378,48 @@ GList* webkit_security_origin_get_all_web_databases(WebKitSecurityOrigin* securi return databases; } -WebKitSecurityOrigin* WebKit::kit(WebCore::SecurityOrigin* coreOrigin) +WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const gchar* databaseName) { - ASSERT(coreOrigin); + g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL); - GHashTable* table = webkit_security_origins(); - WebKitSecurityOrigin* origin = (WebKitSecurityOrigin*) g_hash_table_lookup(table, coreOrigin); + WebKitSecurityOriginPrivate* priv = securityOrigin->priv; + GHashTable* databaseHash = priv->webDatabases; + WebKitWebDatabase* database = (WebKitWebDatabase*) g_hash_table_lookup(databaseHash, databaseName); - if (!origin) { - origin = WEBKIT_SECURITY_ORIGIN(g_object_new(WEBKIT_TYPE_SECURITY_ORIGIN, NULL)); - origin->priv->coreOrigin = coreOrigin; - g_hash_table_insert(table, coreOrigin, origin); + if (!database) { + database = WEBKIT_WEB_DATABASE(g_object_new(WEBKIT_TYPE_WEB_DATABASE, + "security-origin", securityOrigin, + "name", databaseName, + NULL)); + g_hash_table_insert(databaseHash, g_strdup(databaseName), database); } - return origin; + return database; } +namespace WebKit { -WebCore::SecurityOrigin* WebKit::core(WebKitSecurityOrigin* securityOrigin) +WebCore::SecurityOrigin* core(WebKitSecurityOrigin* securityOrigin) { ASSERT(securityOrigin); return securityOrigin->priv->coreOrigin.get(); } -WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin* securityOrigin, const gchar* databaseName) +WebKitSecurityOrigin* kit(WebCore::SecurityOrigin* coreOrigin) { - g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(securityOrigin), NULL); + ASSERT(coreOrigin); - WebKitSecurityOriginPrivate* priv = securityOrigin->priv; - GHashTable* databaseHash = priv->webDatabases; - WebKitWebDatabase* database = (WebKitWebDatabase*) g_hash_table_lookup(databaseHash, databaseName); + GHashTable* table = webkit_security_origins(); + WebKitSecurityOrigin* origin = (WebKitSecurityOrigin*) g_hash_table_lookup(table, coreOrigin); - if (!database) { - database = WEBKIT_WEB_DATABASE(g_object_new(WEBKIT_TYPE_WEB_DATABASE, - "security-origin", securityOrigin, - "name", databaseName, - NULL)); - g_hash_table_insert(databaseHash, g_strdup(databaseName), database); + if (!origin) { + origin = WEBKIT_SECURITY_ORIGIN(g_object_new(WEBKIT_TYPE_SECURITY_ORIGIN, NULL)); + origin->priv->coreOrigin = coreOrigin; + g_hash_table_insert(table, coreOrigin, origin); } - return database; + return origin; } +} diff --git a/WebKit/gtk/webkit/webkitsecurityoriginprivate.h b/WebKit/gtk/webkit/webkitsecurityoriginprivate.h new file mode 100644 index 0000000..5a4a87b --- /dev/null +++ b/WebKit/gtk/webkit/webkitsecurityoriginprivate.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitsecurityoriginprivate_h +#define webkitnavigationactionprivate_h + +#include "SecurityOrigin.h" +#include "webkitsecurityorigin.h" + +namespace WebKit { + +WebKitSecurityOrigin* kit(WebCore::SecurityOrigin*); +WebCore::SecurityOrigin* core(WebKitSecurityOrigin*); + +} + +extern "C" { + +struct _WebKitSecurityOriginPrivate { + RefPtr<WebCore::SecurityOrigin> coreOrigin; + gchar* protocol; + gchar* host; + GHashTable* webDatabases; + + gboolean disposed; +}; + +WEBKIT_API WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin*, const char*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitviewportattributes.cpp b/WebKit/gtk/webkit/webkitviewportattributes.cpp new file mode 100644 index 0000000..c2de5c1 --- /dev/null +++ b/WebKit/gtk/webkit/webkitviewportattributes.cpp @@ -0,0 +1,569 @@ +/* + * Copyright (C) 2010 Joone Hur <joone@kldp.org> + * Copyright (C) 2010 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "webkitviewportattributes.h" + +#include "Chrome.h" +#include "webkitprivate.h" +#include "webkitviewportattributesprivate.h" +#include "webkitwebviewprivate.h" +#include <glib/gi18n-lib.h> + +/** + * SECTION:webkitviewportattributes + * @short_description: Represents the viewport properties of a web page + * @see_also: #WebKitWebView::viewport-attributes-recompute-requested + * @see_also: #WebKitWebView::viewport-attributes-changed + * + * #WebKitViewportAttributes offers the viewport properties to user agents to + * control the viewport layout. It contains the viewport size, initial scale with limits, + * and information about whether a user is able to scale the contents in the viewport. + * This makes a web page fit the device screen. + * + * The #WebKitWebView::viewport-attributes-changed signal will be emitted with #WebKitViewportAttributes + * when the viewport attributes are updated in the case of loading web pages contain + * the viewport properties and calling webkit_viewport_attributes_recompute. + * + * If the device size, available size, desktop width, or device DPI needs to be changed due to + * a consequence of an explicit browser request (caused by screen rotation, resizing, or similar reasons), + * You should call #webkit_viewport_attributes_recompute to recompute the viewport properties and + * override those values in the handler of #WebKitWebView::viewport-attributes-recompute-requested signal. + * + * For more information on the viewport properties, refer to the Safari reference library at + * http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html + * + * <informalexample><programlisting> + * /<!-- -->* Connect to the viewport-attributes-changes signal *<!-- -->/ + * WebKitViewportAttributes* attributes = webkit_web_view_get_viewport_attributes (web_view); + * g_signal_connect (web_view, "viewport-attributes-recompute-requested", G_CALLBACK (viewport_recompute_cb), window); + * g_signal_connect (web_view, "viewport-attributes-changed", G_CALLBACK (viewport_changed_cb), window); + * g_signal_connect (attributes, "notify::valid", G_CALLBACK (viewport_valid_changed_cb), web_view); + * + * /<!-- -->* Handle the viewport-attributes-recompute-requested signal to override the device width *<!-- -->/ + * static void + * viewport_recompute_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, GtkWidget* window) + * { + * int override_available_width = 480; + * g_object_set (G_OBJECT(attributes), "available-width", override_available_width, NULL); + * } + * + * /<!-- -->* Handle the viewport-attributes-changed signal to recompute the initial scale factor *<!-- -->/ + * static void + * viewport_changed_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, gpointer data) + * { + * gfloat initialScale; + * g_object_get (G_OBJECT (atributes), "initial-scale-factor", &initialScale, NULL); + * webkit_web_view_set_zoom_level (web_view, initialScale); + * } + * + * /<!-- -->* Handle the notify::valid signal to initialize the zoom level *<!-- -->/ + * static void + * viewport_valid_changed_cb (WebKitViewportAttributes* attributes, GParamSpec* pspec, WebKitWebView* web_view) + * { + * gboolean is_valid; + * g_object_get (attributes, "valid", &is_valid, NULL); + * if (!is_valid) + * webkit_web_view_set_zoom_level (web_view, 1.0); + * } + * </programlisting></informalexample> + */ + +using namespace WebKit; +using namespace WebCore; + +enum { + PROP_0, + + PROP_DEVICE_WIDTH, + PROP_DEVICE_HEIGHT, + PROP_AVAILABLE_WIDTH, + PROP_AVAILABLE_HEIGHT, + PROP_DESKTOP_WIDTH, + PROP_DEVICE_DPI, + PROP_WIDTH, + PROP_HEIGHT, + PROP_INITIAL_SCALE_FACTOR, + PROP_MINIMUM_SCALE_FACTOR, + PROP_MAXIMUM_SCALE_FACTOR, + PROP_DEVICE_PIXEL_RATIO, + PROP_USER_SCALABLE, + PROP_VALID +}; + +G_DEFINE_TYPE(WebKitViewportAttributes, webkit_viewport_attributes, G_TYPE_OBJECT); + +static void webkit_viewport_attributes_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* paramSpec); +static void webkit_viewport_attributes_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* paramSpec); + +static void webkit_viewport_attributes_class_init(WebKitViewportAttributesClass* kclass) +{ + GObjectClass* gobjectClass = G_OBJECT_CLASS(kclass); + gobjectClass->get_property = webkit_viewport_attributes_get_property; + gobjectClass->set_property = webkit_viewport_attributes_set_property; + + /** + * WebKitViewportAttributs:device-width: + * + * The width of the screen. This value is always automatically + * pre-computed during a viewport attributes recomputation, and + * can be overridden by the handler of + * WebKitWebView::viewport-attributes-recompute-requested. You + * should not do that unless you have a very good reason. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_DEVICE_WIDTH, + g_param_spec_int( + "device-width", + _("Device Width"), + _("The width of the screen."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:device-height: + * + * The height of the screen. This value is always automatically + * pre-computed during a viewport attributes recomputation, and + * can be overriden by the handler of + * WebKitWebView::viewport-attributes-recompute-requested. You + * should not do that unless you have a very good reason. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_DEVICE_HEIGHT, + g_param_spec_int( + "device-height", + _("Device Height"), + _("The height of the screen."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:available-width: + * + * The width of the current visible area. This will usually be the + * same as the space allocated to the widget, but in some cases + * you may have decided to make the widget bigger than the visible + * area. This value is by default initialized to the size + * allocated by the widget, but you can override it in the handler + * of WebKitWebView::viewport-attributes-recompute-requested to + * let the engine know what the visible area is. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_AVAILABLE_WIDTH, + g_param_spec_int( + "available-width", + _("Available Width"), + _("The width of the visible area."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:available-height: + * + * The height of the current visible area. This will usually be the + * same as the space allocated to the widget, but in some cases + * you may have decided to make the widget bigger than the visible + * area. This value is by default initialized to the size + * allocated by the widget, but you can override it in the handler + * of WebKitWebView::viewport-attributes-recompute-requested to + * let the engine know what the visible area is. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_AVAILABLE_HEIGHT, + g_param_spec_int( + "available-height", + _("Available Height"), + _("The height of the visible area."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:desktop-width: + * + * The width of viewport that works well for most web pages designed for + * desktop. This value is initialized to 980 pixels by default and used + * during a viewport attributes recomputation. Also, it can be overriden by + * the handler of WebKitWebView::viewport-attributes-recompute-requested. + * You should not do that unless you have a very good reason. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_DESKTOP_WIDTH, + g_param_spec_int( + "desktop-width", + _("Desktop Width"), + _("The width of viewport that works well for most web pages designed for desktop."), + 0, + G_MAXINT, + 980, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:device-dpi: + * + * The number of dots per inch of the screen. This value is + * initialized to 160 dpi by default and used during a viewport + * attributes recomputation, because it is the dpi of the original + * iPhone and Android devices. Also, it can be overriden by the + * handler of WebKitWebView::viewport-attributes-recompute-requested. + * You should not do that unless you have a very good reason. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_DEVICE_DPI, + g_param_spec_int( + "device-dpi", + _("Device DPI"), + _("The number of dots per inch of the screen."), + 0, + G_MAXINT, + 160, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitViewportAttributs:width: + * + * The width of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_WIDTH, + g_param_spec_int( + "width", + _("Width"), + _("The width of the viewport."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:height: + * + * The height of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_HEIGHT, + g_param_spec_int( + "height", + _("Height"), + _("The height of the viewport."), + 0, + G_MAXINT, + 0, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:initial-scale-factor: + * + * The initial scale of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_INITIAL_SCALE_FACTOR, + g_param_spec_float( + "initial-scale-factor", + _("Initial Scale Factor"), + _("The initial scale of the viewport."), + -1, + G_MAXFLOAT, + -1, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:minimum-scale-factor: + * + * The minimum scale of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_MINIMUM_SCALE_FACTOR, + g_param_spec_float( + "minimum-scale-factor", + _("Minimum Scale Factor"), + _("The minimum scale of the viewport."), + -1, + G_MAXFLOAT, + -1, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:maximum-scale-factor: + * + * The maximum scale of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_MAXIMUM_SCALE_FACTOR, + g_param_spec_float( + "maximum-scale-factor", + _("Maximum Scale Factor"), + _("The maximum scale of the viewport."), + -1, + G_MAXFLOAT, + -1, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:device-pixel-ratio: + * + * The device pixel ratio of the viewport. Before getting this property, + * you need to make sure that #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_DEVICE_PIXEL_RATIO, + g_param_spec_float( + "device-pixel-ratio", + _("Device Pixel Ratio"), + _("The device pixel ratio of the viewport."), + -1, + G_MAXFLOAT, + -1, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:user-scalable: + * + * Determines whether or not the user can zoom in and out. + * Before getting this property, you need to make sure that + * #WebKitViewportAttributes is valid. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_USER_SCALABLE, + g_param_spec_boolean( + _("user-scalable"), + _("User Scalable"), + _("Determines whether or not the user can zoom in and out."), + TRUE, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitViewportAttributs:valid: + * + * Determines whether or not the attributes are valid. + * #WebKitViewportAttributes are only valid on pages + * which have a viewport meta tag, and have already + * had the attributes calculated. + * + * Since: 1.3.8 + */ + g_object_class_install_property(gobjectClass, + PROP_VALID, + g_param_spec_boolean( + _("valid"), + _("Valid"), + _("Determines whether or not the attributes are valid, and can be used."), + FALSE, + WEBKIT_PARAM_READABLE)); + + g_type_class_add_private(kclass, sizeof(WebKitViewportAttributesPrivate)); +} + +static void webkit_viewport_attributes_init(WebKitViewportAttributes* viewport) +{ + viewport->priv = G_TYPE_INSTANCE_GET_PRIVATE(viewport, WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesPrivate); + + viewport->priv->deviceWidth = 0; + viewport->priv->deviceHeight = 0; + viewport->priv->availableWidth = 0; + viewport->priv->availableHeight = 0; + viewport->priv->desktopWidth = 980; // This value works well for most web pages designed for desktop browsers. + viewport->priv->deviceDPI = 160; // It is the dpi of the original iPhone and Android devices. + viewport->priv->width = 0; + viewport->priv->height = 0; + viewport->priv->initialScaleFactor = -1; + viewport->priv->minimumScaleFactor = -1; + viewport->priv->maximumScaleFactor = -1; + viewport->priv->devicePixelRatio = -1; + viewport->priv->userScalable = TRUE; + viewport->priv->isValid = FALSE; +} + +static void webkit_viewport_attributes_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* paramSpec) +{ + WebKitViewportAttributes* viewportAttributes = WEBKIT_VIEWPORT_ATTRIBUTES(object); + WebKitViewportAttributesPrivate* priv = viewportAttributes->priv; + + switch (propertyID) { + case PROP_DEVICE_WIDTH: + g_value_set_int(value, priv->deviceWidth); + break; + case PROP_DEVICE_HEIGHT: + g_value_set_int(value, priv->deviceHeight); + break; + case PROP_AVAILABLE_WIDTH: + g_value_set_int(value, priv->availableWidth); + break; + case PROP_AVAILABLE_HEIGHT: + g_value_set_int(value, priv->availableHeight); + break; + case PROP_DESKTOP_WIDTH: + g_value_set_int(value, priv->desktopWidth); + break; + case PROP_DEVICE_DPI: + g_value_set_int(value, priv->deviceDPI); + break; + case PROP_WIDTH: + g_value_set_int(value, priv->width); + break; + case PROP_HEIGHT: + g_value_set_int(value, priv->height); + break; + case PROP_INITIAL_SCALE_FACTOR: + g_value_set_float(value, priv->initialScaleFactor); + break; + case PROP_MINIMUM_SCALE_FACTOR: + g_value_set_float(value, priv->minimumScaleFactor); + break; + case PROP_MAXIMUM_SCALE_FACTOR: + g_value_set_float(value, priv->maximumScaleFactor); + break; + case PROP_DEVICE_PIXEL_RATIO: + g_value_set_float(value, priv->devicePixelRatio); + break; + case PROP_USER_SCALABLE: + g_value_set_boolean(value, priv->userScalable); + break; + case PROP_VALID: + g_value_set_boolean(value, priv->isValid); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec); + break; + } +} + +static void webkit_viewport_attributes_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* paramSpec) +{ + WebKitViewportAttributes* viewportAttributes = WEBKIT_VIEWPORT_ATTRIBUTES(object); + WebKitViewportAttributesPrivate* priv = viewportAttributes->priv; + + switch (propertyID) { + case PROP_DEVICE_WIDTH: + priv->deviceWidth = g_value_get_int(value); + break; + case PROP_DEVICE_HEIGHT: + priv->deviceHeight = g_value_get_int(value); + break; + case PROP_AVAILABLE_WIDTH: + priv->availableWidth = g_value_get_int(value); + break; + case PROP_AVAILABLE_HEIGHT: + priv->availableHeight = g_value_get_int(value); + break; + case PROP_DESKTOP_WIDTH: + priv->desktopWidth = g_value_get_int(value); + break; + case PROP_DEVICE_DPI: + priv->deviceDPI = g_value_get_int(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, paramSpec); + break; + } +} + +void webkitViewportAttributesRecompute(WebKitViewportAttributes* viewportAttributes) +{ + WebKitViewportAttributesPrivate* priv = viewportAttributes->priv; + WebKitWebView* webView = priv->webView; + + IntRect windowRect(webView->priv->corePage->chrome()->windowRect()); + priv->deviceWidth = windowRect.width(); + priv->deviceHeight = windowRect.height(); + + IntRect rect(webView->priv->corePage->chrome()->pageRect()); + priv->availableWidth = rect.width(); + priv->availableHeight = rect.height(); + + // First of all, we give the application an opportunity to override some of the values. + g_signal_emit_by_name(webView, "viewport-attributes-recompute-requested", viewportAttributes); + + ViewportArguments arguments = webView->priv->corePage->mainFrame()->document()->viewportArguments(); + + ViewportAttributes attributes = computeViewportAttributes(arguments, priv->desktopWidth, priv->deviceWidth, priv->deviceHeight, priv->deviceDPI, IntSize(priv->availableWidth, priv->availableHeight)); + + priv->width = attributes.layoutSize.width(); + priv->height = attributes.layoutSize.height(); + priv->initialScaleFactor = attributes.initialScale; + priv->minimumScaleFactor = attributes.minimumScale; + priv->maximumScaleFactor = attributes.maximumScale; + priv->devicePixelRatio = attributes.devicePixelRatio; + priv->userScalable = arguments.userScalable; + + if (!priv->isValid) { + priv->isValid = TRUE; + g_object_notify(G_OBJECT(viewportAttributes), "valid"); + } + + // Now let the application know it is safe to use the new values. + g_signal_emit_by_name(webView, "viewport-attributes-changed", viewportAttributes); +} + +/** + * webkit_viewport_attributes_recompute: + * @viewportAttributes: a #WebKitViewportAttributes + * + * Recompute the optimal viewport attributes and emit the viewport-attribute-changed signal. + * The viewport-attributes-recompute-requested signal also will be handled to override + * the device size, available size, desktop width, or device DPI. + * + * Since: 1.3.8 + */ +void webkit_viewport_attributes_recompute(WebKitViewportAttributes* viewportAttributes) +{ + if (!viewportAttributes->priv->isValid) + return; + webkitViewportAttributesRecompute(viewportAttributes); +} diff --git a/WebKit/gtk/webkit/webkitviewportattributes.h b/WebKit/gtk/webkit/webkitviewportattributes.h new file mode 100644 index 0000000..7d90c1b --- /dev/null +++ b/WebKit/gtk/webkit/webkitviewportattributes.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 Joone Hur <joone@kldp.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitviewportattributes_h +#define webkitviewportattributes_h + +#include <glib-object.h> +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_VIEWPORT_ATTRIBUTES (webkit_viewport_attributes_get_type()) +#define WEBKIT_VIEWPORT_ATTRIBUTES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributes)) +#define WEBKIT_VIEWPORT_ATTRIBUTES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesClass)) +#define WEBKIT_IS_VIEWPORT_ATTRIBUTES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES)) +#define WEBKIT_IS_VIEWPORT_ATTRIBUTES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES)) +#define WEBKIT_VIEWPORT_ATTRIBUTES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, WebKitViewportAttributesClass)) + +typedef struct _WebKitViewportAttributesPrivate WebKitViewportAttributesPrivate; + +struct _WebKitViewportAttributes { + GObject parent_instance; + + /*< private >*/ + WebKitViewportAttributesPrivate *priv; +}; + +struct _WebKitViewportAttributesClass { + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_webkit_reserved0) (void); + void (*_webkit_reserved1) (void); + void (*_webkit_reserved2) (void); + void (*_webkit_reserved3) (void); +}; + +WEBKIT_API GType +webkit_viewport_attributes_get_type (void); + +WEBKIT_API void +webkit_viewport_attributes_recompute(WebKitViewportAttributes* viewportAttributes); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitviewportattributesprivate.h b/WebKit/gtk/webkit/webkitviewportattributesprivate.h new file mode 100644 index 0000000..11cb668 --- /dev/null +++ b/WebKit/gtk/webkit/webkitviewportattributesprivate.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitviewportattributesprivate_h +#define webkitnavigationactionprivate_h + +#include <webkit/webkitviewportattributes.h> + +extern "C" { + +struct _WebKitViewportAttributesPrivate { + WebKitWebView* webView; + int deviceWidth; + int deviceHeight; + int availableWidth; + int availableHeight; + int desktopWidth; + int deviceDPI; + + int width; + int height; + float initialScaleFactor; + float minimumScaleFactor; + float maximumScaleFactor; + float devicePixelRatio; + gboolean userScalable; + gboolean isValid; +}; + + +void webkitViewportAttributesRecompute(WebKitViewportAttributes*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp index 9b5bf8b..c906ba3 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp @@ -24,8 +24,11 @@ #include "BackForwardListImpl.h" #include "HistoryItem.h" #include "webkitprivate.h" +#include "webkitwebbackforwardlistprivate.h" #include "webkitwebhistoryitem.h" +#include "webkitwebhistoryitemprivate.h" #include "webkitwebview.h" +#include "webkitwebviewprivate.h" #include <glib.h> /** @@ -55,8 +58,6 @@ struct _WebKitWebBackForwardListPrivate { gboolean disposed; }; -#define WEBKIT_WEB_BACK_FORWARD_LIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListPrivate)) - G_DEFINE_TYPE(WebKitWebBackForwardList, webkit_web_back_forward_list, G_TYPE_OBJECT); static void webkit_web_back_forward_list_dispose(GObject* object) @@ -90,7 +91,7 @@ static void webkit_web_back_forward_list_class_init(WebKitWebBackForwardListClas static void webkit_web_back_forward_list_init(WebKitWebBackForwardList* webBackForwardList) { - webBackForwardList->priv = WEBKIT_WEB_BACK_FORWARD_LIST_GET_PRIVATE(webBackForwardList); + webBackForwardList->priv = G_TYPE_INSTANCE_GET_PRIVATE(webBackForwardList, WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListPrivate); } /** diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlistprivate.h b/WebKit/gtk/webkit/webkitwebbackforwardlistprivate.h new file mode 100644 index 0000000..79424c0 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebbackforwardlistprivate.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebbackforwardlistprivate_h +#define webkitwebbackforwardlistprivate_h + +#include "BackForwardListImpl.h" + +namespace WebKit { + +WebCore::BackForwardListImpl* core(WebKitWebBackForwardList*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebdatabase.cpp b/WebKit/gtk/webkit/webkitwebdatabase.cpp index 680d9c9..db72cde 100644 --- a/WebKit/gtk/webkit/webkitwebdatabase.cpp +++ b/WebKit/gtk/webkit/webkitwebdatabase.cpp @@ -20,13 +20,12 @@ #include "config.h" #include "webkitwebdatabase.h" -#include "webkitprivate.h" - #include "DatabaseDetails.h" #include "DatabaseTracker.h" -#include <wtf/text/CString.h> - +#include "webkitprivate.h" +#include "webkitsecurityoriginprivate.h" #include <glib/gi18n-lib.h> +#include <wtf/text/CString.h> /** * SECTION:webkitwebdatabase @@ -78,8 +77,6 @@ struct _WebKitWebDatabasePrivate { static gchar* webkit_database_directory_path = NULL; static guint64 webkit_default_database_quota = 5 * 1024 * 1024; -#define WEBKIT_WEB_DATABASE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabasePrivate)) - static void webkit_web_database_set_security_origin(WebKitWebDatabase* webDatabase, WebKitSecurityOrigin* security_origin); static void webkit_web_database_set_name(WebKitWebDatabase* webDatabase, const gchar* name); @@ -251,7 +248,7 @@ static void webkit_web_database_class_init(WebKitWebDatabaseClass* klass) static void webkit_web_database_init(WebKitWebDatabase* webDatabase) { - webDatabase->priv = WEBKIT_WEB_DATABASE_GET_PRIVATE(webDatabase); + webDatabase->priv = G_TYPE_INSTANCE_GET_PRIVATE(webDatabase, WEBKIT_TYPE_WEB_DATABASE, WebKitWebDatabasePrivate); } // Internal use only diff --git a/WebKit/gtk/webkit/webkitwebdatasource.cpp b/WebKit/gtk/webkit/webkitwebdatasource.cpp index 38c9c48..7d967f7 100644 --- a/WebKit/gtk/webkit/webkitwebdatasource.cpp +++ b/WebKit/gtk/webkit/webkitwebdatasource.cpp @@ -22,18 +22,20 @@ #include "ArchiveResource.h" #include "DocumentLoaderGtk.h" -#include "FrameLoaderClientGtk.h" #include "FrameLoader.h" +#include "FrameLoaderClientGtk.h" #include "KURL.h" #include "PlatformString.h" #include "ResourceRequest.h" -#include "runtime/InitializeThreading.h" #include "SharedBuffer.h" #include "SubstituteData.h" -#include "webkitwebresource.h" +#include "runtime/InitializeThreading.h" +#include "webkitnetworkrequestprivate.h" #include "webkitprivate.h" +#include "webkitwebframeprivate.h" +#include "webkitwebresource.h" +#include "webkitwebviewprivate.h" #include "wtf/Assertions.h" - #include <glib.h> /** @@ -72,8 +74,6 @@ struct _WebKitWebDataSourcePrivate { gchar* unreachableURL; }; -#define WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourcePrivate)) - G_DEFINE_TYPE(WebKitWebDataSource, webkit_web_data_source, G_TYPE_OBJECT); static void webkit_web_data_source_dispose(GObject* object) @@ -133,7 +133,7 @@ static void webkit_web_data_source_class_init(WebKitWebDataSourceClass* klass) static void webkit_web_data_source_init(WebKitWebDataSource* webDataSource) { - webDataSource->priv = WEBKIT_WEB_DATA_SOURCE_GET_PRIVATE(webDataSource); + webDataSource->priv = G_TYPE_INSTANCE_GET_PRIVATE(webDataSource, WEBKIT_TYPE_WEB_DATA_SOURCE, WebKitWebDataSourcePrivate); } WebKitWebDataSource* webkit_web_data_source_new_with_loader(PassRefPtr<WebKit::DocumentLoader> loader) @@ -242,7 +242,7 @@ WebKitNetworkRequest* webkit_web_data_source_get_initial_request(WebKitWebDataSo if (priv->initialRequest) g_object_unref(priv->initialRequest); - priv->initialRequest = webkit_network_request_new_with_core_request(request); + priv->initialRequest = kitNew(request); return priv->initialRequest; } @@ -275,7 +275,7 @@ WebKitNetworkRequest* webkit_web_data_source_get_request(WebKitWebDataSource* we if (priv->networkRequest) g_object_unref(priv->networkRequest); - priv->networkRequest = webkit_network_request_new_with_core_request(request); + priv->networkRequest = kitNew(request); return priv->networkRequest; } @@ -318,7 +318,7 @@ G_CONST_RETURN gchar* webkit_web_data_source_get_encoding(WebKitWebDataSource* w */ gboolean webkit_web_data_source_is_loading(WebKitWebDataSource* webDataSource) { - g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), NULL); + g_return_val_if_fail(WEBKIT_IS_WEB_DATA_SOURCE(webDataSource), FALSE); WebKitWebDataSourcePrivate* priv = webDataSource->priv; diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp index fcb5197..ca2b681 100644 --- a/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/WebKit/gtk/webkit/webkitwebframe.cpp @@ -25,16 +25,11 @@ */ #include "config.h" - -#include "webkitenumtypes.h" #include "webkitwebframe.h" -#include "webkitwebview.h" -#include "webkitmarshal.h" -#include "webkitprivate.h" +#include "AXObjectCache.h" #include "AccessibilityObjectWrapperAtk.h" #include "AnimationController.h" -#include "AXObjectCache.h" #include "DOMObjectCache.h" #include "DocumentLoader.h" #include "DocumentLoaderGtk.h" @@ -42,29 +37,37 @@ #include "FrameLoaderClientGtk.h" #include "FrameTree.h" #include "FrameView.h" -#include <glib/gi18n-lib.h> #include "GCController.h" #include "GraphicsContext.h" #include "GtkVersioning.h" #include "HTMLFrameOwnerElement.h" +#include "JSDOMBinding.h" #include "JSDOMWindow.h" #include "JSElement.h" -#include "JSLock.h" #include "PrintContext.h" #include "RenderListItem.h" -#include "RenderView.h" #include "RenderTreeAsText.h" -#include "JSDOMBinding.h" +#include "RenderView.h" #include "ScriptController.h" #include "SubstituteData.h" +#include "webkitenumtypes.h" +#include "webkitnetworkrequestprivate.h" +#include "webkitnetworkresponseprivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" +#include "webkitsecurityoriginprivate.h" +#include "webkitwebframeprivate.h" +#include "webkitwebview.h" +#include "webkitwebviewprivate.h" +#include <JavaScriptCore/APICast.h> +#include <atk/atk.h> +#include <glib/gi18n-lib.h> +#include <wtf/text/CString.h> + #if ENABLE(SVG) #include "SVGSMILElement.h" #endif -#include <atk/atk.h> -#include <JavaScriptCore/APICast.h> -#include <wtf/text/CString.h> - /** * SECTION:webkitwebframe * @short_description: The content of a #WebKitWebView @@ -378,7 +381,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass) static void webkit_web_frame_init(WebKitWebFrame* frame) { - WebKitWebFramePrivate* priv = WEBKIT_WEB_FRAME_GET_PRIVATE(frame); + WebKitWebFramePrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(frame, WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate); // TODO: Move constructor code here. frame->priv = priv; @@ -401,7 +404,7 @@ WebKitWebFrame* webkit_web_frame_new(WebKitWebView* webView) WebKitWebFrame* frame = WEBKIT_WEB_FRAME(g_object_new(WEBKIT_TYPE_WEB_FRAME, NULL)); WebKitWebFramePrivate* priv = frame->priv; - WebKitWebViewPrivate* viewPriv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + WebKitWebViewPrivate* viewPriv = webView->priv; priv->webView = webView; WebKit::FrameLoaderClient* client = new WebKit::FrameLoaderClient(frame); @@ -742,155 +745,6 @@ WebKitWebDataSource* webkit_web_frame_get_provisional_data_source(WebKitWebFrame return webkit_web_frame_get_data_source_from_core_loader(coreFrame->loader()->provisionalDocumentLoader()); } -/** - * webkit_web_frame_get_children: - * @frame: a #WebKitWebFrame - * - * Return value: child frames of @frame - */ -GSList* webkit_web_frame_get_children(WebKitWebFrame* frame) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return NULL; - - 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()); - if (client) - children = g_slist_append(children, client->webFrame()); - } - - return children; -} - -/** - * webkit_web_frame_get_inner_text: - * @frame: a #WebKitWebFrame - * - * Return value: inner text of @frame - */ -gchar* webkit_web_frame_get_inner_text(WebKitWebFrame* frame) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return g_strdup(""); - - FrameView* view = coreFrame->view(); - - if (view && view->layoutPending()) - view->layout(); - - Element* documentElement = coreFrame->document()->documentElement(); - String string = documentElement->innerText(); - return g_strdup(string.utf8().data()); -} - -/** - * 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) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return g_strdup(""); - - FrameView* view = coreFrame->view(); - - if (view && view->layoutPending()) - view->layout(); - - String string = externalRepresentation(coreFrame); - return g_strdup(string.utf8().data()); -} - -/** - * webkit_web_frame_counter_value_for_element_by_id: - * @frame: a #WebKitWebFrame - * @id: an element ID string - * - * Return value: The counter value of element @id in @frame - */ -gchar* webkit_web_frame_counter_value_for_element_by_id(WebKitWebFrame* frame, const gchar* id) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return 0; - - Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); - if (!coreElement) - return 0; - String counterValue = counterValueForElement(coreElement); - return g_strdup(counterValue.utf8().data()); -} - -/** - * webkit_web_frame_page_number_for_element_by_id - * @frame: a #WebKitWebFrame - * @id: an element ID string - * @pageWidth: width of a page - * @pageHeight: height of a page - * - * Return value: The number of page where the specified element will be put - */ -int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return -1; - - Element* coreElement = coreFrame->document()->getElementById(AtomicString(id)); - if (!coreElement) - return -1; - return PrintContext::pageNumberForElement(coreElement, FloatSize(pageWidth, pageHeight)); -} - -/** - * webkit_web_frame_number_of_pages - * @frame: a #WebKitWebFrame - * @pageWidth: width of a page - * @pageHeight: height of a page - * - * Return value: The number of pages to be printed. - */ -int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - - Frame* coreFrame = core(frame); - if (!coreFrame) - return -1; - - return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidth, pageHeight)); -} - -/** - * webkit_web_frame_get_pending_unload_event_count: - * @frame: a #WebKitWebFrame - * - * Return value: number of pending unload events - */ -guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), 0); - - return core(frame)->domWindow()->pendingUnloadEventListeners(); -} - static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) { PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); @@ -1001,81 +855,6 @@ void webkit_web_frame_print(WebKitWebFrame* frame) } } -bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) -{ - ASSERT(core(frame)); - Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); - if (!coreElement || !coreElement->renderer()) - return false; - return core(frame)->animation()->pauseAnimationAtTime(coreElement->renderer(), AtomicString(name), time); -} - -bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element) -{ - ASSERT(core(frame)); - Element* coreElement = core(frame)->document()->getElementById(AtomicString(element)); - if (!coreElement || !coreElement->renderer()) - return false; - return core(frame)->animation()->pauseTransitionAtTime(coreElement->renderer(), AtomicString(name), time); -} - -bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId) -{ - ASSERT(core(frame)); -#if ENABLE(SVG) - Document* document = core(frame)->document(); - if (!document || !document->svgExtensions()) - return false; - Element* coreElement = document->getElementById(AtomicString(animationId)); - if (!coreElement || !SVGSMILElement::isSMILElement(coreElement)) - return false; - return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreElement), time); -#else - return false; -#endif -} - -gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject) -{ - JSC::ExecState* exec = toJS(context); - Element* element = toElement(toJS(exec, nodeObject)); - if (!element) - return 0; - - return g_strdup(markerTextForListItem(element).utf8().data()); -} - -unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame) -{ - Frame* coreFrame = core(frame); - if (!coreFrame) - return 0; - - AnimationController* controller = coreFrame->animation(); - if (!controller) - return 0; - - return controller->numberOfActiveAnimations(); -} - -void webkit_web_frame_suspend_animations(WebKitWebFrame* frame) -{ - Frame* coreFrame = core(frame); - if (!coreFrame) - return; - - coreFrame->animation()->suspendAnimations(); -} - -void webkit_web_frame_resume_animations(WebKitWebFrame* frame) -{ - Frame* coreFrame = core(frame); - if (!coreFrame) - return; - - coreFrame->animation()->resumeAnimations(); -} - gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame) { Frame* coreFrame = core(frame); @@ -1100,56 +879,6 @@ WebKitLoadStatus webkit_web_frame_get_load_status(WebKitWebFrame* frame) return priv->loadStatus; } -void webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame) -{ - g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); - - core(frame)->tree()->clearName(); -} - -void webkit_gc_collect_javascript_objects() -{ - gcController().garbageCollectNow(); -} - -void webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone) -{ - gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone); -} - -gsize webkit_gc_count_javascript_objects() -{ - JSC::JSLock lock(JSC::SilenceAssertionsOnly); - return JSDOMWindow::commonJSGlobalData()->heap.objectCount(); - -} - -AtkObject* webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); - -#if HAVE(ACCESSIBILITY) - if (!AXObjectCache::accessibilityEnabled()) - AXObjectCache::enableAccessibility(); - - WebKitWebFramePrivate* priv = frame->priv; - if (!priv->coreFrame || !priv->coreFrame->document()) - return NULL; - - RenderView* root = toRenderView(priv->coreFrame->document()->renderer()); - if (!root) - return NULL; - - AtkObject* wrapper = priv->coreFrame->document()->axObjectCache()->getOrCreate(root)->wrapper(); - if (!wrapper) - return NULL; - - return webkit_accessible_get_focused_element(WEBKIT_ACCESSIBLE(wrapper)); -#else - return NULL; -#endif -} - GtkPolicyType webkit_web_frame_get_horizontal_scrollbar_policy(WebKitWebFrame* frame) { g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_POLICY_AUTOMATIC); @@ -1216,19 +945,6 @@ WebKitSecurityOrigin* webkit_web_frame_get_security_origin(WebKitWebFrame* frame return priv->origin; } -void webkit_web_frame_layout(WebKitWebFrame* frame) -{ - Frame* coreFrame = core(frame); - if (!coreFrame) - return; - - FrameView* view = coreFrame->view(); - if (!view) - return; - - view->layout(); -} - /** * webkit_web_frame_get_network_response: * @frame: a #WebKitWebFrame @@ -1252,5 +968,34 @@ WebKitNetworkResponse* webkit_web_frame_get_network_response(WebKitWebFrame* fra if (!loader) return NULL; - return webkit_network_response_new_with_core_response(loader->response()); + return kitNew(loader->response()); +} + +namespace WebKit { + +WebKitWebView* getViewFromFrame(WebKitWebFrame* frame) +{ + WebKitWebFramePrivate* priv = frame->priv; + return priv->webView; +} + +WebCore::Frame* core(WebKitWebFrame* frame) +{ + if (!frame) + return 0; + + WebKitWebFramePrivate* priv = frame->priv; + return priv ? priv->coreFrame : 0; +} + +WebKitWebFrame* kit(WebCore::Frame* coreFrame) +{ + if (!coreFrame) + return 0; + + ASSERT(coreFrame->loader()); + WebKit::FrameLoaderClient* client = static_cast<WebKit::FrameLoaderClient*>(coreFrame->loader()->client()); + return client ? client->webFrame() : 0; +} + } diff --git a/WebKit/gtk/webkit/webkitwebframeprivate.h b/WebKit/gtk/webkit/webkitwebframeprivate.h new file mode 100644 index 0000000..23f1e40 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebframeprivate.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebframeprivate_h +#define webkitwebframeprivate_h + +namespace WebKit { + +WebKitWebView* getViewFromFrame(WebKitWebFrame*); + +WebCore::Frame* core(WebKitWebFrame*); +WebKitWebFrame* kit(WebCore::Frame*); + +} + +extern "C" { + +typedef struct _WebKitWebFramePrivate WebKitWebFramePrivate; +struct _WebKitWebFramePrivate { + WebCore::Frame* coreFrame; + WebKitWebView* webView; + + gchar* name; + gchar* title; + gchar* uri; + WebKitLoadStatus loadStatus; + WebKitSecurityOrigin* origin; +}; + +void webkit_web_frame_core_frame_gone(WebKitWebFrame*); + +// FIXME: move this functionality into 'WebKitWebDataSource'? +WEBKIT_API gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp index ce30704..ac8e57f 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp @@ -23,11 +23,11 @@ #include "webkitwebhistoryitem.h" #include "webkitprivate.h" -#include <glib.h> -#include <glib/gi18n-lib.h> - #include "HistoryItem.h" #include "PlatformString.h" +#include "webkitwebhistoryitemprivate.h" +#include <glib.h> +#include <glib/gi18n-lib.h> #include <wtf/text/CString.h> /** @@ -62,8 +62,6 @@ struct _WebKitWebHistoryItemPrivate { gboolean disposed; }; -#define WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemPrivate)) - enum { PROP_0, @@ -217,7 +215,7 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass) static void webkit_web_history_item_init(WebKitWebHistoryItem* webHistoryItem) { - webHistoryItem->priv = WEBKIT_WEB_HISTORY_ITEM_GET_PRIVATE(webHistoryItem); + webHistoryItem->priv = G_TYPE_INSTANCE_GET_PRIVATE(webHistoryItem, WEBKIT_TYPE_WEB_HISTORY_ITEM, WebKitWebHistoryItemPrivate); } static void webkit_web_history_item_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) diff --git a/WebKit/gtk/webkit/webkitwebhistoryitemprivate.h b/WebKit/gtk/webkit/webkitwebhistoryitemprivate.h new file mode 100644 index 0000000..22b50ee --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebhistoryitemprivate.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebhistoryitemprivate_h +#define webkitwebhistoryitemprivate_h + +#include "HistoryItem.h" + +namespace WebKit { + +WebCore::HistoryItem* core(WebKitWebHistoryItem*); +WebKitWebHistoryItem* kit(PassRefPtr<WebCore::HistoryItem>); + +} + +extern "C" { + +GHashTable* webkit_history_items(); + +WebKitWebHistoryItem* webkit_web_history_item_new_with_core_item(PassRefPtr<WebCore::HistoryItem>); + +WEBKIT_API G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem*); + +WEBKIT_API gboolean webkit_web_history_item_is_target_item(WebKitWebHistoryItem*); + +WEBKIT_API GList* webkit_web_history_item_get_children(WebKitWebHistoryItem*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp index 626df32..ad455bb 100644 --- a/WebKit/gtk/webkit/webkitwebinspector.cpp +++ b/WebKit/gtk/webkit/webkitwebinspector.cpp @@ -24,7 +24,6 @@ #include "FocusController.h" #include "Frame.h" -#include <glib/gi18n-lib.h> #include "HitTestRequest.h" #include "HitTestResult.h" #include "InspectorClientGtk.h" @@ -35,6 +34,8 @@ #include "webkit/WebKitDOMNodePrivate.h" #include "webkitmarshal.h" #include "webkitprivate.h" +#include "webkitwebinspectorprivate.h" +#include <glib/gi18n-lib.h> /** * SECTION:webkitwebinspector @@ -97,8 +98,6 @@ struct _WebKitWebInspectorPrivate { 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); @@ -325,7 +324,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) static void webkit_web_inspector_init(WebKitWebInspector* web_inspector) { - web_inspector->priv = WEBKIT_WEB_INSPECTOR_GET_PRIVATE(web_inspector); + web_inspector->priv = G_TYPE_INSTANCE_GET_PRIVATE(web_inspector, WEBKIT_TYPE_WEB_INSPECTOR, WebKitWebInspectorPrivate); } static void webkit_web_inspector_finalize(GObject* object) @@ -578,3 +577,42 @@ void webkit_web_inspector_execute_script(WebKitWebInspector* webInspector, long WebKitWebInspectorPrivate* priv = webInspector->priv; priv->page->inspectorController()->evaluateForTestInFrontend(callId, script); } + +#ifdef HAVE_GSETTINGS +static bool isSchemaAvailable(const char* schemaID) +{ + const char* const* availableSchemas = g_settings_list_schemas(); + char* const* iter = const_cast<char* const*>(availableSchemas); + + while (*iter) { + if (g_str_equal(schemaID, *iter)) + return true; + iter++; + } + + return false; +} + +GSettings* inspectorGSettings() +{ + static GSettings* settings = 0; + + if (settings) + return settings; + + const gchar* schemaID = "org.webkitgtk-"WEBKITGTK_API_VERSION_STRING".inspector"; + + // Unfortunately GSettings will abort the process execution if the + // schema is not installed, which is the case for when running + // tests, or even the introspection dump at build time, so check + // if we have the schema before trying to initialize it. + if (!isSchemaAvailable(schemaID)) { + g_warning("GSettings schema not found - settings will not be used or saved."); + return 0; + } + + settings = g_settings_new(schemaID); + + return settings; +} +#endif diff --git a/WebKit/gtk/webkit/webkitwebinspectorprivate.h b/WebKit/gtk/webkit/webkitwebinspectorprivate.h new file mode 100644 index 0000000..46d57b0 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebinspectorprivate.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebinspectorprivate_h +#define webkitwebinspectorprivate_h + +extern "C" { + +#ifdef HAVE_GSETTINGS +GSettings* inspectorGSettings(); +#endif + +void webkit_web_inspector_set_inspector_client(WebKitWebInspector*, WebCore::Page*); + +void webkit_web_inspector_set_web_view(WebKitWebInspector*, WebKitWebView*); + +void webkit_web_inspector_set_inspected_uri(WebKitWebInspector*, const gchar*); + +WEBKIT_API void webkit_web_inspector_execute_script(WebKitWebInspector*, long callId, const gchar* script); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp index ce5dd92..b12279e 100644 --- a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp +++ b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp @@ -48,8 +48,6 @@ struct _WebKitWebNavigationActionPrivate { gchar* targetFrame; }; -#define WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionPrivate)) - enum { PROP_0, @@ -118,7 +116,7 @@ static void webkit_web_navigation_action_set_property(GObject* object, guint pro static void webkit_web_navigation_action_init(WebKitWebNavigationAction* navigationAction) { - navigationAction->priv = WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(navigationAction); + navigationAction->priv = G_TYPE_INSTANCE_GET_PRIVATE(navigationAction, WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionPrivate); } static void webkit_web_navigation_action_finalize(GObject* obj) @@ -369,3 +367,17 @@ static void webkit_web_navigation_action_set_target_frame(WebKitWebNavigationAct navigationAction->priv->targetFrame = g_strdup(targetFrame); g_object_notify(G_OBJECT(navigationAction), "target-frame"); } + +namespace WebKit { + +WebKitWebNavigationReason kit(WebCore::NavigationType type) +{ + return (WebKitWebNavigationReason)type; +} + +WebCore::NavigationType core(WebKitWebNavigationReason type) +{ + return static_cast<WebCore::NavigationType>(type); +} + +} diff --git a/WebKit/gtk/webkit/webkitwebnavigationactionprivate.h b/WebKit/gtk/webkit/webkitwebnavigationactionprivate.h new file mode 100644 index 0000000..a8bc5ca --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebnavigationactionprivate.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebnavigationactionprivate_h +#define webkitnavigationactionprivate_h + +#include <webkit/webkitwebnavigationaction.h> + +namespace WebKit { + +WebKitWebNavigationReason kit(WebCore::NavigationType); +WebCore::NavigationType core(WebKitWebNavigationReason); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebplugin.cpp b/WebKit/gtk/webkit/webkitwebplugin.cpp new file mode 100644 index 0000000..0b06416 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebplugin.cpp @@ -0,0 +1,251 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "webkitwebplugin.h" + +#include "PluginPackage.h" +#include "webkitprivate.h" +#include "webkitwebpluginprivate.h" +#include <glib/gi18n-lib.h> + +/** + * SECTION:webkitwebplugin + * @short_description: Represents a plugin, enabling fine-grained control + * @see_also: #WebKitWebPluginDatabase + * + * This object represents a single plugin, found by WebKitGTK+ while + * scanning the various usual directories. This object can be used to + * get more information about a plugin, and enable/disable it, + * allowing fine-grained control of plugins. The list of available + * plugins can be obtained from the #WebKitWebPluginDatabase object. + */ + +using namespace WebCore; + +enum { + PROP_0, + + PROP_ENABLED +}; + +G_DEFINE_TYPE(WebKitWebPlugin, webkit_web_plugin, G_TYPE_OBJECT) + +static void freeMIMEType(WebKitWebPluginMIMEType* mimeType) +{ + if (mimeType->name) + g_free(mimeType->name); + if (mimeType->description) + g_free(mimeType->description); + if (mimeType->extensions) + g_strfreev(mimeType->extensions); + g_slice_free(WebKitWebPluginMIMEType, mimeType); +} + +static void webkit_web_plugin_finalize(GObject* object) +{ + WebKitWebPlugin* plugin = WEBKIT_WEB_PLUGIN(object); + WebKitWebPluginPrivate* priv = plugin->priv; + + g_slist_foreach(priv->mimeTypes, (GFunc)freeMIMEType, 0); + g_slist_free(priv->mimeTypes); + + delete plugin->priv; + + G_OBJECT_CLASS(webkit_web_plugin_parent_class)->finalize(object); +} + +static void webkit_web_plugin_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* paramSpec) +{ + WebKitWebPlugin* plugin = WEBKIT_WEB_PLUGIN(object); + + switch (prop_id) { + case PROP_ENABLED: + g_value_set_boolean(value, webkit_web_plugin_get_enabled(plugin)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, paramSpec); + } +} + +static void webkit_web_plugin_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* paramSpec) +{ + WebKitWebPlugin* plugin = WEBKIT_WEB_PLUGIN(object); + + switch (prop_id) { + case PROP_ENABLED: + webkit_web_plugin_set_enabled(plugin, g_value_get_boolean(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, paramSpec); + } +} + +static void webkit_web_plugin_class_init(WebKitWebPluginClass* klass) +{ + webkit_init(); + + GObjectClass* gobjectClass = reinterpret_cast<GObjectClass*>(klass); + + gobjectClass->finalize = webkit_web_plugin_finalize; + gobjectClass->get_property = webkit_web_plugin_get_property; + gobjectClass->set_property = webkit_web_plugin_set_property; + + g_object_class_install_property(gobjectClass, + PROP_ENABLED, + g_param_spec_boolean("enabled", + _("Enabled"), + _("Whether the plugin is enabled"), + FALSE, + WEBKIT_PARAM_READWRITE)); +} + +static void webkit_web_plugin_init(WebKitWebPlugin *plugin) +{ + plugin->priv = new WebKitWebPluginPrivate(); + plugin->priv->mimeTypes = 0; +} + +namespace WebKit { +WebKitWebPlugin* kitNew(WebCore::PluginPackage* package) +{ + WebKitWebPlugin* plugin = WEBKIT_WEB_PLUGIN(g_object_new(WEBKIT_TYPE_WEB_PLUGIN, 0)); + + plugin->priv->corePlugin = package; + + return plugin; +} +} + +/** + * webkit_web_plugin_get_name: + * @plugin: a #WebKitWebPlugin + * + * Returns: the name string for @plugin. + * + * Since: 1.3.8 + */ +const char* webkit_web_plugin_get_name(WebKitWebPlugin* plugin) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0); + + WebKitWebPluginPrivate* priv = plugin->priv; + + if (!priv->name.length()) + priv->name = priv->corePlugin->name().utf8(); + + return priv->name.data(); +} + +/** + * webkit_web_plugin_get_description: + * @plugin: a #WebKitWebPlugin + * + * Returns: the description string for @plugin. + * + * Since: 1.3.8 + */ +const char* webkit_web_plugin_get_description(WebKitWebPlugin* plugin) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0); + + WebKitWebPluginPrivate* priv = plugin->priv; + + if (!priv->description.length()) + priv->description = priv->corePlugin->description().utf8(); + + return priv->description.data(); +} + +/** + * webkit_web_plugin_get_mimetypes: + * @plugin: a #WebKitWebPlugin + * + * Returns all the #WebKitWebPluginMIMEType that @plugin is handling + * at the moment. + * + * Returns: (transfer none) (element-type WebKitWebPluginMIMEType): a #GSList of #WebKitWebPluginMIMEType + * + * Since: 1.3.8 + */ +GSList* webkit_web_plugin_get_mimetypes(WebKitWebPlugin* plugin) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), 0); + + WebKitWebPluginPrivate* priv = plugin->priv; + + if (priv->mimeTypes) + return priv->mimeTypes; + + const MIMEToDescriptionsMap& mimeToDescriptions = priv->corePlugin->mimeToDescriptions(); + MIMEToDescriptionsMap::const_iterator end = mimeToDescriptions.end(); + + for (MIMEToDescriptionsMap::const_iterator it = mimeToDescriptions.begin(); it != end; ++it) { + WebKitWebPluginMIMEType* mimeType = g_slice_new0(WebKitWebPluginMIMEType); + mimeType->name = g_strdup(it->first.utf8().data()); + mimeType->description = g_strdup(it->second.utf8().data()); + + Vector<String> extensions = priv->corePlugin->mimeToExtensions().get(it->first); + mimeType->extensions = static_cast<gchar**>(g_malloc0(extensions.size() + 1)); + for (unsigned i = 0; i < extensions.size(); i++) + mimeType->extensions[i] = g_strdup(extensions[i].utf8().data()); + + priv->mimeTypes = g_slist_append(priv->mimeTypes, mimeType); + } + + return priv->mimeTypes; +} + +/** + * webkit_web_plugin_set_enabled: + * @plugin: a #WebKitWebPlugin + * @enabled: whether to enable the plugin + * + * Sets the enabled status of the @plugin. + * + * Since: 1.3.8 + */ +void webkit_web_plugin_set_enabled(WebKitWebPlugin* plugin, gboolean enabled) +{ + g_return_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin)); + WebKitWebPluginPrivate* priv = plugin->priv; + + ASSERT(priv->corePlugin); + if (priv->corePlugin->isEnabled() == enabled) + return; + + priv->corePlugin->setEnabled(enabled); + + g_object_notify(G_OBJECT(plugin), "enabled"); +} + +/** + * webkit_web_plugin_get_enabled: + * @plugin: a #WebKitWebPlugin + * + * Returns: %TRUE if the plugin is enabled, %FALSE otherwise + * + * Since: 1.3.8 + */ +gboolean webkit_web_plugin_get_enabled(WebKitWebPlugin* plugin) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN(plugin), FALSE); + + ASSERT(plugin->priv->corePlugin); + return plugin->priv->corePlugin->isEnabled(); +} diff --git a/WebKit/gtk/webkit/webkitwebplugin.h b/WebKit/gtk/webkit/webkitwebplugin.h new file mode 100644 index 0000000..3514d1e --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebplugin.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef webkitwebplugin_h +#define webkitwebplugin_h + +#include <glib-object.h> + +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_WEB_PLUGIN (webkit_web_plugin_get_type()) +#define WEBKIT_WEB_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPlugin)) +#define WEBKIT_WEB_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPluginClass)) +#define WEBKIT_IS_WEB_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_PLUGIN)) +#define WEBKIT_IS_WEB_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_PLUGIN)) +#define WEBKIT_WEB_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_PLUGIN, WebKitWebPluginClass)) + +typedef struct _WebKitWebPluginPrivate WebKitWebPluginPrivate; + +/** + * WebKitWebPluginMIMEType: + * @name: the name of the MIME type. + * @description: the description of the MIME type. + * @extensions: a %NULL-terminated array with the extensions + * associated with this MIME type. + * + * A structure representing one of the MIME types associated with a + * plugin. A #GSList of these objects will be returned by + * #webkit_web_plugin_get_mimetypes, use + * #webkit_web_plugin_mime_type_list_free to free it. + * + * Since: 1.3.8 + */ +typedef struct _WebKitWebPluginMIMEType { + char* name; + char* description; + char** extensions; +} WebKitWebPluginMIMEType; + +struct _WebKitWebPluginClass { + GObjectClass parentClass; +}; + +struct _WebKitWebPlugin { + GObject parentInstance; + + WebKitWebPluginPrivate* priv; +}; + +WEBKIT_API GType +webkit_web_plugin_get_type (void) G_GNUC_CONST; + +WEBKIT_API const char* +webkit_web_plugin_get_name (WebKitWebPlugin*); + +WEBKIT_API const char* +webkit_web_plugin_get_description (WebKitWebPlugin*); + +WEBKIT_API GSList* +webkit_web_plugin_get_mimetypes (WebKitWebPlugin*); + +WEBKIT_API void +webkit_web_plugin_set_enabled (WebKitWebPlugin*, gboolean); + +WEBKIT_API gboolean +webkit_web_plugin_get_enabled (WebKitWebPlugin*); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitwebplugindatabase.cpp b/WebKit/gtk/webkit/webkitwebplugindatabase.cpp new file mode 100644 index 0000000..08328a0 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebplugindatabase.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "webkitwebplugindatabase.h" + +#include "PluginDatabase.h" +#include "webkitprivate.h" +#include "webkitwebplugindatabaseprivate.h" +#include "webkitwebpluginprivate.h" + +/** + * SECTION:webkitwebplugindatabase + * @short_description: Provides information about the plugins the engine knows about + * @see_also: #WebKitWebPlugin + * + * This object allows you to query information about the plugins found + * by the engine while scanning the usual directories. You can then + * use the #WebKitWebPlugin objects to get more information or + * enable/disable individual plugins. + */ + +using namespace WebKit; +using namespace WebCore; + +G_DEFINE_TYPE(WebKitWebPluginDatabase, webkit_web_plugin_database, G_TYPE_OBJECT) + +static void webkit_web_plugin_database_dispose(GObject* object) +{ + G_OBJECT_CLASS(webkit_web_plugin_database_parent_class)->dispose(object); +} + +static void webkit_web_plugin_database_class_init(WebKitWebPluginDatabaseClass* klass) +{ + webkit_init(); + + GObjectClass* gobjectClass = reinterpret_cast<GObjectClass*>(klass); + + gobjectClass->dispose = webkit_web_plugin_database_dispose; + + g_type_class_add_private(klass, sizeof(WebKitWebPluginDatabasePrivate)); +} + +static void webkit_web_plugin_database_init(WebKitWebPluginDatabase* database) +{ + WebKitWebPluginDatabasePrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(database, WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabasePrivate); + database->priv = priv; + + priv->coreDatabase = PluginDatabase::installedPlugins(); +} + +/** + * webkit_web_plugin_database_list_free: + * @list: a #WebKitWebPluginDatabasePluginList + * + * Frees @list. + * + * Since: 1.3.8 + */ +void webkit_web_plugin_database_plugins_list_free(GSList* list) +{ + g_return_if_fail(list); + + for (GSList* p = list; p; p = p->next) + g_object_unref(p->data); + + g_slist_free(list); +} + +/** + * webkit_web_plugin_database_get_plugins: + * @database: a #WebKitWebPluginDatabase + * + * Returns all #WebKitWebPlugin available in @database. + * The returned list must be freed with webkit_web_plugin_database_plugins_list_free() + * + * Returns: (transfer full) (element-type WebKitWebPlugin): a #GSList of #WebKitWebPlugin + * + * Since: 1.3.8 + */ +GSList* webkit_web_plugin_database_get_plugins(WebKitWebPluginDatabase* database) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database), 0); + + GSList* gPlugins = 0; + const Vector<PluginPackage*>& plugins = database->priv->coreDatabase->plugins(); + + for (unsigned int i = 0; i < plugins.size(); ++i) { + PluginPackage* plugin = plugins[i]; + gPlugins = g_slist_append(gPlugins, kitNew(plugin)); + } + + return gPlugins; +} + +/** + * webkit_web_plugin_database_get_plugin_for_mimetype: + * @database: a #WebKitWebPluginDatabase + * @mimeType: a mime type + * + * Returns the #WebKitWebPlugin that is handling @mimeType in the + * @database, or %NULL if there's none doing so. + * + * Returns: (transfer full): a #WebKitWebPlugin + * + * Since: 1.3.8 + */ +WebKitWebPlugin* webkit_web_plugin_database_get_plugin_for_mimetype(WebKitWebPluginDatabase* database, const char* mimeType) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database), 0); + g_return_val_if_fail(mimeType, 0); + + return kitNew(database->priv->coreDatabase->pluginForMIMEType(mimeType)); +} + +/** + * webkit_web_plugin_database_refresh: + * @database: a #WebKitWebPluginDatabase + * + * Refreshes @database adding new plugins that are now in use and + * removing those that have been disabled or are otherwise no longer + * available. + * + * Since: 1.3.8 + */ +void webkit_web_plugin_database_refresh(WebKitWebPluginDatabase* database) +{ + g_return_if_fail(WEBKIT_IS_WEB_PLUGIN_DATABASE(database)); + + database->priv->coreDatabase->refresh(); +} + +WebKitWebPluginDatabase* webkit_web_plugin_database_new(void) +{ + return WEBKIT_WEB_PLUGIN_DATABASE(g_object_new(WEBKIT_TYPE_WEB_PLUGIN_DATABASE, 0)); +} diff --git a/WebKit/gtk/webkit/webkitwebplugindatabase.h b/WebKit/gtk/webkit/webkitwebplugindatabase.h new file mode 100644 index 0000000..0b02c26 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebplugindatabase.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef webkitwebplugindatabase_h +#define webkitwebplugindatabase_h + +#include <glib-object.h> + +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_WEB_PLUGIN_DATABASE (webkit_web_plugin_database_get_type()) +#define WEBKIT_WEB_PLUGIN_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabase)) +#define WEBKIT_WEB_PLUGIN_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabaseClass)) +#define WEBKIT_IS_WEB_PLUGIN_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE)) +#define WEBKIT_IS_WEB_PLUGIN_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_PLUGIN_DATABASE)) +#define WEBKIT_WEB_PLUGIN_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_PLUGIN_DATABASE, WebKitWebPluginDatabaseClass)) + +typedef struct _WebKitWebPluginDatabasePrivate WebKitWebPluginDatabasePrivate; + +struct _WebKitWebPluginDatabaseClass { + GObjectClass parentClass; +}; + +struct _WebKitWebPluginDatabase { + GObject parentInstance; + + WebKitWebPluginDatabasePrivate* priv; +}; + +WEBKIT_API GType +webkit_web_plugin_database_get_type (void) G_GNUC_CONST; + +WEBKIT_API void +webkit_web_plugin_database_plugins_list_free (GSList*); + +WEBKIT_API GSList* +webkit_web_plugin_database_get_plugins (WebKitWebPluginDatabase*); + +WEBKIT_API WebKitWebPlugin* +webkit_web_plugin_database_get_plugin_for_mimetype (WebKitWebPluginDatabase*, const char *); + +WEBKIT_API void +webkit_web_plugin_database_refresh (WebKitWebPluginDatabase*); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h b/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h new file mode 100644 index 0000000..199aede --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebplugindatabaseprivate.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebplugindatabaseprivate_h +#define webkitwebplugindatabaseprivate_h + +#include <glib-object.h> + +namespace WebCore { +class PluginDatabase; +} + +extern "C" { + +typedef struct _WebKitWebPluginDatabasePrivate WebKitWebPluginDatabasePrivate; +struct _WebKitWebPluginDatabasePrivate { + WebCore::PluginDatabase* coreDatabase; +}; + +WebKitWebPluginDatabase* webkit_web_plugin_database_new(); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebpluginprivate.h b/WebKit/gtk/webkit/webkitwebpluginprivate.h new file mode 100644 index 0000000..885313e --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebpluginprivate.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef webkitwebpluginprivate_h +#define webkitwebpluginprivate_h + +#include "webkitwebplugin.h" +#include <glib-object.h> + +namespace WebCore { +class PluginPackage; +} + +namespace WebKit { +WebKitWebPlugin* kitNew(WebCore::PluginPackage* package); +} + +extern "C" { + +typedef struct _WebKitWebPluginPrivate WebKitWebPluginPrivate; +struct _WebKitWebPluginPrivate { + RefPtr<WebCore::PluginPackage> corePlugin; + CString name; + CString description; + GSList* mimeTypes; +}; + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp index 5ef6310..06c1fcb 100644 --- a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp +++ b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp @@ -18,11 +18,12 @@ */ #include "config.h" - #include "webkitwebpolicydecision.h" #include "FrameLoaderTypes.h" #include "webkitprivate.h" +#include "webkitwebframeprivate.h" +#include "webkitwebpolicydecisionprivate.h" using namespace WebKit; using namespace WebCore; @@ -45,8 +46,6 @@ struct _WebKitWebPolicyDecisionPrivate { gboolean isCancelled; }; -#define WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionPrivate)) - static void webkit_web_policy_decision_class_init(WebKitWebPolicyDecisionClass* decisionClass) { g_type_class_add_private(decisionClass, sizeof(WebKitWebPolicyDecisionPrivate)); @@ -54,7 +53,7 @@ static void webkit_web_policy_decision_class_init(WebKitWebPolicyDecisionClass* static void webkit_web_policy_decision_init(WebKitWebPolicyDecision* decision) { - decision->priv = WEBKIT_WEB_POLICY_DECISION_GET_PRIVATE(decision); + decision->priv = G_TYPE_INSTANCE_GET_PRIVATE(decision, WEBKIT_TYPE_WEB_POLICY_DECISION, WebKitWebPolicyDecisionPrivate); } WebKitWebPolicyDecision* webkit_web_policy_decision_new(WebKitWebFrame* frame, WebCore::FramePolicyFunction function) diff --git a/WebKit/gtk/webkit/webkitwebpolicydecisionprivate.h b/WebKit/gtk/webkit/webkitwebpolicydecisionprivate.h new file mode 100644 index 0000000..2d264ab --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebpolicydecisionprivate.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebpolicydecisionprivate_h +#define webkitwebpolicydecisionprivate_h + +#include "webkitwebpolicydecision.h" + +extern "C" { + +WebKitWebPolicyDecision* webkit_web_policy_decision_new(WebKitWebFrame*, WebCore::FramePolicyFunction); + +void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebresource.cpp b/WebKit/gtk/webkit/webkitwebresource.cpp index fb0acfc..c2f3a15 100644 --- a/WebKit/gtk/webkit/webkitwebresource.cpp +++ b/WebKit/gtk/webkit/webkitwebresource.cpp @@ -18,9 +18,7 @@ */ #include "config.h" - #include "webkitwebresource.h" -#include "webkitprivate.h" #include "ArchiveResource.h" #include "KURL.h" @@ -28,7 +26,9 @@ #include "SharedBuffer.h" #include "webkitenumtypes.h" #include "webkitmarshal.h" -#include "wtf/Assertions.h" +#include "webkitprivate.h" +#include "webkitwebresourceprivate.h" +#include <wtf/Assertions.h> #include <wtf/text/CString.h> #include <glib.h> @@ -217,7 +217,7 @@ static void webkit_web_resource_set_property(GObject* object, guint prop_id, con static void webkit_web_resource_init(WebKitWebResource* webResource) { - webResource->priv = WEBKIT_WEB_RESOURCE_GET_PRIVATE(webResource); + webResource->priv = G_TYPE_INSTANCE_GET_PRIVATE(webResource, WEBKIT_TYPE_WEB_RESOURCE, WebKitWebResourcePrivate); } // internal use only diff --git a/WebKit/gtk/webkit/webkitwebresourceprivate.h b/WebKit/gtk/webkit/webkitwebresourceprivate.h new file mode 100644 index 0000000..2ae3d05 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebresourceprivate.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebresourceprivate_h +#define webkitwebresourceprivate_h + +#include "ArchiveResource.h" +#include "webkitwebresource.h" + +extern "C" { + +struct _WebKitWebResourcePrivate { + WebCore::ArchiveResource* resource; + + gchar* uri; + gchar* mimeType; + gchar* textEncoding; + gchar* frameName; + + GString* data; +}; + +WebKitWebResource* webkit_web_resource_new_with_core_resource(PassRefPtr<WebCore::ArchiveResource>); + +void webkit_web_resource_init_with_core_resource(WebKitWebResource*, PassRefPtr<WebCore::ArchiveResource>); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 2661b82..92370d7 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -26,16 +26,15 @@ #include "config.h" #include "webkitwebsettings.h" +#include "FileSystem.h" +#include "Language.h" +#include "PluginDatabase.h" #include "webkitenumtypes.h" #include "webkitprivate.h" #include "webkitversion.h" - -#include "FileSystem.h" -#include "PluginDatabase.h" -#include "Language.h" +#include "webkitwebsettingsprivate.h" #include <wtf/text/CString.h> #include <wtf/text/StringConcatenate.h> - #include <glib/gi18n-lib.h> #if OS(UNIX) #include <sys/utsname.h> @@ -110,6 +109,7 @@ struct _WebKitWebSettingsPrivate { gboolean auto_resize_window; gboolean enable_java_applet; gboolean enable_hyperlink_auditing; + gboolean enable_fullscreen; }; #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate)) @@ -161,7 +161,8 @@ enum { PROP_ENABLE_PAGE_CACHE, PROP_AUTO_RESIZE_WINDOW, PROP_ENABLE_JAVA_APPLET, - PROP_ENABLE_HYPERLINK_AUDITING + PROP_ENABLE_HYPERLINK_AUDITING, + PROP_ENABLE_FULLSCREEN }; // Create a default user agent string @@ -902,12 +903,21 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) FALSE, flags)); + /* Undocumented for now */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_FULLSCREEN, + g_param_spec_boolean("enable-fullscreen", + _("Enable Fullscreen"), + _("Whether the Mozilla style API should be enabled."), + FALSE, + flags)); + g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate)); } static void webkit_web_settings_init(WebKitWebSettings* web_settings) { - web_settings->priv = WEBKIT_WEB_SETTINGS_GET_PRIVATE(web_settings); + web_settings->priv = G_TYPE_INSTANCE_GET_PRIVATE(web_settings, WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate); } static EnchantBroker* get_enchant_broker() @@ -950,6 +960,13 @@ static void webkit_web_settings_finalize(GObject* object) G_OBJECT_CLASS(webkit_web_settings_parent_class)->finalize(object); } +static void getAvailableDictionariesCallback(const char* const languageTag, const char* const, const char* const, const char* const, void* data) +{ + Vector<CString>* dicts = static_cast<Vector<CString>*>(data); + + dicts->append(languageTag); +} + static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object); @@ -1064,6 +1081,14 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con if (enchant_broker_dict_exists(broker, language)) { dict = enchant_broker_request_dict(broker, language); spellDictionaries = g_slist_append(spellDictionaries, dict); + } else { + // No dictionaries selected, we get one from the list + Vector<CString> allDictionaries; + enchant_broker_list_dicts(broker, getAvailableDictionariesCallback, &allDictionaries); + if (!allDictionaries.isEmpty()) { + dict = enchant_broker_request_dict(broker, allDictionaries[0].data()); + spellDictionaries = g_slist_append(spellDictionaries, dict); + } } } g_slist_foreach(priv->enchant_dicts, free_spell_checking_language, 0); @@ -1128,6 +1153,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_ENABLE_HYPERLINK_AUDITING: priv->enable_hyperlink_auditing = g_value_get_boolean(value); break; + case PROP_ENABLE_FULLSCREEN: + priv->enable_fullscreen = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1275,6 +1303,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_HYPERLINK_AUDITING: g_value_set_boolean(value, priv->enable_hyperlink_auditing); break; + case PROP_ENABLE_FULLSCREEN: + g_value_set_boolean(value, priv->enable_fullscreen); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1350,6 +1381,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "auto-resize-window", priv->auto_resize_window, "enable-java-applet", priv->enable_java_applet, "enable-hyperlink-auditing", priv->enable_hyperlink_auditing, + "enable-fullscreen", priv->enable_fullscreen, NULL)); return copy; diff --git a/WebKit/gtk/webkit/webkitwebsettingsprivate.h b/WebKit/gtk/webkit/webkitwebsettingsprivate.h new file mode 100644 index 0000000..e848a08 --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebsettingsprivate.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebsettingsprivate_h +#define webkitwebsettingsprivate_h + +#include "webkitwebsettings.h" + +extern "C" { + +WEBKIT_API void webkit_web_settings_add_extra_plugin_directory(WebKitWebView*, const gchar* directory); + +GSList* webkit_web_settings_get_enchant_dicts(WebKitWebView*); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index 3e888f8..c814474 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -10,6 +10,7 @@ * Copyright (C) 2009, 2010 Igalia S.L. * Copyright (C) 2009 Movial Creative Technologies Inc. * Copyright (C) 2009 Bobby Powers + * Copyright (C) 2010 Joone Hur <joone@kldp.org> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,26 +30,15 @@ #include "config.h" #include "webkitwebview.h" -#include "webkitdownload.h" -#include "webkitenumtypes.h" -#include "webkitgeolocationpolicydecision.h" -#include "webkitmarshal.h" -#include "webkitnetworkrequest.h" -#include "webkitnetworkresponse.h" -#include "webkitprivate.h" -#include "webkitwebinspector.h" -#include "webkitwebbackforwardlist.h" -#include "webkitwebhistoryitem.h" - #include "AXObjectCache.h" #include "AbstractDatabase.h" #include "BackForwardListImpl.h" -#include "MemoryCache.h" +#include "Chrome.h" #include "ChromeClientGtk.h" #include "ClipboardUtilitiesGtk.h" +#include "ContextMenu.h" #include "ContextMenuClientGtk.h" #include "ContextMenuController.h" -#include "ContextMenu.h" #include "Cursor.h" #include "Document.h" #include "DocumentLoader.h" @@ -56,29 +46,29 @@ #include "DragClientGtk.h" #include "DragController.h" #include "DragData.h" -#include "EditorClientGtk.h" #include "Editor.h" +#include "EditorClientGtk.h" #include "EventHandler.h" #include "FloatQuad.h" #include "FocusController.h" #include "FrameLoader.h" #include "FrameLoaderTypes.h" #include "FrameView.h" -#include <glib/gi18n-lib.h> -#include <GOwnPtr.h> -#include <GOwnPtrGtk.h> +#include "GOwnPtrGtk.h" #include "GraphicsContext.h" #include "GtkVersioning.h" +#include "HTMLNames.h" #include "HitTestRequest.h" #include "HitTestResult.h" #include "IconDatabase.h" #include "InspectorClientGtk.h" +#include "MemoryCache.h" #include "MouseEventWithHitTestResults.h" #include "NotImplemented.h" #include "PageCache.h" #include "Pasteboard.h" -#include "PasteboardHelperGtk.h" #include "PasteboardHelper.h" +#include "PasteboardHelperGtk.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" #include "ProgressTracker.h" @@ -87,9 +77,31 @@ #include "ScriptValue.h" #include "Scrollbar.h" #include "webkit/WebKitDOMDocumentPrivate.h" -#include <wtf/text/CString.h> - +#include "webkitdownload.h" +#include "webkitdownloadprivate.h" +#include "webkitenumtypes.h" +#include "webkitgeolocationpolicydecision.h" +#include "webkithittestresultprivate.h" +#include "webkitmarshal.h" +#include "webkitnetworkrequest.h" +#include "webkitnetworkresponse.h" +#include "webkitprivate.h" +#include "webkitviewportattributes.h" +#include "webkitviewportattributesprivate.h" +#include "webkitwebbackforwardlist.h" +#include "webkitwebframeprivate.h" +#include "webkitwebhistoryitem.h" +#include "webkitwebhistoryitemprivate.h" +#include "webkitwebinspector.h" +#include "webkitwebinspectorprivate.h" +#include "webkitwebpolicydecision.h" +#include "webkitwebresource.h" +#include "webkitwebplugindatabaseprivate.h" +#include "webkitwebviewprivate.h" #include <gdk/gdkkeysyms.h> +#include <glib/gi18n-lib.h> +#include <wtf/gobject/GOwnPtr.h> +#include <wtf/text/CString.h> /** * SECTION:webkitwebview @@ -107,7 +119,7 @@ * * <programlisting> * /<!-- -->* Create the widgets *<!-- -->/ - * GtkWidget *main_window = gtk_window_new (GTK_WIDGET_TOPLEVEL); + * GtkWidget *main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); * GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL); * GtkWidget *web_view = webkit_web_view_new (); * @@ -125,7 +137,7 @@ */ static const double defaultDPI = 96.0; -static WebKitCacheModel cacheModel; +static WebKitCacheModel cacheModel = WEBKIT_CACHE_MODEL_DEFAULT; static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& clientPoint); using namespace WebKit; @@ -173,7 +185,6 @@ enum { GEOLOCATION_POLICY_DECISION_CANCELLED, ONLOAD_EVENT, FRAME_CREATED, - SHOULD_BEGIN_EDITING, SHOULD_END_EDITING, SHOULD_INSERT_NODE, @@ -185,6 +196,8 @@ enum { EDITING_BEGAN, USER_CHANGED_CONTENTS, EDITING_ENDED, + VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED, + VIEWPORT_ATTRIBUTES_CHANGED, LAST_SIGNAL }; @@ -199,6 +212,7 @@ enum { PROP_EDITABLE, PROP_SETTINGS, PROP_WEB_INSPECTOR, + PROP_VIEWPORT_ATTRIBUTES, PROP_WINDOW_FEATURES, PROP_TRANSPARENT, PROP_ZOOM_LEVEL, @@ -237,7 +251,7 @@ static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView*); static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData) { WebKitWebView* view = WEBKIT_WEB_VIEW(userData); - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(view); + WebKitWebViewPrivate* priv = view->priv; GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view)); GtkRequisition menuSize; @@ -265,6 +279,25 @@ static Node* getFocusedNode(Frame* frame) return 0; } +static void contextMenuItemActivated(GtkMenuItem* item, ContextMenuController* controller) +{ + ContextMenuItem contextItem(item); + controller->contextMenuItemSelected(&contextItem); +} + +static void contextMenuConnectActivate(GtkMenuItem* item, ContextMenuController* controller) +{ + if (GTK_IS_SEPARATOR_MENU_ITEM(item)) + return; + + if (GtkWidget* menu = gtk_menu_item_get_submenu(item)) { + gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller); + return; + } + + g_signal_connect(item, "activate", G_CALLBACK(contextMenuItemActivated), controller); +} + static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event) { Page* page = core(webView); @@ -305,7 +338,8 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie // If coreMenu is NULL, this means WebCore decided to not create // the default context menu; this may happen when the page is // handling the right-click for reasons other than the context menu. - ContextMenu* coreMenu = page->contextMenuController()->contextMenu(); + ContextMenuController* controller = page->contextMenuController(); + ContextMenu* coreMenu = controller->contextMenu(); if (!coreMenu) return mousePressEventResult; @@ -323,22 +357,23 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie if (!menu) return FALSE; + // We connect the "activate" signal here rather than in ContextMenuGtk to avoid + // a layering violation. ContextMenuGtk should not know about the ContextMenuController. + gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback)contextMenuConnectActivate, controller); + g_signal_emit(webView, webkit_web_view_signals[POPULATE_POPUP], 0, menu); - GList* items = gtk_container_get_children(GTK_CONTAINER(menu)); - bool empty = !g_list_nth(items, 0); - g_list_free(items); - if (empty) + // If the context menu is now empty, don't show it. + GOwnPtr<GList> items(gtk_container_get_children(GTK_CONTAINER(menu))); + if (!items) return FALSE; - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + WebKitWebViewPrivate* priv = webView->priv; priv->currentMenu = menu; priv->lastPopupXPosition = event.globalX(); priv->lastPopupYPosition = event.globalY(); - gtk_menu_popup(menu, NULL, NULL, - &PopupMenuPositionFunc, - webView, event.button() + 1, gtk_get_current_event_time()); + gtk_menu_popup(menu, 0, 0, &PopupMenuPositionFunc, webView, event.button() + 1, gtk_get_current_event_time()); return TRUE; } @@ -508,6 +543,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* case PROP_WEB_INSPECTOR: g_value_set_object(value, webkit_web_view_get_inspector(webView)); break; + case PROP_VIEWPORT_ATTRIBUTES: + g_value_set_object(value, webkit_web_view_get_viewport_attributes(webView)); + break; case PROP_WINDOW_FEATURES: g_value_set_object(value, webkit_web_view_get_window_features(webView)); break; @@ -1355,6 +1393,7 @@ static void webkit_web_view_dispose(GObject* object) } priv->webInspector.clear(); + priv->viewportAttributes.clear(); priv->webWindowFeatures.clear(); priv->mainResource.clear(); priv->subResources.clear(); @@ -1477,7 +1516,7 @@ static IntPoint globalPointForClientPoint(GdkWindow* window, const IntPoint& cli static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + WebKitWebViewPrivate* priv = webView->priv; // This might happen if a drag is still in progress after a WebKitWebView // is disposed and before it is finalized. @@ -1515,7 +1554,7 @@ static void webkit_web_view_drag_end(GtkWidget* widget, GdkDragContext* context) static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint) { - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(WEBKIT_WEB_VIEW(widget)); + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; // This might happen if a drag is still in progress after a WebKitWebView // is diposed and before it is finalized. @@ -1652,7 +1691,7 @@ static gboolean webkit_web_view_drag_drop(GtkWidget* widget, GdkDragContext* con #if GTK_CHECK_VERSION(2, 12, 0) static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip) { - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(widget); + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW(widget)->priv; if (keyboard_mode) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); @@ -1670,8 +1709,10 @@ static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, if (titleNode->isElementNode()) { String title = static_cast<Element*>(titleNode)->title(); if (!title.isEmpty()) { - GdkRectangle area = coreFrame->view()->contentsToWindow(node->getRect()); - gtk_tooltip_set_tip_area(tooltip, &area); + if (FrameView* view = coreFrame->view()) { + GdkRectangle area = view->contentsToWindow(node->getRect()); + gtk_tooltip_set_tip_area(tooltip, &area); + } gtk_tooltip_set_text(tooltip, title.utf8().data()); return TRUE; @@ -2716,6 +2757,55 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); /* + * WebKitWebView::viewport-attributes-recompute-requested + * @web_view: the object which received the signal + * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes. + * + * The #WebKitWebView::viewport-attributes-recompute-requested + * signal will be emitted when a page with a viewport meta tag + * loads and when webkit_viewport_attributes_recompute is called. + * + * The #WebKitViewportAttributes will have device size, available size, + * desktop width, and device DPI pre-filled by values that make sense + * for the current screen and widget, but you can override those values + * if you have special requirements (for instance, if you made your + * widget bigger than the available visible area, you should override + * the available-width and available-height properties to the actual + * visible area). + * + * Since: 1.3.8 + */ + webkit_web_view_signals[VIEWPORT_ATTRIBUTES_RECOMPUTE_REQUESTED] = g_signal_new("viewport-attributes-recompute-requested", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + 0, 0, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + WEBKIT_TYPE_VIEWPORT_ATTRIBUTES); + + /* + * WebKitWebView::viewport-attributes-changed + * @web_view: the object which received the signal + * @viewport_attributes: the #WebKitViewportAttributes which has the viewport attributes. + * + * The #WebKitWebView::viewport-attributes-changed signal will be emitted + * after the emission of #WebKitWebView::viewport-attributes-recompute-requested + * and the subsequent viewport attribute recomputation. At this point, + * if the #WebKitViewportAttributes are valid, the viewport attributes are available. + * + * Since: 1.3.8 + */ + webkit_web_view_signals[VIEWPORT_ATTRIBUTES_CHANGED] = g_signal_new("viewport-attributes-changed", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + 0, 0, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + WEBKIT_TYPE_VIEWPORT_ATTRIBUTES); + + /* * implementations of virtual methods */ webViewClass->create_web_view = webkit_web_view_real_create_web_view; @@ -2959,6 +3049,20 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_PARAM_READABLE)); /** + * WebKitWebView:viewport-attributes: + * + * The associated #WebKitViewportAttributes instance. + * + * Since: 1.3.8 + */ + g_object_class_install_property(objectClass, PROP_VIEWPORT_ATTRIBUTES, + g_param_spec_object("viewport-attributes", + _("Viewport Attributes"), + _("The associated WebKitViewportAttributes instance"), + WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, + WEBKIT_PARAM_READABLE)); + + /** * WebKitWebView:window-features: * * An associated WebKitWebWindowFeatures instance. @@ -3157,7 +3261,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) javaScriptCanAccessClipboard, enableOfflineWebAppCache, enableUniversalAccessFromFileURI, enableFileAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements, - enableSiteSpecificQuirks, usePageCache, enableJavaApplet, enableHyperlinkAuditing; + enableSiteSpecificQuirks, usePageCache, enableJavaApplet, enableHyperlinkAuditing, enableFullscreen; WebKitEditingBehavior editingBehavior; @@ -3196,6 +3300,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "enable-page-cache", &usePageCache, "enable-java-applet", &enableJavaApplet, "enable-hyperlink-auditing", &enableHyperlinkAuditing, + "enable-fullscreen", &enableFullscreen, NULL); settings->setDefaultTextEncodingName(defaultEncoding); @@ -3233,7 +3338,9 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) settings->setUsesPageCache(usePageCache); settings->setJavaEnabled(enableJavaApplet); settings->setHyperlinkAuditingEnabled(enableHyperlinkAuditing); - +#if ENABLE(FULLSCREEN_API) + settings->setFullScreenEnabled(enableFullscreen); +#endif Page* page = core(webView); if (page) page->setTabKeyCyclesThroughElements(tabKeyCyclesThroughElements); @@ -3355,7 +3462,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar static void webkit_web_view_init(WebKitWebView* webView) { - WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(webView); + WebKitWebViewPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(webView, WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate); webView->priv = priv; // This is the placement new syntax: http://www.parashift.com/c++-faq-lite/dtors.html#faq-11.10 // It allows us to call a constructor on manually allocated locations in memory. We must use it @@ -3385,6 +3492,10 @@ static void webkit_web_view_init(WebKitWebView* webView) priv->webInspector = adoptPlatformRef(WEBKIT_WEB_INSPECTOR(g_object_new(WEBKIT_TYPE_WEB_INSPECTOR, NULL))); webkit_web_inspector_set_inspector_client(priv->webInspector.get(), priv->corePage); + // And our ViewportAttributes friend. + priv->viewportAttributes = adoptPlatformRef(WEBKIT_VIEWPORT_ATTRIBUTES(g_object_new(WEBKIT_TYPE_VIEWPORT_ATTRIBUTES, NULL))); + priv->viewportAttributes->priv->webView = webView; + // The smart pointer will call g_object_ref_sink on these adjustments. 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)); @@ -3524,6 +3635,29 @@ WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) return webView->priv->webInspector.get(); } +/** + * webkit_web_view_get_viewport_attributes: + * @webView: a #WebKitWebView + * + * Obtains the #WebKitViewportAttributes associated with the + * #WebKitWebView. Every #WebKitWebView object has a + * #WebKitWebViewporAttributes 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. Do note however that the viewport + * attributes object only contains valid information when the current + * page has a viewport meta tag. You can check whether the data should + * be used by checking the #WebKitViewport:valid property. + * + * Return value: (transfer none): the #WebKitViewportAttributes instance. + * + * Since: 1.3.8 + */ +WebKitViewportAttributes* webkit_web_view_get_viewport_attributes(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + return webView->priv->viewportAttributes.get(); +} + // internal static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures) { @@ -4000,7 +4134,7 @@ void webkit_web_view_execute_script(WebKitWebView* webView, const gchar* script) } /** - * webkit_web_view_cut_clipboard: + * webkit_web_view_can_cut_clipboard: * @webView: a #WebKitWebView * * Determines whether or not it is currently possible to cut to the clipboard. @@ -4016,7 +4150,7 @@ gboolean webkit_web_view_can_cut_clipboard(WebKitWebView* webView) } /** - * webkit_web_view_copy_clipboard: + * webkit_web_view_can_copy_clipboard: * @webView: a #WebKitWebView * * Determines whether or not it is currently possible to copy to the clipboard. @@ -4032,7 +4166,7 @@ gboolean webkit_web_view_can_copy_clipboard(WebKitWebView* webView) } /** - * webkit_web_view_paste_clipboard: + * webkit_web_view_can_paste_clipboard: * @webView: a #WebKitWebView * * Determines whether or not it is currently possible to paste from the clipboard. @@ -4754,16 +4888,17 @@ gboolean webkit_web_view_get_view_source_mode (WebKitWebView* webView) } // Internal subresource management -void webkit_web_view_add_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) +void webkit_web_view_add_main_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) { WebKitWebViewPrivate* priv = webView->priv; - if (!priv->mainResource) { - priv->mainResource = adoptPlatformRef(webResource); - priv->mainResourceIdentifier = identifier; - return; - } + priv->mainResource = adoptPlatformRef(webResource); + priv->mainResourceIdentifier = identifier; +} +void webkit_web_view_add_resource(WebKitWebView* webView, const char* identifier, WebKitWebResource* webResource) +{ + WebKitWebViewPrivate* priv = webView->priv; g_hash_table_insert(priv->subResources.get(), g_strdup(identifier), webResource); } @@ -4804,8 +4939,6 @@ WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView* webView) void webkit_web_view_clear_resources(WebKitWebView* webView) { WebKitWebViewPrivate* priv = webView->priv; - priv->mainResourceIdentifier = ""; - priv->mainResource = 0; if (priv->subResources) g_hash_table_remove_all(priv->subResources.get()); @@ -4992,6 +5125,8 @@ void webkit_set_cache_model(WebKitCacheModel model) deadDecodedDataDeletionInterval = 0; break; case WEBKIT_CACHE_MODEL_WEB_BROWSER: + // Page cache capacity (in pages). Comment from Mac port: + // (Research indicates that value / page drops substantially after 3 pages.) pageCacheCapacity = 3; cacheTotalCapacity = 32 * 1024 * 1024; cacheMinDeadCapacity = cacheTotalCapacity / 4; @@ -5025,21 +5160,26 @@ WebKitCacheModel webkit_get_cache_model() return cacheModel; } -void webkit_web_view_execute_core_command_by_name(WebKitWebView* webView, const gchar* name, const gchar* value) +/** + * webkit_get_web_plugin_database: + * + * Returns the current #WebKitWebPluginDatabase with information about + * all the plugins WebKit knows about in this instance. + * + * Return value: (transfer none): the current #WebKitWebPluginDatabase + * + * Since: 1.3.8 + */ +WebKitWebPluginDatabase* webkit_get_web_plugin_database() { - g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - g_return_if_fail(name); - g_return_if_fail(value); + static WebKitWebPluginDatabase* database = 0; - core(webView)->focusController()->focusedOrMainFrame()->editor()->command(name).execute(value); -} + webkit_init(); -gboolean webkit_web_view_is_command_enabled(WebKitWebView* webView, const gchar* name) -{ - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - g_return_val_if_fail(name, FALSE); + if (!database) + database = webkit_web_plugin_database_new(); - return core(webView)->focusController()->focusedOrMainFrame()->editor()->command(name).isEnabled(); + return database; } GtkMenu* webkit_web_view_get_context_menu(WebKitWebView* webView) @@ -5055,3 +5195,54 @@ GtkMenu* webkit_web_view_get_context_menu(WebKitWebView* webView) return 0; #endif } + +void webViewEnterFullscreen(WebKitWebView* webView, Node* node) +{ + if (!node->hasTagName(HTMLNames::videoTag)) + return; + +#if ENABLE(VIDEO) + HTMLMediaElement* videoElement = static_cast<HTMLMediaElement*>(node); + WebKitWebViewPrivate* priv = webView->priv; + + // First exit Fullscreen for the old mediaElement. + if (priv->fullscreenVideoController) + priv->fullscreenVideoController->exitFullscreen(); + + priv->fullscreenVideoController = new FullscreenVideoController; + priv->fullscreenVideoController->setMediaElement(videoElement); + priv->fullscreenVideoController->enterFullscreen(); +#endif +} + +void webViewExitFullscreen(WebKitWebView* webView) +{ +#if ENABLE(VIDEO) + WebKitWebViewPrivate* priv = webView->priv; + if (priv->fullscreenVideoController) + priv->fullscreenVideoController->exitFullscreen(); +#endif +} + +namespace WebKit { + +WebCore::Page* core(WebKitWebView* webView) +{ + if (!webView) + return 0; + + WebKitWebViewPrivate* priv = webView->priv; + return priv ? priv->corePage : 0; +} + +WebKitWebView* kit(WebCore::Page* corePage) +{ + if (!corePage) + return 0; + + ASSERT(corePage->chrome()); + WebKit::ChromeClient* client = static_cast<WebKit::ChromeClient*>(corePage->chrome()->client()); + return client ? client->webView() : 0; +} + +} diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h index cf8e669..9abfef6 100644 --- a/WebKit/gtk/webkit/webkitwebview.h +++ b/WebKit/gtk/webkit/webkitwebview.h @@ -50,8 +50,21 @@ typedef enum { WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD } WebKitNavigationResponse; +/* + * WebKitCacheModel: + * @WEBKIT_CACHE_MODEL_DEFAULT: The default cache model. This is + * WEBKIT_CACHE_MODEL_WEB_BROWSER. + * @WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: Disable the cache completely, which + * substantially reduces memory usage. Useful for applications that only + * access local files. + * @WEBKIT_CACHE_MODEL_WEB_BROWSER: Improve document load speed substantially + * by caching previously viewed content. + * + * Enum values used for determining the webview cache model. + */ typedef enum { - WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER = 1, + WEBKIT_CACHE_MODEL_DEFAULT, + WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER, WEBKIT_CACHE_MODEL_WEB_BROWSER } WebKitCacheModel; @@ -351,6 +364,9 @@ webkit_web_view_set_full_content_zoom (WebKitWebView *webView, WEBKIT_API SoupSession* webkit_get_default_session (void); +WEBKIT_API WebKitWebPluginDatabase * +webkit_get_web_plugin_database (void); + WEBKIT_API const gchar* webkit_web_view_get_encoding (WebKitWebView * webView); @@ -414,6 +430,9 @@ webkit_get_cache_model (void); WEBKIT_API WebKitDOMDocument * webkit_web_view_get_dom_document (WebKitWebView *webView); +WEBKIT_API WebKitViewportAttributes* +webkit_web_view_get_viewport_attributes (WebKitWebView *webView); + G_END_DECLS #endif diff --git a/WebKit/gtk/webkit/webkitwebviewprivate.h b/WebKit/gtk/webkit/webkitwebviewprivate.h new file mode 100644 index 0000000..dec6dad --- /dev/null +++ b/WebKit/gtk/webkit/webkitwebviewprivate.h @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2007, 2008, 2009 Holger Hans Peter Freyther + * Copyright (C) 2008 Jan Michael C. Alonzo + * Copyright (C) 2008, 2010 Collabora Ltd. + * Copyright (C) 2010 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitwebviewprivate_h +#define webkitwebviewprivate_h + +#include "DataObjectGtk.h" +#include "FullscreenVideoController.h" +#include "GOwnPtr.h" +#include "ResourceHandle.h" +#include <webkit/webkitwebview.h> + +namespace WebKit { + +WebCore::Page* core(WebKitWebView*); +WebKitWebView* kit(WebCore::Page*); + + +typedef struct DroppingContext_ { + WebKitWebView* webView; + GdkDragContext* gdkContext; + RefPtr<WebCore::DataObjectGtk> dataObject; + WebCore::IntPoint lastMotionPosition; + int pendingDataRequests; + bool dropHappened; +} DroppingContext; + +} + +extern "C" { + +#define WEBKIT_WEB_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate)) +typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; +struct _WebKitWebViewPrivate { + WebCore::Page* corePage; + PlatformRefPtr<WebKitWebSettings> webSettings; + PlatformRefPtr<WebKitWebInspector> webInspector; + PlatformRefPtr<WebKitViewportAttributes> viewportAttributes; + PlatformRefPtr<WebKitWebWindowFeatures> webWindowFeatures; + + WebKitWebFrame* mainFrame; + PlatformRefPtr<WebKitWebBackForwardList> backForwardList; + + PlatformRefPtr<GtkMenu> currentMenu; + gint lastPopupXPosition; + gint lastPopupYPosition; + + HashSet<GtkWidget*> children; + bool editable; + PlatformRefPtr<GtkIMContext> imContext; + + gboolean transparent; + + PlatformRefPtr<GtkAdjustment> horizontalAdjustment; + PlatformRefPtr<GtkAdjustment> verticalAdjustment; + +#ifndef GTK_API_VERSION_2 + // GtkScrollablePolicy needs to be checked when + // driving the scrollable adjustment values + GtkScrollablePolicy horizontalScrollingPolicy; + GtkScrollablePolicy verticalScrollingPolicy; +#endif + + gboolean zoomFullContent; + WebKitLoadStatus loadStatus; + CString encoding; + CString customEncoding; + + CString iconURI; + + gboolean disposing; + gboolean usePrimaryForPaste; + +#if ENABLE(VIDEO) + FullscreenVideoController* fullscreenVideoController; +#endif + + // These are hosted here because the DataSource object is + // created too late in the frame loading process. + PlatformRefPtr<WebKitWebResource> mainResource; + CString mainResourceIdentifier; + PlatformRefPtr<GHashTable> subResources; + CString tooltipText; + WebCore::IntRect tooltipArea; + + int currentClickCount; + WebCore::IntPoint previousClickPoint; + guint previousClickButton; + guint32 previousClickTime; + HashMap<GdkDragContext*, RefPtr<WebCore::DataObjectGtk> > draggingDataObjects; + HashMap<GdkDragContext*, WebKit::DroppingContext*> droppingContexts; +}; + +void webkit_web_view_notify_ready(WebKitWebView*); + +void webkit_web_view_request_download(WebKitWebView*, WebKitNetworkRequest*, const WebCore::ResourceResponse& = WebCore::ResourceResponse(), WebCore::ResourceHandle* = 0); + +void webkit_web_view_add_resource(WebKitWebView*, const char*, WebKitWebResource*); +void webkit_web_view_add_main_resource(WebKitWebView*, const char*, WebKitWebResource*); +void webkit_web_view_remove_resource(WebKitWebView*, const char*); +WebKitWebResource* webkit_web_view_get_resource(WebKitWebView*, char*); +WebKitWebResource* webkit_web_view_get_main_resource(WebKitWebView*); +void webkit_web_view_clear_resources(WebKitWebView*); +GList* webkit_web_view_get_subresources(WebKitWebView*); + +void webkit_web_view_set_tooltip_text(WebKitWebView*, const char*); +GtkMenu* webkit_web_view_get_context_menu(WebKitWebView*); + +WEBKIT_API gchar* webkit_web_view_get_selected_text(WebKitWebView*); +bool webkit_web_view_use_primary_for_paste(WebKitWebView*); + +void webViewEnterFullscreen(WebKitWebView* webView, WebCore::Node*); +void webViewExitFullscreen(WebKitWebView* webView); + +} + +#endif diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp index e5d65bd..ddc657d 100644 --- a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp +++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp @@ -276,7 +276,7 @@ static void webkit_web_window_features_class_init(WebKitWebWindowFeaturesClass* static void webkit_web_window_features_init(WebKitWebWindowFeatures* web_window_features) { - web_window_features->priv = WEBKIT_WEB_WINDOW_FEATURES_GET_PRIVATE(web_window_features); + web_window_features->priv = G_TYPE_INSTANCE_GET_PRIVATE(web_window_features, WEBKIT_TYPE_WEB_WINDOW_FEATURES, WebKitWebWindowFeaturesPrivate); } static void webkit_web_window_features_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) diff --git a/WebKit/gtk/webkit/webkitworkers.cpp b/WebKit/gtk/webkit/webkitworkers.cpp deleted file mode 100644 index 255863c..0000000 --- a/WebKit/gtk/webkit/webkitworkers.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "webkitprivate.h" - -#include "WorkerThread.h" - -unsigned int webkit_worker_thread_count(void) -{ -#if ENABLE(WORKERS) - return WebCore::WorkerThread::workerThreadCount(); -#else - return 0; -#endif -} - - |