From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51712: 29.0.50; [PATCH] New function `xwidget-webkit-load-html' Date: Wed, 10 Nov 2021 07:56:02 +0800 Message-ID: <87wnlgyjcd.fsf@yahoo.com> References: <878rxx8w1i.fsf.ref@yahoo.com> <878rxx8w1i.fsf@yahoo.com> <83h7cl5urs.fsf@gnu.org> <87y25x5tu9.fsf@yahoo.com> <831r3p5sn4.fsf@gnu.org> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14289"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: larsi@gnus.org, 51712@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 10 00:57:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkazF-0003UJ-N7 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 00:57:09 +0100 Original-Received: from localhost ([::1]:49152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkazE-00008X-DF for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 18:57:08 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkaz8-00008P-UW for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 18:57:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mkaz7-0002R2-MK for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 18:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mkaz7-0000Dk-Im for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 18:57:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Nov 2021 23:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51712 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 51712-submit@debbugs.gnu.org id=B51712.1636502178798 (code B ref 51712); Tue, 09 Nov 2021 23:57:01 +0000 Original-Received: (at 51712) by debbugs.gnu.org; 9 Nov 2021 23:56:18 +0000 Original-Received: from localhost ([127.0.0.1]:36255 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkayQ-0000Co-Dn for submit@debbugs.gnu.org; Tue, 09 Nov 2021 18:56:18 -0500 Original-Received: from sonic313-9.consmr.mail.ne1.yahoo.com ([66.163.185.32]:36762) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkayO-0000Cb-PH for 51712@debbugs.gnu.org; Tue, 09 Nov 2021 18:56:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636502170; bh=2cGumqjwPfUqXkGKQeHj2N6wTQOruOPYYtL2z7oBK6E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=MI4oGVw/UwQAHQ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rsGidVyFK6VtYRixOcxixbrJ5yK4fNooEo4_JiIRxvDg5zYrWjv AnjyRJabMbdRIJgSGaQ0q_gtxIslEj8tRVuK4gO5mTQaKdD11Y5sfH0B9rBtKO4JcNLnOBIpm4KT CzrVqiUSqvHUuW6sr0VnwcxJl3HAw_reQG0tYvG9tPO7BjQVg9J2fMUst9MkgW0roWFH.KrCfN.7 HOLc.UXIdjmZLuVIr2_ynbJ_XXo2UkwsZFe0r9YY6vYtHlWu7TZsaOMVkHzHcrKLYwXAvstB2.RN afTMpgHFOdc7WO8dvS9fVGjvuxg7XTyBKgDgmhmBrriVOySvjtn_Loy2XfSvtadWDQDLBN40Dhr7 ZTcz_iLzrBnC2bTmT9HZzq5OLDK2vsF7lgCaPWe.FR._XuQ3EeubZ9FmqYN3rB_X.vMk8eX7thqv _7obVMj5NI5kqzjiW85_xswE_dJ0ma64O2xHZ.v049Km1LxPer2JfSg9uG0VYBx7ecH5n7KvDPn1 Rpf02M8FkyX1IO0TRK09g9.eCmQ5USE2z0uXpQjClqQZnjpiBFByAZd8wRyojKce3txSZx1AWofB ZGe55fpG2fI56b9Fzp1_maefuSqrJ9XdQAyng3g7sg X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Tue, 9 Nov 2021 23:56:10 +0000 Original-Received: by kubenode502.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 2eb3350e3b406d760b277791ff090563; Tue, 09 Nov 2021 23:56:05 +0000 (UTC) In-Reply-To: <831r3p5sn4.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 09 Nov 2021 16:07:59 +0200") X-Mailer: WebService/1.1.19306 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219481 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Then I'd suggest not to have it defined on non-GTK builds for now. It > is confusing to have a function that silently does nothing (after > wasting some cycles). Thanks, I'll keep that in mind. > I'd say that TEXT should be a string. The name itself doesn't > necessarily say so. Fixed, thanks. >> +Optional argument @var{base-uri}, which should be a string, specifies >> +the location of web resources, such as the resource @samp{foo.png} in >> +the HTML tag @samp{}. It defaults to >> +@samp{about:blank}. > Hmm... this is better, but at least I am still in the dark regarding > the need for this optional argument. E.g., what would happen if you > use that tag, but don't specify the URI? I'm in the dark too. I am not a web developer, and browser engines are remarkably lax about these things, but hopefully Lars can explain better (after all, shr must deal with these things too), so I added him to the Ccs. > This still leaves me wondering why the entry talks about temporary > files. Previously, loading custom markup into a widget required using a temporary file to store the markup. >> +DEFUN ("xwidget-webkit-load-html", Fxwidget_webkit_load_html, >> + Sxwidget_webkit_load_html, 2, 3, 0, >> + doc: /* Make XWIDGET's WebKit widget render text. > ^^^^ > "text" should be in CAPS. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-xwidget-webkit-load-html.patch >From 8877c57a09dce06f6b1b64294ce8a632f862cc6e Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 9 Nov 2021 21:36:40 +0800 Subject: [PATCH] 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 | 11 +++++++++++ etc/NEWS | 5 +++++ src/xwidget.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index b6bd14f887..0b6dc05267 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -6943,6 +6943,17 @@ Xwidgets 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. It treats @var{text} as HTML markup, which will be +rendered by @var{xwidget}. + +Optional argument @var{base-uri}, which should be a string, specifies +the location of web resources, such as the resource @samp{foo.png} in +the HTML tag @samp{}. It defaults to +@samp{about:blank}. +@end defun + @node Buttons @section Buttons @cindex buttons in buffers diff --git a/etc/NEWS b/etc/NEWS index 807f31fa33..b55630336e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -792,6 +792,11 @@ 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, without +having to create a temporary file to store the markup. + +++ *** New functions for performing searches on WebKit xwidgets. Some new functions, such as 'xwidget-webkit-search', have been added diff --git a/src/xwidget.c b/src/xwidget.c index fc76ce307e..2587b658e7 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -2139,6 +2139,43 @@ DEFUN ("xwidget-webkit-finish-search", Fxwidget_webkit_finish_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 fetch +resources, 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) { @@ -2177,6 +2214,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"); -- 2.31.1 --=-=-=--