From: Jim Porter Date: Mon, 24 Jun 2024 00:27:24 +0000 (-0700) Subject: Support rescaling sliced images in EWW via 'text-scale-mode' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0ac8790d158690754bb470418903c0798648e76c;p=emacs.git Support rescaling sliced images in EWW via 'text-scale-mode' * src/xdisp.c (find_display_property): When the property value has multiple elements, return the whole list. * lisp/net/eww.el (eww--rescale-images): Use 'get-display-property'. * doc/lispref/display.texi (Display Property): Describe the new 'get-display-property' behavior (bug#71741). (cherry picked from commit 6837828219b965148219f6d8eba4c740aaddacbb) --- diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 9960e807437..7c8727901bd 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -5210,8 +5210,10 @@ specifications. This convenience function can be used to get a specific display property, no matter whether the @code{display} property is a vector, a list or a simple property. This is like @code{get-text-property} -(@pxref{Examining Properties}), but works on the @code{display} -property only. +(@pxref{Examining Properties}), but works on the @code{display} property +only. For properties with a single value (e.g.@: @code{height}, this +returns the value itself; for properties with a list of values (e.g.@: +@code{slice}), this returns the list of values. @var{position} is the position in the buffer or string to examine, and @var{prop} is the @code{display} property to return. The optional diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 94bfd333fa9..907b35f8565 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el @@ -1370,8 +1370,13 @@ within text input fields." (save-excursion (goto-char (point-min)) (while-let ((match (text-property-search-forward - 'display nil (lambda (_ value) (imagep value))))) - (let* ((image (prop-match-value match)) + 'display nil + (lambda (_ value) + (and value (get-display-property + nil 'image nil value)))))) + (let* ((image (cons 'image + (get-display-property nil 'image nil + (prop-match-value match)))) (original-scale (or (image-property image :original-scale) (setf (image-property image :original-scale) (or (image-property image :scale) diff --git a/src/xdisp.c b/src/xdisp.c index 18ac5b69d7e..8c7e8e5cb43 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -5549,6 +5549,7 @@ setup_for_ellipsis (struct it *it, int len) static Lisp_Object find_display_property (Lisp_Object disp, Lisp_Object prop) { + Lisp_Object elem; if (NILP (disp)) return Qnil; /* We have a vector of display specs. */ @@ -5556,11 +5557,11 @@ find_display_property (Lisp_Object disp, Lisp_Object prop) { for (ptrdiff_t i = 0; i < ASIZE (disp); i++) { - Lisp_Object elem = AREF (disp, i); + elem = AREF (disp, i); if (CONSP (elem) && CONSP (XCDR (elem)) && EQ (XCAR (elem), prop)) - return XCAR (XCDR (elem)); + goto found; } return Qnil; } @@ -5570,11 +5571,11 @@ find_display_property (Lisp_Object disp, Lisp_Object prop) { while (!NILP (disp)) { - Lisp_Object elem = XCAR (disp); + elem = XCAR (disp); if (CONSP (elem) && CONSP (XCDR (elem)) && EQ (XCAR (elem), prop)) - return XCAR (XCDR (elem)); + goto found; /* Check that we have a proper list before going to the next element. */ @@ -5589,9 +5590,20 @@ find_display_property (Lisp_Object disp, Lisp_Object prop) else if (CONSP (disp) && CONSP (XCDR (disp)) && EQ (XCAR (disp), prop)) - return XCAR (XCDR (disp)); + { + elem = disp; + goto found; + } + + return Qnil; + + found: + /* If the property value is a list of one element, just return the + CAR. */ + if (NILP (XCDR (XCDR (elem)))) + return XCAR (XCDR (elem)); else - return Qnil; + return XCDR (elem); } static Lisp_Object