@@ -106,13 +106,20 @@ const Finder = Module("finder", {
106
106
* @param {string } str The string to find.
107
107
* @see Bug537013 https://bugzilla.mozilla.org/show_bug.cgi?id=537013
108
108
*/
109
+ get fastFind ( ) {
110
+ var fn = config . browser . fastFind
111
+ ? function _fastFind ( ) config . browser . fastFind
112
+ : function _fastFind ( ) window . gFindBar . browser . fastFind
113
+ ;
114
+ Object . defineProperty ( this , "fastFind" , { get : fn } ) ;
115
+ return fn ( ) ;
116
+ } ,
109
117
find : Services . vc . compare ( Services . appinfo . version , "25.0" ) >= 0 ?
110
118
function ( str ) {
111
- let fastFind = config . browser . getFindBar ( ) ;
119
+ let fastFind = this . fastFind ;
112
120
this . _processUserPattern ( str ) ;
113
- fastFind . _typeAheadCaseSensitive = this . _caseSensitive ;
114
- fastFind . _typeAheadLinksOnly = this . _linksOnly ;
115
- let result = fastFind . _find ( str ) ;
121
+ let result = fastFind . find ( str , this . _linksOnly ) ;
122
+ window . gFindBar . _findField . value = str ;
116
123
} :
117
124
// FIXME: remove when minVersion >= 25
118
125
function ( str ) {
@@ -134,13 +141,12 @@ const Finder = Module("finder", {
134
141
*/
135
142
findAgain : Services . vc . compare ( Services . appinfo . version , "25.0" ) >= 0 ?
136
143
function ( reverse ) {
137
- let fastFind = config . browser . getFindBar ( ) ;
138
- if ( fastFind . _findField . value != this . _lastSearchString )
144
+ let fastFind = this . fastFind ;
145
+ if ( window . gFindBar . _findField . value != this . _lastSearchString )
139
146
this . find ( this . _lastSearchString ) ;
140
147
141
148
let backwards = reverse ? ! this . _lastSearchBackwards : this . _lastSearchBackwards ;
142
- fastFind . _typeAheadLinksOnly = this . _linksOnly ;
143
- let result = fastFind . _findAgain ( backwards ) ;
149
+ let result = fastFind . findAgain ( backwards , this . _linksOnly ) ;
144
150
this . _displayFindResult ( result , backwards ) ;
145
151
} :
146
152
// FIXME: remove when minVersion >= 25
@@ -216,9 +222,7 @@ const Finder = Module("finder", {
216
222
// focus links after searching, so the user can just hit <Enter> another time to follow the link
217
223
// This has to be done async, because the mode reset after onSubmit would
218
224
// clear the focus
219
- let elem = Services . vc . compare ( Services . appinfo . version , "25.0" ) >= 0 ?
220
- config . browser . getFindBar ( ) . _foundLinkRef . get ( ) :
221
- config . browser . fastFind . foundLink ; // FIXME: remove when minVersion >= 25
225
+ let elem = this . fastFind . foundLink ;
222
226
this . setTimeout ( function ( ) {
223
227
if ( elem )
224
228
elem . focus ( ) ;
@@ -238,6 +242,21 @@ const Finder = Module("finder", {
238
242
this . highlight ( this . _searchString ) ;
239
243
} ,
240
244
245
+ get _highlight ( ) {
246
+ var gFindBar = window . gFindBar ;
247
+ if ( config . name === "Muttator" ) {
248
+ gFindBar = document . getElementById ( "FindToolbar" ) ;
249
+ }
250
+ if ( ! gFindBar ) return null ;
251
+
252
+ var fn = gFindBar . _highlightDoc
253
+ //? gFindBar._highlightDoc.bind(gFindBar)
254
+ ? function _highlight ( aHighlight , word ) { return gFindBar . _highlightDoc ( aHighlight , word ) ; }
255
+ : function _highlight ( aHighlight , word ) { return window . gFindBar . browser . finder . _highlight ( aHighlight , word ) ; } ;
256
+ Object . defineProperty ( this , "_highlight" , { value : fn } ) ;
257
+ return fn ;
258
+ } ,
259
+
241
260
/**
242
261
* Highlights all occurances of <b>str</b> in the buffer.
243
262
*
@@ -250,8 +269,8 @@ const Finder = Module("finder", {
250
269
251
270
if ( window . gFindBar ) {
252
271
window . gFindBar . _setCaseSensitivity ( this . _caseSensitive ) ;
253
- window . gFindBar . _highlightDoc ( false ) ;
254
- window . gFindBar . _highlightDoc ( true , str ) ;
272
+ this . _highlight ( false ) ;
273
+ this . _highlight ( true , str ) ;
255
274
}
256
275
} ,
257
276
@@ -264,7 +283,7 @@ const Finder = Module("finder", {
264
283
return ;
265
284
266
285
if ( window . gFindBar )
267
- window . gFindBar . _highlightDoc ( false ) ;
286
+ this . _highlight ( false ) ;
268
287
}
269
288
} , {
270
289
} , {
0 commit comments