merge the last green changeset on fx-team to m-c
authorTim Taubert <tim.taubert@gmx.de>
Wed, 10 Aug 2011 01:30:21 +0200
changeset 74105 2805d0fc9d91f4548e563bf78d1a1023a773c9a6
parent 74104 248aed2b337d2c9a0012f21c055fddc1cd0f851a (diff)
parent 74101 42992432ed560519f3d1d93c6788458200daf85f (current diff)
child 74106 04dfb49d3a3d3469be379c76405f18f3592ac48b
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone8.0a1
merge the last green changeset on fx-team to m-c
accessible/tests/mochitest/test_takeFocus.html
content/base/public/nsISelection2.idl
content/base/public/nsISelection3.idl
testing/tps/config.json
xpcom/glue/pldhash.c
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -481,36 +481,46 @@ GroupItem.prototype = Utils.extend(new I
       if (arrangeGroup)
         this.arrange();
     }
   },
 
   // ----------
   // Function: getContentBounds
   // Returns a <Rect> for the groupItem's content area (which doesn't include the title, etc).
-  getContentBounds: function GroupItem_getContentBounds() {
+  //
+  // Parameters:
+  //   options - an object with additional parameters, see below
+  //
+  // Possible options:
+  //   forceStacked - true to force content bounds for stacked mode
+  getContentBounds: function GroupItem_getContentBounds(options) {
     var box = this.getBounds();
     var titleHeight = this.$titlebar.height();
     box.top += titleHeight;
     box.height -= titleHeight;
 
     let appTabTrayContainer = iQ(this.$appTabTray[0].parentNode);
     var appTabTrayWidth = appTabTrayContainer.width();
     if (appTabTrayWidth)
       appTabTrayWidth += parseInt(appTabTrayContainer.css(UI.rtl ? "left" : "right"));
 
     box.width -= appTabTrayWidth;
     if (UI.rtl) {
       box.left += appTabTrayWidth;
     }
 
-    // Make the computed bounds' "padding" and new tab button margin actually be
+    // Make the computed bounds' "padding" and expand button margin actually be
     // themeable --OR-- compute this from actual bounds. Bug 586546
     box.inset(6, 6);
-    box.height -= 33; // For new tab button
+
+    // make some room for the expand button if we're stacked
+    let isStacked = (options && options.forceStacked) || this.isStacked();
+    if (isStacked)
+      box.height -= 33; // 33px room for the expand button
 
     return box;
   },
 
   // ----------
   // Function: setBounds
   // Sets the bounds with the given <Rect>, animating unless "immediately" is false.
   //
@@ -1350,20 +1360,21 @@ GroupItem.prototype = Utils.extend(new I
     });
 
     if (GroupItems._arrangePaused) {
       GroupItems.pushArrange(this, options);
       return false;
     }
     
     let shouldStack = this.shouldStack(childrenToArrange.length + (options.addTab ? 1 : 0));
-    let box = this.getContentBounds();
+    let shouldStackArrange = (shouldStack && !this.expanded);
+    let box = this.getContentBounds({forceStacked: shouldStackArrange});
     
     // if we should stack and we're not expanded
