From 67e03311a0b9091fe98a2cca86c6a6a933fc6e05 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Tue, 25 Oct 2016 23:00:35 -0700 Subject: [PATCH] xwidget: Remove title hack. * 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 37edd5254ec..a1b9b505161 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 8552810636e..dbd8fc18ad7 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.39.2