(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"
(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."
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)
defsubr (&Sxwidget_webkit_goto_uri);
defsubr (&Sxwidget_webkit_execute_script);
- defsubr (&Sxwidget_webkit_get_title);
DEFSYM (Qwebkit, "webkit");
defsubr (&Sxwidget_size_request);