-    if (shouldStack && !this.expanded) {
+    if (shouldStackArrange) {
       this.showExpandControl();
       this._stackArrange(childrenToArrange, box, options);
       return false;
     } else {
       this.hideExpandControl();
       // a dropIndex is returned
       return this._gridArrange(childrenToArrange, box, options);
     }
--- a/browser/base/content/test/tabview/browser_tabview_bug588265.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug588265.js
@@ -5,27 +5,27 @@ let contentWindow;
 let groupItemTwoId;
 
 function test() {
   waitForExplicitFinish();
   
   registerCleanupFunction(function() {
     while (gBrowser.tabs[1])
       gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView(function() {});
+    hideTabView();
   });
   gBrowser.loadOneTab("about:blank", { inBackground: true });
   showTabView(setup);
 }
 
 function setup() {
   registerCleanupFunction(function() {
     let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
     if (groupItem)
-      closeGroupItem(groupItem, function() {}); 
+      closeGroupItem(groupItem);
   });
 
   let contentWindow = TabView.getContentWindow();
   is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
 
   let groupItemOne = contentWindow.GroupItems.groupItems[0];
   is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
 
--- a/browser/base/content/test/tabview/browser_tabview_bug590606.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug590606.js
@@ -10,26 +10,26 @@ function test() {
 
   originalTab = gBrowser.visibleTabs[0];
   // add a tab to the existing group.
   newTabOne = gBrowser.addTab();
 
   registerCleanupFunction(function() {
     while (gBrowser.tabs[1])
       gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView(function() {});
+    hideTabView();
   });
 
   showTabView(function() {
     let contentWindow = TabView.getContentWindow();
 
     registerCleanupFunction(function() {
       let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
       if (groupItem)
-        closeGroupItem(groupItem, function() {});
+        closeGroupItem(groupItem);
     });
 
     is(contentWindow.GroupItems.groupItems.length, 1, 
        "There is one group item on startup");
     let groupItemOne = contentWindow.GroupItems.groupItems[0];
     is(groupItemOne.getChildren().length, 2, 
        "There should be two tab items in that group.");
     is(gBrowser.selectedTab, groupItemOne.getChild(0).tab,
--- a/browser/base/content/test/tabview/browser_tabview_bug604098.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug604098.js
@@ -5,17 +5,17 @@ let contentWindow;
 let contentElement;
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function() {
     if (gBrowser.tabs.length > 1)
       gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView(function() {});
+    hideTabView();
   });
 
   showTabView(function() {
     contentWindow = TabView.getContentWindow();
     contentElement = contentWindow.document.getElementById("content");
     test1();
   });
 }
--- a/browser/base/content/test/tabview/browser_tabview_bug610208.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug610208.js
@@ -123,25 +123,29 @@ function test() {
   }
 
   // make sure we don't freeze item size when removing an item from a stack
   let testRemoveWhileStacked = function () {
     let oldBounds = groupItem.getBounds();
     groupItem.setSize(250, 250, true);
     groupItem.setUserSize();
 
-    let originalBounds = groupItem.getChild(0).getBounds();
     ok(!groupItem.isStacked(), 'testRemoveWhileStacked: group is not stacked');
 
+    let originalBounds;
+    let tabItem = groupItem.getChild(0);
+
     // add new tabs to let the group stack
-    while (!groupItem.isStacked())
-      win.gBrowser.loadOneTab('about:blank', {inBackground: true});
+    while (!groupItem.isStacked()) {
+      originalBounds = tabItem.getBounds();
+      win.gBrowser.addTab();
+    }
 
     afterAllTabsLoaded(function () {
-      groupItem.getChild(0).close();
+      tabItem.close();
       ok(!groupItem.isStacked(), 'testRemoveWhileStacked: group is not stacked');
 
       let bounds = groupItem.getChild(0).getBounds();
       ok(originalBounds.equals(bounds), 'testRemoveWhileStacked: tabs did not change their size');
 
       // reset group size
       groupItem.setBounds(oldBounds);
       groupItem.setUserSize();
--- a/browser/base/content/test/tabview/browser_tabview_bug624265.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug624265.js
@@ -148,24 +148,8 @@ function loadTabView(callback) {
 }
 
 // ----------
 function enterAndLeavePrivateBrowsing(callback) {
   togglePrivateBrowsing(function () {
     togglePrivateBrowsing(callback);
   });
 }
-
-// ----------
-function togglePrivateBrowsing(callback) {
-  let topic = "private-browsing-transition-complete";
-
-  function pbObserver(aSubject, aTopic, aData) {
-    if (aTopic != topic)
-      return;
-
-    Services.obs.removeObserver(pbObserver, topic, false);
-    afterAllTabsLoaded(callback);
-  }
-
-  Services.obs.addObserver(pbObserver, topic, false);
-  pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
-}
--- a/browser/base/content/test/tabview/browser_tabview_bug624727.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug624727.js
@@ -58,18 +58,17 @@ function test() {
     assertOneTabInGroup(prefix, group1);
     assertOneTabInGroup(prefix, group2);
   }
 
   let testStateAfterEnteringPB = function () {
     let prefix = 'enter';
     ok(!pb.privateBrowsingEnabled, prefix + ': private browsing is disabled');
     registerCleanupFunction(function () {
-      if (pb.privateBrowsingEnabled)
-        pb.privateBrowsingEnabled = false
+      pb.privateBrowsingEnabled = false;
     });
 
     togglePrivateBrowsing(function () {
       assertTabViewIsHidden(prefix);
 
       showTabView(function () {
         assertNumberOfGroups(prefix, 1);
         assertNumberOfTabs(prefix, 1);
@@ -124,24 +123,8 @@ function test() {
       gBrowser.pinTab(tabItem1.tab);
       gBrowser.pinTab(tabItem2.tab);
 
       assertValidSetup('setup');
       hideTabView(testStateAfterEnteringPB);
     });
   });
 }
-
-// ----------
-function togglePrivateBrowsing(callback) {
-  let topic = 'private-browsing-transition-complete';
-
-  function pbObserver(aSubject, aTopic, aData) {
-    if (aTopic != topic)
-      return;
-
-    Services.obs.removeObserver(pbObserver, topic);
-    afterAllTabsLoaded(callback);
-  }
-
-  Services.obs.addObserver(pbObserver, topic, false);
-  pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
-}
--- a/browser/base/content/test/tabview/browser_tabview_bug627239.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug627239.js
@@ -10,17 +10,17 @@ function test() {
   newTab = gBrowser.addTab();
 
   HttpRequestObserver.register();
 
   registerCleanupFunction(function () {
     HttpRequestObserver.unregister();
     if (gBrowser.tabs[1])
       gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView(function () {});
+    hideTabView();
 
     contentWindow.ThumbnailStorage.enablePersistentHttpsCaching =
         enablePersistentHttpsCaching;
   });
 
   showTabView(function() {
     contentWindow = TabView.getContentWindow();
     test1();
--- a/browser/base/content/test/tabview/browser_tabview_bug641802.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug641802.js
@@ -24,21 +24,21 @@ function test() {
   let tvMenu = document.getElementById("context_tabViewMenu");
   let contextMenu = document.getElementById("tabContextMenu");
   let tvMenuPopup = document.getElementById("context_tabViewMenuPopup");
 
   waitForExplicitFinish();
 
   registerCleanupFunction(function () {
     hideMoveToGroupPopup();
-    hideTabView(function () {});
+    hideTabView();
 
     let groupItems = TabView.getContentWindow().GroupItems.groupItems;
     if (groupItems.length > 1)
-      closeGroupItem(groupItems[0], function () {});
+      closeGroupItem(groupItems[0]);
   });
 
   showTabView(function () {
     assertValidPrerequisites(true);
 
     hideTabView(function () {
       let groupItem = createGroupItemWithBlankTabs(window, 200, 200, 10, 1);
       groupItem.setTitle("group2");
--- a/browser/base/content/test/tabview/browser_tabview_bug649006.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug649006.js
@@ -3,17 +3,17 @@
 let contentWindow;
 let contentElement;
 let groupItem;
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function () {
-    hideTabView(function () {});
+    hideTabView();
   });
 
   showTabView(function() {
     contentWindow = TabView.getContentWindow();
     contentElement = contentWindow.document.getElementById("content");
     test1();
   });
 }
--- a/browser/base/content/test/tabview/browser_tabview_click_group.js
+++ b/browser/base/content/test/tabview/browser_tabview_click_group.js
@@ -7,18 +7,18 @@ let groupItemId;
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function() {
     contentWindow.gPrefBranch.clearUserPref("animate_zoom");
     let createdGroupItem = contentWindow.GroupItems.groupItem(groupItemId)
     if (createdGroupItem)
-      closeGroupItem(createdGroupItem, function() {});
-    hideTabView(function() {});
+      closeGroupItem(createdGroupItem);
+    hideTabView();
   });
 
   showTabView(function() {
     contentWindow = TabView.getContentWindow();
     groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
     groupItemId = groupItem.id;
     testMouseClickOnEmptyGroupItem();
   });
--- a/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js
+++ b/browser/base/content/test/tabview/browser_tabview_privatebrowsing.js
@@ -60,23 +60,23 @@ function onTabViewLoadedAndShown() {
     // Get normal tab urls
     for (let a = 0; a < gBrowser.tabs.length; a++)
       normalURLs.push(gBrowser.tabs[a].linkedBrowser.currentURI.spec);
 
     // verify that we're all set up for our test
     verifyNormal();
 
     // go into private browsing and make sure Tab View becomes hidden
-    togglePBAndThen(function() {
+    togglePrivateBrowsing(function() {
       whenTabViewIsHidden(function() {
         ok(!TabView.isVisible(), "Tab View is no longer visible");
         verifyPB();
 
         // exit private browsing and make sure Tab View is shown again
-        togglePBAndThen(function() {
+        togglePrivateBrowsing(function() {
           whenTabViewIsShown(function() {
             ok(TabView.isVisible(), "Tab View is visible again");
             verifyNormal();
 
             hideTabView(onTabViewHidden);
           });
         });
       });
@@ -84,22 +84,22 @@ function onTabViewLoadedAndShown() {
   });
 }
 
 // -----------
 function onTabViewHidden() {
   ok(!TabView.isVisible(), "Tab View is not visible");
   
   // go into private browsing and make sure Tab View remains hidden
-  togglePBAndThen(function() {
+  togglePrivateBrowsing(function() {
     ok(!TabView.isVisible(), "Tab View is still not visible");
     verifyPB();
     
     // turn private browsing back off
-    togglePBAndThen(function() {
+    togglePrivateBrowsing(function() {
       verifyNormal();
       
       // end game
       ok(!TabView.isVisible(), "we finish with Tab View not visible");
       registerCleanupFunction(verifyCleanState); // verify after all cleanups
 
       gBrowser.selectedTab = gBrowser.tabs[0];
       finish();
@@ -148,22 +148,8 @@ function verifyNormal() {
 
     let groupItem = contentWindow.GroupItems.groupItems[a];
     is(groupItem.getTitle(), groupTitles[a], prefix + "correct group title");
     
     ok(tab._tabViewTabItem.parent == groupItem,
         prefix + "tab " + a + " is in group " + a);
   }
 }
-
-// ----------
-function togglePBAndThen(callback) {
-  function pbObserver(aSubject, aTopic, aData) {
-    if (aTopic != "private-browsing-transition-complete")
-      return;
-
-    Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete");
-    afterAllTabsLoaded(callback);
-  }
-
-  Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false);
-  pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
-}
--- a/browser/base/content/test/tabview/browser_tabview_undo_group.js
+++ b/browser/base/content/test/tabview/browser_tabview_undo_group.js
@@ -2,30 +2,30 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
   waitForExplicitFinish();
 
   registerCleanupFunction(function() {
     while (gBrowser.tabs[1])
       gBrowser.removeTab(gBrowser.tabs[1]);
-    hideTabView(function() {});
+    hideTabView();
   });
   showTabView(onTabViewWindowLoaded);
 }
 
 function onTabViewWindowLoaded() {
   ok(TabView.isVisible(), "Tab View is visible");
 
   let contentWindow = TabView.getContentWindow();
 
   registerCleanupFunction(function() {
     let groupItem = contentWindow.GroupItems.groupItem(groupItemId);
     if (groupItem)
-      closeGroupItem(groupItem, function() {});
+      closeGroupItem(groupItem);
   });
 
   // create a group item
   let groupItem = createGroupItemWithBlankTabs(window, 300, 300, 400, 1);
   let groupItemId = groupItem.id;
   is(groupItem.getChildren().length, 1, "The new group has a tab item");
   // start the tests
   waitForFocus(function() {
--- a/browser/base/content/test/tabview/head.js
+++ b/browser/base/content/test/tabview/head.js
@@ -43,21 +43,22 @@ function createGroupItemWithBlankTabs(wi
   let urls = [];
   while(numNewTabs--)
     urls.push("about:blank");
   return createGroupItemWithTabs(win, width, height, padding, urls, animate);
 }
 
 // ----------
 function closeGroupItem(groupItem, callback) {
-  groupItem.addSubscriber("close", function onClose() {
-    groupItem.removeSubscriber("close", onClose);
-    if ("function" == typeof callback)
+  if (callback) {
+    groupItem.addSubscriber("close", function onClose() {
+      groupItem.removeSubscriber("close", onClose);
       executeSoon(callback);
-  });
+    });
+  }
 
   if (groupItem.getChildren().length) {
     groupItem.addSubscriber("groupHidden", function onHide() {
       groupItem.removeSubscriber("groupHidden", onHide);
       groupItem.closeHidden();
     });
   }
 
@@ -135,32 +136,36 @@ function afterAllTabsLoaded(callback, wi
 function showTabView(callback, win) {
   win = win || window;
 
   if (win.TabView.isVisible()) {
     waitForFocus(callback, win);
     return;
   }
 
-  whenTabViewIsShown(function() {
+  whenTabViewIsShown(function () {
     waitForFocus(callback, win);
   }, win);
+
   win.TabView.show();
 }
 
 // ----------
 function hideTabView(callback, win) {
   win = win || window;
 
   if (!win.TabView.isVisible()) {
-    callback();
+    if (callback)
+      callback();
     return;
   }
 
-  whenTabViewIsHidden(callback, win);
+  if (callback)
+    whenTabViewIsHidden(callback, win);
+
   win.TabView.hide();
 }
 
 // ----------
 function whenTabViewIsHidden(callback, win) {
   win = win || window;
 
   if (!win.TabView.isVisible()) {
@@ -185,40 +190,29 @@ function whenTabViewIsShown(callback, wi
 
   win.addEventListener('tabviewshown', function onShown() {
     win.removeEventListener('tabviewshown', onShown, false);
     callback();
   }, false);
 }
 
 // ----------
-function showSearch(callback, win) {
-  win = win || window;
-
-  let contentWindow = win.TabView.getContentWindow();
-  if (contentWindow.isSearchEnabled()) {
-    callback();
-    return;
-  }
-
-  whenSearchIsEnabled(callback, win);
-  contentWindow.performSearch();
-}
-
-// ----------
 function hideSearch(callback, win) {
   win = win || window;
 
   let contentWindow = win.TabView.getContentWindow();
   if (!contentWindow.isSearchEnabled()) {
-    callback();
+    if (callback)
+      callback();
     return;
   }
 
-  whenSearchIsDisabled(callback, win);
+  if (callback)
+    whenSearchIsDisabled(callback, win);
+
   contentWindow.hideSearch();
 }
 
 // ----------
 function whenSearchIsEnabled(callback, win) {
   win = win || window;
 
   let contentWindow = win.TabView.getContentWindow();
@@ -248,38 +242,46 @@ function whenSearchIsDisabled(callback, 
     callback();
   }, false);
 }
 
 
 // ----------
 function hideGroupItem(groupItem, callback) {
   if (groupItem.hidden) {
-    callback();
+    if (callback)
+      callback();
     return;
   }
 
-  groupItem.addSubscriber("groupHidden", function onHide() {
-    groupItem.removeSubscriber("groupHidden", onHide);
-    callback();
-  });
+  if (callback) {
+    groupItem.addSubscriber("groupHidden", function onHide() {
+      groupItem.removeSubscriber("groupHidden", onHide);
+      callback();
+    });
+  }
+
   groupItem.closeAll();
 }
 
 // ----------
 function unhideGroupItem(groupItem, callback) {
   if (!groupItem.hidden) {
-    callback();
+    if (callback)
+      callback();
     return;
   }
 
-  groupItem.addSubscriber("groupShown", function onShown() {
-    groupItem.removeSubscriber("groupShown", onShown);
-    callback();
-  });
+  if (callback) {
+    groupItem.addSubscriber("groupShown", function onShown() {
+      groupItem.removeSubscriber("groupShown", onShown);
+      callback();
+    });
+  }
+
   groupItem._unhide();
 }
 
 // ----------
 function whenWindowLoaded(win, callback) {
   win.addEventListener("load", function onLoad() {
     win.removeEventListener("load", onLoad, false);
     executeSoon(callback);
@@ -347,8 +349,23 @@ function restoreTab(callback, index, win
     return;
   }
 
   tab._tabViewTabItem.addSubscriber("reconnected", function onReconnected() {
     tab._tabViewTabItem.removeSubscriber("reconnected", onReconnected);
     finalize();
   });
 }
+
+// ----------
+function togglePrivateBrowsing(callback) {
+  let topic = "private-browsing-transition-complete";
+
+  Services.obs.addObserver(function observe() {
+    Services.obs.removeObserver(observe, topic);
+    afterAllTabsLoaded(callback);
+  }, topic, false);
+
+  let pb = Cc["@mozilla.org/privatebrowsing;1"].
+           getService(Ci.nsIPrivateBrowsingService);
+
+  pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
+}