Changeset 109120 in webkit
- Timestamp:
- Feb 28, 2012 10:24:46 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r109118 r109120 1 2012-02-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Inconsistent state of WebKitWebView when replacing content in WebKit2 4 https://bugs.webkit.org/show_bug.cgi?id=79775 5 6 Reviewed by Martin Robinson. 7 8 Use an enum instead of a boolean to track the status of a 9 replace_content() load operation. We need to know when the load of 10 the replace content actually starts to not ignore valid load 11 events of a previous ongoing load operation. 12 13 * UIProcess/API/gtk/WebKitWebView.cpp: 14 (webkitWebViewLoadChanged): Transit to new replace content state 15 when replacing content depending on the load event. 16 (webkitWebViewLoadFailed): Ignore load failed events when 17 replacing content. 18 (webkitWebViewSetEstimatedLoadProgress): Ignore load progress when 19 replacing content. 20 (webkit_web_view_replace_content): Set replace content status to 21 WillReplaceContent. 22 * UIProcess/API/gtk/tests/TestWebKitWebView.cpp: 23 (replaceContentLoadCallback): 24 (testWebViewReplaceContent): 25 * UIProcess/API/gtk/tests/WebViewTest.cpp: 26 (titleChanged): 27 (WebViewTest::waitUntilTitleChanged): Convenient method to wait 28 until title changes. Use with replaceConent() since load events 29 are not emitted when replacing content. 30 * UIProcess/API/gtk/tests/WebViewTest.h: 31 1 32 2012-02-27 Anders Carlsson <andersca@apple.com> 2 33 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r108069 r109120 79 79 }; 80 80 81 typedef enum { 82 NotReplacingContent, 83 WillReplaceContent, 84 ReplacingContent, 85 DidReplaceContent 86 } ReplaceContentStatus; 87 81 88 struct _WebKitWebViewPrivate { 82 89 WebKitWebContext* context; … … 85 92 double estimatedLoadProgress; 86 93 CString activeURI; 87 bool replacingContent;94 ReplaceContentStatus replaceContentStatus; 88 95 89 96 GRefPtr<WebKitBackForwardList> backForwardList; … … 680 687 } 681 688 689 static bool updateReplaceContentStatus(WebKitWebView* webView, WebKitLoadEvent loadEvent) 690 { 691 if (webView->priv->replaceContentStatus == ReplacingContent) { 692 if (loadEvent == WEBKIT_LOAD_FINISHED) 693 webView->priv->replaceContentStatus = DidReplaceContent; 694 return true; 695 } 696 697 if (loadEvent == WEBKIT_LOAD_STARTED) { 698 if (webView->priv->replaceContentStatus == WillReplaceContent) { 699 webView->priv->replaceContentStatus = ReplacingContent; 700 return true; 701 } 702 webView->priv->replaceContentStatus = NotReplacingContent; 703 } 704 705 return false; 706 } 707 682 708 void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent) 683 709 { 684 if (webView->priv->replacingContent) { 685 if (loadEvent == WEBKIT_LOAD_FINISHED) 686 webView->priv->replacingContent = false; 710 if (updateReplaceContentStatus(webView, loadEvent)) 687 711 return; 688 }689 712 690 713 if (loadEvent != WEBKIT_LOAD_FINISHED) … … 695 718 void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error) 696 719 { 697 if (webView->priv->replac ingContent)720 if (webView->priv->replaceContentStatus == ReplacingContent) 698 721 return; 699 722 … … 715 738 void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress) 716 739 { 717 if (webView->priv->replac ingContent)740 if (webView->priv->replaceContentStatus != NotReplacingContent) 718 741 return; 719 742 … … 966 989 g_return_if_fail(contentURI); 967 990 968 webView->priv->replac ingContent = true;991 webView->priv->replaceContentStatus = WillReplaceContent; 969 992 970 993 WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content)); -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
r107250 r109120 72 72 } 73 73 74 static void replaceContentTitleChangedCallback(WebViewTest* test) 75 { 76 g_main_loop_quit(test->m_mainLoop); 77 } 78 79 static void replaceContentLoadCallback() 80 { 81 g_assert_not_reached(); 74 static void replaceContentLoadCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, WebViewTest* test) 75 { 76 // There might be an event from a previous load, 77 // but never a WEBKIT_LOAD_STARTED after webkit_web_view_replace_content(). 78 g_assert_cmpint(loadEvent, !=, WEBKIT_LOAD_STARTED); 82 79 } 83 80 84 81 static void testWebViewReplaceContent(WebViewTest* test, gconstpointer) 85 82 { 86 g_signal_connect_swapped(test->m_webView, "notify::title", G_CALLBACK(replaceContentTitleChangedCallback), test); 83 test->loadHtml("<html><head><title>Replace Content Test</title></head><body>Content to replace</body></html>", 0); 84 test->waitUntilTitleChangedTo("Replace Content Test"); 85 87 86 g_signal_connect(test->m_webView, "load-changed", G_CALLBACK(replaceContentLoadCallback), test); 88 g_signal_connect(test->m_webView, "load-failed", G_CALLBACK(replaceContentLoadCallback), test); 89 test->replaceContent("<html><head><title>Content Replaced</title></head><body>New Content</body></html>", 87 test->replaceContent("<html><body onload='document.title=\"Content Replaced\"'>New Content</body></html>", 90 88 "http://foo.com/bar", 0); 91 g_main_loop_run(test->m_mainLoop);89 test->waitUntilTitleChangedTo("Content Replaced"); 92 90 } 93 91 -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
r107250 r109120 137 137 } 138 138 139 static void titleChanged(WebKitWebView* webView, GParamSpec*, WebViewTest* test) 140 { 141 if (!test->m_expectedTitle.isNull() && test->m_expectedTitle != webkit_web_view_get_title(webView)) 142 return; 143 144 g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(titleChanged), test); 145 g_main_loop_quit(test->m_mainLoop); 146 } 147 148 void WebViewTest::waitUntilTitleChangedTo(const char* expectedTitle) 149 { 150 m_expectedTitle = expectedTitle; 151 g_signal_connect(m_webView, "notify::title", G_CALLBACK(titleChanged), this); 152 g_main_loop_run(m_mainLoop); 153 m_expectedTitle = CString(); 154 } 155 156 void WebViewTest::waitUntilTitleChanged() 157 { 158 waitUntilTitleChangedTo(0); 159 } 160 139 161 static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test) 140 162 { -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
r107250 r109120 43 43 void wait(double seconds); 44 44 void waitUntilLoadFinished(); 45 void waitUntilTitleChangedTo(const char* expectedTitle); 46 void waitUntilTitleChanged(); 45 47 void showInWindowAndWaitUntilMapped(); 46 48 … … 51 53 CString m_activeURI; 52 54 GtkWidget* m_parentWindow; 55 CString m_expectedTitle; 53 56 }; 54 57
Note: See TracChangeset
for help on using the changeset viewer.