Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hints not finding elements from shadow roots #7617

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joelkur
Copy link

@joelkur joelkur commented Mar 13, 2023

Hi! I recently discovered qutebrowser and instantly became a fan of it :) However I'm working with Shadow DOM currently so the lack of shadow dom support became a blocker for being able to fully use it.

As a quick fix, this change modifies find_css function so that it recursively collects elements with shadowRoot to a list, and then adds the clickable elements from those shadowRoots to the returned result. AFAIK there isn't any easier way of finding all shadowRoots in a page (as also seems to be discussed in #3569)

This change should at least partially resolve #3569.

@chaorace
Copy link
Contributor

I'm using this PR rebased onto current master and can confirm it's working nicely for sites with open shadow roots. Looking forward to seeing this land in the official release 👍

@The-Compiler
Copy link
Member

Thanks for testing @chaorace, feedback like this is much appreciated! I'll try to prioritize this once I get back around to merging PRs. Right now I'm focused on getting Qt 6 and qutebrowser v3.0.0 out of the door first.

@chaorace
Copy link
Contributor

chaorace commented Jul 12, 2023

@joelkur I think that this PR might be breaking subframe element detection. Hints seem to be completely missing for any element nested within an iframe on the page, regardless of whether it's in a shadowroot or not.

Screenshot demonstrating the missing hints for button elements nested inside of an iframe, even though identical elements outside of this iframe show hints normally
Note: the pictured "s" hint points to the iframe element, not the nested button

Reproduction steps:

  1. Download the following html files into the same directory: https://gist.github.com/chaorace/ccaaa3f3968677f06922db1331faa84e
  2. Open example.html using a patched qutebrowser with default configuration
  3. Press f to summon hints
  4. Observe that only "IFrame Button" and "IFrame Shadow Button" are missing hints

@hakan-demirli
Copy link

I have tried to fix subframe problem by using vieb browsers implementation since it works quite well but I failed.
I am not a JS developer so I will leave a link in case anyone else wants to try.

It can traverse shadow doms.
https://github.com/Jelmerro/Vieb/blob/6eb7095eebd4889fe4cc6c596a8d3cc7ff6cd75d/app/util.js#L519

@The-Compiler
Copy link
Member

@hakan-demirli The code isn't the problem. Vieb likely can run JS with elevated permissions via Electron, but qutebrowser can only do whatever the webpage itself is allowed to do in JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Improved support for frames and shadow DOMs / shadow roots
4 participants