Automated merge with https://hg.mozilla.org/mozilla-central
This commit is contained in:
@@ -91,6 +91,12 @@ XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "AboutHomeUtils",
|
||||
"resource:///modules/AboutHomeUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gCustomizeMode", function() {
|
||||
let scope = {};
|
||||
Cu.import("resource:///modules/CustomizeMode.jsm", scope);
|
||||
return new scope.CustomizeMode(window);
|
||||
});
|
||||
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Weave",
|
||||
"resource://services-sync/main.js");
|
||||
@@ -147,6 +153,7 @@ let gInitialPages = [
|
||||
];
|
||||
|
||||
#include browser-addons.js
|
||||
#include browser-customization.js
|
||||
#include browser-feeds.js
|
||||
#include browser-fullScreen.js
|
||||
#include browser-fullZoom.js
|
||||
@@ -1031,7 +1038,9 @@ var gBrowserInit = {
|
||||
OfflineApps.init();
|
||||
IndexedDBPromptHelper.init();
|
||||
gFormSubmitObserver.init();
|
||||
PanelUI.init();
|
||||
SocialUI.init();
|
||||
LightweightThemeListener.init();
|
||||
AddonManager.addAddonListener(AddonsMgrListener);
|
||||
WebrtcIndicator.init();
|
||||
|
||||
@@ -1266,6 +1275,11 @@ var gBrowserInit = {
|
||||
window.addEventListener("mousemove", MousePosTracker, false);
|
||||
window.addEventListener("dragover", MousePosTracker, false);
|
||||
|
||||
window.addEventListener("CustomizationStart", CustomizationHandler, false);
|
||||
window.addEventListener("CustomizationEnd", CustomizationHandler, false);
|
||||
|
||||
gCustomizeMode.init();
|
||||
|
||||
// End startup crash tracking after a delay to catch crashes while restoring
|
||||
// tabs and to postpone saving the pref to disk.
|
||||
try {
|
||||
@@ -1361,6 +1375,9 @@ var gBrowserInit = {
|
||||
IndexedDBPromptHelper.uninit();
|
||||
AddonManager.removeAddonListener(AddonsMgrListener);
|
||||
SocialUI.uninit();
|
||||
LightweightThemeListener.uninit();
|
||||
gCustomizeMode.uninit();
|
||||
PanelUI.uninit();
|
||||
}
|
||||
|
||||
// Final window teardown, do this last.
|
||||
@@ -3310,118 +3327,13 @@ function OpenBrowserWindow(options)
|
||||
return win;
|
||||
}
|
||||
|
||||
var gCustomizeSheet = false;
|
||||
//XXXunf Are these still useful to keep around?
|
||||
function BrowserCustomizeToolbar() {
|
||||
// Disable the toolbar context menu items
|
||||
var menubar = document.getElementById("main-menubar");
|
||||
for (let childNode of menubar.childNodes)
|
||||
childNode.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);
|
||||
|
||||
CombinedStopReload.uninit();
|
||||
|
||||
PlacesToolbarHelper.customizeStart();
|
||||
BookmarksMenuButton.customizeStart();
|
||||
DownloadsButton.customizeStart();
|
||||
|
||||
TabsInTitlebar.allowedBy("customizing-toolbars", false);
|
||||
|
||||
var customizeURL = "chrome://global/content/customizeToolbar.xul";
|
||||
gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
|
||||
|
||||
if (gCustomizeSheet) {
|
||||
let sheetFrame = document.createElement("iframe");
|
||||
let panel = document.getElementById("customizeToolbarSheetPopup");
|
||||
sheetFrame.id = "customizeToolbarSheetIFrame";
|
||||
sheetFrame.toolbox = gNavToolbox;
|
||||
sheetFrame.panel = panel;
|
||||
sheetFrame.setAttribute("style", panel.getAttribute("sheetstyle"));
|
||||
panel.appendChild(sheetFrame);
|
||||
|
||||
// Open the panel, but make it invisible until the iframe has loaded so
|
||||
// that the user doesn't see a white flash.
|
||||
panel.style.visibility = "hidden";
|
||||
gNavToolbox.addEventListener("beforecustomization", function onBeforeCustomization() {
|
||||
gNavToolbox.removeEventListener("beforecustomization", onBeforeCustomization, false);
|
||||
panel.style.removeProperty("visibility");
|
||||
}, false);
|
||||
|
||||
sheetFrame.setAttribute("src", customizeURL);
|
||||
|
||||
panel.openPopup(gNavToolbox, "after_start", 0, 0);
|
||||
} else {
|
||||
window.openDialog(customizeURL,
|
||||
"CustomizeToolbar",
|
||||
"chrome,titlebar,toolbar,location,resizable,dependent",
|
||||
gNavToolbox);
|
||||
}
|
||||
gCustomizeMode.enter();
|
||||
}
|
||||
|
||||
function BrowserToolboxCustomizeDone(aToolboxChanged) {
|
||||
if (gCustomizeSheet) {
|
||||
document.getElementById("customizeToolbarSheetPopup").hidePopup();
|
||||
let iframe = document.getElementById("customizeToolbarSheetIFrame");
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
}
|
||||
|
||||
// Update global UI elements that may have been added or removed
|
||||
if (aToolboxChanged) {
|
||||
gURLBar = document.getElementById("urlbar");
|
||||
|
||||
gProxyFavIcon = document.getElementById("page-proxy-favicon");
|
||||
gHomeButton.updateTooltip();
|
||||
gIdentityHandler._cacheElements();
|
||||
window.XULBrowserWindow.init();
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
updateEditUIVisibility();
|
||||
#endif
|
||||
|
||||
// Hacky: update the PopupNotifications' object's reference to the iconBox,
|
||||
// if it already exists, since it may have changed if the URL bar was
|
||||
// added/removed.
|
||||
if (!window.__lookupGetter__("PopupNotifications"))
|
||||
PopupNotifications.iconBox = document.getElementById("notification-popup-box");
|
||||
}
|
||||
|
||||
PlacesToolbarHelper.customizeDone();
|
||||
BookmarksMenuButton.customizeDone();
|
||||
DownloadsButton.customizeDone();
|
||||
|
||||
// The url bar splitter state is dependent on whether stop/reload
|
||||
// and the location bar are combined, so we need this ordering
|
||||
CombinedStopReload.init();
|
||||
UpdateUrlbarSearchSplitterState();
|
||||
setUrlAndSearchBarWidthForConditionalForwardButton();
|
||||
|
||||
// Update the urlbar
|
||||
if (gURLBar) {
|
||||
URLBarSetURI();
|
||||
XULBrowserWindow.asyncUpdateUI();
|
||||
BookmarksMenuButton.updateStarState();
|
||||
SocialMark.updateMarkState();
|
||||
}
|
||||
|
||||
TabsInTitlebar.allowedBy("customizing-toolbars", true);
|
||||
|
||||
// Re-enable parts of the UI we disabled during the dialog
|
||||
var menubar = document.getElementById("main-menubar");
|
||||
for (let childNode of menubar.childNodes)
|
||||
childNode.setAttribute("disabled", false);
|
||||
var cmd = document.getElementById("cmd_CustomizeToolbars");
|
||||
cmd.removeAttribute("disabled");
|
||||
|
||||
// make sure to re-enable click-and-hold
|
||||
if (!getBoolPref("ui.click_hold_context_menus", false))
|
||||
SetClickAndHoldHandlers();
|
||||
|
||||
gBrowser.selectedBrowser.focus();
|
||||
gCustomizeMode.exit(aToolboxChanged);
|
||||
}
|
||||
|
||||
function BrowserToolboxCustomizeChange(aType) {
|
||||
@@ -3592,6 +3504,9 @@ var XULBrowserWindow = {
|
||||
startTime: 0,
|
||||
statusText: "",
|
||||
isBusy: false,
|
||||
// The pages in this array should be kept in sync with what pages that
|
||||
// panelUIOverlay.xul is set to overlay in
|
||||
// browser/components/customizableui/content/jar.mn
|
||||
inContentWhitelist: ["about:addons", "about:downloads", "about:permissions",
|
||||
"about:sync-progress", "about:preferences"],
|
||||
|
||||
@@ -4143,8 +4058,7 @@ var CombinedStopReload = {
|
||||
var stop = document.getElementById("stop-button");
|
||||
|
||||
if (urlbar) {
|
||||
if (urlbar.parentNode.getAttribute("mode") != "icons" ||
|
||||
!reload || urlbar.nextSibling != reload ||
|
||||
if (!reload || urlbar.nextSibling != reload ||
|
||||
!stop || reload.nextSibling != stop)
|
||||
urlbar.removeAttribute("combined");
|
||||
else {
|
||||
@@ -4561,10 +4475,19 @@ var TabsInTitlebar = {
|
||||
this._readPref();
|
||||
Services.prefs.addObserver(this._prefName, this, false);
|
||||
|
||||
// Don't trust the initial value of the sizemode attribute; wait for
|
||||
// the resize event (handled in tabbrowser.xml).
|
||||
this.allowedBy("sizemode", false);
|
||||
|
||||
// We need to update the appearance of the titlebar when the menu changes
|
||||
// from the active to the inactive state. We can't, however, rely on
|
||||
// DOMMenuBarInactive, because the menu fires this event and then removes
|
||||
// the inactive attribute after an event-loop spin.
|
||||
//
|
||||
// Because updating the appearance involves sampling the heights and margins
|
||||
// of various elements, it's important that the layout be more or less
|
||||
// settled before updating the titlebar. So instead of listening to
|
||||
// DOMMenuBarActive and DOMMenuBarInactive, we use a MutationObserver to
|
||||
// watch the "invalid" attribute directly.
|
||||
let menu = document.getElementById("toolbar-menubar");
|
||||
this._menuObserver = new MutationObserver(this._onMenuMutate);
|
||||
this._menuObserver.observe(menu, {attributes: true});
|
||||
this._initialized = true;
|
||||
#endif
|
||||
},
|
||||
@@ -4574,17 +4497,23 @@ var TabsInTitlebar = {
|
||||
if (allow) {
|
||||
if (condition in this._disallowed) {
|
||||
delete this._disallowed[condition];
|
||||
this._update();
|
||||
this._update(true);
|
||||
}
|
||||
} else {
|
||||
if (!(condition in this._disallowed)) {
|
||||
this._disallowed[condition] = null;
|
||||
this._update();
|
||||
this._update(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
updateAppearance: function updateAppearance(aForce) {
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
this._update(aForce);
|
||||
#endif
|
||||
},
|
||||
|
||||
get enabled() {
|
||||
return document.documentElement.getAttribute("tabsintitlebar") == "true";
|
||||
},
|
||||
@@ -4595,35 +4524,73 @@ var TabsInTitlebar = {
|
||||
this._readPref();
|
||||
},
|
||||
|
||||
_onMenuMutate: function (aMutations) {
|
||||
// We don't care about restored windows, since the menu shouldn't be
|
||||
// pushing the tab-strip down.
|
||||
if (document.documentElement.getAttribute("sizemode") == "normal") {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let mutation of aMutations) {
|
||||
if (mutation.attributeName == "inactive" ||
|
||||
mutation.attributeName == "autohide") {
|
||||
TabsInTitlebar._update(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_initialized: false,
|
||||
_disallowed: {},
|
||||
_prefName: "browser.tabs.drawInTitlebar",
|
||||
_lastSizeMode: null,
|
||||
|
||||
_readPref: function () {
|
||||
this.allowedBy("pref",
|
||||
Services.prefs.getBoolPref(this._prefName));
|
||||
},
|
||||
|
||||
_update: function () {
|
||||
_update: function (aForce=false) {
|
||||
if (!this._initialized || window.fullScreen)
|
||||
return;
|
||||
|
||||
let allowed = true;
|
||||
|
||||
if (!aForce) {
|
||||
// _update is called on resize events, because the window is not ready
|
||||
// after sizemode events. However, we only care about the event when the
|
||||
// sizemode is different from the last time we updated the appearance of
|
||||
// the tabs in the titlebar.
|
||||
let sizemode = document.documentElement.getAttribute("sizemode");
|
||||
if (this._lastSizeMode == sizemode) {
|
||||
return;
|
||||
}
|
||||
this._lastSizeMode = sizemode;
|
||||
}
|
||||
|
||||
for (let something in this._disallowed) {
|
||||
allowed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (allowed == this.enabled)
|
||||
return;
|
||||
|
||||
function $(id) document.getElementById(id);
|
||||
|
||||
let titlebar = $("titlebar");
|
||||
let titlebarContent = $("titlebar-content");
|
||||
let menubar = $("toolbar-menubar");
|
||||
|
||||
// Reset the margins and padding that _update modifies so that we can take
|
||||
// accurate measurements.
|
||||
titlebarContent.style.marginBottom = "";
|
||||
titlebar.style.marginBottom = "";
|
||||
menubar.style.paddingBottom = "";
|
||||
|
||||
if (allowed) {
|
||||
function rect(ele) ele.getBoundingClientRect();
|
||||
// We set the tabsintitlebar attribute first so that our CSS for
|
||||
// tabsintitlebar manifests before we do our measurements.
|
||||
document.documentElement.setAttribute("tabsintitlebar", "true");
|
||||
|
||||
let tabsToolbar = $("TabsToolbar");
|
||||
function rect(ele) ele.getBoundingClientRect();
|
||||
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
let appmenuButtonBox = $("appmenu-button-container");
|
||||
@@ -4631,26 +4598,62 @@ var TabsInTitlebar = {
|
||||
#endif
|
||||
let captionButtonsBox = $("titlebar-buttonbox");
|
||||
this._sizePlaceholder("caption-buttons", rect(captionButtonsBox).width);
|
||||
#ifdef XP_MACOSX
|
||||
let fullscreenButton = $("titlebar-fullscreen-button");
|
||||
this._sizePlaceholder("fullscreen-button", rect(fullscreenButton).width);
|
||||
#endif
|
||||
let titlebarContentHeight = rect(titlebarContent).height;
|
||||
let menuHeight = this._outerHeight(menubar);
|
||||
|
||||
let tabsToolbarRect = rect(tabsToolbar);
|
||||
let titlebarTop = rect($("titlebar-content")).top;
|
||||
titlebar.style.marginBottom = - Math.min(tabsToolbarRect.top - titlebarTop,
|
||||
tabsToolbarRect.height) + "px";
|
||||
// If the titlebar is taller than the menubar, add more padding to the
|
||||
// bottom of the menubar so that it matches.
|
||||
if (menuHeight && titlebarContentHeight > menuHeight) {
|
||||
let menuTitlebarDelta = titlebarContentHeight - menuHeight;
|
||||
menubar.style.paddingBottom = menuTitlebarDelta + "px";
|
||||
menuHeight += menuTitlebarDelta;
|
||||
}
|
||||
|
||||
document.documentElement.setAttribute("tabsintitlebar", "true");
|
||||
// Next, we calculate how much we need to stretch the titlebar down to
|
||||
// go all the way to the bottom of the tab strip.
|
||||
let tabsToolbar = $("TabsToolbar");
|
||||
let tabAndMenuHeight = this._outerHeight(tabsToolbar) + menuHeight;
|
||||
titlebarContent.style.marginBottom = tabAndMenuHeight + "px";
|
||||
|
||||
if (!this._draghandle) {
|
||||
// Finally, we have to determine how much to bring up the elements below
|
||||
// the titlebar. We start with a baseHeight of tabAndMenuHeight, to offset
|
||||
// the amount we added to the titlebar content. Then, we have two cases:
|
||||
//
|
||||
// 1) The titlebar is larger than the tabAndMenuHeight. This can happen in
|
||||
// large font mode with the menu autohidden. In this case, we want to
|
||||
// add tabAndMenuHeight, since this should line up the bottom of the
|
||||
// tabstrip with the bottom of the titlebar.
|
||||
//
|
||||
// 2) The titlebar is equal to or smaller than the tabAndMenuHeight. This
|
||||
// is the more common case, and occurs with normal font sizes. In this
|
||||
// case, we want to bring the menu and tabstrip right up to the top of
|
||||
// the titlebar, so we add the titlebarContentHeight to the baseHeight.
|
||||
let baseHeight = tabAndMenuHeight;
|
||||
baseHeight += (titlebarContentHeight > tabAndMenuHeight) ? tabAndMenuHeight
|
||||
: titlebarContentHeight;
|
||||
titlebar.style.marginBottom = "-" + baseHeight + "px";
|
||||
|
||||
if (!this._draghandles) {
|
||||
this._draghandles = {};
|
||||
let tmp = {};
|
||||
Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp);
|
||||
this._draghandle = new tmp.WindowDraggingElement(tabsToolbar);
|
||||
this._draghandle.mouseDownCheck = function () {
|
||||
|
||||
let mouseDownCheck = function () {
|
||||
return !this._dragBindingAlive && TabsInTitlebar.enabled;
|
||||
};
|
||||
|
||||
this._draghandles.tabsToolbar = new tmp.WindowDraggingElement(tabsToolbar);
|
||||
this._draghandles.tabsToolbar.mouseDownCheck = mouseDownCheck;
|
||||
|
||||
this._draghandles.navToolbox = new tmp.WindowDraggingElement(gNavToolbox);
|
||||
this._draghandles.navToolbox.mouseDownCheck = mouseDownCheck;
|
||||
}
|
||||
} else {
|
||||
document.documentElement.removeAttribute("tabsintitlebar");
|
||||
|
||||
titlebar.style.marginBottom = "";
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4658,12 +4661,30 @@ var TabsInTitlebar = {
|
||||
Array.forEach(document.querySelectorAll(".titlebar-placeholder[type='"+ type +"']"),
|
||||
function (node) { node.width = width; });
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve the height of an element, including its top and bottom
|
||||
* margins.
|
||||
*
|
||||
* @param ele
|
||||
* The element to measure.
|
||||
* @return
|
||||
* The height and margins as an integer. If the height of the element
|
||||
* is 0, then this returns 0, regardless of what the margins are.
|
||||
*/
|
||||
_outerHeight: function (ele) {
|
||||
let cstyle = document.defaultView.getComputedStyle(ele);
|
||||
let margins = parseInt(cstyle.marginTop) + parseInt(cstyle.marginBottom);
|
||||
let height = ele.getBoundingClientRect().height;
|
||||
return height > 0 ? Math.abs(height + margins) : 0;
|
||||
},
|
||||
#endif
|
||||
|
||||
uninit: function () {
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
this._initialized = false;
|
||||
Services.prefs.removeObserver(this._prefName, this);
|
||||
this._menuObserver.disconnect();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@@ -4676,14 +4697,14 @@ function updateAppButtonDisplay() {
|
||||
document.getElementById("toolbar-menubar").getAttribute("autohide") == "true";
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
document.getElementById("titlebar").hidden = !displayAppButton;
|
||||
document.getElementById("titlebar").hidden = gInPrintPreviewMode;
|
||||
|
||||
if (displayAppButton)
|
||||
if (!gInPrintPreviewMode)
|
||||
document.documentElement.setAttribute("chromemargin", "0,2,2,2");
|
||||
else
|
||||
document.documentElement.removeAttribute("chromemargin");
|
||||
|
||||
TabsInTitlebar.allowedBy("drawing-in-titlebar", displayAppButton);
|
||||
TabsInTitlebar.allowedBy("drawing-in-titlebar", !gInPrintPreviewMode);
|
||||
#else
|
||||
document.getElementById("appmenu-toolbar-button").hidden =
|
||||
!displayAppButton;
|
||||
@@ -6724,12 +6745,6 @@ let gPrivateBrowsingUI = {
|
||||
document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
|
||||
|
||||
if (window.location.href == getBrowserURL()) {
|
||||
#ifdef XP_MACOSX
|
||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
document.documentElement.setAttribute("drawintitlebar", true);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Adjust the window's title
|
||||
let docElement = document.documentElement;
|
||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
|
||||
Reference in New Issue
Block a user