Changeset 98845 in webkit
- Timestamp:
- Oct 31, 2011 4:45:37 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r98842 r98845 1 2011-10-31 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add methods to get/set the settings of a web view to WebKit2 GTK+ API 4 https://bugs.webkit.org/show_bug.cgi?id=71109 5 6 Reviewed by Martin Robinson. 7 8 * GNUmakefile.am: Add WebKitSettingsPrivate.h. 9 * UIProcess/API/gtk/WebKitSettings.cpp: 10 (webkitSettingsAttachSettingsToPage): Set the preferences of the 11 given WebKitSettings object to the page group of the given WKPage. 12 * UIProcess/API/gtk/WebKitSettingsPrivate.h: Added. 13 * UIProcess/API/gtk/WebKitWebView.cpp: 14 (webkitWebViewConstructed): Create the default WebKitSettings for 15 the view. 16 (webkit_web_view_set_settings): 17 (webkit_web_view_get_settings): 18 * UIProcess/API/gtk/WebKitWebView.h: 19 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: 20 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 21 (testWebViewSettings): 22 (beforeAll): 23 1 24 2011-10-31 Carlos Garcia Campos <cgarcia@igalia.com> 2 25 -
trunk/Source/WebKit2/GNUmakefile.am
r98842 r98845 498 498 Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp \ 499 499 Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h \ 500 Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h \ 500 501 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h \ 501 502 Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
r98497 r98845 33 33 34 34 #include "WebKitPrivate.h" 35 #include <WebKit2/WKPreferences.h>35 #include "WebKitSettingsPrivate.h" 36 36 #include <WebKit2/WKRetainPtr.h> 37 #include <WebKit2/WKType.h>38 37 #include <glib/gi18n-lib.h> 39 38 … … 381 380 } 382 381 382 void webkitSettingsAttachSettingsToPage(WebKitSettings* settings, WKPageRef wkPage) 383 { 384 WKPageGroupSetPreferences(WKPageGetPageGroup(wkPage), settings->priv->preferences.get()); 385 } 386 383 387 /** 384 388 * webkit_settings_new: -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r98707 r98845 22 22 23 23 #include "WebKitBackForwardListPrivate.h" 24 #include "WebKitSettingsPrivate.h" 24 25 #include "WebKitWebContextPrivate.h" 25 26 #include "WebKitWebLoaderClient.h" … … 55 56 GRefPtr<WebKitWebLoaderClient> loaderClient; 56 57 GRefPtr<WebKitBackForwardList> backForwardList; 58 GRefPtr<WebKitSettings> settings; 57 59 }; 58 60 … … 82 84 83 85 priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page)))); 86 priv->settings = adoptGRef(webkit_settings_new()); 87 webkitSettingsAttachSettingsToPage(priv->settings.get(), toAPI(page)); 84 88 } 85 89 … … 602 606 webkitWebViewUpdateURI(webView); 603 607 } 608 609 /** 610 * webkit_web_view_set_settings: 611 * @web_view: a #WebKitWebView 612 * @settings: a #WebKitSettings 613 * 614 * Sets the #WebKitSettings to be applied to @web_view. The 615 * existing #WebKitSettings of @web_view will be replaced by 616 * @settings. New settings are applied immediately on @web_view. 617 * The same #WebKitSettings object can be shared 618 * by multiple #WebKitWebView<!-- -->s. 619 */ 620 void webkit_web_view_set_settings(WebKitWebView* webView, WebKitSettings* settings) 621 { 622 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 623 g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); 624 625 if (webView->priv->settings == settings) 626 return; 627 628 webView->priv->settings = settings; 629 webkitSettingsAttachSettingsToPage(settings, toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)))); 630 } 631 632 /** 633 * webkit_web_view_get_settings: 634 * @web_view: a #WebKitWebView 635 * 636 * Gets the #WebKitSettings currently applied to @web_view. 637 * If no other #WebKitSettings have been explicitly applied to 638 * @web_view with webkit_web_view_set_settings(), the default 639 * #WebKitSettings will be returned. This method always returns 640 * a valid #WebKitSettings object. 641 * To modify any of the @web_view settings, you can either create 642 * a new #WebKitSettings object with webkit_settings_new(), setting 643 * the desired preferences, and then replace the existing @web_view 644 * settings with webkit_web_view_set_settings() or get the existing 645 * @web_view settings and update it directly. #WebKitSettings objects 646 * can be shared by multiple #WebKitWebView<!-- -->s, so modifying 647 * the settings of a #WebKitWebView would affect other 648 * #WebKitWebView<!-- -->s using the same #WebKitSettings. 649 * 650 * Returns: (transfer none): the #WebKitSettings attached to @web_view 651 */ 652 WebKitSettings* webkit_web_view_get_settings(WebKitWebView* webView) 653 { 654 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 655 656 return webView->priv->settings.get(); 657 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r98707 r98845 32 32 #include <webkit2/WebKitWebContext.h> 33 33 #include <webkit2/WebKitWebLoaderClient.h> 34 #include <webkit2/WebKitSettings.h> 34 35 #include <webkit2/WebKitWebViewBase.h> 35 36 … … 135 136 const gchar *charset); 136 137 138 WEBKIT_API void 139 webkit_web_view_set_settings (WebKitWebView *web_view, 140 WebKitSettings *settings); 141 142 WEBKIT_API WebKitSettings * 143 webkit_web_view_get_settings (WebKitWebView *web_view); 144 137 145 G_END_DECLS 138 146 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r98707 r98845 65 65 webkit_web_view_go_to_back_forward_list_item 66 66 webkit_web_view_get_uri 67 webkit_web_view_set_settings 68 webkit_web_view_get_settings 67 69 68 70 <SUBSECTION Standard> -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r97920 r98845 48 48 } 49 49 50 static void testWebViewSettings(WebViewTest* test, gconstpointer) 51 { 52 WebKitSettings* defaultSettings = webkit_web_view_get_settings(test->m_webView); 53 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultSettings)); 54 g_assert(defaultSettings); 55 g_assert(webkit_settings_get_enable_javascript(defaultSettings)); 56 57 GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new()); 58 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings.get())); 59 g_object_set(G_OBJECT(newSettings.get()), "enable-javascript", FALSE, NULL); 60 webkit_web_view_set_settings(test->m_webView, newSettings.get()); 61 62 WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView); 63 g_assert(settings != defaultSettings); 64 g_assert(!webkit_settings_get_enable_javascript(settings)); 65 66 GRefPtr<GtkWidget> webView2 = webkit_web_view_new(); 67 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webView2.get())); 68 webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), settings); 69 g_assert(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())) == settings); 70 71 GRefPtr<WebKitSettings> newSettings2 = adoptGRef(webkit_settings_new()); 72 test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings2.get())); 73 webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), newSettings2.get()); 74 settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())); 75 g_assert(settings == newSettings2.get()); 76 g_assert(webkit_settings_get_enable_javascript(settings)); 77 } 78 50 79 void beforeAll() 51 80 { … … 53 82 WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset); 54 83 Test::add("WebKitWebView", "webviews-share-clients", testWebViewsShareClients); 84 WebViewTest::add("WebKitWebView", "settings", testWebViewSettings); 55 85 } 56 86
Note: See TracChangeset
for help on using the changeset viewer.