From fa893b980153dd6f187ba15bf665024c51bf8959 Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Fri, 30 Nov 2012 00:58:47 +0900 Subject: [PATCH] Change the algorythm to find tab from coordinate based on _animateTabMove --- modules/browser.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/browser.js b/modules/browser.js index 9e88fcbc..c1826cdd 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -376,8 +376,30 @@ TreeStyleTabBrowser.prototype = { return null; return this.getTabFromCoordinate(aEvent[this.screenPositionProp]); }, - getTabFromCoordinate : function TSTBrowser_getTabFromCoordinate(aCoordinate) + getTabFromCoordinate : function TSTBrowser_getTabFromCoordinate(aCoordinate, aTabs) { + var tabs = aTabs || this.getTabs(this.mTabBrowser); + if (this.getTabActualScreenPosition(tabs[0]) > aCoordinate || + this.getTabActualScreenPosition(tabs[tabs.length-1]) < aCoordinate) + return null; + + var low = 0; + var high = tabs.length - 1; + while (low <= high) { + let middle = Math.floor((low + high) / 2); + let position = this.getTabActualScreenPosition(tabs[middle]); + if (position > aCoordinate) { + high = middle - 1; + } + else if (position + tabs[middle].boxObject[this.sizeProp] < aCoordinate) { + low = middle + 1; + } + else { + return tabs[middle]; + } + } + return null; +/* var tab = null; this.getTabs(this.mTabBrowser).some(function(aTab) { var box = aTab.boxObject; @@ -389,6 +411,7 @@ TreeStyleTabBrowser.prototype = { return true; }, this); return tab; +*/ }, getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab)