Bug 3640 - Implement performFindPanelAction: in WebView
Summary: Implement performFindPanelAction: in WebView
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Maciej Stachowiak
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2005-06-21 16:15 PDT by David Smith
Modified: 2021-04-29 22:28 PDT (History)
6 users (show)

See Also:


Attachments
performFindPanelAction interface and implementation to add to WebView interface and implementation (972 bytes, patch)
2006-09-23 12:36 PDT, Robert Burns
no flags Details | Formatted Diff | Diff
implementation file (5.01 KB, patch)
2006-09-23 12:37 PDT, Robert Burns
no flags Details | Formatted Diff | Diff
nib with pseudo-standard find panel (text archive format) (4.67 KB, application/zip)
2006-09-23 12:51 PDT, Robert Burns
no flags Details
image of sample xhtml find panel (24.01 KB, image/png)
2006-09-23 17:48 PDT, Robert Burns
no flags Details
find panel in xhtml (2.67 KB, text/html)
2006-09-23 18:20 PDT, Robert Burns
no flags Details
xhtml find panel (revision) (2.74 KB, text/html)
2006-09-23 18:41 PDT, Robert Burns
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Smith 2005-06-21 16:15:24 PDT
WebView in Safari 1.3 and later is documented to implement performFindPanelAction:, but the actual 
implementation just consists of 

- (void)performFindPanelAction:(id)sender
{
    // Implementing this will probably require copying all of NSFindPanel.h and .m.
    // We need *almost* the same thing as AppKit, but not quite.
    ERROR("unimplemented");
}

This is the same as rdar://4109997
Comment 1 Joost de Valk (AlthA) 2005-06-23 10:04:38 PDT
confirmed.
Comment 2 David Smith 2005-11-04 15:07:14 PST
If there's any reasonable way of implementing this without access to the AppKit source (NSFindPanel.h and 
.m, as mentioned in the comment), then I would be happy to look into writing a patch for it.
Comment 3 Sören Kuklau 2006-04-08 19:18:14 PDT
I'd like to offer 100 Euros to any person who implements the feature, i.e. the ability to search within a WebKit view with the normal Cocoa Find panel, paid via PayPal or moneybookers. If the work is done by multiple people, it'll obviously be split fairly.

As I'm CC'd to the bug, I'll know when someone's working on it, and will try and pay as soon as someone can confirm that the patch works without causing major regressions.
Comment 4 Robert Burns 2006-09-22 21:50:09 PDT
I thought an ealier version of TextEdit had this implemented separately (it has since been integrated into the cocoa text system). If someone had access to that code it might show the way.
Comment 5 Robert Burns 2006-09-23 12:36:35 PDT
Created attachment 10723 [details]
performFindPanelAction interface and implementation to add to WebView interface and implementation

I took a stab at this. I'm not that familiar with the inner workings of WebKit and not really familiar enoght with c++ to poke around there. However, using just the public objective-C APIs I think I have an initial stab at this. What I've done is independent of the  AppKit. It deos add many methods to WebView to implement fully (see the .h file).

It doesn't yet implement:

1)  "replace all" or 
2) "replace all within selection". 

I think those should be implemented so that they are undoable in one undo action.  It also doesn't undo replace string when the string is an empty string. I'm not familiar enough with WebView protocols to know how best to implement those undos.

The standard Find Panel has a popup for selecting "Contains",  "Full word" or "Starts with".  I have not implemented either:

3) "Full word" or
4) "Starts with"

Also I added an NSLocalizedString for the "Not Found" message on the standard find panel for localization. This would require 

5) a Localizable.strings file to finish implementing.

I've included a nib file with an approximation of the standard Find Panel. This could alternately be created with HTML forms or .Net, or XWindows, etc. It merely provides a UI to set the other instance variables, invoke performFindPanelActions and, for performFindPanelAction == 1, to have a panel to display.

If one were to remove the popup button, and the replace all button this implementation is ready as is.
Comment 6 Robert Burns 2006-09-23 12:37:45 PDT
Created attachment 10724 [details]
implementation file
Comment 7 Robert Burns 2006-09-23 12:51:17 PDT
Created attachment 10725 [details]
nib with pseudo-standard find panel (text archive format)

This si a nib file containing an approximation of the standard Find Panel (from TextEdit). The tags are set approrpiately on the round buttons and can be wired to the performFindPanelAction of the first responder. The checkboxes can be bound, wireed or otherwise linked up to the appropriate methods included in this interface. Likewise the notfound. The enclosed NSPanel should then be sent as the argument like:

[aWebView setFindPanel:thisFindPanel]

As an alternative, a different find panel could be created using another UI enviornment of even HTML forms. The performFindPanel method does require the sender invoking the message repsond to introspection through the "tag" method.
Comment 8 Robert Burns 2006-09-23 13:42:21 PDT
Just by way of reference, I wanted to provide a link to the Apple documentation ont performFindPanelAction (specifically the constant tag integers used). You'll find them here:

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextView_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSFindPanelActionShowFindPanel

I think for the benefit of appKit users it might mkae sense to add IBOutlets for:
1) searchStringField
2) replaceStringField
3) searchWrapsAroundFlag
4) caseSensitiveSearchFlag

That way those ivars can be wired up to a find panel. Just a thought to deal with the need to update those ivars from the find panel immediately before a search takes place.
Comment 9 Robert Burns 2006-09-23 17:48:45 PDT
Created attachment 10727 [details]
image of sample xhtml find panel

Here's another proto-idea to make this even more independent of the AppKit. We could have a default find panel that could be overridden by using the setFindPanel method. This deffault find panel would be another WebView populated with XHTML UI controls and laid out with CSS (attachment forthcoming. This is just an image of what it looks like now. The CSS keyword "caption" for the system font does not seem to work (I'll file a bug). This could also use the pinstripe Augua background for Mac OS X or some others for other systems.

I call it a proto idea, becuase I'm not familiar enough with WebKit (and all the other necessary technologies)  to know whether there's a way to invoke actions from this WebView on other WebViews that are the first responder to thes actions. If anyone has some ideas on this I'd be happy to work on it.
Comment 10 Robert Burns 2006-09-23 18:20:51 PDT
Created attachment 10728 [details]
find panel in  xhtml

Here is the sample xhtml for a buil in cross-platform find-pane independent of AppKit (at least as indpendent as anything else in WebKit). The CSS could use some improving, but more importantly we would need a mechnaism for this find panel to invoke the performFindPanelAction method in the first responder chain. We could aslo generate this find panel using the DOM (and with CSS) have a flexible localized find panel.
Comment 11 Robert Burns 2006-09-23 18:41:29 PDT
Created attachment 10729 [details]
xhtml find panel (revision)
Comment 12 Eric Seidel (no email) 2012-12-30 17:10:10 PST
Is this still a valid bug?
Comment 13 Alexey Proskuryakov 2012-12-31 19:04:39 PST
The "unimplemented" error message is still there. Why are you asking?
Comment 14 Eric Seidel (no email) 2012-12-31 19:17:09 PST
The last comment was 6 years ago. :)  Just figured someone should check in. :)
Comment 15 David Smith 2012-12-31 20:10:44 PST
Hard to say if this is still relevant. -performFindPanelAction: has mostly been replaced by NSTextFinder, but having NSTextFinder support (via a subclass perhaps?) in WebView would still be quite helpful.
Comment 16 Bill 2017-10-15 23:50:20 PDT
I found this WebView subclass implementation to be a helpful starting point: https://github.com/shc-vj/SHCWebView