Bug 489545 - Switch to using the toolkit support for toolbar customization sheets, r=mano

This commit is contained in:
Phil Ringnalda 2009-05-18 18:12:59 -07:00
Родитель 9e30170668
Коммит 9d32e37a42
8 изменённых файлов: 41 добавлений и 208 удалений

Просмотреть файл

@ -822,3 +822,10 @@ 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

Просмотреть файл

@ -76,10 +76,6 @@ 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

Просмотреть файл

@ -11,10 +11,8 @@
%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

Просмотреть файл

@ -3275,6 +3275,7 @@ function OpenBrowserWindow()
return win;
}
var gCustomizeSheet = false;
// Returns a reference to the window in which the toolbar
// customization document is loaded.
function BrowserCustomizeToolbar()
@ -3292,38 +3293,42 @@ function BrowserCustomizeToolbar()
splitter.parentNode.removeChild(splitter);
var customizeURL = "chrome://global/content/customizeToolbar.xul";
#ifdef TOOLBAR_CUSTOMIZATION_SHEET
var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
sheetFrame.hidden = false;
gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", 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);
if (gCustomizeSheet) {
var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
sheetFrame.hidden = false;
sheetFrame.toolbox = gNavToolbox;
// 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);
// 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);
return sheetFrame.contentWindow;
#else
return window.openDialog(customizeURL,
"CustomizeToolbar",
"chrome,titlebar,toolbar,location,resizable,dependent",
gNavToolbox);
#endif
// 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) {
@ -3379,10 +3384,10 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) {
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() {

Просмотреть файл

@ -557,13 +557,11 @@
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"/>

Просмотреть файл

@ -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"));
}
};

Просмотреть файл

@ -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>

Просмотреть файл

@ -59,9 +59,6 @@ browser.jar:
* 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
@ -74,8 +71,3 @@ browser.jar:
# 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