WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
140210
Provide public WKWebView API for find-in-page
https://bugs.webkit.org/show_bug.cgi?id=140210
Summary
Provide public WKWebView API for find-in-page
Eugene But
Reported
2015-01-07 14:25:31 PST
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
Comment 1
2015-01-07 16:08:36 PST
Radar ID: 17581332
Frédéric Wang (:fredw)
Comment 2
2018-11-15 08:20:50 PST
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
Comment 3
2018-11-15 08:26:14 PST
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)
Comment 4
2018-11-15 08:29:26 PST
(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
Comment 5
2018-11-15 08:47:28 PST
Thank you, Frédéric! We will check window.find and document.execCommand('FindString').
thegreenfrog
Comment 6
2018-11-29 14:16:06 PST
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)
Comment 7
2018-11-29 21:17:41 PST
(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
Comment 8
2022-05-22 06:45:29 PDT
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.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug