relanding bug 400327 since it doesn't look to be the source of the regression
authorjonas@sicking.cc
Wed, 14 Nov 2007 19:38:16 -0800
changeset 8002 08159a575452c1a76f2f9748c1aa8bc00359e5d2
parent 8001 bf336560966b78af9c21ce9422fd7fb73ab3f835
child 8003 dcd4080065f92b5081bbb54b65dd23c7f15b29fb
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs400327
milestone1.9b2pre
relanding bug 400327 since it doesn't look to be the source of the regression
browser/base/content/browser.js
layout/xul/base/src/nsSplitterFrame.cpp
toolkit/content/customizeToolbar.js
toolkit/content/widgets/toolbar.xml
toolkit/locales/en-US/chrome/global/customizeToolbar.properties
toolkit/themes/gnomestripe/global/toolbar.css
toolkit/themes/pinstripe/global/toolbar.css
toolkit/themes/pmstripe/global/toolbar.css
toolkit/themes/winstripe/global/toolbar.css
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1067,16 +1067,18 @@ function delayedStartup()
   Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
 
   if (gMustLoadSidebar) {
     var sidebar = document.getElementById("sidebar");
     var sidebarBox = document.getElementById("sidebar-box");
     sidebar.setAttribute("src", sidebarBox.getAttribute("src"));
   }
 
+  UpdateUrlbarSearchSplitterState();
+
   initPlacesDefaultQueries();
   initBookmarksToolbar();
   PlacesUtils.bookmarks.addObserver(gBookmarksObserver, false);
   PlacesStarButton.init();
 
   // called when we go into full screen, even if it is
   // initiated by a web page script
   window.addEventListener("fullscreen", onFullScreen, true);
@@ -2156,16 +2158,42 @@ function canonizeUrl(aTriggeringEvent, a
   }
 
   gURLBar.value = getShortcutOrURI(url, aPostDataRef);
 
   // Also update this so the browser display keeps the new value (bug 310651)
   gBrowser.userTypedValue = gURLBar.value;
 }
 
+function UpdateUrlbarSearchSplitterState()
+{
+  var splitter = document.getElementById("urlbar-search-splitter");
+
+  var urlbar = document.getElementById("urlbar-container");
+  var searchbar = document.getElementById("search-container");
+  var ibefore = null;
+  if (urlbar.nextSibling == searchbar)
+    ibefore = searchbar;
+  else if (searchbar.nextSibling == urlbar)
+    ibefore = urlbar;
+  else if (splitter)
+    splitter.parentNode.removeChild(splitter);
+
+  if (ibefore) {
+    if (!splitter) {
+      splitter = document.createElement("splitter");
+      splitter.id = "urlbar-search-splitter";
+      splitter.setAttribute("resizebefore", "flex");
+      splitter.setAttribute("resizeafter", "flex");
+      splitter.className = "chromeclass-toolbar-additional";
+    }
+    urlbar.parentNode.insertBefore(splitter, ibefore);
+  }
+}
+
 function UpdatePageProxyState()
 {
   if (gURLBar && gURLBar.value != gLastValidURLStr)
     SetPageProxyState("invalid");
 }
 
 function SetPageProxyState(aState)
 {
@@ -3208,16 +3236,20 @@ function BrowserCustomizeToolbar()
   // Disable the toolbar context menu items
   var menubar = document.getElementById("main-menubar");
   for (var i = 0; i < menubar.childNodes.length; ++i)
     menubar.childNodes[i].setAttribute("disabled", true);
 
   var cmd = document.getElementById("cmd_CustomizeToolbars");
   cmd.setAttribute("disabled", "true");
 
+  var splitter = document.getElementById("urlbar-search-splitter");
+  if (splitter)
+    splitter.parentNode.removeChild(splitter);
+
 #ifdef TOOLBAR_CUSTOMIZATION_SHEET
   var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
   sheetFrame.hidden = false;
   // XXXmano: there's apparently no better way to get this when the iframe is
   // hidden
   var sheetWidth = sheetFrame.style.width.match(/([0-9]+)px/)[1];
   document.getElementById("customizeToolbarSheetPopup")
           .openPopup(getNavToolbox(), "after_start", (window.innerWidth - sheetWidth) / 2, 0);
@@ -3241,16 +3273,18 @@ function BrowserToolboxCustomizeDone(aTo
     gURLBar = document.getElementById("urlbar");
     gProxyButton = document.getElementById("page-proxy-button");
     gProxyFavIcon = document.getElementById("page-proxy-favicon");
     gProxyDeck = document.getElementById("page-proxy-deck");
     gHomeButton.updateTooltip();
     window.XULBrowserWindow.init();
   }
 
+  UpdateUrlbarSearchSplitterState();
+
   // Update the urlbar
   var url = getWebNavigation().currentURI.spec;
   if (gURLBar) {
     gURLBar.value = url == "about:blank" ? "" : url;
     SetPageProxyState("valid");
     XULBrowserWindow.asyncUpdateUI();
     PlacesStarButton.updateState();
   }
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -140,17 +140,17 @@ public:
                    PRInt32 aChildrenAfterCount, 
                    PRBool aBounded);
 
   void UpdateState();
 
   void AddListener(nsPresContext* aPresContext);
   void RemoveListener();
 
-  enum ResizeType { Closest, Farthest, Grow };
+  enum ResizeType { Closest, Farthest, Flex, Grow };
   enum State { Open, CollapsedBefore, CollapsedAfter, Dragging };
   enum CollapseDirection { Before, After };
 
   ResizeType GetResizeBefore();
   ResizeType GetResizeAfter();
   State GetState();
 
   //nsresult CaptureMouse(nsPresContext* aPresContext, PRBool aGrabMouseEvents);
@@ -180,39 +180,44 @@ public:
 };
 
 
 NS_IMPL_ISUPPORTS2(nsSplitterFrameInner, nsIDOMMouseListener, nsIDOMMouseMotionListener)
 
 nsSplitterFrameInner::ResizeType
 nsSplitterFrameInner::GetResizeBefore()
 {
-  if (mOuter->GetContent()->
-        AttrValueIs(kNameSpaceID_None, nsGkAtoms::resizebefore,
-                    NS_LITERAL_STRING("farthest"), eCaseMatters))
-    return Farthest;
+  static nsIContent::AttrValuesArray strings[] =
+    {&nsGkAtoms::farthest, &nsGkAtoms::flex, nsnull};
+  switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
+                                                nsGkAtoms::resizebefore,
+                                                strings, eCaseMatters)) {
+    case 0: return Farthest;
+    case 1: return Flex;
+  }
   return Closest;
 }
 
 nsSplitterFrameInner::~nsSplitterFrameInner() 
 {
   delete[] mChildInfosBefore;
   delete[] mChildInfosAfter;
 }
 
 nsSplitterFrameInner::ResizeType
 nsSplitterFrameInner::GetResizeAfter()
 {
   static nsIContent::AttrValuesArray strings[] =
-    {&nsGkAtoms::farthest, &nsGkAtoms::grow, nsnull};
+    {&nsGkAtoms::farthest, &nsGkAtoms::flex, &nsGkAtoms::grow, nsnull};
   switch (mOuter->GetContent()->FindAttrValueIn(kNameSpaceID_None,
                                                 nsGkAtoms::resizeafter,
                                                 strings, eCaseMatters)) {
     case 0: return Farthest;
-    case 1: return Grow;
+    case 1: return Flex;
+    case 2: return Grow;
   }
   return Closest;
 }
 
 nsSplitterFrameInner::State
 nsSplitterFrameInner::GetState()
 {
   static nsIContent::AttrValuesArray strings[] =
@@ -802,26 +807,26 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
         r.Inflate(margin);
 
         // We need to check for hidden attribute too, since treecols with
         // the hidden="true" attribute are not really hidden, just collapsed
         if (!content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::fixed,
                                   nsGkAtoms::_true, eCaseMatters) &&
             !content->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
                                   nsGkAtoms::_true, eCaseMatters)) {
-            if (count < childIndex) {
+            if (count < childIndex && (resizeBefore != Flex || flex > 0)) {
                 mChildInfosBefore[mChildInfosBeforeCount].childElem = content;
                 mChildInfosBefore[mChildInfosBeforeCount].min     = isHorizontal ? minSize.width : minSize.height;
                 mChildInfosBefore[mChildInfosBeforeCount].max     = isHorizontal ? maxSize.width : maxSize.height;
                 mChildInfosBefore[mChildInfosBeforeCount].current = isHorizontal ? r.width : r.height;
                 mChildInfosBefore[mChildInfosBeforeCount].flex    = flex;
                 mChildInfosBefore[mChildInfosBeforeCount].index   = count;
                 mChildInfosBefore[mChildInfosBeforeCount].changed = mChildInfosBefore[mChildInfosBeforeCount].current;
                 mChildInfosBeforeCount++;
-            } else if (count > childIndex) {
+            } else if (count > childIndex && (resizeAfter != Flex || flex > 0)) {
                 mChildInfosAfter[mChildInfosAfterCount].childElem = content;
                 mChildInfosAfter[mChildInfosAfterCount].min     = isHorizontal ? minSize.width : minSize.height;
                 mChildInfosAfter[mChildInfosAfterCount].max     = isHorizontal ? maxSize.width : maxSize.height;
                 mChildInfosAfter[mChildInfosAfterCount].current = isHorizontal ? r.width : r.height;
                 mChildInfosAfter[mChildInfosAfterCount].flex    = flex;
                 mChildInfosAfter[mChildInfosAfterCount].index   = count;
                 mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
                 mChildInfosAfterCount++;
@@ -843,19 +848,19 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
     nscoord newAfterCount = mChildInfosBeforeCount;
     mChildInfosBeforeCount = mChildInfosAfterCount;
     mChildInfosAfterCount = newAfterCount;
     nsSplitterInfo* temp = mChildInfosAfter;
     mChildInfosAfter = mChildInfosBefore;
     mChildInfosBefore = temp;
   }
 
-  // if the resizebefore is closest we must reverse the list because the first child in the list
-  // is the Farthest we want the first child to be the closest.
-  if (resizeBefore == Closest)
+  // if resizebefore is not Farthest, reverse the list because the first child
+  // in the list is the farthest, and we want the first child to be the closest.
+  if (resizeBefore != Farthest)
      Reverse(mChildInfosBefore, mChildInfosBeforeCount);
 
   // if the resizeafter is the Farthest we must reverse the list because the first child in the list
   // is the closest we want the first child to be the Farthest.
   if (resizeAfter == Farthest)
      Reverse(mChildInfosAfter, mChildInfosAfterCount);
 
   // grow only applys to the children after. If grow is set then no space should be taken out of any children after
--- a/toolkit/content/customizeToolbar.js
+++ b/toolkit/content/customizeToolbar.js
@@ -334,23 +334,16 @@ function buildPalette()
 
   // Add the toolbar spacer item.
   templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                               "toolbarspacer");
   templateNode.id = "spacer";
   templateNode.flex = 1;
   wrapPaletteItem(templateNode, currentRow, null);
 
-  // Add the splitter item.
-  templateNode = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                          "splitter");
-  templateNode.id = "splitter";
-  templateNode.className = "toolbar-splitter";
-  wrapPaletteItem(templateNode, currentRow, null);
-
   var rowSlot = 3;
 
   var currentItems = getCurrentItemIds();
   templateNode = gToolbox.palette.firstChild;
   while (templateNode) {
     // Check if the item is already in a toolbar before adding it to the palette.
     if (!(templateNode.id in currentItems)) {
       var paletteItem = templateNode.cloneNode(true);
@@ -482,18 +475,16 @@ function cleanupItemForToolbar(aItem, aW
 function setWrapperType(aItem, aWrapper)
 {
   if (aItem.localName == "toolbarseparator") {
     aWrapper.setAttribute("type", "separator");
   } else if (aItem.localName == "toolbarspring") {
     aWrapper.setAttribute("type", "spring");
   } else if (aItem.localName == "toolbarspacer") {
     aWrapper.setAttribute("type", "spacer");
-  } else if (aItem.localName == "splitter") {
-    aWrapper.setAttribute("type", "splitter");
   } else if (aItem.localName == "toolbaritem" && aItem.firstChild) {
     aWrapper.setAttribute("type", aItem.firstChild.localName);
   }
 }
 
 function setDragActive(aItem, aValue)
 {
   var node = aItem;
@@ -702,28 +693,26 @@ function isCustomizableToolbar(aElt)
   return aElt.localName == "toolbar" &&
          aElt.getAttribute("customizable") == "true";
 }
 
 function isSpecialItem(aElt)
 {
   return aElt.localName == "toolbarseparator" ||
          aElt.localName == "toolbarspring" ||
-         aElt.localName == "toolbarspacer" ||
-         aElt.localName == "splitter";
+         aElt.localName == "toolbarspacer";
 }
 
 function isToolbarItem(aElt)
 {
   return aElt.localName == "toolbarbutton" ||
          aElt.localName == "toolbaritem" ||
          aElt.localName == "toolbarseparator" ||
          aElt.localName == "toolbarspring" ||
-         aElt.localName == "toolbarspacer" ||
-         aElt.localName == "splitter";
+         aElt.localName == "toolbarspacer";
 }
 
 ///////////////////////////////////////////////////////////////////////////
 //// Drag and Drop observers
 
 function onToolbarDragGesture(aEvent)
 {
   nsDragAndDrop.startDrag(aEvent, dragStartObserver);
@@ -872,18 +861,17 @@ var toolbarDNDObserver =
       cleanupItemForToolbar(newItem, wrapper);
       wrapper.id = "wrapper-"+newItem.id;
       wrapper.flex = newItem.flex;
 
       // Remove the wrapper from the palette.
       var currentRow = draggedPaletteWrapper.parentNode;
       if (draggedItemId != "separator" &&
           draggedItemId != "spring" &&
-          draggedItemId != "spacer" &&
-          draggedItemId != "splitter")
+          draggedItemId != "spacer")
       {
         currentRow.removeChild(draggedPaletteWrapper);
 
         while (currentRow) {
           // Pull the first child of the next row up
           // into this row.
           var nextRow = currentRow.nextSibling;
           
@@ -957,18 +945,17 @@ var paletteDNDObserver =
         return;
 
       // The item was dragged out of the toolbar.
       wrapper.parentNode.removeChild(wrapper);
       
       var wrapperType = wrapper.getAttribute("type");
       if (wrapperType != "separator" &&
           wrapperType != "spacer" &&
-          wrapperType != "spring" &&
-          wrapperType != "splitter") {
+          wrapperType != "spring") {
         // Find the template node in the toolbox palette
         var templateNode = gToolbox.palette.firstChild;
         while (templateNode) {
           if (templateNode.id == itemId)
             break;
           templateNode = templateNode.nextSibling;
         }
         if (!templateNode)
--- a/toolkit/content/widgets/toolbar.xml
+++ b/toolkit/content/widgets/toolbar.xml
@@ -133,30 +133,27 @@
             var node = this.firstChild;
             var currentSet = "";
             while (node) {
               if (node.id &&
                   node.localName == "toolbaritem" || 
                   node.localName == "toolbarbutton" ||
                   node.localName == "toolbarseparator" ||
                   node.localName == "toolbarspring" ||
-                  node.localName == "toolbarspacer" ||
-                  node.localName == "splitter")
+                  node.localName == "toolbarspacer")
               {
                 if (currentSet)
                   currentSet += ",";
 
                 if (node.localName == "toolbarseparator")
                   currentSet += "separator";
                 else if (node.localName == "toolbarspring")
                   currentSet += "spring";
                 else if (node.localName == "toolbarspacer")
                   currentSet += "spacer";
-                else if (node.localName == "splitter")
-                  currentSet += "splitter";
                 else
                   currentSet += node.id;
               }
               node = node.nextSibling;
             }
             
             return currentSet ? currentSet : "__empty";
           ]]>
@@ -225,22 +222,16 @@
               newItem.id = "spring" + uniqueId;
               newItem.className = "chromeclass-toolbar-additional";
             } else if (aId == "spacer") {
               newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
                                                  "toolbarspacer");
               uniqueId = (new Date()).getTime()+this.childNodes.length;
               newItem.id = "spacer" + uniqueId;
               newItem.className = "chromeclass-toolbar-additional";
-            } else if (aId == "splitter") {
-              newItem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
-                                                 "splitter");
-              uniqueId = (new Date()).getTime()+this.childNodes.length;
-              newItem.id = "splitter" + uniqueId;
-              newItem.className = "toolbar-splitter chromeclass-toolbar-additional";
             } else if (this.parentNode.localName == "toolbox") {
               // Attempt to locate an item with a matching id within palette.
               var paletteItem = this.parentNode.palette.firstChild;
               while (paletteItem) {
                 var paletteId = paletteItem.id;
                 if (paletteId == aId) {
                   newItem = paletteItem.cloneNode(true);
                   break;
--- a/toolkit/locales/en-US/chrome/global/customizeToolbar.properties
+++ b/toolkit/locales/en-US/chrome/global/customizeToolbar.properties
@@ -1,8 +1,7 @@
 enterToolbarTitle=New Toolbar
 enterToolbarName=Enter a name for this toolbar:
 enterToolbarDup=There is already a toolbar with the name "%S". Please enter a different name.
 enterToolbarBlank=You must enter a name to create a new toolbar.
 separatorTitle=Separator
 springTitle=Flexible Space
 spacerTitle=Space
-splitterTitle=Resizer
\ No newline at end of file
--- a/toolkit/themes/gnomestripe/global/toolbar.css
+++ b/toolkit/themes/gnomestripe/global/toolbar.css
@@ -124,21 +124,16 @@ toolbarpaletteitem[place="toolbar"] > to
   -moz-margin-end: 2px;
 }
 
 .toolbarpaletteitem-box[type="separator"][place="palette"] {
   width: 2px;
   height: 50px;
 }
 
-.toolbarpaletteitem-box[type="splitter"][place="palette"] {
-  width: 8px;
-  height: 50px;
-}
-
 .toolbarpaletteitem-box[type="spacer"][place="palette"],
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
   margin-bottom: 2px;
   width: 50px;
   height: 50px;
 }
 
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
--- a/toolkit/themes/pinstripe/global/toolbar.css
+++ b/toolkit/themes/pinstripe/global/toolbar.css
@@ -137,21 +137,16 @@ toolbarpaletteitem[type="spacer"] {
   margin: 2px;
 }
 
 .toolbarpaletteitem-box[type="separator"][place="palette"] {
   width: 2px;
   height: 50px;
 }
 
-.toolbarpaletteitem-box[type="splitter"][place="palette"] {
-  width: 8px;
-  height: 50px;
-}
-
 .toolbarpaletteitem-box[type="spacer"][place="palette"],
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
   margin-bottom: 2px;
   width: 50px;
   height: 50px;
 }
 
 /* ..... drag and drop feedback ..... */
