Thursday, September 25, 2008

Mozilla Source - Looking for Find in This Page...

The Search
Chinmay and I decided to look for how "Find in This Page...", on a Mac it is just "Find", works.
Searching mxr.mozilla.org for "Find in This Page..." found only a test xml file, strangely enough. So we looked for "Edit".

We found a DTD file that had a label and a accesskey for Find, the entity was called findcmd. A search on findcmd found a XUL file for the overlay of the Edit Menu. The overlay XUL file had an element for findcmd entity and a command attribute with the value of key_find. The key_find is a key element in the same XUL file. Its command attribute is cmd_find.

A search for cmd_find found a findbar.xml file. The cmd_find is associated with a method called onFindCommand. This method calls startFind method. The startFind method calls the open command which generates the findbar at the bottom of the screen. In the startFind method after the bar has been opened it then populates the text box with any selected text and enables the findbar buttons if any text is in the textbox.

That is how we found the "Find in This Page..." code.

No comments: