diff options
| author | Jim Porter | 2024-06-23 12:18:57 -0700 |
|---|---|---|
| committer | Jim Porter | 2024-07-04 12:14:37 -0700 |
| commit | 3ce7e4ee3f1f8bf85c2c455ac624bec6c7cd10a8 (patch) | |
| tree | adad05d70f7de8eed8676aa09500b77b87d5d557 /test | |
| parent | fa6f088a483f1f2e19863800c6215a8136288b8f (diff) | |
| download | emacs-3ce7e4ee3f1f8bf85c2c455ac624bec6c7cd10a8.tar.gz emacs-3ce7e4ee3f1f8bf85c2c455ac624bec6c7cd10a8.zip | |
Slice images based on their height in SHR, not their zoom level
* lisp/net/shr.el (shr-sliced-image-height): New option...
(shr-put-image): ... use it. Compute the number of slices in relation
to the image height; this way, each slice is roughly the height of a
line of ordinary text.
* test/lisp/net/shr-tests.el (shr-test/zoom-image): Update test, since
zooming no longer necessarily triggers slicing.
* doc/misc/eww.texi (Advanced): Document 'shr-sliced-image-proportion'.
* etc/NEWS: Announce this change.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/net/shr-tests.el | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/test/lisp/net/shr-tests.el b/test/lisp/net/shr-tests.el index 54d85ee95f9..c813103b408 100644 --- a/test/lisp/net/shr-tests.el +++ b/test/lisp/net/shr-tests.el | |||
| @@ -158,6 +158,7 @@ settings, then once more for each (OPTION . VALUE) pair.") | |||
| 158 | (shr-width 80) | 158 | (shr-width 80) |
| 159 | (shr-use-fonts nil) | 159 | (shr-use-fonts nil) |
| 160 | (shr-image-animate nil) | 160 | (shr-image-animate nil) |
| 161 | (shr-sliced-image-height nil) | ||
| 161 | (inhibit-message t) | 162 | (inhibit-message t) |
| 162 | (dom (libxml-parse-html-region (point-min) (point-max)))) | 163 | (dom (libxml-parse-html-region (point-min) (point-max)))) |
| 163 | ;; Render the document. | 164 | ;; Render the document. |
| @@ -170,19 +171,15 @@ settings, then once more for each (OPTION . VALUE) pair.") | |||
| 170 | (shr-zoom-image) | 171 | (shr-zoom-image) |
| 171 | (shr-test-wait-for (lambda () (= put-image-calls 2)) | 172 | (shr-test-wait-for (lambda () (= put-image-calls 2)) |
| 172 | "Timed out waiting to zoom image") | 173 | "Timed out waiting to zoom image") |
| 173 | ;; Check that we got a sliced image. | 174 | ;; Check that we have a single image at original size. |
| 174 | (let ((slice-count 0)) | 175 | (let (image-sizes) |
| 175 | (goto-char (point-min)) | 176 | (goto-char (point-min)) |
| 176 | (while (< (point) (point-max)) | 177 | (while (< (point) (point-max)) |
| 177 | (when-let ((display (get-text-property (point) 'display))) | 178 | (when (get-text-property (point) 'display) |
| 178 | ;; If this is nil, we found a non-sliced image, but we | 179 | (push (get-text-property (point) 'image-size) image-sizes)) |
| 179 | ;; should have replaced that! | ||
| 180 | (should (assq 'slice display)) | ||
| 181 | (cl-incf slice-count)) | ||
| 182 | (goto-char (or (next-single-property-change (point) 'display) | 180 | (goto-char (or (next-single-property-change (point) 'display) |
| 183 | (point-max)))) | 181 | (point-max)))) |
| 184 | ;; Make sure we actually saw a slice. | 182 | (should (equal image-sizes '(original)))))))))) |
| 185 | (should (> slice-count 1))))))))) | ||
| 186 | 183 | ||
| 187 | (require 'shr) | 184 | (require 'shr) |
| 188 | 185 | ||