Changeset 97624 in webkit
- Timestamp:
- Oct 17, 2011 9:23:51 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r97608 r97624 1 2011-10-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add methods to get/set a custom text enconding to WebKit2 GTK+ API 4 https://bugs.webkit.org/show_bug.cgi?id=69524 5 6 Reviewed by Martin Robinson. 7 8 * UIProcess/API/gtk/WebKitWebView.cpp: 9 (webkit_web_view_get_custom_charset): 10 (webkit_web_view_set_custom_charset): 11 * UIProcess/API/gtk/WebKitWebView.h: 12 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 13 (testWebViewCustomCharset): 14 (beforeAll): 15 1 16 2011-10-14 Jesus Sanchez-Palencia <jesus.palencia@openbossa.org> 2 17 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r97364 r97624 44 44 struct _WebKitWebViewPrivate { 45 45 WebKitWebContext* context; 46 CString customTextEncoding; 46 47 47 48 GRefPtr<WebKitWebLoaderClient> loaderClient; … … 311 312 WKPageGoForward(toAPI(page)); 312 313 } 314 315 /** 316 * webkit_web_view_get_custom_charset: 317 * @web_view: a #WebKitWebView 318 * 319 * Returns the current custom character encoding name of @web_view. 320 * 321 * Returns: the current custom character encoding name or %NULL if no 322 * custom character encoding has been set. 323 */ 324 const gchar* webkit_web_view_get_custom_charset(WebKitWebView* webView) 325 { 326 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); 327 328 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); 329 WKRetainPtr<WKStringRef> wkCustomEncoding(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(page))); 330 if (WKStringIsEmpty(wkCustomEncoding.get())) 331 return 0; 332 333 webView->priv->customTextEncoding = toImpl(wkCustomEncoding.get())->string().utf8(); 334 return webView->priv->customTextEncoding.data(); 335 } 336 337 /** 338 * webkit_web_view_set_custom_charset: 339 * @web_view: a #WebKitWebView 340 * @charset: (allow-none): a character encoding name or %NULL 341 * 342 * Sets the current custom character encoding override of @web_view. The custom 343 * character encoding will override any text encoding detected via HTTP headers or 344 * META tags. Calling this method will stop any current load operation and reload the 345 * current page. Setting the custom character encoding to %NULL removes the character 346 * encoding override. 347 */ 348 void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* charset) 349 { 350 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 351 352 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); 353 WKRetainPtr<WKStringRef> wkEncodingName = charset ? adoptWK(WKStringCreateWithUTF8CString(charset)) : 0; 354 WKPageSetCustomTextEncodingName(toAPI(page), wkEncodingName.get()); 355 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r97047 r97624 108 108 webkit_web_view_go_forward (WebKitWebView *web_view); 109 109 110 WEBKIT_API const gchar * 111 webkit_web_view_get_custom_charset (WebKitWebView *web_view); 112 113 WEBKIT_API void 114 webkit_web_view_set_custom_charset (WebKitWebView *web_view, 115 const gchar *charset); 116 110 117 G_END_DECLS 111 118 -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r97226 r97624 27 27 } 28 28 29 static void testWebViewCustomCharset(WebViewTest* test, gconstpointer) 30 { 31 g_assert(!webkit_web_view_get_custom_charset(test->m_webView)); 32 webkit_web_view_set_custom_charset(test->m_webView, "utf8"); 33 g_assert_cmpstr(webkit_web_view_get_custom_charset(test->m_webView), ==, "utf8"); 34 // Go back to the default charset. 35 webkit_web_view_set_custom_charset(test->m_webView, 0); 36 g_assert(!webkit_web_view_get_custom_charset(test->m_webView)); 37 } 38 39 29 40 void beforeAll() 30 41 { 31 42 WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext); 43 WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset); 32 44 } 33 45
Note: See TracChangeset
for help on using the changeset viewer.