Bug 489545 - Switch to using the toolkit support for toolbar customization sheets, r=mano
authorPhil Ringnalda <philringnalda@gmail.com>
Mon, 18 May 2009 18:12:59 -0700
changeset 28524 2103cf22598cfecfb12ffe44659322573c5e040a
parent 28523 4a32b3101121f0bf8bc34d0b183b23439f674894
child 28525 8ae3e659599bb803131169a8d57d57d484cb23f4
push id7107
push userphilringnalda@gmail.com
push dateTue, 19 May 2009 01:13:30 +0000
treeherdermozilla-central@2103cf22598c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmano
bugs489545
milestone1.9.2a1pre
Bug 489545 - Switch to using the toolkit support for toolbar customization sheets, r=mano
browser/app/profile/firefox.js
browser/base/Makefile.in
browser/base/content/browser-doctype.inc
browser/base/content/browser.js
browser/base/content/browser.xul
browser/base/content/customizeToolbarSheet.js
browser/base/content/customizeToolbarSheet.xul
browser/base/jar.mn
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -817,8 +817,15 @@ pref("browser.privatebrowsing.autostart"
 pref("browser.privatebrowsing.dont_prompt_on_enter", false);
 
 // Don't try to alter this pref, it'll be reset the next time you use the
 // bookmarking dialog
 pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
 
 // base url for the wifi geolocation network provider
 pref("geo.wifi.uri", "https://www.google.com/loc/json");
+
+// Whether to use a panel that looks like an OS X sheet for customization
+#ifdef XP_MACOSX
+pref("toolbar.customization.usesheet", true);
+#else
+pref("toolbar.customization.usesheet", false);
+#endif
--- a/browser/base/Makefile.in
+++ b/browser/base/Makefile.in
@@ -71,20 +71,16 @@ endif
 ifneq (,$(filter windows gtk2 mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
 DEFINES += -DHAVE_SHELL_SERVICE=1
 endif
 
 ifdef MOZ_UPDATER
 DEFINES += -DMOZ_UPDATER=1
 endif
 
-ifneq (,$(filter mac cocoa, $(MOZ_WIDGET_TOOLKIT)))
-DEFINES += -DTOOLBAR_CUSTOMIZATION_SHEET
-endif
-
 ifndef MOZ_BRANDING_DIRECTORY
 libs locale::
 	$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/browserconfig.properties $(DIST)/bin
 	$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/old-homepage-default.properties $(DIST)/bin
 
 install::
 	$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/browserconfig.properties $(DESTDIR)$(mozappdir)
 	$(SYSINSTALL) $(IFLAGS1) $(srcdir)/content/old-homepage-default.properties $(DESTDIR)$(mozappdir)
--- a/browser/base/content/browser-doctype.inc
+++ b/browser/base/content/browser-doctype.inc
@@ -6,20 +6,18 @@
 <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
 %globalDTD;
 <!ENTITY % globalRegionDTD SYSTEM "chrome://global-region/locale/region.dtd">
 %globalRegionDTD;
 <!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetOverlay.dtd" >
 %charsetDTD;
 <!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
 %textcontextDTD;
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
 <!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
   %customizeToolbarDTD;
-#endif
 <!ENTITY % placesDTD SYSTEM "chrome://browser/locale/places/places.dtd">
 %placesDTD;
 #ifdef MOZ_SAFE_BROWSING
 <!ENTITY % safebrowsingDTD SYSTEM "chrome://browser/locale/safebrowsing/phishing-afterload-warning-message.dtd">
 %safebrowsingDTD;
 #endif
 ]>
 
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -3270,16 +3270,17 @@ function OpenBrowserWindow()
   else // forget about the charset information.
   {
     win = window.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no", defaultArgs);
   }
 
   return win;
 }
 
+var gCustomizeSheet = false;
 // Returns a reference to the window in which the toolbar
 // customization document is loaded.
 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);
@@ -3287,48 +3288,52 @@ function BrowserCustomizeToolbar()
   var cmd = document.getElementById("cmd_CustomizeToolbars");
   cmd.setAttribute("disabled", "true");
 
   var splitter = document.getElementById("urlbar-search-splitter");
   if (splitter)
     splitter.parentNode.removeChild(splitter);
 
   var customizeURL = "chrome://global/content/customizeToolbar.xul";
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-  var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
-  sheetFrame.hidden = false;
-
-  // The document might not have been loaded yet, if this is the first time.
-  // If it is already loaded, reload it so that the onload initialization code
-  // re-runs.
-  if (sheetFrame.getAttribute("src") == customizeURL)
-    sheetFrame.contentWindow.location.reload()
-  else
-    sheetFrame.setAttribute("src", customizeURL);
-
-  // 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(gNavToolbox, "after_start", (window.innerWidth - sheetWidth) / 2, 0);
-
-  return sheetFrame.contentWindow;
-#else
-  return window.openDialog(customizeURL,
-                           "CustomizeToolbar",
-                           "chrome,titlebar,toolbar,location,resizable,dependent",
-                           gNavToolbox);
-#endif
+  gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
+
+  if (gCustomizeSheet) {
+    var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
+    sheetFrame.hidden = false;
+    sheetFrame.toolbox = gNavToolbox;
+
+    // The document might not have been loaded yet, if this is the first time.
+    // If it is already loaded, reload it so that the onload initialization code
+    // re-runs.
+    if (sheetFrame.getAttribute("src") == customizeURL)
+      sheetFrame.contentWindow.location.reload()
+    else
+      sheetFrame.setAttribute("src", customizeURL);
+
+    // 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(gNavToolbox, "after_start",
+                       (window.innerWidth - sheetWidth) / 2, 0);
+
+    return sheetFrame.contentWindow;
+  } else {
+    return window.openDialog(customizeURL,
+                             "CustomizeToolbar",
+                             "chrome,titlebar,toolbar,location,resizable,dependent",
+                             gNavToolbox);
+  }
 }
 
 function BrowserToolboxCustomizeDone(aToolboxChanged) {
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-  document.getElementById("customizeToolbarSheetIFrame").hidden = true;
-  document.getElementById("customizeToolbarSheetPopup").hidePopup();
-#endif
+  if (gCustomizeSheet) {
+    document.getElementById("customizeToolbarSheetIFrame").hidden = true;
+    document.getElementById("customizeToolbarSheetPopup").hidePopup();
+  }
 
   // Update global UI elements that may have been added or removed
   if (aToolboxChanged) {
     gURLBar = document.getElementById("urlbar");
     if (gURLBar)
       gURLBar.emptyText = gURLBarEmptyText.value;
 
     gProxyFavIcon = document.getElementById("page-proxy-favicon");
@@ -3374,20 +3379,20 @@ function BrowserToolboxCustomizeDone(aTo
   cmd.removeAttribute("disabled");
 
 #ifdef XP_MACOSX
   // make sure to re-enable click-and-hold
   if (!getBoolPref("ui.click_hold_context_menus", false))
     SetClickAndHoldHandlers();
 #endif
 
-#ifndef TOOLBAR_CUSTOMIZATION_SHEET
   // XXX Shouldn't have to do this, but I do
-  window.focus();
-#endif
+  if (!gCustomizeSheet)
+    window.focus();
+
 }
 
 function BrowserToolboxCustomizeChange() {
   gHomeButton.updatePersonalToolbarStyle();
 }
 
 /**
  * Update the global flag that tracks whether or not any edit UI (the Edit menu,
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -552,23 +552,21 @@
                   flex="1" contenttooltip="aHTMLTooltip"
                   contentcontextmenu="contentAreaContextMenu"
                   onnewtab="BrowserOpenTab();"
                   autocompletepopup="PopupAutoComplete"
                   ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"
                   onclick="return contentAreaClick(event, false);"/>
     </vbox>
   </hbox>
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
   <panel id="customizeToolbarSheetPopup" noautohide="true">
     <iframe id="customizeToolbarSheetIFrame"
             style="&dialog.style;"
             hidden="true"/>
   </panel>
-#endif
 
   <vbox id="browser-bottombox">
     <findbar browserid="content" id="FindToolbar"/>
   
     <statusbar class="chromeclass-status" id="status-bar"
                ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
       <statusbarpanel id="statusbar-display" label="" flex="1"/>
       <statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
deleted file mode 100644
--- a/browser/base/content/customizeToolbarSheet.js
+++ /dev/null
@@ -1,42 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org Code.
-#
-# The Initial Developer of the Original Code is
-# Mozilla Corporation
-# Portions created by the Initial Developer are Copyright (C) 2005-2006
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Asaf Romano <mozilla.mano@sent.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-var gCustomizeToolbarSheet = {
-  init: function() {
-    InitWithToolbox(window.parent.document.getElementById("navigator-toolbox"));
-  }
-};
deleted file mode 100644
--- a/browser/base/content/customizeToolbarSheet.xul
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0"?> 
-
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla Communicator client code, released
-# March 31, 1998.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998-1999
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   David Hyatt (hyatt@apple.com)
-#   Blake Ross (blaker@netscape.com)
-#   Asaf Romano <mozilla.mano@sent.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-<!DOCTYPE dialog [
-<!ENTITY % customizeToolbarDTD SYSTEM "chrome://global/locale/customizeToolbar.dtd">
-  %customizeToolbarDTD;
-]>
-
-<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
-<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
-<?xml-stylesheet href="chrome://global/content/customizeToolbar.css" type="text/css"?>
-<?xml-stylesheet href="chrome://global/skin/customizeToolbar.css" type="text/css"?>
-
-<window id="CustomizeToolbarSheet"
-        title="&dialog.title;"
-        style="&dialog.style;"
-        onload="gCustomizeToolbarSheet.init();"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-  <script type="application/x-javascript"
-          src="chrome://global/content/customizeToolbar.js"/>
-  <script type="application/x-javascript"
-          src="chrome://global/content/nsDragAndDrop.js"/>
-  <script type="application/x-javascript"
-          src="chrome://browser/content/customizeToolbarSheet.js"/>
-
-  <stringbundle id="stringBundle"
-                src="chrome://global/locale/customizeToolbar.properties"/>
-
-  <keyset id="CustomizeToolbarSheetKeyset">
-    <key id="cmd_close_sheet"
-         keycode="VK_ESCAPE"
-         oncommand="finishToolbarCustomization();"/>
-    <key id="cmd_close_sheet" keycode="VK_RETURN"
-         oncommand="finishToolbarCustomization();"/>
-    <key id="cmd_close_sheet" keycode="VK_ENTER"
-         oncommand="finishToolbarCustomization();"/>
-  </keyset>
-
-  <vbox id="main-box" flex="1">
-    <label id="instructions" value="&instructions.description;"/>
-
-    <vbox flex="1" id="palette-box"
-          ondraggesture="nsDragAndDrop.startDrag(event, dragStartObserver);"
-          ondragover="nsDragAndDrop.dragOver(event, paletteDNDObserver);"
-          ondragdrop="nsDragAndDrop.drop(event, paletteDNDObserver);"/>
-
-    <box align="center">
-      <label value="&show.label;"/>
-      <menulist id="modelist"
-                value="icons"
-                oncommand="updateToolbarMode(this.value);">
-        <menupopup>
-          <menuitem value="full" label="&iconsAndText.label;"/>
-          <menuitem value="icons" label="&icons.label;"/>
-          <menuitem value="text" label="&text.label;"/>
-        </menupopup>
-      </menulist>
-
-      <checkbox id="smallicons"
-                oncommand="updateIconSize(this.checked);"
-                label="&useSmallIcons.label;"/>
-    
-      <button label="&addNewToolbar.label;"
-              oncommand="addNewToolbar();"
-              icon="add"/>
-      <button label="&restoreDefaultSet.label;"
-              oncommand="restoreDefaultSet();"
-              icon="revert"/>
-    </box>
-
-    <separator class="groove"/>
-
-    <hbox align="center" pack="end">
-      <button label="&saveChanges.label;"
-              id="donebutton"
-              oncommand="finishToolbarCustomization();"
-              default="true"
-              icon="close"/>
-    </hbox>
-  </vbox>
-</window>
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -54,28 +54,20 @@ browser.jar:
 *       content/browser/hiddenWindow.xul              (content/hiddenWindow.xul)
 #ifdef XP_MACOSX
 *       content/browser/macBrowserOverlay.xul         (content/macBrowserOverlay.xul)
 *       content/browser/downloadManagerOverlay.xul    (content/downloadManagerOverlay.xul)
 *       content/browser/extensionsManagerOverlay.xul  (content/extensionsManagerOverlay.xul)
 *       content/browser/jsConsoleOverlay.xul          (content/jsConsoleOverlay.xul)
 *       content/browser/softwareUpdateOverlay.xul  (content/softwareUpdateOverlay.xul)
 #endif
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-*       content/browser/customizeToolbarSheet.js          (content/customizeToolbarSheet.js)
-#endif
 *       content/browser/viewSourceOverlay.xul         (content/viewSourceOverlay.xul)
 #ifdef MOZ_USE_GENERIC_BRANDING
 % content branding %content/branding/ xpcnativewrappers=yes
   content/branding/about.png                     (branding/about.png)
   content/branding/aboutCredits.png              (branding/aboutCredits.png)
   content/branding/aboutFooter.png               (branding/aboutFooter.png)
   content/branding/icon48.png                    (branding/icon48.png)
   content/branding/icon64.png                    (branding/icon64.png)
 #endif
 # the following files are browser-specific overrides
 *       content/browser/license.html                  (/toolkit/content/license.html)
 % override chrome://global/content/license.html chrome://browser/content/license.html
-
-#ifdef TOOLBAR_CUSTOMIZATION_SHEET
-toolkit.jar:
-*+      content/global/customizeToolbar.xul           (content/customizeToolbarSheet.xul)
-#endif