• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WebView find panel/bar implementation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebView find panel/bar implementation


  • Subject: Re: WebView find panel/bar implementation
  • From: Mike Abdullah <email@hidden>
  • Date: Tue, 02 Apr 2013 17:13:59 +0100

On 2 Apr 2013, at 12:43, email@hidden wrote:

> I provide some app documentation in both RTF and MarkDown and switch in an NSTextView or WebView for display as required.
> Text view searching works well using the NSTextFinder find bar.
> However, implementing a WebView find panel/bar seems difficult.
>
> - (void)performFindPanelAction:(id)sender is still not implemented - ref: https://bugs.webkit.org/show_bug.cgi?id=3640
> Current WebKit source still documents this as unimplemented - ref: https://trac.webkit.org/browser/trunk/Source/WebKit/mac/WebView/WebHTMLView.mm
>
> Some swizzling however can be effective - ref : http://www.taffysoft.com/pages/20120908-01.html
> So this can be investigated.
>
> But I don't see much in way of integrating NSTextFinder and WebView. The NSTextFinderClient protocol is quite extensive, which might explain why.
>
> Does anyone have any further insight into this?

The problem is that Cocoa's Find Bar provides a whole raft of its own functionality, not just a UI. It requires you to feed it a string, which it will then search itself. There's no way (that I've come across) to have it ask you to perform a search on its behalf.

I believe the reason for this is that the Find Bar actually supports some pretty complex, regular-expression-based searches, such as finding the URLs in a given piece of text.

WebKit does supply a decent bit of search functionality as it happens. It's kinda hidden though — look up the WebDocumentSearching protocol! You could provide your own UI atop that.

To make use of the find bar, I think you'd have to:

A) Walk the DOM for text nodes to feed into NSTextFinder. Make sure to handle whitespace the same way as WebKit renders it
B) Implement looking up a bit of such text from a given index. Likely some sort of cache is needed to avoid walking the entire DOM every time for this
C) Watch for the DOM being modified as a cue to update the find system

Also, file a radar asking for WebViews to support the Find Bar. Mine's getting lonely!
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: WebView find panel/bar implementation
      • From: "email@hidden" <email@hidden>
References: 
 >WebView find panel/bar implementation (From: "email@hidden" <email@hidden>)

  • Prev by Date: WebView find panel/bar implementation
  • Next by Date: Are custom clipping files dead?
  • Previous by thread: WebView find panel/bar implementation
  • Next by thread: Re: WebView find panel/bar implementation
  • Index(es):
    • Date
    • Thread