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).
This commit is contained in:
parent
3abcfe013d
commit
6837828219
3 changed files with 29 additions and 10 deletions
|
@ -5182,8 +5182,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
|
||||
|
|
|
@ -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)
|
||||
|
|
24
src/xdisp.c
24
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
|
||||
|
|
Loading…
Add table
Reference in a new issue