Skip to content

Commit

Permalink
Closes #273 fix how unique findbar ids are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
Quicksaver committed Dec 8, 2016
1 parent b679f03 commit 348fc71
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
15 changes: 14 additions & 1 deletion resource/modules/gFindBar.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 1.2.8
// VERSION 1.2.9

this.__defineGetter__('gFindBar', function() { return window.gFindBar || $('FindToolbar'); });
this.__defineGetter__('gFindBarInitialized', function() { return FITFull || viewSource || window.gFindBarInitialized; });
Expand Down Expand Up @@ -234,6 +234,11 @@ this.baseDeinit = function(bar) {

bar._findStatusDesc.hidden = false;
bar._findStatusIcon.hidden = false;

if(!viewSource) {
// Sometimes we add a unique id to each findbar, to identify it in stylesheets. These need to be removed when disabling the add-on.
bar.id = '';
}
}

delete bar._quickFindTimeoutLength;
Expand Down Expand Up @@ -311,6 +316,14 @@ this.findbar = {
this.currentTab = gBrowser.selectedTab;
},

// Some things need to identify individual findbars, such as calculating their position at the top with Tile Tabs.
getUniqueId: function(bar) {
if(!bar.id) {
bar.id = 'FindToolbar-'+gBrowser.getNotificationBox(bar.browser).id;
}
return bar.id;
},

newBar: function(bar) {
for(let [ name, routine ] of this.routines) {
this.initRoutine(bar, name, routine.init);
Expand Down
22 changes: 9 additions & 13 deletions resource/modules/moveToTop.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 3.1.4
// VERSION 3.1.5

this.__defineGetter__('DevEdition', function() { return window.DevEdition; });
this.__defineGetter__('SidebarUI', function() { return window.SidebarUI; });
Expand Down Expand Up @@ -41,7 +41,8 @@ this.moveToTop = {

case 'TabClose':
if(gBrowser.isFindBarInitialized(e.target)) {
let sheetId = this.kSheetId+'-'+gBrowser.getFindBar(e.target).id;
let id = findbar.getUniqueId(gBrowser.getFindBar(e.target));
let sheetId = this.kSheetId+'-'+id;
if(this.onTopSheets.has(sheetId)) {
Styles.unload(sheetId);
this.onTopSheets.delete(sheetId);
Expand Down Expand Up @@ -121,7 +122,9 @@ this.moveToTop = {
Watchers.removeAttributeWatcher(SidebarUI._box, 'hidden', this);

Listeners.remove(gBrowser.tabContainer, 'TabSelect', this);
Listeners.remove(gBrowser.tabContainer, 'TabClose', this);
if(window.tileTabs) {
Listeners.remove(gBrowser.tabContainer, 'TabClose', this);
}
Observers.remove(this, "lightweight-theme-styling-update");

findbar.deinit('DevEdition');
Expand Down Expand Up @@ -290,8 +293,9 @@ this.moveToTop = {

// Tile Tabs requires maxWidths for individual findbars, as not all tabs will have the same width
if(window.tileTabs) {
selector += "#"+gFindBar.id;
sheetId += '-'+gFindBar.id;
let id = findbar.getUniqueId(gFindBar);
selector += "#"+id;
sheetId += '-'+id;
}

let sscode = '\
Expand Down Expand Up @@ -355,10 +359,6 @@ this.moveToTop = {

findbar.init('movetotop',
function(bar) {
// necessary for the Tile Tabs compatibility fix in .calc() above
if(window.tileTabs) {
bar.id = 'FindToolbar-'+gBrowser.getNotificationBox(bar.browser).id;
}
setAttribute(bar, 'movetotop', 'true');
bar.style.maxHeight = height+'px';
},
Expand All @@ -367,10 +367,6 @@ this.moveToTop = {

removeAttribute(bar, 'movetotop');
bar.style.maxHeight = '';

if(window.tileTabs) {
bar.id = '';
}
},
true
);
Expand Down

0 comments on commit 348fc71

Please sign in to comment.