[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3d253fa: Add `xwidget-webkit-load-html'
From: |
Po Lu |
Subject: |
master 3d253fa: Add `xwidget-webkit-load-html' |
Date: |
Wed, 10 Nov 2021 19:31:32 -0500 (EST) |
branch: master
commit 3d253fa3aa7316adcc69864c6c1cd0f9bd7a18cb
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
doc/lispref/display.texi | 10 ++++++++++
etc/NEWS | 7 +++++++
src/xwidget.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+)
diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index b6bd14f..ad1077e 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
signals an error.
@end defun
+@defun xwidget-webkit-load-html xwidget text &optional base-uri
+Load @var{text}, a string, into @var{xwidget}, which should be a
+WebKit xwidget. Any HTML markup in @var{text} will be processed
+by @var{xwidget} while rendering the text.
+
+Optional argument @var{base-uri}, which should be a string, specifies
+the absolute location of the web resources referenced by @var{text},
+to be used for resolving relative links in @var{text}.
+@end defun
+
@node Buttons
@section Buttons
@cindex buttons in buffers
diff --git a/etc/NEWS b/etc/NEWS
index b403be6..78ce3c0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -736,6 +736,13 @@ what the widget will actually receive.
On GTK+, only key and function key events are implemented.
+++
+*** New function 'xwidget-webkit-load-html'.
+This function is used to load HTML text into WebKit xwidgets
+directly, in contrast to creating a temporary file to hold the
+markup, and passing the URI of the file as an argument to
+'xwidget-webkit-goto-uri'.
+
++++
*** New functions for performing searches on WebKit xwidgets.
Some new functions, such as 'xwidget-webkit-search', have been added
for performing searches on WebKit xwidgets.
diff --git a/src/xwidget.c b/src/xwidget.c
index 2ae6350..fc05f4f 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -2278,6 +2278,44 @@ using `xwidget-webkit-search'. */)
return Qnil;
}
+#ifdef USE_GTK
+DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html,
+ Sxwidget_webkit_load_html, 2, 3, 0,
+ doc: /* Make XWIDGET's WebKit widget render TEXT.
+XWIDGET should be a WebKit xwidget, that will receive TEXT. TEXT
+should be a string that will be displayed by XWIDGET as HTML markup.
+BASE_URI should be a string containing a URI that is used to locate
+resources with relative URLs, and if not specified, defaults
+to "about:blank". */)
+ (Lisp_Object xwidget, Lisp_Object text, Lisp_Object base_uri)
+{
+ struct xwidget *xw;
+ WebKitWebView *webview;
+ char *data, *uri;
+
+ CHECK_XWIDGET (xwidget);
+ CHECK_STRING (text);
+ if (NILP (base_uri))
+ base_uri = build_string ("about:blank");
+ else
+ CHECK_STRING (base_uri);
+
+ base_uri = ENCODE_UTF_8 (base_uri);
+ text = ENCODE_UTF_8 (text);
+ xw = XXWIDGET (xwidget);
+
+ data = SSDATA (text);
+ uri = SSDATA (base_uri);
+ webview = WEBKIT_WEB_VIEW (xw->widget_osr);
+
+ block_input ();
+ webkit_web_view_load_html (webview, data, uri);
+ unblock_input ();
+
+ return Qnil;
+}
+#endif
+
void
syms_of_xwidget (void)
{
@@ -2316,6 +2354,9 @@ syms_of_xwidget (void)
defsubr (&Sxwidget_webkit_next_result);
defsubr (&Sxwidget_webkit_previous_result);
defsubr (&Sset_xwidget_buffer);
+#ifdef USE_GTK
+ defsubr (&Sxwidget_webkit_load_html);
+#endif
DEFSYM (QCxwidget, ":xwidget");
DEFSYM (QCtitle, ":title");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3d253fa: Add `xwidget-webkit-load-html',
Po Lu <=