From 2cc45c59f55b1820ea74de4b1d34afd2a0855c82 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Thu, 17 Feb 2011 21:37:32 +0100 Subject: [PATCH] Bug 634085 - Stacks do not show last-visited tab in the front for children after number 6 [r=ian, a=beltzner] --- browser/base/content/tabview/groupitems.js | 14 ++++-- browser/base/content/test/tabview/Makefile.in | 1 + .../test/tabview/browser_tabview_bug588265.js | 2 +- .../test/tabview/browser_tabview_bug634085.js | 49 +++++++++++++++++++ .../test/tabview/browser_tabview_group.js | 4 +- .../test/tabview/browser_tabview_layout.js | 2 +- browser/base/content/test/tabview/head.js | 7 ++- 7 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 browser/base/content/test/tabview/browser_tabview_bug634085.js diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 0196fa66c5db..e2e0b0e98347 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -1316,7 +1316,6 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { {hideTitle:true}); } - // x is the left margin that the stack will have, within the content area (bb) // y is the vertical margin var x = (bb.width - size.x) / 2; @@ -1325,15 +1324,20 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { var self = this; var children = []; + + // ensure this.topChild is the first item in childrenToArrange + let topChildPos = childrenToArrange.indexOf(this.topChild); + if (topChildPos > 0) { + childrenToArrange.splice(topChildPos, 1); + childrenToArrange.unshift(this.topChild); + } + childrenToArrange.forEach(function GroupItem__stackArrange_order(child) { // Children are still considered stacked even if they're hidden later. child.addClass("stacked"); child.isStacked = true; if (numInPile-- > 0) { - if (child == self.topChild) - children.unshift(child); - else - children.push(child); + children.push(child); } else { child.setHidden(true); } diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index e43f9f342680..4f9647099b36 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -114,6 +114,7 @@ _BROWSER_FILES = \ browser_tabview_bug630157.js \ browser_tabview_bug631662.js \ browser_tabview_bug634077.js \ + browser_tabview_bug634085.js \ browser_tabview_bug634158.js \ browser_tabview_dragdrop.js \ browser_tabview_exit_button.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug588265.js b/browser/base/content/test/tabview/browser_tabview_bug588265.js index f509135bf58f..b3c2c47600f3 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug588265.js +++ b/browser/base/content/test/tabview/browser_tabview_bug588265.js @@ -54,7 +54,7 @@ function setup() { is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items"); // create group two with a blank tab. - let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40, true); + let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40); createNewTabItemInGroupItem(groupItemTwo, contentWindow, function() { // start the first test. testGroups(groupItemOne, groupItemTwo, contentWindow); diff --git a/browser/base/content/test/tabview/browser_tabview_bug634085.js b/browser/base/content/test/tabview/browser_tabview_bug634085.js new file mode 100644 index 000000000000..0e53b4650dca --- /dev/null +++ b/browser/base/content/test/tabview/browser_tabview_bug634085.js @@ -0,0 +1,49 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + let numChildren = 7; + + let assertTopOfStack = function (tabItem) { + ok(!tabItem.getHidden(), "tabItem is visible"); + is(tabItem.zIndex, tabItem.parent.getZ() + numChildren + 1, "zIndex"); + } + + let testTopOfStack = function (tabItem, callback) { + hideTabView(function () { + gBrowser.selectedTab = tabItem.tab; + + showTabView(function () { + assertTopOfStack(tabItem); + callback(); + }); + }); + } + + let finishTest = function () { + registerCleanupFunction(function () { + is(1, gBrowser.tabs.length, "there is one tab, only"); + ok(!TabView.isVisible(), "tabview is not visible"); + }); + + finish(); + } + + waitForExplicitFinish(); + + showTabView(function () { + let groupItem = createGroupItemWithBlankTabs(window, 150, 150, 10, numChildren); + + registerCleanupFunction(function () { + closeGroupItem(groupItem, function () TabView.hide()); + }); + + testTopOfStack(groupItem.getChild(1), function () { + testTopOfStack(groupItem.getChild(6), function () { + closeGroupItem(groupItem, function () { + hideTabView(finishTest); + }); + }); + }); + }); +} diff --git a/browser/base/content/test/tabview/browser_tabview_group.js b/browser/base/content/test/tabview/browser_tabview_group.js index e90ef89e615b..422867a7c844 100644 --- a/browser/base/content/test/tabview/browser_tabview_group.js +++ b/browser/base/content/test/tabview/browser_tabview_group.js @@ -65,7 +65,7 @@ function testEmptyGroupItem(contentWindow) { let groupItemCount = contentWindow.GroupItems.groupItems.length; // create empty group item - let emptyGroupItem = createEmptyGroupItem(contentWindow, 300, 300, 100, true); + let emptyGroupItem = createEmptyGroupItem(contentWindow, 300, 300, 100); ok(emptyGroupItem.isEmpty(), "This group is empty"); is(contentWindow.GroupItems.groupItems.length, ++groupItemCount, @@ -89,7 +89,7 @@ function testEmptyGroupItem(contentWindow) { } function testGroupItemWithTabItem(contentWindow) { - let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200, true); + let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200); let tabItemCount = 0; let onTabViewHidden = function() { diff --git a/browser/base/content/test/tabview/browser_tabview_layout.js b/browser/base/content/test/tabview/browser_tabview_layout.js index 285e86c8f900..8614e1344fff 100644 --- a/browser/base/content/test/tabview/browser_tabview_layout.js +++ b/browser/base/content/test/tabview/browser_tabview_layout.js @@ -73,7 +73,7 @@ function testEmptyGroupItem(contentWindow) { // // create empty group item - let emptyGroupItem = createEmptyGroupItem(contentWindow, 253, 335, 100, true); + let emptyGroupItem = createEmptyGroupItem(contentWindow, 253, 335, 100); ok(emptyGroupItem.isEmpty(), "This group is empty"); is(contentWindow.GroupItems.groupItems.length, ++groupItemCount, diff --git a/browser/base/content/test/tabview/head.js b/browser/base/content/test/tabview/head.js index f2f5f58c2f9a..6766edd1ff1d 100644 --- a/browser/base/content/test/tabview/head.js +++ b/browser/base/content/test/tabview/head.js @@ -37,17 +37,16 @@ * * ***** END LICENSE BLOCK ***** */ -function createEmptyGroupItem(contentWindow, width, height, padding, noAnimation) { +function createEmptyGroupItem(contentWindow, width, height, padding, animate) { let pageBounds = contentWindow.Items.getPageBounds(); pageBounds.inset(padding, padding); let box = new contentWindow.Rect(pageBounds); box.width = width; box.height = height; - - let immediately = noAnimation ? true: false; + let emptyGroupItem = - new contentWindow.GroupItem([], { bounds: box, immediately: immediately }); + new contentWindow.GroupItem([], { bounds: box, immediately: !animate }); return emptyGroupItem; }