From: Po Lu Date: Sat, 20 Nov 2021 10:23:02 +0000 (+0800) Subject: Allow terminating page loading operations in webkit xwidgets X-Git-Tag: emacs-29.0.90~2852^2~170 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fbf361f593df52ff414a4483f105e2e4c1a921e2;p=emacs.git Allow terminating page loading operations in webkit xwidgets * doc/lispref/display.texi (Xwidgets): Document new function. * etc/NEWS: Announce `xwidget-webkit-stop-loading'. * src/xwidget.c (Fxwidget_webkit_stop_loading): New function. (syms_of_xwidget): Define new subr. --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 08426032e09..c093901ea1d 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -7025,6 +7025,12 @@ If this function is not called at least once on @var{xwidget} or a related widget, @var{xwidget} will not store cookies on disk at all. @end defun +@defun xwidget-webkit-stop-loading xwidget +Terminate any data transfer still in progress in the WebKit widget +@var{xwidget} as part of a page-loading operation. If a page is not +being loaded, this function does nothing. +@end defun + @node Buttons @section Buttons @cindex buttons in buffers diff --git a/etc/NEWS b/etc/NEWS index 70ba5341d8a..a5ca8fbb2be 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -873,6 +873,11 @@ WebKit xwidget. This function is used to obtain the estimated progress of page loading in a given WebKit xwidget. ++++ +*** New function 'xwidget-webkit-stop-loading'. +This function is used to terminate all data transfer during page loads +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 8cad2fbc2c1..b1bf291a168 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -2615,6 +2615,30 @@ store cookies in FILE and load them from there. */) return Qnil; } +DEFUN ("xwidget-webkit-stop-loading", Fxwidget_webkit_stop_loading, + Sxwidget_webkit_stop_loading, + 1, 1, 0, doc: /* Stop loading data in the WebKit widget XWIDGET. +This will stop any data transfer that may still be in progress inside +XWIDGET as part of loading a page. */) + (Lisp_Object xwidget) +{ +#ifdef USE_GTK + struct xwidget *xw; + WebKitWebView *webview; + + CHECK_LIVE_XWIDGET (xwidget); + xw = XXWIDGET (xwidget); + CHECK_WEBKIT_WIDGET (xw); + + block_input (); + webview = WEBKIT_WEB_VIEW (xw->widget_osr); + webkit_web_view_stop_loading (webview); + unblock_input (); +#endif + + return Qnil; +} + void syms_of_xwidget (void) { @@ -2656,6 +2680,7 @@ syms_of_xwidget (void) defsubr (&Sxwidget_webkit_previous_result); defsubr (&Sset_xwidget_buffer); defsubr (&Sxwidget_webkit_set_cookie_storage_file); + defsubr (&Sxwidget_webkit_stop_loading); #ifdef USE_GTK defsubr (&Sxwidget_webkit_load_html); defsubr (&Sxwidget_webkit_back_forward_list);