summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/downloads/content/downloadsViewCommon.js
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-07-29 12:41:33 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-07-29 12:41:33 +0200
commitbeeede618586155d0f3fcb8e9313e076eef3e6e5 (patch)
treefb58542b59d8a7573a79a14f9ed5d1ae0456efe8 /application/palemoon/components/downloads/content/downloadsViewCommon.js
parent761b6eb255109a07d7cbcaaef6891cb14c961dbc (diff)
downloadUXP-beeede618586155d0f3fcb8e9313e076eef3e6e5.tar
UXP-beeede618586155d0f3fcb8e9313e076eef3e6e5.tar.gz
UXP-beeede618586155d0f3fcb8e9313e076eef3e6e5.tar.lz
UXP-beeede618586155d0f3fcb8e9313e076eef3e6e5.tar.xz
UXP-beeede618586155d0f3fcb8e9313e076eef3e6e5.zip
[PALEMOON] Bug 1127867 - Use the new back-end property to get the size of downloads asynchronously
Diffstat (limited to 'application/palemoon/components/downloads/content/downloadsViewCommon.js')
-rw-r--r--application/palemoon/components/downloads/content/downloadsViewCommon.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/application/palemoon/components/downloads/content/downloadsViewCommon.js b/application/palemoon/components/downloads/content/downloadsViewCommon.js
index 999d82317..7ae3eb850 100644
--- a/application/palemoon/components/downloads/content/downloadsViewCommon.js
+++ b/application/palemoon/components/downloads/content/downloadsViewCommon.js
@@ -142,6 +142,15 @@ DownloadElementShell.prototype = {
* namely the progress bar and the status line.
*/
_updateProgress() {
+ if (this.download.succeeded) {
+ // We only need to add or remove this attribute for succeeded downloads.
+ if (this.download.target.exists) {
+ this.element.setAttribute("exists", "true");
+ } else {
+ this.element.removeAttribute("exists");
+ }
+ }
+
// The progress bar is only displayed for in-progress downloads.
if (this.download.hasProgress) {
this.element.setAttribute("progressmode", "normal");
@@ -182,26 +191,26 @@ DownloadElementShell.prototype = {
let tip = "";
if (!this.download.stopped) {
- let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download);
+ let total = this.download.hasProgress ? this.download.totalBytes : -1;
// By default, extended status information including the individual
// download rate is displayed in the tooltip. The history view overrides
// the getter and displays the detials in the main area instead.
[text] = DownloadUtils.getDownloadStatusNoRate(
this.download.currentBytes,
- maxBytes,
+ total,
this.download.speed,
this.lastEstimatedSecondsLeft);
let newEstimatedSecondsLeft;
[tip, newEstimatedSecondsLeft] = DownloadUtils.getDownloadStatus(
this.download.currentBytes,
- maxBytes,
+ total,
this.download.speed,
this.lastEstimatedSecondsLeft);
this.lastEstimatedSecondsLeft = newEstimatedSecondsLeft;
} else if (this.download.canceled && this.download.hasPartialData) {
- let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download);
+ let total = this.download.hasProgress ? this.download.totalBytes : -1;
let transfer = DownloadUtils.getTransferTotal(this.download.currentBytes,
- maxBytes);
+ total);
// We use the same XUL label to display both the state and the amount
// transferred, for example "Paused - 1.1 MB".
@@ -213,12 +222,13 @@ DownloadElementShell.prototype = {
let stateLabel;
if (this.download.succeeded) {
- // For completed downloads, show the file size (e.g. "1.5 MB")
- let maxBytes = DownloadsCommon.maxBytesOfDownload(this.download);
- if (maxBytes >= 0) {
- let [size, unit] = DownloadUtils.convertByteUnits(maxBytes);
+ // For completed downloads, show the file size (e.g. "1.5 MB").
+ if (this.download.target.size !== undefined) {
+ let [size, unit] = DownloadUtils.convertByteUnits(
+ this.download.target.size);
stateLabel = s.sizeWithUnits(size, unit);
} else {
+ // History downloads may not have a size defined.
stateLabel = s.sizeUnknown;
}
} else if (this.download.canceled) {