Summary: WKWebView appears to have private API for doing a native implementation of find in page (_WKFindDelegate, _findString:, etc.). Chrome for iOS currently has to implement find-in-page via JS, which is significantly slower, and has to alter the DOM for display which has the potential to cause web compatibility issues. The ability to use a native Find API would make the features better for users, since it would be faster and more reliable. Steps to Reproduce: Attempt to implement find in page. Expected Results: Access to the apparently-existing API. Actual Results: No way to do it except re-implementing it from scratch in JS.
Radar ID: 17581332
Yes, the API was added for testing purpose. When you say JS, you mean you have your own pure HTML5 implementation? I think you can rely on (proprietary) JS APIs like window.find or execCommand('FindString') to use more native implementation, but they probably have some bugs (e.g. bug 163911). See also https://github.com/whatwg/html/issues/3539
By JS I mean that Chrome for iOS performs search on the page by calling -[WKWebView evaluateJavaScript:completionHandler:]. The script searches for keywords, highlights them, scrolls the page. Safari has "Find On Page" feature (Share -> Find On Page) and it seems like that feature actually uses _findString:.
(In reply to Eugene But from comment #3) > Safari has "Find On Page" feature (Share -> Find On Page) and it seems like > that feature actually uses _findString:. OK, IIRC window.find or document.execCommand('FindString') share some logic with the Find UI.
Thank you, Frédéric! We will check window.find and document.execCommand('FindString').
Hi Frederic! I tried out window.find and only was able to get it to highlight the results using document.execCommand('HiliteColor', false, 'yellow'). But I was unable to get it to scroll to results outside of the screen. So my question is two-fold: 1. Does window.find actually scroll & highlight, or is that a safari addition on top? 2. Are you aware of helpful ways to scroll to a given selected content (which is what window.find does)
(In reply to thegreenfrog from comment #6) > Hi Frederic! > > I tried out window.find and only was able to get it to highlight the results > using document.execCommand('HiliteColor', false, 'yellow'). But I was unable > to get it to scroll to results outside of the screen. So my question is > two-fold: > > 1. Does window.find actually scroll & highlight, or is that a safari > addition on top? > 2. Are you aware of helpful ways to scroll to a given selected content > (which is what window.find does) Regarding 1. window.find or document.execCommand('FindString') are nonstandard. Safari does scroll/highlight but I don't know for other browsers. Discussion is at https://github.com/whatwg/html/issues/3539 Regarding 2., window.find should do the scroll, if it does not it is a bug :-) I already mentioned bug 163911 on mobile safari.
The webkit2gtk provide FindController to highlight search text but the wkwebview doesn’t provide this feature. Is there a reason why the wkwebview doesn’t provide it? Thank you.