From: Po Lu Date: Fri, 19 Nov 2021 09:45:03 +0000 (+0800) Subject: Add `xwidget-webkit-estimated-load-progress' X-Git-Tag: emacs-29.0.90~2852^2~197 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5bab11348602b7f5281d3dd76cc7f93f48b18696;p=emacs.git Add `xwidget-webkit-estimated-load-progress' * doc/lispref/display.texi (Xwidgets): Document new function. * etc/NEWS: Announce new function. * src/xwidget.c (Fxwidget_webkit_estimated_load_progress): New function. (syms_of_xwidget): Define new subr. --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 8decff6fa8f..e9b50707ded 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -7004,6 +7004,14 @@ manually to reach a specific history item. Instead, @var{idx} should be passed as an index to @code{xwidget-webkit-goto-history}. @end defun +@defun xwidget-webkit-estimated-load-progress xwidget +Return an estimate of how much data is remaining to be transferred +before the page displayed by the WebKit widget @var{xwidget} is fully +loaded. + +The value returned is a float ranging between 0.0 and 1.0. +@end defun + @node Buttons @section Buttons @cindex buttons in buffers diff --git a/etc/NEWS b/etc/NEWS index cee2844be3a..ad31b232714 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -863,6 +863,11 @@ for performing searches on WebKit xwidgets. This function is used to obtain the history of page-loads in a given WebKit xwidget. ++++ +*** New function 'xwidget-webkit-estimated-load-progress'. +This function is used to obtain the estimated progress of page loading +in a given WebKit xwidget. + +++ *** 'load-changed' xwidget events are now more detailed. In particular, they can now have different arguments based on the diff --git a/src/xwidget.c b/src/xwidget.c index e1bf40ea437..62b01b741cd 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -2555,6 +2555,29 @@ LIMIT is not specified or nil, it is treated as `50'. */) return list3 (back, here, forward); } + +DEFUN ("xwidget-webkit-estimated-load-progress", + Fxwidget_webkit_estimated_load_progress, Sxwidget_webkit_estimated_load_progress, + 1, 1, 0, doc: /* Get the estimated load progress of XWIDGET, a WebKit widget. +Return a value ranging from 0.0 to 1.0, based on how close XWIDGET +is to completely loading its page. */) + (Lisp_Object xwidget) +{ + struct xwidget *xw; + WebKitWebView *webview; + double value; + + CHECK_XWIDGET (xwidget); + xw = XXWIDGET (xwidget); + CHECK_WEBKIT_WIDGET (xw); + + block_input (); + webview = WEBKIT_WEB_VIEW (xw->widget_osr); + value = webkit_web_view_get_estimated_load_progress (webview); + unblock_input (); + + return make_float (value); +} #endif void @@ -2600,6 +2623,7 @@ syms_of_xwidget (void) #ifdef USE_GTK defsubr (&Sxwidget_webkit_load_html); defsubr (&Sxwidget_webkit_back_forward_list); + defsubr (&Sxwidget_webkit_estimated_load_progress); #endif defsubr (&Skill_xwidget);