diff options
| -rw-r--r-- | lisp/xwidget.el | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index f2c79afec03..223f4f290b2 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -23,9 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | ;; | 25 | ;; |
| 26 | ;; See xwidget.c for more api functions | 26 | ;; See xwidget.c for more api functions. |
| 27 | 27 | ||
| 28 | ;;TODO this breaks compilation when we dont have xwidgets | 28 | ;; TODO this breaks compilation when we don't have xwidgets. |
| 29 | ;;(require 'xwidget-internal) | 29 | ;;(require 'xwidget-internal) |
| 30 | 30 | ||
| 31 | ;;; Code: | 31 | ;;; Code: |
| @@ -75,8 +75,8 @@ Optional argument ARGS usage depends on the xwidget." | |||
| 75 | 75 | ||
| 76 | (defun xwidget-at (pos) | 76 | (defun xwidget-at (pos) |
| 77 | "Return xwidget at POS." | 77 | "Return xwidget at POS." |
| 78 | ;;TODO this function is a bit tedious because the C layer isnt well | 78 | ;; TODO this function is a bit tedious because the C layer isn't well |
| 79 | ;;protected yet and xwidgetp aparently doesnt work yet | 79 | ;; protected yet and xwidgetp apparently doesn't work yet. |
| 80 | (let* ((disp (get-text-property pos 'display)) | 80 | (let* ((disp (get-text-property pos 'display)) |
| 81 | (xw (car (cdr (cdr disp))))) | 81 | (xw (car (cdr (cdr disp))))) |
| 82 | ;;(if ( xwidgetp xw) xw nil) | 82 | ;;(if ( xwidgetp xw) xw nil) |
| @@ -169,9 +169,9 @@ defaults to the string looking like a url around the cursor position." | |||
| 169 | (xwidget-webkit-scroll-backward))) | 169 | (xwidget-webkit-scroll-backward))) |
| 170 | 170 | ||
| 171 | 171 | ||
| 172 | ;;the xwidget event needs to go into a higher level handler | 172 | ;; The xwidget event needs to go into a higher level handler |
| 173 | ;;since the xwidget can generate an event even if its offscreen | 173 | ;; since the xwidget can generate an event even if it's offscreen. |
| 174 | ;;TODO this needs to use callbacks and consider different xw ev types | 174 | ;; TODO this needs to use callbacks and consider different xwidget event types. |
| 175 | (define-key (current-global-map) [xwidget-event] 'xwidget-event-handler) | 175 | (define-key (current-global-map) [xwidget-event] 'xwidget-event-handler) |
| 176 | (defun xwidget-log ( &rest msg) | 176 | (defun xwidget-log ( &rest msg) |
| 177 | "Log MSG to a buffer." | 177 | "Log MSG to a buffer." |
| @@ -241,7 +241,7 @@ XWIDGET instance, XWIDGET-EVENT-TYPE depends on the originating xwidget." | |||
| 241 | 241 | ||
| 242 | (defvar xwidget-webkit-last-session-buffer nil) | 242 | (defvar xwidget-webkit-last-session-buffer nil) |
| 243 | 243 | ||
| 244 | (defun xwidget-webkit-last-session () | 244 | (defun xwidget-webkit-last-session () |
| 245 | "Last active webkit, or nil." | 245 | "Last active webkit, or nil." |
| 246 | (if (buffer-live-p xwidget-webkit-last-session-buffer) | 246 | (if (buffer-live-p xwidget-webkit-last-session-buffer) |
| 247 | (with-current-buffer xwidget-webkit-last-session-buffer | 247 | (with-current-buffer xwidget-webkit-last-session-buffer |
| @@ -249,17 +249,17 @@ XWIDGET instance, XWIDGET-EVENT-TYPE depends on the originating xwidget." | |||
| 249 | nil)) | 249 | nil)) |
| 250 | 250 | ||
| 251 | (defun xwidget-webkit-current-session () | 251 | (defun xwidget-webkit-current-session () |
| 252 | "Either the webkit in the current buffer, or the last one used, | 252 | "Either the webkit in the current buffer, or the last one used. |
| 253 | which might be nil." | 253 | The latter might be nil." |
| 254 | (if (xwidget-at 1) | 254 | (if (xwidget-at 1) |
| 255 | (xwidget-at 1) | 255 | (xwidget-at 1) |
| 256 | (xwidget-webkit-last-session))) | 256 | (xwidget-webkit-last-session))) |
| 257 | 257 | ||
| 258 | (defun xwidget-adjust-size-to-content (xw) | 258 | (defun xwidget-adjust-size-to-content (xw) |
| 259 | "Resize XW to content." | 259 | "Resize XW to content." |
| 260 | ;;xwidgets doesnt support widgets that have their own opinions about | 260 | ;; xwidgets doesn't support widgets that have their own opinions about |
| 261 | ;;size well yet this reads the desired size and resizes the emacs | 261 | ;; size well, yet this reads the desired size and resizes the emacs |
| 262 | ;;allocated area accordingly | 262 | ;; allocated area accordingly. |
| 263 | (let ((size (xwidget-size-request xw))) | 263 | (let ((size (xwidget-size-request xw))) |
| 264 | (xwidget-resize xw (car size) (cadr size)))) | 264 | (xwidget-resize xw (car size) (cadr size)))) |
| 265 | 265 | ||
| @@ -288,9 +288,9 @@ function findactiveelement(doc){ | |||
| 288 | " | 288 | " |
| 289 | 289 | ||
| 290 | "javascript that finds the active element." | 290 | "javascript that finds the active element." |
| 291 | ;;yes its ugly. because: | 291 | ;; Yes it's ugly, because: |
| 292 | ;; - there is aparently no way to find the active frame other than recursion | 292 | ;; - there is apparently no way to find the active frame other than recursion |
| 293 | ;; - the js "for each" construct missbehaved on the "frames" collection | 293 | ;; - the js "for each" construct misbehaved on the "frames" collection |
| 294 | ;; - a window with no frameset still has frames.length == 1, but | 294 | ;; - a window with no frameset still has frames.length == 1, but |
| 295 | ;; frames[0].document.activeElement != document.activeElement | 295 | ;; frames[0].document.activeElement != document.activeElement |
| 296 | ;;TODO the activeelement type needs to be examined, for iframe, etc. | 296 | ;;TODO the activeelement type needs to be examined, for iframe, etc. |
| @@ -300,7 +300,7 @@ function findactiveelement(doc){ | |||
| 300 | "Insert string in the active field in the webkit. | 300 | "Insert string in the active field in the webkit. |
| 301 | Argument XW webkit. | 301 | Argument XW webkit. |
| 302 | Argument STR string." | 302 | Argument STR string." |
| 303 | ;;read out the string in the field first and provide for edit | 303 | ;; Read out the string in the field first and provide for edit. |
| 304 | (interactive | 304 | (interactive |
| 305 | (let* ((xww (xwidget-webkit-current-session)) | 305 | (let* ((xww (xwidget-webkit-current-session)) |
| 306 | 306 | ||
| @@ -359,7 +359,7 @@ Argument ELEMENT-NAME is the element name to display in the webkit xwidget." | |||
| 359 | ;; This function implements a proof-of-concept for this. Problems | 359 | ;; This function implements a proof-of-concept for this. Problems |
| 360 | ;; remaining: - The selected window is scrolled but this is not | 360 | ;; remaining: - The selected window is scrolled but this is not |
| 361 | ;; always correct - This needs to be interfaced into browse-url | 361 | ;; always correct - This needs to be interfaced into browse-url |
| 362 | ;; somehow. the tricky part is that we need to do this in two steps: | 362 | ;; somehow. The tricky part is that we need to do this in two steps: |
| 363 | ;; A: load the base url, wait for load signal to arrive B: navigate | 363 | ;; A: load the base url, wait for load signal to arrive B: navigate |
| 364 | ;; to the anchor when the base url is finished rendering | 364 | ;; to the anchor when the base url is finished rendering |
| 365 | 365 | ||
| @@ -424,8 +424,8 @@ Argument ELEMENT-ID is either a name or an element id." | |||
| 424 | (xwidget-webkit-adjust-size-to-window) | 424 | (xwidget-webkit-adjust-size-to-window) |
| 425 | (xwidget-webkit-adjust-size-to-content)) | 425 | (xwidget-webkit-adjust-size-to-content)) |
| 426 | ;; The recenter is intended to correct a visual glitch. | 426 | ;; The recenter is intended to correct a visual glitch. |
| 427 | ;; It errors out if the buffer isn't visible, but then we dont get the glitch, | 427 | ;; It errors out if the buffer isn't visible, but then we don't get |
| 428 | ;; so silence errors | 428 | ;; the glitch, so silence errors. |
| 429 | (ignore-errors | 429 | (ignore-errors |
| 430 | (recenter-top-bottom)) | 430 | (recenter-top-bottom)) |
| 431 | ) | 431 | ) |
| @@ -437,7 +437,7 @@ Argument ELEMENT-ID is either a name or an element id." | |||
| 437 | (window-pixel-height))) | 437 | (window-pixel-height))) |
| 438 | 438 | ||
| 439 | (defun xwidget-webkit-adjust-size (w h) | 439 | (defun xwidget-webkit-adjust-size (w h) |
| 440 | "Manualy set webkit size. | 440 | "Manually set webkit size. |
| 441 | Argument W width. | 441 | Argument W width. |
| 442 | Argument H height." | 442 | Argument H height." |
| 443 | ;; TODO shouldn't be tied to the webkit xwidget | 443 | ;; TODO shouldn't be tied to the webkit xwidget |
| @@ -495,15 +495,15 @@ Argument H height." | |||
| 495 | 495 | ||
| 496 | (defun xwidget-webkit-execute-script-rv (xw script &optional default) | 496 | (defun xwidget-webkit-execute-script-rv (xw script &optional default) |
| 497 | "Same as 'xwidget-webkit-execute-script' but but with return value. | 497 | "Same as 'xwidget-webkit-execute-script' but but with return value. |
| 498 | XW is the webkit instance. SCRIPT is the script to execut. | 498 | XW is the webkit instance. SCRIPT is the script to execute. |
| 499 | DEFAULT is the defaultreturn value." | 499 | DEFAULT is the defaultreturn value." |
| 500 | ;; Notice the ugly "title" hack. It is needed because the Webkit | 500 | ;; Notice the ugly "title" hack. It is needed because the Webkit |
| 501 | ;; API at the time of writing didn't support returning values. This | 501 | ;; API at the time of writing didn't support returning values. This |
| 502 | ;; is a wrapper for the title hack so its easy to remove should | 502 | ;; is a wrapper for the title hack so it's easy to remove should |
| 503 | ;; Webkit someday support JS return values or we find some other way | 503 | ;; Webkit someday support JS return values or we find some other way |
| 504 | ;; to access the DOM. | 504 | ;; to access the DOM. |
| 505 | 505 | ||
| 506 | ;; Reset webkit title. Not very nice. | 506 | ;; Reset webkit title. Not very nice. |
| 507 | (let* ((emptytag "titlecantbewhitespaceohthehorror") | 507 | (let* ((emptytag "titlecantbewhitespaceohthehorror") |
| 508 | title) | 508 | title) |
| 509 | (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" | 509 | (xwidget-webkit-execute-script xw (format "document.title=\"%s\";" |
| @@ -529,7 +529,7 @@ DEFAULT is the defaultreturn value." | |||
| 529 | 529 | ||
| 530 | 530 | ||
| 531 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 531 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 532 | ;; Xwidget plist management(similar to the process plist functions) | 532 | ;; Xwidget plist management (similar to the process plist functions) |
| 533 | 533 | ||
| 534 | (defun xwidget-get (xwidget propname) | 534 | (defun xwidget-get (xwidget propname) |
| 535 | "Return the value of XWIDGET' PROPNAME property. | 535 | "Return the value of XWIDGET' PROPNAME property. |
| @@ -562,7 +562,7 @@ It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." | |||
| 562 | ;; xwidget instances. | 562 | ;; xwidget instances. |
| 563 | ;; This function tries to implement a workaround should it occur again. | 563 | ;; This function tries to implement a workaround should it occur again. |
| 564 | (interactive) | 564 | (interactive) |
| 565 | ;; Kill xviews who should have been deleted but stull linger. | 565 | ;; Kill xviews that should have been deleted but still linger. |
| 566 | (xwidget-delete-zombies) | 566 | (xwidget-delete-zombies) |
| 567 | ;; Redraw display otherwise ghost of zombies will remain to haunt the screen | 567 | ;; Redraw display otherwise ghost of zombies will remain to haunt the screen |
| 568 | (redraw-display)) | 568 | (redraw-display)) |
| @@ -573,7 +573,7 @@ It can be retrieved with `(xwidget-get XWIDGET PROPNAME)'." | |||
| 573 | (add-hook 'window-configuration-change-hook 'xwidget-delete-zombies)) | 573 | (add-hook 'window-configuration-change-hook 'xwidget-delete-zombies)) |
| 574 | 574 | ||
| 575 | (defun xwidget-kill-buffer-query-function () | 575 | (defun xwidget-kill-buffer-query-function () |
| 576 | "Ask beforek illing a buffer that has xwidgets." | 576 | "Ask before killing a buffer that has xwidgets." |
| 577 | (let ((xwidgets (get-buffer-xwidgets (current-buffer)))) | 577 | (let ((xwidgets (get-buffer-xwidgets (current-buffer)))) |
| 578 | (or (not xwidgets) | 578 | (or (not xwidgets) |
| 579 | (not (memq t (mapcar 'xwidget-query-on-exit-flag xwidgets))) | 579 | (not (memq t (mapcar 'xwidget-query-on-exit-flag xwidgets))) |