There is a new interface for finding text within an nsIWebBrowser:

http://lxr.mozilla.org/seamonkey/source/embedding/browser/webBrowser/nsIWebBrowserFind.idl
This interface only performs the search. It does not provide any Find 
dialog UI. That needs to be provided by the embedding app and the search 
parameters from the dialog are set as attributes on the 
nsIWebBrowserFind interface. The implementation handles searching in 
framesets. In this case, the frame searched is the frame which currently 
has the focus. A click in the frame will give it the focus.

So, if mWebBrowser is an nsCOMPtr<nsIWebBrowser>, you can get an 
nsIWebBrowserFind by doing this:

nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mWebBrowser));

Then,  set the attributes which define the search:
(1) At least the searchString attribute must be set or an error will be 
returned. The other attributes are optional.
(2) These attributes are remembered for the lifetime of the web browser.
(3) If you are putting up Find dialog UI, you can get the attributes to 
set up the dialog.

finder->SetSearchString(searchString.GetUnicode());
finder->SetFindBackwards(findBackwards);   
finder->SetWrapFind(wrapFind);   
finder->SetEntireWord(entireWord);   
finder->SetMatchCase(matchCase);

and do the search:

PRBool didFind;
rv = finder->FindNext(&didFind);

If the string is found, it will be hilited and scrolled into view.


-Conrad






Reply via email to