Use xwidget-live-p' inside xwidget-at'.

It should no longer be possible for Lisp code to abuse internal
xwidget state, or cause crashes with killed xwidgets and such,
so the pedantic checking done in this function is no longer
necessary.  (In fact, it is even wrong, as it won't catch
killed xwidgets.)

* lisp/xwidget.el (xwidget-at): Use `xwidget-live-p'.
This commit is contained in:
Po Lu 2021-11-20 14:30:12 +08:00
parent 8331916c85
commit da508cf4bd

View file

@ -58,6 +58,7 @@
(declare-function xwidget-webkit-back-forward-list "xwidget.c" (xwidget &optional limit))
(declare-function xwidget-webkit-estimated-load-progress "xwidget.c" (xwidget))
(declare-function xwidget-webkit-set-cookie-storage-file "xwidget.c" (xwidget file))
(declare-function xwidget-live-p "xwidget.c" (xwidget))
(defgroup xwidget nil
"Displaying native widgets in Emacs buffers."
@ -77,12 +78,9 @@ This returns the result of `make-xwidget'."
(defun xwidget-at (pos)
"Return xwidget at POS."
;; TODO this function is a bit tedious because the C layer isn't well
;; protected yet and xwidgetp apparently doesn't work yet.
(let* ((disp (get-text-property pos 'display))
(xw (car (cdr (cdr disp)))))
;;(if (xwidgetp xw) xw nil)
(if (equal 'xwidget (car disp)) xw)))
(xw (car (cdr (cdr disp)))))
(when (xwidget-live-p xw) xw)))