!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 39 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/toolkit/content/findUtils.js"
2 var gPromptService;
3 var gFindBundle;
4
nsFindInstData
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
5 function nsFindInstData() {}
6 nsFindInstData.prototype =
7 {
8 // set the next three attributes on your object to override the defaults
9 browser : null,
10
get_rootSearchWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
11 get rootSearchWindow() { return this._root || this.window.content; },
set_rootSearchWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
12 set rootSearchWindow(val) { this._root = val; },
13
get_currentSearchWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
14 get currentSearchWindow() {
15 if (this._current)
16 return this._current;
17
18 var focusedWindow = this.window.document.commandDispatcher.focusedWindow;
19 if (!focusedWindow || focusedWindow == this.window)
20 focusedWindow = this.window.content;
21
22 return focusedWindow;
23 },
set_currentSearchWindow
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
24 set currentSearchWindow(val) { this._current = val; },
25
get_webBrowserFind
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
26 get webBrowserFind() { return this.browser.webBrowserFind; },
27
init
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
28 init : function() {
29 var findInst = this.webBrowserFind;
30 // set up the find to search the focussedWindow, bounded by the content window.
31 var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames);
32 findInFrames.rootSearchFrame = this.rootSearchWindow;
33 findInFrames.currentSearchFrame = this.currentSearchWindow;
34
35 // always search in frames for now. We could add a checkbox to the dialog for this.
36 findInst.searchFrames = true;
37 },
38
39 window : window,
40 _root : null,
41 _current : null
42 }
43
44 // browser is the <browser> element
45 // rootSearchWindow is the window to constrain the search to (normally window.content)
46 // currentSearchWindow is the frame to start searching (can be, and normally, rootSearchWindow)
findInPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
47 function findInPage(findInstData)
48 {
49 // is the dialog up already?
50 if ("findDialog" in window && window.findDialog)
51 window.findDialog.focus();
52 else
53 {
54 findInstData.init();
55 window.findDialog = window.openDialog("chrome://global/content/finddialog.xul", "_blank", "chrome,resizable=no,dependent=yes", findInstData);
56 }
57 }
58
findAgainInPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
59 function findAgainInPage(findInstData, reverse)
60 {
61 if ("findDialog" in window && window.findDialog)
62 window.findDialog.focus();
63 else
64 {
65 // get the find service, which stores global find state, and init the
66 // nsIWebBrowser find with it. We don't assume that there was a previous
67 // Find that set this up.
68 var findService = Components.classes["@mozilla.org/find/find_service;1"]
69 .getService(Components.interfaces.nsIFindService);
70
71 var searchString = findService.searchString;
72 if (searchString.length == 0) {
73 // no previous find text
74 findInPage(findInstData);
75 return;
76 }
77
78 findInstData.init();
79 var findInst = findInstData.webBrowserFind;
80 findInst.searchString = searchString;
81 findInst.matchCase = findService.matchCase;
82 findInst.wrapFind = findService.wrapFind;
83 findInst.entireWord = findService.entireWord;
84 findInst.findBackwards = findService.findBackwards ^ reverse;
85
86 var found = findInst.findNext();
87 if (!found) {
88 if (!gPromptService)
89 gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService()
90 .QueryInterface(Components.interfaces.nsIPromptService);
91 if (!gFindBundle)
92 gFindBundle = document.getElementById("findBundle");
93
94 gPromptService.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
95 }
96
97 // Reset to normal value, otherwise setting can get changed in find dialog
98 findInst.findBackwards = findService.findBackwards;
99 }
100 }
101
canFindAgainInPage
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
102 function canFindAgainInPage()
103 {
104 var findService = Components.classes["@mozilla.org/find/find_service;1"]
105 .getService(Components.interfaces.nsIFindService);
106 return (findService.searchString.length > 0);
107 }