diff options
| author | Glenn Morris | 2016-01-19 18:13:07 -0500 |
|---|---|---|
| committer | Glenn Morris | 2016-01-19 18:13:07 -0500 |
| commit | 0b356a6aeb7c908e778ac20497bc90fee287af66 (patch) | |
| tree | eb68b783df5c544e1ec7c12a3ecfe4097a0f7d88 | |
| parent | b88f4a2c7624362081aca2bc81cc0c5c72b7245d (diff) | |
| download | emacs-0b356a6aeb7c908e778ac20497bc90fee287af66.tar.gz emacs-0b356a6aeb7c908e778ac20497bc90fee287af66.zip | |
Avoid advising image-display-size for xwidgets.
* lisp/xwidget.el (xwidget-image-display-size): Remove.
(image-display-size): Remove advice.
* lisp/image-mode.el (xwidget-info, xwidget-at): Declare.
(image-display-size): Incorporate xwidget code directly.
| -rw-r--r-- | lisp/image-mode.el | 43 | ||||
| -rw-r--r-- | lisp/xwidget.el | 17 |
2 files changed, 25 insertions, 35 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el index e677dd0d0e7..38a25d2b7a6 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el | |||
| @@ -153,6 +153,8 @@ otherwise it defaults to t, used for times when the buffer is not displayed." | |||
| 153 | (selected-window)))) | 153 | (selected-window)))) |
| 154 | 154 | ||
| 155 | (declare-function image-size "image.c" (spec &optional pixels frame)) | 155 | (declare-function image-size "image.c" (spec &optional pixels frame)) |
| 156 | (declare-function xwidget-info "xwidget.c" (xwidget)) | ||
| 157 | (declare-function xwidget-at "xwidget.el" (pos)) | ||
| 156 | 158 | ||
| 157 | (defun image-display-size (spec &optional pixels frame) | 159 | (defun image-display-size (spec &optional pixels frame) |
| 158 | "Wrapper around `image-size', handling slice display properties. | 160 | "Wrapper around `image-size', handling slice display properties. |
| @@ -160,24 +162,29 @@ Like `image-size', the return value is (WIDTH . HEIGHT). | |||
| 160 | WIDTH and HEIGHT are in canonical character units if PIXELS is | 162 | WIDTH and HEIGHT are in canonical character units if PIXELS is |
| 161 | nil, and in pixel units if PIXELS is non-nil. | 163 | nil, and in pixel units if PIXELS is non-nil. |
| 162 | 164 | ||
| 163 | If SPEC is an image display property, this function is equivalent | 165 | If SPEC is an image display property, this function is equivalent to |
| 164 | to `image-size'. If SPEC is a list of properties containing | 166 | `image-size'. If SPEC represents an xwidget object, defer to `xwidget-info'. |
| 165 | `image' and `slice' properties, return the display size taking | 167 | If SPEC is a list of properties containing `image' and `slice' properties, |
| 166 | the slice property into account. If the list contains `image' | 168 | return the display size taking the slice property into account. If the list |
| 167 | but not `slice', return the `image-size' of the specified image." | 169 | contains `image' but not `slice', return the `image-size' of the specified |
| 168 | (if (eq (car spec) 'image) | 170 | image." |
| 169 | (image-size spec pixels frame) | 171 | (cond ((eq (car spec) 'xwidget) |
| 170 | (let ((image (assoc 'image spec)) | 172 | (let ((xwi (xwidget-info (xwidget-at 1)))) ; FIXME point-min? |
| 171 | (slice (assoc 'slice spec))) | 173 | (cons (aref xwi 2) (aref xwi 3)))) |
| 172 | (cond ((and image slice) | 174 | ((eq (car spec) 'image) |
| 173 | (if pixels | 175 | (image-size spec pixels frame)) |
| 174 | (cons (nth 3 slice) (nth 4 slice)) | 176 | (t (let ((image (assoc 'image spec)) |
| 175 | (cons (/ (float (nth 3 slice)) (frame-char-width frame)) | 177 | (slice (assoc 'slice spec))) |
| 176 | (/ (float (nth 4 slice)) (frame-char-height frame))))) | 178 | (cond ((and image slice) |
| 177 | (image | 179 | (if pixels |
| 178 | (image-size image pixels frame)) | 180 | (cons (nth 3 slice) (nth 4 slice)) |
| 179 | (t | 181 | (cons (/ (float (nth 3 slice)) (frame-char-width frame)) |
| 180 | (error "Invalid image specification: %s" spec)))))) | 182 | (/ (float (nth 4 slice)) |
| 183 | (frame-char-height frame))))) | ||
| 184 | (image | ||
| 185 | (image-size image pixels frame)) | ||
| 186 | (t | ||
| 187 | (error "Invalid image specification: %s" spec))))))) | ||
| 181 | 188 | ||
| 182 | (defun image-forward-hscroll (&optional n) | 189 | (defun image-forward-hscroll (&optional n) |
| 183 | "Scroll image in current window to the left by N character widths. | 190 | "Scroll image in current window to the left by N character widths. |
diff --git a/lisp/xwidget.el b/lisp/xwidget.el index ff3b977ade5..41e2c1cef6c 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el | |||
| @@ -87,23 +87,6 @@ defaults to the string looking like a url around the cursor position." | |||
| 87 | (xwidget-webkit-new-session url) | 87 | (xwidget-webkit-new-session url) |
| 88 | (xwidget-webkit-goto-url url)))) | 88 | (xwidget-webkit-goto-url url)))) |
| 89 | 89 | ||
| 90 | |||
| 91 | ;;shims for adapting image mode code to the webkit browser window | ||
| 92 | (defun xwidget-image-display-size (spec &optional pixels frame) | ||
| 93 | "Image code adaptor. SPEC PIXELS FRAME like the corresponding | ||
| 94 | `image-mode' fn." | ||
| 95 | (let ((xwi (xwidget-info (xwidget-at 1)))) | ||
| 96 | (cons (aref xwi 2) | ||
| 97 | (aref xwi 3)))) | ||
| 98 | |||
| 99 | (defadvice image-display-size (around image-display-size-for-xwidget | ||
| 100 | (spec &optional pixels frame) | ||
| 101 | activate) | ||
| 102 | "Advice for re-using image mode for xwidget." | ||
| 103 | (if (eq (car spec) 'xwidget) | ||
| 104 | (setq ad-return-value (xwidget-image-display-size spec pixels frame)) | ||
| 105 | ad-do-it)) | ||
| 106 | |||
| 107 | ;;todo. | 90 | ;;todo. |
| 108 | ;; - check that the webkit support is compiled in | 91 | ;; - check that the webkit support is compiled in |
| 109 | (defvar xwidget-webkit-mode-map | 92 | (defvar xwidget-webkit-mode-map |