Skip to content

Commit ae3808b

Browse files
committed
fix: broken finder
1 parent b3b6a06 commit ae3808b

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

common/content/finder.js

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,20 @@ const Finder = Module("finder", {
106106
* @param {string} str The string to find.
107107
* @see Bug537013 https://bugzilla.mozilla.org/show_bug.cgi?id=537013
108108
*/
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+
},
109117
find: Services.vc.compare(Services.appinfo.version, "25.0") >= 0 ?
110118
function (str) {
111-
let fastFind = config.browser.getFindBar();
119+
let fastFind = this.fastFind;
112120
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;
116123
} :
117124
// FIXME: remove when minVersion >= 25
118125
function (str) {
@@ -134,13 +141,12 @@ const Finder = Module("finder", {
134141
*/
135142
findAgain: Services.vc.compare(Services.appinfo.version, "25.0") >= 0 ?
136143
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)
139146
this.find(this._lastSearchString);
140147

141148
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);
144150
this._displayFindResult(result, backwards);
145151
} :
146152
// FIXME: remove when minVersion >= 25
@@ -216,9 +222,7 @@ const Finder = Module("finder", {
216222
// focus links after searching, so the user can just hit <Enter> another time to follow the link
217223
// This has to be done async, because the mode reset after onSubmit would
218224
// 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;
222226
this.setTimeout(function() {
223227
if (elem)
224228
elem.focus();
@@ -238,6 +242,21 @@ const Finder = Module("finder", {
238242
this.highlight(this._searchString);
239243
},
240244

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+
241260
/**
242261
* Highlights all occurances of <b>str</b> in the buffer.
243262
*
@@ -250,8 +269,8 @@ const Finder = Module("finder", {
250269

251270
if (window.gFindBar) {
252271
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);
255274
}
256275
},
257276

@@ -264,7 +283,7 @@ const Finder = Module("finder", {
264283
return;
265284

266285
if (window.gFindBar)
267-
window.gFindBar._highlightDoc(false);
286+
this._highlight(false);
268287
}
269288
}, {
270289
}, {

0 commit comments

Comments
 (0)