akhodakivskiy/VimFx

Scrolling does not work on some sites

odknt opened this issue · 7 comments

Because overflow/underflow event is now disabled by default in Firefox 131.
Make it work as before by setting the following in about:config, but is this a problem that can be handled on the VimFx side?

layout.overflow-underflow.content.enabled = true
layout.overflow-underflow.content.enabled_in_addons = true

Since these events are scheduled to be removed in the future, add-ons like TreeStyleTab seem to have switched to using ResizeObserver.

I produced a minimal example (github doesn't seem to allow html attachments)
scrolling_issue.html.txt

  • If the body overflows, it works correctly.
  • If an element with a set height overflows, scrolling will stop working.

I believe I have a plan for this worked out. No clue if it is performant or not; only the implementation will tell. If someone has a better idea, please let me know.

a resizeobserver apparently does not trigger for child elements, so we have to
add one to every single dom node (hopefully this doesn't kill performance too
much). this will be done like so: on frame load, add a MutationObserver to the
root node, which on addition of new nodes registers changed elements to the
ResizeObserver. this code also likely needs to get executed immedately once on
frame load, to catch already loaded dom nodes.

the two observers should probably be instantiated in the constructor of
ScrollableElements(). the resizeObserver's .observe method will get called
directly from mutationObserver's callback; mutationObserver's .observe needs to
be called by vim-frame.coffee when it is added into the frame, passing the
content's window object (called @content).

resizeObserver's callback will then have to check if the element is overflowing
and call scrollable-element's .addChecked (or .deleteChecked).

I can't reproduce the error, but I got a other error in ResizeObserver callback. As follows.

TypeError: Window.getComputedStyle: Argument 1 does not implement interface Element.

Also, scrolling works only immediately after the add-on is installed, but stops working when the page is reloaded.