<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>140210</bug_id>
          
          <creation_ts>2015-01-07 14:25:31 -0800</creation_ts>
          <short_desc>Provide public WKWebView API for find-in-page</short_desc>
          <delta_ts>2022-05-22 06:45:29 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit API</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Eugene But">eugenebut</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ajuma</cc>
    
    <cc>craig</cc>
    
    <cc>fred.wang</cc>
    
    <cc>keiya.s.0210</cc>
    
    <cc>stefan</cc>
    
    <cc>stuartmorgan</cc>
    
    <cc>thebnich</cc>
    
    <cc>thegreenfrog</cc>
    
    <cc>thorton</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1059534</commentid>
    <comment_count>0</comment_count>
    <who name="Eugene But">eugenebut</who>
    <bug_when>2015-01-07 14:25:31 -0800</bug_when>
    <thetext>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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1059615</commentid>
    <comment_count>1</comment_count>
    <who name="Eugene But">eugenebut</who>
    <bug_when>2015-01-07 16:08:36 -0800</bug_when>
    <thetext>Radar ID: 17581332</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478905</commentid>
    <comment_count>2</comment_count>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2018-11-15 08:20:50 -0800</bug_when>
    <thetext>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(&apos;FindString&apos;) to use more native implementation, but they probably have some bugs (e.g. bug 163911). See also https://github.com/whatwg/html/issues/3539</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478908</commentid>
    <comment_count>3</comment_count>
    <who name="Eugene But">eugenebut</who>
    <bug_when>2018-11-15 08:26:14 -0800</bug_when>
    <thetext>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 &quot;Find On Page&quot; feature (Share -&gt; Find On Page) and it seems like that feature actually uses _findString:.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478910</commentid>
    <comment_count>4</comment_count>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2018-11-15 08:29:26 -0800</bug_when>
    <thetext>(In reply to Eugene But from comment #3)
&gt; Safari has &quot;Find On Page&quot; feature (Share -&gt; Find On Page) and it seems like
&gt; that feature actually uses _findString:.

OK, IIRC window.find or document.execCommand(&apos;FindString&apos;) share some logic with the Find UI.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478919</commentid>
    <comment_count>5</comment_count>
    <who name="Eugene But">eugenebut</who>
    <bug_when>2018-11-15 08:47:28 -0800</bug_when>
    <thetext>Thank you, Frédéric! We will check window.find and document.execCommand(&apos;FindString&apos;).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483178</commentid>
    <comment_count>6</comment_count>
    <who name="">thegreenfrog</who>
    <bug_when>2018-11-29 14:16:06 -0800</bug_when>
    <thetext>Hi Frederic!

I tried out window.find and only was able to get it to highlight the results using document.execCommand(&apos;HiliteColor&apos;, false, &apos;yellow&apos;). 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 &amp; 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)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483395</commentid>
    <comment_count>7</comment_count>
    <who name="Frédéric Wang Nélar">fred.wang</who>
    <bug_when>2018-11-29 21:17:41 -0800</bug_when>
    <thetext>(In reply to thegreenfrog from comment #6)
&gt; Hi Frederic!
&gt; 
&gt; I tried out window.find and only was able to get it to highlight the results
&gt; using document.execCommand(&apos;HiliteColor&apos;, false, &apos;yellow&apos;). But I was unable
&gt; to get it to scroll to results outside of the screen. So my question is
&gt; two-fold:
&gt; 
&gt; 1. Does window.find actually scroll &amp; highlight, or is that a safari
&gt; addition on top?
&gt; 2. Are you aware of helpful ways to scroll to a given selected content
&gt; (which is what window.find does)

Regarding 1. window.find or document.execCommand(&apos;FindString&apos;) are nonstandard.  Safari does scroll/highlight but I don&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1871005</commentid>
    <comment_count>8</comment_count>
    <who name="Keiya Sasaki">keiya.s.0210</who>
    <bug_when>2022-05-22 06:45:29 -0700</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>