Summary: | Provide public WKWebView API for find-in-page | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eugene But <eugenebut> |
Component: | WebKit API | Assignee: | Nobody <webkit-unassigned> |
Status: | NEW --- | ||
Severity: | Normal | CC: | ajuma, craig, fred.wang, keiya.s.0210, stefan, stuartmorgan, thebnich, thegreenfrog, thorton |
Priority: | P2 | Keywords: | InRadar |
Version: | 528+ (Nightly build) | ||
Hardware: | iPhone / iPad | ||
OS: | All |
Description
Eugene But
2015-01-07 14:25:31 PST
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. |