aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2021-11-10 21:01:40 +0800
committerPo Lu2021-11-11 08:31:09 +0800
commit3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb (patch)
tree31f34c5934124d0ddb85caaf44245e000eef9848
parentd3ccf0895dbb18ac04e1e2e0c6624af43d467c1b (diff)
downloademacs-3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb.tar.gz
emacs-3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb.zip
Add `xwidget-webkit-load-html'
* doc/lispref/display.texi (Xwidgets): Document new function. * etc/NEWS: Announce new function. * src/xwidget.c (Fxwidget_webkit_load_html): New function. (syms_of_xwidget): Define new subr.
-rw-r--r--doc/lispref/display.texi10
-rw-r--r--etc/NEWS7
-rw-r--r--src/xwidget.c41
3 files changed, 58 insertions, 0 deletions
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index b6bd14f8874..ad1077e0c48 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -6943,6 +6943,16 @@ Finish a search operation started with @code{xwidget-webkit-search} in
6943signals an error. 6943signals an error.
6944@end defun 6944@end defun
6945 6945
6946@defun xwidget-webkit-load-html xwidget text &optional base-uri
6947Load @var{text}, a string, into @var{xwidget}, which should be a
6948WebKit xwidget. Any HTML markup in @var{text} will be processed
6949by @var{xwidget} while rendering the text.
6950
6951Optional argument @var{base-uri}, which should be a string, specifies
6952the absolute location of the web resources referenced by @var{text},
6953to be used for resolving relative links in @var{text}.
6954@end defun
6955
6946@node Buttons 6956@node Buttons
6947@section Buttons 6957@section Buttons
6948@cindex buttons in buffers 6958@cindex buttons in buffers
diff --git a/etc/NEWS b/etc/NEWS
index b403be65da5..78ce3c067fe 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -736,6 +736,13 @@ what the widget will actually receive.
736On GTK+, only key and function key events are implemented. 736On GTK+, only key and function key events are implemented.
737 737
738+++ 738+++
739*** New function 'xwidget-webkit-load-html'.
740This function is used to load HTML text into WebKit xwidgets
741directly, in contrast to creating a temporary file to hold the
742markup, and passing the URI of the file as an argument to
743'xwidget-webkit-goto-uri'.
744
745+++
739*** New functions for performing searches on WebKit xwidgets. 746*** New functions for performing searches on WebKit xwidgets.
740Some new functions, such as 'xwidget-webkit-search', have been added 747Some new functions, such as 'xwidget-webkit-search', have been added
741for performing searches on WebKit xwidgets. 748for performing searches on WebKit xwidgets.
diff --git a/src/xwidget.c b/src/xwidget.c
index 2ae635092d6..fc05f4f5709 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -2278,6 +2278,44 @@ using `xwidget-webkit-search'. */)
2278 return Qnil; 2278 return Qnil;
2279} 2279}
2280 2280
2281#ifdef USE_GTK
2282DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html,
2283 Sxwidget_webkit_load_html, 2, 3, 0,
2284 doc: /* Make XWIDGET's WebKit widget render TEXT.
2285XWIDGET should be a WebKit xwidget, that will receive TEXT. TEXT
2286should be a string that will be displayed by XWIDGET as HTML markup.
2287BASE_URI should be a string containing a URI that is used to locate
2288resources with relative URLs, and if not specified, defaults
2289to "about:blank". */)
2290 (Lisp_Object xwidget, Lisp_Object text, Lisp_Object base_uri)
2291{
2292 struct xwidget *xw;
2293 WebKitWebView *webview;
2294 char *data, *uri;
2295
2296 CHECK_XWIDGET (xwidget);
2297 CHECK_STRING (text);
2298 if (NILP (base_uri))
2299 base_uri = build_string ("about:blank");
2300 else
2301 CHECK_STRING (base_uri);
2302
2303 base_uri = ENCODE_UTF_8 (base_uri);
2304 text = ENCODE_UTF_8 (text);
2305 xw = XXWIDGET (xwidget);
2306
2307 data = SSDATA (text);
2308 uri = SSDATA (base_uri);
2309 webview = WEBKIT_WEB_VIEW (xw->widget_osr);
2310
2311 block_input ();
2312 webkit_web_view_load_html (webview, data, uri);
2313 unblock_input ();
2314
2315 return Qnil;
2316}
2317#endif
2318
2281void 2319void
2282syms_of_xwidget (void) 2320syms_of_xwidget (void)
2283{ 2321{
@@ -2316,6 +2354,9 @@ syms_of_xwidget (void)
2316 defsubr (&Sxwidget_webkit_next_result); 2354 defsubr (&Sxwidget_webkit_next_result);
2317 defsubr (&Sxwidget_webkit_previous_result); 2355 defsubr (&Sxwidget_webkit_previous_result);
2318 defsubr (&Sset_xwidget_buffer); 2356 defsubr (&Sset_xwidget_buffer);
2357#ifdef USE_GTK
2358 defsubr (&Sxwidget_webkit_load_html);
2359#endif
2319 2360
2320 DEFSYM (QCxwidget, ":xwidget"); 2361 DEFSYM (QCxwidget, ":xwidget");
2321 DEFSYM (QCtitle, ":title"); 2362 DEFSYM (QCtitle, ":title");