aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-05-16 13:38:11 +0200
committerLars Ingebrigtsen2019-05-16 13:38:11 +0200
commitbc0adf112d82a9b89f858f80e04f1ee2f401fa05 (patch)
tree6c9a7ddb439e0251833f1bb38a4bd8697e8abd03
parent63a71535a8998ac6e8cadb9db44cf1dca650d4cb (diff)
downloademacs-bc0adf112d82a9b89f858f80e04f1ee2f401fa05.tar.gz
emacs-bc0adf112d82a9b89f858f80e04f1ee2f401fa05.zip
Make shr-rescale-image respect get-buffer-window again
* lisp/net/shr.el (shr-rescale-image): Partially revert previous change -- ressurrect the check for `get-buffer-window'.
-rw-r--r--lisp/net/shr.el56
1 files changed, 29 insertions, 27 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 3ff0c247780..c1e9fdd30d7 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -1101,36 +1101,38 @@ WIDTH and HEIGHT are the sizes given in the HTML data, if any.
1101The size of the displayed image will not exceed 1101The size of the displayed image will not exceed
1102MAX-WIDTH/MAX-HEIGHT. If not given, use the current window 1102MAX-WIDTH/MAX-HEIGHT. If not given, use the current window
1103width/height instead." 1103width/height instead."
1104 (let* ((edges (window-inside-pixel-edges 1104 (if (not (get-buffer-window (current-buffer)))
1105 (get-buffer-window (current-buffer)))) 1105 (create-image data nil t :ascent 100)
1106 (max-width (truncate (* shr-max-image-proportion 1106 (let* ((edges (window-inside-pixel-edges
1107 (or max-width 1107 (get-buffer-window (current-buffer))))
1108 (- (nth 2 edges) (nth 0 edges)))))) 1108 (max-width (truncate (* shr-max-image-proportion
1109 (max-height (truncate (* shr-max-image-proportion 1109 (or max-width
1110 (or max-height 1110 (- (nth 2 edges) (nth 0 edges))))))
1111 (- (nth 3 edges) (nth 1 edges)))))) 1111 (max-height (truncate (* shr-max-image-proportion
1112 (scaling (image-compute-scaling-factor image-scaling-factor))) 1112 (or max-height
1113 (when (or (and width 1113 (- (nth 3 edges) (nth 1 edges))))))
1114 (> width max-width)) 1114 (scaling (image-compute-scaling-factor image-scaling-factor)))
1115 (and height 1115 (when (or (and width
1116 (> height max-height))) 1116 (> width max-width))
1117 (setq width nil 1117 (and height
1118 height nil)) 1118 (> height max-height)))
1119 (if (and width height 1119 (setq width nil
1120 (< (* width scaling) max-width) 1120 height nil))
1121 (< (* height scaling) max-height)) 1121 (if (and width height
1122 (< (* width scaling) max-width)
1123 (< (* height scaling) max-height))
1124 (create-image
1125 data nil t
1126 :ascent 100
1127 :width width
1128 :height height
1129 :format content-type)
1122 (create-image 1130 (create-image
1123 data nil t 1131 data nil t
1124 :ascent 100 1132 :ascent 100
1125 :width width 1133 :max-width max-width
1126 :height height 1134 :max-height max-height
1127 :format content-type) 1135 :format content-type)))))
1128 (create-image
1129 data nil t
1130 :ascent 100
1131 :max-width max-width
1132 :max-height max-height
1133 :format content-type))))
1134 1136
1135;; url-cache-extract autoloads url-cache. 1137;; url-cache-extract autoloads url-cache.
1136(declare-function url-cache-create-filename "url-cache" (url)) 1138(declare-function url-cache-create-filename "url-cache" (url))