Changeset 96833 in webkit
- Timestamp:
- Oct 6, 2011 11:03:11 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r96829 r96833 1 2011-10-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add estimated-progress property to WebKitWebLoaderClient 4 https://bugs.webkit.org/show_bug.cgi?id=69509 5 6 Reviewed by Martin Robinson. 7 8 It allows to monitor the estimated progress of a lof operation by 9 connecting to the notify signal. 10 11 * UIProcess/API/gtk/WebKitWebLoaderClient.cpp: 12 (didChangeProgress): Update estimated-progress property and notify when 13 it changes. 14 (webkitWebLoaderClientConstructed): Add implementations for 15 didStartProgress, didChangeProgress and didFinishProgress. 16 (webkitWebLoaderClientGetProperty): 17 (webkit_web_loader_client_class_init): Add estimated-progress property. 18 (webkit_web_loader_client_get_estimated_progress): Returns the 19 value of estimated-progress property. 20 * UIProcess/API/gtk/WebKitWebLoaderClient.h: 21 * UIProcess/API/gtk/tests/testloading.c: 22 (webLoadingFixtureSetup): 23 (loadProgressEstimatedProgressChanged): 24 (loadProgressLoadFinished): 25 (testLoadProgress): 26 (main): 27 1 28 2011-10-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 29 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp
r96616 r96833 47 47 PROP_0, 48 48 49 PROP_WEB_VIEW 49 PROP_WEB_VIEW, 50 PROP_ESTIMATED_PROGRESS 50 51 }; 51 52 52 53 struct _WebKitWebLoaderClientPrivate { 53 54 GRefPtr<WebKitWebView> view; 55 56 gdouble estimatedProgress; 54 57 }; 55 58 … … 120 123 g_signal_emit(WEBKIT_WEB_LOADER_CLIENT(clientInfo), signals[LOAD_FAILED], 0, resourceError.failingURL().utf8().data(), 121 124 webError.get(), &returnValue); 125 } 126 127 static void didChangeProgress(WKPageRef page, const void* clientInfo) 128 { 129 WebKitWebLoaderClient* client = WEBKIT_WEB_LOADER_CLIENT(clientInfo); 130 gdouble estimatedProgress = WKPageGetEstimatedProgress(page); 131 132 if (client->priv->estimatedProgress == estimatedProgress) 133 return; 134 135 client->priv->estimatedProgress = estimatedProgress; 136 g_object_notify(G_OBJECT(clientInfo), "estimated-progress"); 122 137 } 123 138 … … 146 161 0, // canAuthenticateAgainstProtectionSpaceInFrame 147 162 0, // didReceiveAuthenticationChallengeInFrame 148 0,// didStartProgress149 0, // didChangeProgress150 0,// didFinishProgress163 didChangeProgress, // didStartProgress 164 didChangeProgress, 165 didChangeProgress, // didFinishProgress 151 166 0, // didBecomeUnresponsive 152 167 0, // didBecomeResponsive … … 194 209 g_value_set_object(value, client->priv->view.get()); 195 210 break; 211 case PROP_ESTIMATED_PROGRESS: 212 g_value_set_double(value, webkit_web_loader_client_get_estimated_progress(client)); 213 break; 196 214 default: 197 215 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); … … 225 243 226 244 /** 227 * WebKitWeb View:web-view:245 * WebKitWebLoaderClient:web-view: 228 246 * 229 247 * The #WebKitWebView of the loader client. … … 236 254 WEBKIT_TYPE_WEB_VIEW, 237 255 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY))); 256 /** 257 * WebKitWebLoaderClient:estimated-progress: 258 * 259 * An estimate of the percent completion for the current loading operation. 260 * This value will range from 0.0 to 1.0 and, once a load completes, 261 * will remain at 1.0 until a new load starts, at which point it 262 * will be reset to 0.0. 263 * The value is an estimate based on the total number of bytes expected 264 * to be received for a document, including all its possible subresources. 265 */ 266 g_object_class_install_property(objectClass, 267 PROP_ESTIMATED_PROGRESS, 268 g_param_spec_double("estimated-progress", 269 "Estimated Progress", 270 "An estimate of the percent completion for a document load", 271 0.0, 1.0, 0.0, 272 WEBKIT_PARAM_READABLE)); 238 273 239 274 /** … … 384 419 g_type_class_add_private(clientClass, sizeof(WebKitWebLoaderClientPrivate)); 385 420 } 421 422 /** 423 * webkit_web_loader_client_get_estimated_progress: 424 * @client: a #WebKitWebLoaderClient 425 * 426 * Gets the value of #WebKitWebLoaderClient:estimated-progress. 427 * You can monitor the estimated progress of a load operation by 428 * connecting to the ::notify signal of @client. 429 * 430 * Returns: an estimate of the of the percent complete for a document 431 * load as a range from 0.0 to 1.0. 432 */ 433 gdouble webkit_web_loader_client_get_estimated_progress(WebKitWebLoaderClient* client) 434 { 435 g_return_val_if_fail(WEBKIT_IS_WEB_LOADER_CLIENT(client), 0.); 436 437 return client->priv->estimatedProgress; 438 } -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.h
r96821 r96833 64 64 65 65 WEBKIT_API GType 66 webkit_web_loader_client_get_type (void); 66 webkit_web_loader_client_get_type (void); 67 68 WEBKIT_API gdouble 69 webkit_web_loader_client_get_estimated_progress (WebKitWebLoaderClient* client); 67 70 68 71 G_END_DECLS -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/testloading.c
r96614 r96833 65 65 gboolean hasBeenFinished; 66 66 gboolean hasBeenFailed; 67 gdouble progress; 67 68 } WebLoadingFixture; 68 69 … … 77 78 fixture->hasBeenFinished = FALSE; 78 79 fixture->hasBeenFailed = FALSE; 80 fixture->progress = 0; 79 81 } 80 82 … … 248 250 uriString = getURIForPath("/alternate"); 249 251 webkit_web_view_load_alternate_html(fixture->webView, "<html><body>Alternate Content</body></html>", NULL, uriString); 252 g_free(uriString); 253 254 g_main_loop_run(fixture->loop); 255 } 256 257 static void loadProgressEstimatedProgressChanged(GObject *object, GParamSpec *pspec, WebLoadingFixture *fixture) 258 { 259 gdouble progress = webkit_web_loader_client_get_estimated_progress(WEBKIT_WEB_LOADER_CLIENT(object)); 260 261 g_assert_cmpfloat(fixture->progress, <, progress); 262 fixture->progress = progress; 263 } 264 265 static gboolean loadProgressLoadFinished(WebKitWebLoaderClient *client, WebLoadingFixture *fixture) 266 { 267 g_assert_cmpfloat(fixture->progress, ==, 1.0); 268 g_main_loop_quit(fixture->loop); 269 270 return TRUE; 271 } 272 273 static void testLoadProgress(WebLoadingFixture *fixture, gconstpointer data) 274 { 275 char *uriString; 276 WebKitWebLoaderClient *client = webkit_web_view_get_loader_client(fixture->webView); 277 278 g_signal_connect(client, "load-finished", G_CALLBACK(loadProgressLoadFinished), fixture); 279 g_signal_connect(client, "notify::estimated-progress", G_CALLBACK(loadProgressEstimatedProgressChanged), fixture); 280 281 uriString = getURIForPath("/"); 282 webkit_web_view_load_uri(fixture->webView, uriString); 250 283 g_free(uriString); 251 284 … … 286 319 testLoadAlternateContent, 287 320 webLoadingFixtureTeardown); 321 g_test_add("/webkit2/loading/progress", 322 WebLoadingFixture, NULL, 323 webLoadingFixtureSetup, 324 testLoadProgress, 325 webLoadingFixtureTeardown); 288 326 289 327 return g_test_run();
Note: See TracChangeset
for help on using the changeset viewer.