From fb7140e519ca7b7d2283e74129985b378ae3ca83 Mon Sep 17 00:00:00 2001 From: Raymond Lee Date: Sat, 3 Dec 2011 00:31:12 +0800 Subject: [PATCH] Bug 696602 - Active tab not shown in tab strip on return from Panorama r=tim --- browser/base/content/tabbrowser.xml | 2 + browser/components/tabview/test/Makefile.in | 1 + .../tabview/test/browser_tabview_bug696602.js | 51 +++++++++++++++++++ browser/components/tabview/ui.js | 10 ++++ 4 files changed, 64 insertions(+) create mode 100644 browser/components/tabview/test/browser_tabview_bug696602.js diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index d4df769127c..781e2626e02 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1963,6 +1963,8 @@ else this.showTab(tab); }, this); + + this.tabContainer.mTabstrip.ensureElementIsVisible(this.selectedTab, false); ]]> diff --git a/browser/components/tabview/test/Makefile.in b/browser/components/tabview/test/Makefile.in index 10efe121914..03411c594ab 100644 --- a/browser/components/tabview/test/Makefile.in +++ b/browser/components/tabview/test/Makefile.in @@ -164,6 +164,7 @@ _BROWSER_FILES = \ browser_tabview_bug685476.js \ browser_tabview_bug685692.js \ browser_tabview_bug686654.js \ + browser_tabview_bug696602.js \ browser_tabview_bug697390.js \ browser_tabview_bug705621.js \ browser_tabview_bug706430.js \ diff --git a/browser/components/tabview/test/browser_tabview_bug696602.js b/browser/components/tabview/test/browser_tabview_bug696602.js new file mode 100644 index 00000000000..db51f344d73 --- /dev/null +++ b/browser/components/tabview/test/browser_tabview_bug696602.js @@ -0,0 +1,51 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +let win; + +function test() { + waitForExplicitFinish(); + + newWindowWithTabView(function(newWin) { + win = newWin; + + registerCleanupFunction(function() { + win.close(); + }); + + let cw = win.TabView.getContentWindow(); + let groupItemOne = cw.GroupItems.groupItems[0]; + let groupItemTwo = createGroupItemWithBlankTabs(win, 300, 300, 20, 10); + + is(win.gBrowser.tabContainer.getAttribute("overflow"), "true", + "The tabstrip is overflow"); + + is(groupItemOne.getChildren().length, 10, "Group one has 10 tabs"); + is(groupItemTwo.getChildren().length, 10, "Group two has 10 tabs"); + + checkSelectedTabVisible("two", function() { + showTabView(function() { + checkSelectedTabVisible("one", finish); + groupItemOne.getChild(9).zoomIn(); + }, win); + }); + groupItemTwo.getChild(9).zoomIn(); + }, function(newWin) { + for (let i = 0; i < 9; i++) + newWin.gBrowser.addTab(); + }); +} + +function isSelectedTabVisible() { + let tabstrip = win.gBrowser.tabContainer.mTabstrip; + let scrollRect = tabstrip.scrollClientRect; + let tab = win.gBrowser.selectedTab.getBoundingClientRect(); + + return (scrollRect.left <= tab.left && tab.right <= scrollRect.right); +} + +function checkSelectedTabVisible(groupName, callback) { + whenTabViewIsHidden(function() { + ok(isSelectedTabVisible(), "Group " + groupName + " selected tab is visible"); + callback(); + }, win); +} diff --git a/browser/components/tabview/ui.js b/browser/components/tabview/ui.js index f7f662c2a78..9306f6488c7 100644 --- a/browser/components/tabview/ui.js +++ b/browser/components/tabview/ui.js @@ -152,6 +152,10 @@ let UI = { // Used to keep track of the last opened tab. _lastOpenedTab: null, + // Variable: _originalSmoothScroll + // Used to keep track of the tab strip smooth scroll value. + _originalSmoothScroll: null, + // ---------- // Function: toString // Prints [UI] for debug use @@ -514,6 +518,11 @@ let UI = { this._isChangingVisibility = true; + // store tab strip smooth scroll value and disable it. + let tabStrip = gBrowser.tabContainer.mTabstrip; + this._originalSmoothScroll = tabStrip.smoothScroll; + tabStrip.smoothScroll = false; + // initialize the direction of the page this._initPageDirection(); @@ -609,6 +618,7 @@ let UI = { gBrowser.selectedBrowser.focus(); gBrowser.updateTitlebar(); + gBrowser.tabContainer.mTabstrip.smoothScroll = this._originalSmoothScroll; #ifdef XP_MACOSX this.setTitlebarColors(false); #endif