<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AX: WKContentView needs to implement UITextInput methods to make speak selection highlighting work"
   href="https://bugs.webkit.org/show_bug.cgi?id=166955#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - AX: WKContentView needs to implement UITextInput methods to make speak selection highlighting work"
   href="https://bugs.webkit.org/show_bug.cgi?id=166955">bug 166955</a>
              from <span class="vcard"><a class="email" href="mailto:n_wang&#64;apple.com" title="Nan Wang &lt;n_wang&#64;apple.com&gt;"> <span class="fn">Nan Wang</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=299684&amp;action=diff" name="attach_299684" title="patch">attachment 299684</a> <a href="attachment.cgi?id=299684&amp;action=edit" title="patch">[details]</a></span>
patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=299684&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=299684&amp;action=review</a>

<span class="quote">&gt;&gt; Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm:1870
&gt;&gt; +        next = !next.isNull() ? next.next() : next;
&gt; 
&gt; This is quite possibly the most inefficient way of expanding positions all the way to the beginning or the end of a document.
&gt; Why can't we just use findPlainText? Please explain in the change or in the comment.</span >

I've got a comment already: Try to search for a range which is the closest to the position within the selection range that matches the passed in text.

I think the problem with findPlainText is that the result range might not be the closest or includes the position we passed in. 

e.g. we want to search for the second &quot;the&quot; in &quot;the car is the fastest in the world&quot; at offset 12 (at &quot;h&quot; of the second &quot;the&quot;), findPlainText might return the range of the first or third &quot;the&quot; depending on the range and direction we passed in.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>