Skip to content

Conversation

deepak1556
Copy link
Member

@deepak1556 deepak1556 commented Mar 18, 2021

Description of Change

Refs microsoft/vscode#96307

An app switching from <webview> to use OOPIF cannot use the current find functionality exposed on electron::api::WebContents::Find as it will initiate search from the top-level WebContents. The new api allows users to target a particular frame where the search has to be initiated from.

Checklist

Release Notes

Notes: Added webFramMain.findInFrame/stopFindInFrame

@deepak1556 deepak1556 requested a review from a team as a code owner March 18, 2021 19:18
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 18, 2021
@deepak1556 deepak1556 added api-review/requested 🗳 semver/minor backwards-compatible functionality labels Mar 18, 2021
Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if the WebContents.findInPage/stopFindInPage could be replaced with this new implementation. ie. just calling webContents.mainFrame.findInFrame internally.

Copy link
Contributor

@nornagon nornagon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marking request changes until we have more info on upstreaming.

@deepak1556
Copy link
Member Author

It would be great if the WebContents.findInPage/stopFindInPage could be replaced with this new implementation. ie. just calling webContents.mainFrame.findInFrame internally.

They are different in behavior, hence I haven't replaced them. FindInPage will go over the frames in all WebContents of a page (i-e) if a top-level WebContents can have multiple child WebContents. This api is only for frames in the same WebContents

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 25, 2021
@miniak miniak changed the title feat: add webFramMain.findInFrame/stopFindInFrame feat: add webFrameMain.findInFrame/stopFindInFrame Mar 31, 2021
@mjbvz
Copy link

mjbvz commented Apr 19, 2021

@deepak1556 @rzhao271 Thanks for looking into this.

I just tried it out for VS Code but one difference I noticed compared to search inside <webviews> is that find seems to focus the iframe. This causes problems when typing in our custom search widget, since the text input keeps losing focus

Any ideas on if that's something this API could change or if we can workaround this?

* Get subframes directly rather than from main frame

* Add parent frame check
@nornagon
Copy link
Contributor

nornagon commented Mar 3, 2022

@deepak1556 are you still interested in landing this?

If so, how do WebContents.findInPage and WebFrameMain.findInFrame interact with one another?

Could we possibly consolidate these two systems into one by having WebFrameMain.findInFrame recurse into webviews that are hosted in subframes of the target frame?

@nornagon nornagon self-assigned this Mar 7, 2022
@deepak1556
Copy link
Member Author

Sorry for the delay in getting back to this PR

Could we possibly consolidate these two systems into one by having WebFrameMain.findInFrame recurse into webviews that are hosted in subframes of the target frame?

Originally I was not sure about merging them #28274 (comment) mainly because the FindRequestManager cannot handle concurrent find sessions within the same root and with FindInPage api user will never hit this scenario as they can only trigger the search from page root. But looking at it now, I can merge the behavior of FindInPage into FindInFrame when the target frame is a mainFrame FindRequestManager and possible throw a user facing error if there was an attempt for a search from another frame within the tree when there is an active session in progress.

are you still interested in landing this?

What is your take on the patch ? Unfortunately, I couldn't get any traction on the upstream issue https://bugs.chromium.org/p/chromium/issues/detail?id=1189789, so this will end up being an electron only patch if the API were to be supported.

@nornagon
Copy link
Contributor

What is your take on the patch?

It's not a crazy huge patch and it does add a legitimately useful feature which is sort of Electron-specific. It's a bit of a niche feature and it's likely to run into at least some code shear, so I'm not enthusiastic about it, but begrudgingly willing to take it. It would probably be worth spending some time thinking about whether we can reduce the surface area of the patch. Can we do some subclassing instead? Can we apply the filtering at a different point? Any thoughts?

@deepak1556
Copy link
Member Author

Can we do some subclassing instead? Can we apply the filtering at a different point? Any thoughts?

The filtering in this case has to be performed at FindRequestManager, basically this class owns a per frame client called FindInPageClient that makes the find request with blink and awaits for response. FindRequestManager then combines the results from all the FindInPageClient for a given tree including out of process frames and allows traversal of the active matches.

I will first update the branch against main since the current patch is outdated and will check if there is a possibility to minimize it.

@ckerr
Copy link
Member

ckerr commented May 23, 2024

@deepak1556 is this PR still live?

@deepak1556
Copy link
Member Author

There is need to upstream the frame find implementation but don't have cycles to visit this anytime soon. Closing for now.

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

Successfully merging this pull request may close these issues.

6 participants