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 10:44:52 +0800 Message-ID: <87fss4ohjv.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> <87wnlgyjcd.fsf@yahoo.com> <87r1bolvx1.fsf@gnus.org> <87czn8yii2.fsf@yahoo.com> <877ddgluzr.fsf@gnus.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="31038"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: Eli Zaretskii , 51712@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 10 03:46:12 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 1mkdcp-0007tv-JO for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 03:46:11 +0100 Original-Received: from localhost ([::1]:35174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkdco-0005qR-BO for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 21:46:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkdcg-0005q2-Dp for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 21:46:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mkdcg-0001qt-5Q for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 21:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mkdcg-0004sh-0R for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 21:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Nov 2021 02:46: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.163651230818692 (code B ref 51712); Wed, 10 Nov 2021 02:46:01 +0000 Original-Received: (at 51712) by debbugs.gnu.org; 10 Nov 2021 02:45:08 +0000 Original-Received: from localhost ([127.0.0.1]:36484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkdbn-0004rQ-UD for submit@debbugs.gnu.org; Tue, 09 Nov 2021 21:45:08 -0500 Original-Received: from sonic310-25.consmr.mail.ne1.yahoo.com ([66.163.186.206]:38885) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkdbk-0004qZ-A8 for 51712@debbugs.gnu.org; Tue, 09 Nov 2021 21:45:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636512298; bh=W5i6Q/X3V5x9PkMedktclghhPiQqVcs3dWGkzdyol9w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=iQmdiNPmPUU0Fe3mI7vzDik2aNRci0WEOK+QKu+LBLnI4/F04+E9vjpf7/FtsC24TiemSN+rQJ3lgiKUvd4x2XOrONVYLlSw5Wecajk1fUNrtauSAWAo+TJqNDySfycdok7XbpU6t1TH8THh9L0KkTHHo7cqBqjKUc/rBl77VopnHyOAOHSdO5fbAcFdgMljbjxnUCArXgT6AWVpjwGJgbsRt7yndb2679a7jksrVGTT6b031aY5WsgzZEgagDpYktp9CveLqxM5Uam9ilmtGluQKhaSz3YMO047zmXBFIZ028Sn76hsl7peWfEFV9BSb0sPrTok8jvxhN0a4gYPUQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1636512298; bh=AHUfWHOFvPUyAyLeDjBs288Mn/bU7yY6SE97Pcm9jUD=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=mb8xo9MQ8LuHxCrS3ClmOajtQfWmwGXE/kJ9qxN2OzHRTdR2aJGkBEo3mdcxlHXKAgrlROKT9eivKnXbHrb/S1RhBTOTLdHT6kvOXWfUnrE7Z2THpYGnJ84cOJvnbWS6chrTD+iHblGzwolJX87EV5vbzVIbGKWUy40R/nM0G25qo6aJPZ9E8k1wI4yWI7uejKFIJTZu2p8M3gGsq/1o9jrNj/k7nDAXw/tZVL38220Uk4dReNgPXAg3jO2B/O3QnDSIGrbe6honm3NzCu9bUKdYvYyPKVIWYT3wRHPOosowhhouDTly1V0X5Tqj/tgZdSvxRMIFrkvtJKBQS/a4lw== X-YMail-OSG: nignoDgVM1lQ2Zbgy1izirozpGPmg_OFP_lIj__E2w65c3oajy66WN2SaP2MZbC nNwALmk6H2YcuqhSPm8SGv3aYv6k2T1EtdrB7qy8q2agFY_dfjAHstM4dSW_CwwD3LPBuG9Zx73M cdTPuFcSofLn0HycvVyedi.6eBPoojoEVeJ8UtKS3kpkq1Pgzwhy1lcSG97MuFd4aU6tO63Pi03y mGz4UGmn_2yiA3ZWRojST8r9rSnHO1bKPO8z1Fsz8s4HK.BDHfFKih4uFdY_..yQE1TLmKA0aIdL 88KgeULz3wFsENXw6z4tq.R6C6CCv3BDE3OS28yP5fcXVYkIZ23CRbzp0Vv32Fl08gOLn8CObupt 3GY_PkEJ14th82kHxNhhb19gJrY.oOkoOq1R.DUhUtse.n_VAUFW_z08hmgbIDp49lTHpJ4wynQo QSefM2135qWP6UHjkGuOToEL0Ky_vh8qwOhVKh8n.dASgurgtl8F8xgW2GMjM7HyHSRtbeouXj_e t4sviOkHjHXumv1Bi9x7.EJigIPM_cEYXP1RP6b4efusccAr2LGC6zBKBhAkpunOy7FCYBIQ9m4I UL5Wn_MvJxQBRvobdE3SAp_fsjot4GrWnYThExdjamOtM6zJjmgpzjGe.r3V_yhThByRptbAP0sR C2x6Q7hpdyNbRmmCF2iHt415Y_1dKxMZxmSZUVLAgkTTybDc8SOYFDXVcCKvItZ_zSQakLGxSyaZ Dpb_Mlp5lpid4ex.gsGhusATv0Ae2F4TaBaDT.Su3WmA.1yy.DKLZA0_x7z50CSWLdAZfJ2grfd2 LJm3Vju087TGEklO1tLtbzGZZEN4SmvrGfNR05b1pc X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Wed, 10 Nov 2021 02:44:58 +0000 Original-Received: by kubenode503.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 6ca6bd34e8964ea7162fe0898d2bb791; Wed, 10 Nov 2021 02:44:55 +0000 (UTC) In-Reply-To: <877ddgluzr.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 10 Nov 2021 01:22:48 +0100") 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:219501 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > Po Lu writes: > >> Thanks, does this look OK to you? And I'm afraid I'm not terribly good >> at phrasing this into words, so I would really appreciate it if you >> could help write that section of the manual. > > [...] > >> +Optional argument @var{base-uri}, which should be a string, specifies >> +the location of web resources specified through relative links, such >> +as the resource @samp{foo.png} in the HTML tag @samp{> +src="foo.png">}. It defaults to @samp{about:blank}. > > Looks good to me. > >> +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'. */) > > Should probably be "relative resources (i.e., URLs that aren't > absolute)" or something of the kind. Hmm, OK, how's this? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-xwidget-webkit-load-html.patch >From 1d701339df5ed91ed730fb134976137bcf1e0ce6 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..aa7d64493c 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 specified through relative links, 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 3cad0995ac..ae318be1c0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -796,6 +796,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,44 @@ 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 locate +resources described by 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) { @@ -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 --=-=-= Content-Type: text/plain Thanks. --=-=-=--