Changeset 104129 in webkit
- Timestamp:
- Jan 5, 2012 2:08:07 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r104122 r104129 1 2012-01-05 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Rename webkit_web_view_load_alternate_html as webkit_web_view_replace_content in WebKit2 GTK+ 4 https://bugs.webkit.org/show_bug.cgi?id=75433 5 6 Reviewed by Martin Robinson. 7 8 * UIProcess/API/gtk/WebKitWebView.cpp: 9 (webkitWebViewLoadFail): Use webkit_web_view_replace_content(). 10 (webkitWebViewLoadChanged): Do not emit load-changed signal when 11 replacing content. 12 (webkitWebViewLoadFailed): Do not emit load-failed signal when 13 replacing content. 14 (webkitWebViewSetEstimatedLoadProgress): Do not emit 15 notify::estimated-load-progress signal when replacing content. 16 (webkit_web_view_replace_content): 17 * UIProcess/API/gtk/WebKitWebView.h: 18 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: 19 * UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp: 20 (beforeAll): 21 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 22 (replaceContentTitleChangedCallback): 23 (replaceContentLoadCallback): 24 (testWebViewReplaceContent): 25 (beforeAll): 26 * UIProcess/API/gtk/tests/WebViewTest.cpp: 27 (WebViewTest::replaceContent): 28 * UIProcess/API/gtk/tests/WebViewTest.h: 29 1 30 2012-01-05 Keunsoon Lee <keunsoon.lee@samsung.com> 2 31 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r103938 r104129 77 77 double estimatedLoadProgress; 78 78 CString activeURI; 79 bool replacingContent; 79 80 80 81 GRefPtr<WebKitWebLoaderClient> loaderClient; … … 97 98 98 99 GOwnPtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message)); 99 webkit_web_view_ load_alternate_html(webView, htmlString.get(), 0, failingURI);100 webkit_web_view_replace_content(webView, htmlString.get(), failingURI, 0); 100 101 101 102 return TRUE; … … 540 541 void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) 541 542 { 543 if (webView->priv->replacingContent) { 544 if (loadEvent == WEBKIT_LOAD_FINISHED) 545 webView->priv->replacingContent = false; 546 return; 547 } 548 542 549 if (loadEvent != WEBKIT_LOAD_FINISHED) 543 550 webkitWebViewUpdateURI(webView); … … 547 554 void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error) 548 555 { 556 if (webView->priv->replacingContent) 557 return; 558 549 559 gboolean returnValue; 550 560 g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue); … … 564 574 void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress) 565 575 { 576 if (webView->priv->replacingContent) 577 return; 578 566 579 if (webView->priv->estimatedLoadProgress == estimatedLoadProgress) 567 580 return; 581 568 582 webView->priv->estimatedLoadProgress = estimatedLoadProgress; 569 583 g_object_notify(G_OBJECT(webView), "estimated-load-progress"); … … 734 748 735 749 /** 736 * webkit_web_view_load_alternate_html:737 * @web_view: a #WebKitWebView738 * @content: the alternate content to display as the main page of the @web_view739 * @base_uri: the base URI for relative locations740 * @unreachable_uri: the URI for the alternate page content741 *742 * Request loading of an alternate content for a URI that is unreachable. This allows clients743 * to display page-loading errors in the #WebKitWebView itself. This is typically called from744 * #WebKitWebView::load-failed signal.745 * When called from that signal this method will preserve the back-forward list. The URI passed in746 * @base_uri has to be an absolute URI.747 * You can monitor the load operation by connecting to748 * #WebKitWebView::load-changed signal.749 */750 void webkit_web_view_load_alternate_html(WebKitWebView* webView, const gchar* content, const gchar* baseURI, const gchar* unreachableURI)751 {752 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));753 g_return_if_fail(content);754 755 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content));756 WKRetainPtr<WKURLRef> baseURL = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0;757 WKRetainPtr<WKURLRef> unreachableURL = unreachableURI ? adoptWK(WKURLCreateWithUTF8CString(unreachableURI)) : 0;758 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));759 WKPageLoadAlternateHTMLString(toAPI(page), htmlString.get(), baseURL.get(), unreachableURL.get());760 webkitWebViewUpdateURI(webView);761 }762 763 /**764 750 * webkit_web_view_load_request: 765 751 * @web_view: a #WebKitWebView … … 779 765 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); 780 766 WKPageLoadURLRequest(toAPI(page), wkRequest.get()); 767 webkitWebViewUpdateURI(webView); 768 } 769 770 /** 771 * webkit_web_view_replace_content: 772 * @web_view: a #WebKitWebView 773 * @content: the new content to display as the main page of the @web_view 774 * @content_uri: the URI for the page content 775 * @base_uri: (allow-none): the base URI for relative locations or %NULL 776 * 777 * Replace the content of @web_view with @content using @content_uri as page URI. 778 * This allows clients to display page-loading errors in the #WebKitWebView itself. 779 * This is typically called from #WebKitWebView::load-failed signal. The URI passed in 780 * @base_uri has to be an absolute URI. The mime type of the document will be "text/html". 781 * Signals #WebKitWebView::load-changed and #WebKitWebView::load-failed are not emitted 782 * when replacing content of a #WebKitWebView using this method. 783 */ 784 void webkit_web_view_replace_content(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI) 785 { 786 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); 787 g_return_if_fail(content); 788 g_return_if_fail(contentURI); 789 790 webView->priv->replacingContent = true; 791 792 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content)); 793 WKRetainPtr<WKURLRef> contentURL(AdoptWK, WKURLCreateWithUTF8CString(contentURI)); 794 WKRetainPtr<WKURLRef> baseURL = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0; 795 WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); 796 WKPageLoadAlternateHTMLString(toAPI(page), htmlString.get(), baseURL.get(), contentURL.get()); 781 797 webkitWebViewUpdateURI(webView); 782 798 } … … 927 943 * </para></listitem> 928 944 * <listitem><para> 929 * If the load operation was started by webkit_web_view_load_ alternate_html(),945 * If the load operation was started by webkit_web_view_load_html(), 930 946 * the requested URI is "about:blank". 931 947 * </para></listitem> … … 954 970 * or a navigation action within the same page is performed. 955 971 * </para></listitem> 972 * <listitem><para> 973 * When the page content is replaced using webkit_web_view_replace_content(), 974 * the active URI is the content_uri provided. 975 * </para></listitem> 956 976 * </orderedlist> 957 977 * -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r103938 r104129 140 140 141 141 WEBKIT_API void 142 webkit_web_view_load_alternate_html (WebKitWebView *web_view,143 const gchar *content,144 const gchar *base_uri,145 const gchar *unreachable_uri);146 WEBKIT_API void147 142 webkit_web_view_load_request (WebKitWebView *web_view, 148 143 WebKitURIRequest *request); … … 150 145 WEBKIT_API void 151 146 webkit_web_view_stop_loading (WebKitWebView *web_view); 147 148 WEBKIT_API void 149 webkit_web_view_replace_content (WebKitWebView *web_view, 150 const gchar *content, 151 const gchar *content_uri, 152 const gchar *base_uri); 152 153 153 154 WEBKIT_API const gchar * -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r103938 r104129 54 54 webkit_web_view_load_html 55 55 webkit_web_view_load_plain_text 56 webkit_web_view_load_alternate_html57 56 webkit_web_view_load_request 57 webkit_web_view_replace_content 58 58 webkit_web_view_can_go_back 59 59 webkit_web_view_go_back -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp
r103938 r104129 79 79 } 80 80 81 static void testLoadAlternateContent(LoadTrackingTest* test, gconstpointer)82 {83 test->loadAlternateHTML("<html><body>Alternate Content</body></html>", 0, kServer->getURIForPath("/alternate").data());84 test->waitUntilLoadFinished();85 assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);86 }87 88 81 static void testLoadRequest(LoadTrackingTest* test, gconstpointer) 89 82 { … … 252 245 LoadTrackingTest::add("WebKitWebView", "load-html", testLoadHtml); 253 246 LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText); 254 LoadTrackingTest::add("WebKitWebView", "load-alternate-content", testLoadAlternateContent);255 247 LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest); 256 248 LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled); -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r103938 r104129 68 68 } 69 69 70 static void replaceContentTitleChangedCallback(WebViewTest* test) 71 { 72 g_main_loop_quit(test->m_mainLoop); 73 } 74 75 static void replaceContentLoadCallback() 76 { 77 g_assert_not_reached(); 78 } 79 80 static void testWebViewReplaceContent(WebViewTest* test, gconstpointer) 81 { 82 g_signal_connect_swapped(test->m_webView, "notify::title", G_CALLBACK(replaceContentTitleChangedCallback), test); 83 g_signal_connect(test->m_webView, "load-changed", G_CALLBACK(replaceContentLoadCallback), test); 84 g_signal_connect(test->m_webView, "load-failed", G_CALLBACK(replaceContentLoadCallback), test); 85 test->replaceContent("<html><head><title>Content Replaced</title></head><body>New Content</body></html>", 86 "http://foo.com/bar", 0); 87 g_main_loop_run(test->m_mainLoop); 88 } 89 70 90 static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message"; 71 91 static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message"; … … 343 363 WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset); 344 364 WebViewTest::add("WebKitWebView", "settings", testWebViewSettings); 365 WebViewTest::add("WebKitWebView", "replace-content", testWebViewReplaceContent); 345 366 UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose); 346 367 UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs); -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
r101248 r104129 59 59 } 60 60 61 void WebViewTest::loadAlternateHTML(const char* html, const char* baseURI, const char* unreachableURI)62 {63 m_activeURI = "about:blank";64 webkit_web_view_load_alternate_html(m_webView, html, baseURI, unreachableURI);65 }66 67 61 void WebViewTest::loadRequest(WebKitURIRequest* request) 68 62 { 69 63 m_activeURI = webkit_uri_request_get_uri(request); 70 64 webkit_web_view_load_request(m_webView, request); 65 } 66 67 void WebViewTest::replaceContent(const char* html, const char* contentURI, const char* baseURI) 68 { 69 // FIXME: The active uri should be the contentURI, 70 // but WebPageProxy doesn't return the unreachableURL 71 // when the page has been loaded with AlternateHTML() 72 // See https://bugs.webkit.org/show_bug.cgi?id=75465. 73 #if 0 74 m_activeURI = contentURI; 75 #else 76 m_activeURI = "about:blank"; 77 #endif 78 webkit_web_view_replace_content(m_webView, html, contentURI, baseURI); 71 79 } 72 80 -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
r101248 r104129 35 35 void loadHtml(const char* html, const char* baseURI); 36 36 void loadPlainText(const char* plainText); 37 void loadAlternateHTML(const char* html, const char* baseURI, const char* unreachableURI);38 37 void loadRequest(WebKitURIRequest*); 38 void replaceContent(const char* html, const char* contentURI, const char* baseURI); 39 39 void goBack(); 40 40 void goForward(); -
trunk/Tools/ChangeLog
r104115 r104129 1 2012-01-05 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Rename webkit_web_view_load_alternate_html as webkit_web_view_replace_content in WebKit2 GTK+ 4 https://bugs.webkit.org/show_bug.cgi?id=75433 5 6 Reviewed by Martin Robinson. 7 8 * MiniBrowser/gtk/BrowserWindow.c: 9 (webViewLoadFailed): Reset the progress bar when load fails. 10 (browserWindowConstructed): Connect to load-failed signal. 11 1 12 2012-01-04 Dan Bernstein <mitz@apple.com> 2 13 -
trunk/Tools/MiniBrowser/gtk/BrowserWindow.c
r103906 r104129 230 230 } 231 231 232 static gboolean webViewLoadFailed(WebKitWebView *webView, WebKitLoadEvent loadEvent, const char *failingURI, GError *error, BrowserWindow *window) 233 { 234 gtk_entry_set_progress_fraction(GTK_ENTRY(window->uriEntry), 0.); 235 return FALSE; 236 } 237 232 238 static void browserWindowFinalize(GObject *gObject) 233 239 { … … 327 333 g_signal_connect(window->webView, "notify::title", G_CALLBACK(webViewTitleChanged), window); 328 334 g_signal_connect(window->webView, "create", G_CALLBACK(webViewCreate), window); 335 g_signal_connect(window->webView, "load-failed", G_CALLBACK(webViewLoadFailed), window); 329 336 330 337 WebKitBackForwardList *backForwadlist = webkit_web_view_get_back_forward_list(window->webView);
Note: See TracChangeset
for help on using the changeset viewer.