mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 748381 - Update the behavior of the Downloads indicator. r=mano
This commit is contained in:
parent
10d961ef72
commit
baa8eb743d
@ -1239,7 +1239,6 @@ var gBrowserInit = {
|
||||
BookmarksMenuButton.init();
|
||||
TabsInTitlebar.init();
|
||||
gPrivateBrowsingUI.init();
|
||||
DownloadsButton.initializePlaceholder();
|
||||
retrieveToolbarIconsizesFromTheme();
|
||||
|
||||
gDelayedStartupTimeoutId = setTimeout(this._delayedStartup.bind(this), 0, isLoadingBlank, mustLoadSidebar);
|
||||
|
@ -522,7 +522,7 @@
|
||||
toolbarname="&navbarCmd.label;" accesskey="&navbarCmd.accesskey;"
|
||||
fullscreentoolbar="true" mode="icons" customizable="true"
|
||||
iconsize="large"
|
||||
defaultset="unified-back-forward-button,urlbar-container,reload-button,stop-button,search-container,home-button,bookmarks-menu-button-container,window-controls"
|
||||
defaultset="unified-back-forward-button,urlbar-container,reload-button,stop-button,search-container,downloads-button,home-button,bookmarks-menu-button-container,window-controls"
|
||||
context="toolbar-context-menu">
|
||||
|
||||
<toolbaritem id="unified-back-forward-button" class="chromeclass-toolbar-additional"
|
||||
@ -937,8 +937,8 @@
|
||||
tooltiptext="&printButton.tooltip;"/>
|
||||
|
||||
<!-- This is a placeholder for the Downloads Indicator. It is visible
|
||||
only during the customization of the toolbar or in the palette, and
|
||||
is replaced when customization is done. -->
|
||||
during the customization of the toolbar, in the palette, and before
|
||||
the Downloads Indicator overlay is loaded. -->
|
||||
<toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
|
||||
observes="Tools:Downloads"
|
||||
ondrop="DownloadsButtonDNDObserver.onDrop(event)"
|
||||
|
@ -52,30 +52,6 @@ const DownloadsButton = {
|
||||
return document.getElementById("downloads-button");
|
||||
},
|
||||
|
||||
/**
|
||||
* This function is called synchronously at window initialization. It only
|
||||
* sets the visibility of user interface elements to avoid flickering.
|
||||
*
|
||||
* NOTE: To keep startup time to a minimum, this function should not perform
|
||||
* any expensive operations or input/output, and should not cause the
|
||||
* Download Manager service to start.
|
||||
*/
|
||||
initializePlaceholder: function DB_initializePlaceholder()
|
||||
{
|
||||
// Exit now if the feature is disabled. To improve startup time, we don't
|
||||
// load the DownloadsCommon module yet, but check the preference directly.
|
||||
if (gPrefService.getBoolPref("browser.download.useToolkitUI")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We must hide the placeholder used for toolbar customization, unless it
|
||||
// has been removed from the toolbars and is now located in the palette.
|
||||
let placeholder = this._placeholder;
|
||||
if (placeholder) {
|
||||
placeholder.collapsed = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This function is called asynchronously just after window initialization.
|
||||
*
|
||||
@ -141,12 +117,8 @@ const DownloadsButton = {
|
||||
_update: function DB_update() {
|
||||
this._updatePositionInternal();
|
||||
|
||||
let placeholder = this._placeholder;
|
||||
if (!DownloadsCommon.useToolkitUI) {
|
||||
DownloadsIndicatorView.ensureInitialized();
|
||||
if (placeholder) {
|
||||
placeholder.collapsed = true;
|
||||
}
|
||||
} else {
|
||||
DownloadsIndicatorView.ensureTerminated();
|
||||
}
|
||||
@ -181,47 +153,27 @@ const DownloadsButton = {
|
||||
}
|
||||
|
||||
let placeholder = this._placeholder;
|
||||
|
||||
// Firstly, determine if we should always hide the indicator.
|
||||
if (!placeholder && !this._anchorRequested &&
|
||||
!DownloadsIndicatorView.hasDownloads) {
|
||||
if (!placeholder) {
|
||||
// The placeholder has been removed from the browser window.
|
||||
indicator.collapsed = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Position the indicator where the placeholder is located. We should
|
||||
// update the position even if the placeholder is located on an invisible
|
||||
// toolbar, because the toolbar may be displayed later.
|
||||
placeholder.parentNode.insertBefore(indicator, placeholder);
|
||||
placeholder.collapsed = true;
|
||||
indicator.collapsed = false;
|
||||
|
||||
indicator.open = this._anchorRequested;
|
||||
|
||||
// Determine if we should display the indicator in a known position.
|
||||
if (placeholder) {
|
||||
placeholder.parentNode.insertBefore(indicator, placeholder);
|
||||
// Determine if the placeholder is located on a visible toolbar.
|
||||
if (isElementVisible(placeholder.parentNode)) {
|
||||
return DownloadsIndicatorView.indicatorAnchor;
|
||||
}
|
||||
}
|
||||
|
||||
// If not customized, the indicator is normally in the navigation bar.
|
||||
// Always place it in the default position, unless we need an anchor.
|
||||
if (!this._anchorRequested) {
|
||||
this._navBar.appendChild(indicator);
|
||||
// Determine if the placeholder is located on an invisible toolbar.
|
||||
if (!isElementVisible(placeholder.parentNode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Show the indicator temporarily in the navigation bar, if visible.
|
||||
if (isElementVisible(this._navBar)) {
|
||||
this._navBar.appendChild(indicator);
|
||||
return DownloadsIndicatorView.indicatorAnchor;
|
||||
}
|
||||
|
||||
// Show the indicator temporarily in the tab bar, if visible.
|
||||
if (!this._tabsToolbar.collapsed) {
|
||||
this._tabsToolbar.appendChild(indicator);
|
||||
return DownloadsIndicatorView.indicatorAnchor;
|
||||
}
|
||||
|
||||
// The temporary anchor cannot be shown.
|
||||
return null;
|
||||
return DownloadsIndicatorView.indicatorAnchor;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -384,6 +336,10 @@ const DownloadsIndicatorView = {
|
||||
clearTimeout(this._notificationTimeout);
|
||||
}
|
||||
|
||||
// Now that the overlay is loaded, place the indicator in its final
|
||||
// position.
|
||||
DownloadsButton.updatePosition();
|
||||
|
||||
let indicator = this.indicator;
|
||||
indicator.setAttribute("notification", "true");
|
||||
this._notificationTimeout = setTimeout(
|
||||
|
@ -1185,7 +1185,7 @@ BrowserGlue.prototype = {
|
||||
},
|
||||
|
||||
_migrateUI: function BG__migrateUI() {
|
||||
const UI_VERSION = 6;
|
||||
const UI_VERSION = 7;
|
||||
const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
|
||||
let currentUIVersion = 0;
|
||||
try {
|
||||
@ -1283,6 +1283,43 @@ BrowserGlue.prototype = {
|
||||
Services.prefs.setBoolPref("browser.tabs.onTop", tabsOnTopAttribute == "true");
|
||||
}
|
||||
|
||||
// This migration step is executed only if the Downloads Panel feature is
|
||||
// enabled. By default, the feature is enabled only in the Nightly channel.
|
||||
// This means that, unless the preference that enables the feature is
|
||||
// changed manually, the Downloads button is added to the toolbar only if
|
||||
// migration happens while running a build from the Nightly channel. This
|
||||
// migration code will be updated when the feature will be enabled on all
|
||||
// channels, see bug 748381 for details.
|
||||
if (currentUIVersion < 7 &&
|
||||
!Services.prefs.getBoolPref("browser.download.useToolkitUI")) {
|
||||
// This code adds the customizable downloads buttons.
|
||||
let currentsetResource = this._rdf.GetResource("currentset");
|
||||
let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
|
||||
let currentset = this._getPersist(toolbarResource, currentsetResource);
|
||||
|
||||
// Since the Downloads button is located in the navigation bar by default,
|
||||
// migration needs to happen only if the toolbar was customized using a
|
||||
// previous UI version, and the button was not already placed on the
|
||||
// toolbar manually.
|
||||
if (currentset &&
|
||||
currentset.indexOf("downloads-button") == -1) {
|
||||
// The element is added either after the search bar or before the home
|
||||
// button. As a last resort, the element is added just before the
|
||||
// non-customizable window controls.
|
||||
if (currentset.indexOf("search-container") != -1) {
|
||||
currentset = currentset.replace(/(^|,)search-container($|,)/,
|
||||
"$1search-container,downloads-button$2")
|
||||
} else if (currentset.indexOf("home-button") != -1) {
|
||||
currentset = currentset.replace(/(^|,)home-button($|,)/,
|
||||
"$1downloads-button,home-button$2")
|
||||
} else {
|
||||
currentset = currentset.replace(/(^|,)window-controls($|,)/,
|
||||
"$1downloads-button,window-controls$2")
|
||||
}
|
||||
this._setPersist(toolbarResource, currentsetResource, currentset);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._dirty)
|
||||
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user