Bug 140210
| 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 | ||
Eugene But
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.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Eugene But
Radar ID: 17581332
Frédéric Wang (:fredw)
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
Eugene But
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:.
Frédéric Wang (:fredw)
(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.
Eugene But
Thank you, Frédéric! We will check window.find and document.execCommand('FindString').
thegreenfrog
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)
Frédéric Wang (:fredw)
(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.
Keiya Sasaki
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.