--- a/toolkit/themes/pmstripe/global/toolbar.css
+++ b/toolkit/themes/pmstripe/global/toolbar.css
@@ -135,21 +135,16 @@ toolbarpaletteitem[place="toolbar"] > to
   -moz-margin-end: 2px;
 }
 
 .toolbarpaletteitem-box[type="separator"][place="palette"] {
   width: 2px;
   height: 50px;
 }
 
-.toolbarpaletteitem-box[type="splitter"][place="palette"] {
-  width: 8px;
-  height: 50px;
-}
-
 .toolbarpaletteitem-box[type="spacer"][place="palette"],
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
   margin-bottom: 2px;
   width: 50px;
   height: 50px;
 }
 
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
--- a/toolkit/themes/winstripe/global/toolbar.css
+++ b/toolkit/themes/winstripe/global/toolbar.css
@@ -130,21 +130,16 @@ toolbarpaletteitem[place="toolbar"] > to
   -moz-margin-end: 2px;
 }
 
 .toolbarpaletteitem-box[type="separator"][place="palette"] {
   width: 2px;
   height: 50px;
 }
 
-.toolbarpaletteitem-box[type="splitter"][place="palette"] {
-  width: 8px;
-  height: 50px;
-}
-
 .toolbarpaletteitem-box[type="spacer"][place="palette"],
 .toolbarpaletteitem-box[type="spring"][place="palette"] {
   margin-bottom: 2px;
   width: 50px;
   height: 50px;
 }
 
 .toolbarpaletteitem-box[type="spring"][place="palette"] {