Subject: bug#75053: Xwidget widgets shorter than the window height do not scroll correctly

From: JD Smith <[email-masked]>
Date: Mon, 23 Dec 2024 14:49:32 -0500

Xwidget widgets do not stay "in place" as the text they are placed in is scrolled, unlike images and other non-character-sized content.

To reproduced, create a new xwidget of a fixed pixel size that does not occupy the full window height:

(require 'xwidget)
(let ((xw (make-xwidget 'webkit "Test" (- (window-pixel-width) 20) 400)))
  (xwidget-webkit-goto-uri xw "https://www.gnu.org")
  (goto-char (point-max))
  (insert "\n\n\n" (propertize "     " 'display `(xwidget :xwidget ,xw)) "\n\nMORE STUFF BELOW\n"))

Scrolling in the buffer (even via simple (scroll-up/down N) calls), leads to displacement between the text and the widget itself, resulting in overlap.  I.e. the text scrolls, the widget does not.

This tends to resolve with more movement, but in a "jumping" fashion.

Tested on Emacs 29.4 NS and emacs-mac; similar behavior (though emacs-mac can partially scroll the image off-screen, unlike NS).