erkyrath / lectrote

The IF interpreter in an Electron shell
Other
248 stars 28 forks source link

Text search widget finds its own contents #65

Open erkyrath opened 8 years ago

erkyrath commented 8 years ago

When you do a text search, the input in the text widget gets highlighted yellow, indicating that the search has found that text.

We try to disguise this fact: if you're searching forward or backward, it skips over the text widget. (You can see it flicker by if you watch.)

I spent a few days trying to fix this, and wound up with nothing but toothmarks on my knee.

First I put the search widget in the shadow DOM. You'd think that would help, but it turns out that webContents.findInPage searches the shadow DOM as well as the main DOM! This behavior is inherited from Chromium and perhaps Webkit. (See https://github.com/electron/electron/issues/6138 , https://bugs.chromium.org/p/chromium/issues/detail?id=621403 .)

Then I went down the alley of putting the search widget into a webview tag. This worked, but it felt pretty bad. The webview is a third process (which cannot communicate with the main process, only with the window renderer?) so we have a two-step relay for shoving information back and forth. Also, I don't understand the flexbox layout of the webview; I had to hardcode box sizes. Also, I couldn't get the input widget to grab focus from the main page.

So I backed the webview stuff out.

I've got the shadow DOM implementation now, mostly because I didn't have the energy to back that out too. Maybe someday it will start working.

(And then I'll have to delete the skip-over-last hack. Just nuke the found-in-page handler from main.js.)