From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ricardo Wurmus Newsgroups: gmane.emacs.devel Subject: [PATCH 10/15] xwidget: Remove title hack. Date: Mon, 24 Oct 2016 18:40:56 +0200 Message-ID: <20161024164101.26043-11-rekado@elephly.net> References: <20161024164101.26043-1-rekado@elephly.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1477328027 15167 195.159.176.226 (24 Oct 2016 16:53:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Oct 2016 16:53:47 +0000 (UTC) Cc: Ricardo Wurmus To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 24 18:53:42 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1byiVK-0003T3-Ad for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 18:53:42 +0200 Original-Received: from localhost ([::1]:48198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byiVM-0000Wq-Mu for ged-emacs-devel@m.gmane.org; Mon, 24 Oct 2016 12:53:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byiLe-0008KE-Ll for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byiLa-00036p-O6 for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:42 -0400 Original-Received: from sender163-mail.zoho.com ([74.201.84.163]:21474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1byiLa-00036T-FX for emacs-devel@gnu.org; Mon, 24 Oct 2016 12:43:38 -0400 Original-Received: from localhost (89.204.138.233 [89.204.138.233]) by mx.zohomail.com with SMTPS id 1477327413289972.7268191620662; Mon, 24 Oct 2016 09:43:33 -0700 (PDT) X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161024164101.26043-1-rekado@elephly.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 74.201.84.163 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208721 Archived-At: * src/xwidget.c (xwidget-webkit-get-title): Remove procedure. * lisp/xwidget.el (xwidget-webkit-get-title, xwidget-webkit-execute-script-rv): Remove procedures. --- lisp/xwidget.el | 24 ------------------------ src/xwidget.c | 22 ---------------------- 2 files changed, 46 deletions(-) diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 37edd52..a1b9b50 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -37,7 +37,6 @@ (declare-function make-xwidget "xwidget.c" (type title width height arguments &optional buffer)) (declare-function xwidget-buffer "xwidget.c" (xwidget)) -(declare-function xwidget-webkit-get-title "xwidget.c" (xwidget)) (declare-function xwidget-size-request "xwidget.c" (xwidget)) (declare-function xwidget-resize "xwidget.c" (xwidget new-width new-height)) (declare-function xwidget-webkit-execute-script "xwidget.c" @@ -480,29 +479,6 @@ For example, use this to display an anchor." (let ((url (kill-new (or rv "")))) (message "url: %s" url))))) -(defun xwidget-webkit-execute-script-rv (xw script &optional default) - "Same as `xwidget-webkit-execute-script' but with return value. -XW is the webkit instance. SCRIPT is the script to execute. -DEFAULT is the default return value." - ;; Notice the ugly "title" hack. It is needed because the Webkit - ;; API at the time of writing didn't support returning values. This - ;; is a wrapper for the title hack so it's easy to remove should - ;; Webkit someday support JS return values or we find some other way - ;; to access the DOM. - - ;; Reset webkit title. Not very nice. - (let* ((emptytag "titlecantbewhitespaceohthehorror") - title) - (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" - (or default emptytag))) - (xwidget-webkit-execute-script xw (format "document.title=%s;" script)) - (setq title (xwidget-webkit-get-title xw)) - (if (equal emptytag title) - (setq title "")) - (unless title - (setq title default)) - title)) - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun xwidget-webkit-get-selection (proc) "Get the webkit selection and pass it to PROC." diff --git a/src/xwidget.c b/src/xwidget.c index 8552810..dbd8fc1 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -709,27 +709,6 @@ argument procedure FUN.*/) return Qnil; } -DEFUN ("xwidget-webkit-get-title", - Fxwidget_webkit_get_title, Sxwidget_webkit_get_title, - 1, 1, 0, - doc: /* Return the title from the Webkit instance in XWIDGET. -This can be used to work around the lack of a return value from the -exec method. */ ) - (Lisp_Object xwidget) -{ - /* TODO support multibyte strings. */ - WEBKIT_FN_INIT (); - const gchar *str = - webkit_web_view_get_title (WEBKIT_WEB_VIEW (xw->widget_osr)); - if (str == 0) - { - /* TODO maybe return Qnil instead. I suppose webkit returns - null pointer when doc is not properly loaded or something. */ - return build_string (""); - } - return build_string (str); -} - DEFUN ("xwidget-resize", Fxwidget_resize, Sxwidget_resize, 3, 3, 0, doc: /* Resize XWIDGET. NEW_WIDTH, NEW_HEIGHT define the new size. */ ) (Lisp_Object xwidget, Lisp_Object new_width, Lisp_Object new_height) @@ -975,7 +954,6 @@ syms_of_xwidget (void) defsubr (&Sxwidget_webkit_goto_uri); defsubr (&Sxwidget_webkit_execute_script); - defsubr (&Sxwidget_webkit_get_title); DEFSYM (Qwebkit, "webkit"); defsubr (&Sxwidget_size_request); -- 2.10.1