aboutsummaryrefslogtreecommitdiffstats
path: root/src/xwidget.c
diff options
context:
space:
mode:
authorAndrew De Angelis2023-02-23 22:47:41 -0500
committerEli Zaretskii2023-03-02 12:53:35 +0200
commita137f71c67e88204a32ebd747beb8fdd7db2fbe9 (patch)
treec02765980dbbc5478fde4ac29e0a6060f4c4b4ab /src/xwidget.c
parent3f43a16bc63eac12db5707b26da2507077b4f13c (diff)
downloademacs-a137f71c67e88204a32ebd747beb8fdd7db2fbe9.tar.gz
emacs-a137f71c67e88204a32ebd747beb8fdd7db2fbe9.zip
Improvements to xwidget on macOS (bug#60703)
* src/nsxwidget.m () ([XwWebView initWithFrame:configuration:xwidget:]) (nsxwidget_init): Fixed memory leaks: when sending an alloc message to an object, send an autorelease message to any objects we won't explictly release. ([XwWebView webView:didFinishNavigation:]): Second string to store in 'store_xwidget_event_string' is "load finished" rather than empty string. ([XwWebView webView:didStartProvisionalNavigation:]) ([XwWebView webView:didReceiveServerRedirectForProvisionalNavigation:]) ([XwWebView webView:didCommitNavigation:]): New functions. (nsxwidget_webkit_estimated_load_progress): New function. (nsxwidget_webkit_stop_loading): New function. * src/xwidget.c (Fxwidget_webkit_estimated_load_progress): Call 'nsxwidget_webkit_estimated_load_progress' if we're on MacOS. (Fxwidget_webkit_stop_loading): Call 'nsxwidget_webkit_stop_loading' if we're on MacOS. (syms_of_xwidget): Define symbol for function. 'xwidget_webkit_estimated_load_progress' if we're on MacOS. * src/nsxwidget.h: Signature for functions 'nsxwidget_webkit_estimated_load_progress' and 'nsxwidget_webkit_stop_loading'. * lisp/xwidget.el (xwidget-webkit-current-url): Message URL rather than return value of 'kill-new' (which is always nil).
Diffstat (limited to 'src/xwidget.c')
-rw-r--r--src/xwidget.c63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/xwidget.c b/src/xwidget.c
index efe27055629..7f30e48c954 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -3063,6 +3063,36 @@ DEFUN ("xwidget-webkit-title",
3063#endif 3063#endif
3064} 3064}
3065 3065
3066DEFUN ("xwidget-webkit-estimated-load-progress",
3067 Fxwidget_webkit_estimated_load_progress, Sxwidget_webkit_estimated_load_progress,
3068 1, 1, 0, doc: /* Get the estimated load progress of XWIDGET, a WebKit widget.
3069Return a value ranging from 0.0 to 1.0, based on how close XWIDGET
3070is to completely loading its page. */)
3071 (Lisp_Object xwidget)
3072{
3073 struct xwidget *xw;
3074#ifdef USE_GTK
3075 WebKitWebView *webview;
3076#endif
3077 double value;
3078
3079 CHECK_LIVE_XWIDGET (xwidget);
3080 xw = XXWIDGET (xwidget);
3081 CHECK_WEBKIT_WIDGET (xw);
3082
3083 block_input ();
3084#ifdef USE_GTK
3085 webview = WEBKIT_WEB_VIEW (xw->widget_osr);
3086 value = webkit_web_view_get_estimated_load_progress (webview);
3087#elif defined NS_IMPL_COCOA
3088 value = nsxwidget_webkit_estimated_load_progress (xw);
3089#endif
3090
3091 unblock_input ();
3092
3093 return make_float (value);
3094}
3095
3066DEFUN ("xwidget-webkit-goto-uri", 3096DEFUN ("xwidget-webkit-goto-uri",
3067 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri, 3097 Fxwidget_webkit_goto_uri, Sxwidget_webkit_goto_uri,
3068 2, 2, 0, 3098 2, 2, 0,
@@ -3810,28 +3840,6 @@ LIMIT is not specified or nil, it is treated as `50'. */)
3810 return list3 (back, here, forward); 3840 return list3 (back, here, forward);
3811} 3841}
3812 3842
3813DEFUN ("xwidget-webkit-estimated-load-progress",
3814 Fxwidget_webkit_estimated_load_progress, Sxwidget_webkit_estimated_load_progress,
3815 1, 1, 0, doc: /* Get the estimated load progress of XWIDGET, a WebKit widget.
3816Return a value ranging from 0.0 to 1.0, based on how close XWIDGET
3817is to completely loading its page. */)
3818 (Lisp_Object xwidget)
3819{
3820 struct xwidget *xw;
3821 WebKitWebView *webview;
3822 double value;
3823
3824 CHECK_LIVE_XWIDGET (xwidget);
3825 xw = XXWIDGET (xwidget);
3826 CHECK_WEBKIT_WIDGET (xw);
3827
3828 block_input ();
3829 webview = WEBKIT_WEB_VIEW (xw->widget_osr);
3830 value = webkit_web_view_get_estimated_load_progress (webview);
3831 unblock_input ();
3832
3833 return make_float (value);
3834}
3835#endif 3843#endif
3836 3844
3837DEFUN ("xwidget-webkit-set-cookie-storage-file", 3845DEFUN ("xwidget-webkit-set-cookie-storage-file",
@@ -3874,19 +3882,23 @@ This will stop any data transfer that may still be in progress inside
3874XWIDGET as part of loading a page. */) 3882XWIDGET as part of loading a page. */)
3875 (Lisp_Object xwidget) 3883 (Lisp_Object xwidget)
3876{ 3884{
3877#ifdef USE_GTK
3878 struct xwidget *xw; 3885 struct xwidget *xw;
3886#ifdef USE_GTK
3879 WebKitWebView *webview; 3887 WebKitWebView *webview;
3888#endif
3880 3889
3881 CHECK_LIVE_XWIDGET (xwidget); 3890 CHECK_LIVE_XWIDGET (xwidget);
3882 xw = XXWIDGET (xwidget); 3891 xw = XXWIDGET (xwidget);
3883 CHECK_WEBKIT_WIDGET (xw); 3892 CHECK_WEBKIT_WIDGET (xw);
3884 3893
3885 block_input (); 3894 block_input ();
3895#ifdef USE_GTK
3886 webview = WEBKIT_WEB_VIEW (xw->widget_osr); 3896 webview = WEBKIT_WEB_VIEW (xw->widget_osr);
3887 webkit_web_view_stop_loading (webview); 3897 webkit_web_view_stop_loading (webview);
3888 unblock_input (); 3898#elif defined NS_IMPL_COCOA
3899 nsxwidget_webkit_stop_loading (xw);
3889#endif 3900#endif
3901 unblock_input ();
3890 3902
3891 return Qnil; 3903 return Qnil;
3892} 3904}
@@ -3936,8 +3948,9 @@ syms_of_xwidget (void)
3936#ifdef USE_GTK 3948#ifdef USE_GTK
3937 defsubr (&Sxwidget_webkit_load_html); 3949 defsubr (&Sxwidget_webkit_load_html);
3938 defsubr (&Sxwidget_webkit_back_forward_list); 3950 defsubr (&Sxwidget_webkit_back_forward_list);
3939 defsubr (&Sxwidget_webkit_estimated_load_progress);
3940#endif 3951#endif
3952
3953 defsubr (&Sxwidget_webkit_estimated_load_progress);
3941 defsubr (&Skill_xwidget); 3954 defsubr (&Skill_xwidget);
3942 3955
3943 DEFSYM (QCxwidget, ":xwidget"); 3956 DEFSYM (QCxwidget, ":xwidget");