Bug 1658074, update numPages to reflect the number of copies the user has r=mstriemer
authorEmma Malysz <emalysz@mozilla.com>
Wed, 12 Aug 2020 01:24:37 +0000
changeset 544349 4909c8ec371cc4f3d2a8024dbbf4c5a251bdf958
parent 544348 bf0c6945edbe201fbc701fb994e859beb0a9aba0
child 544350 d95ae26b4a96388190aba96aaffc8e09eea86ff8
push id123984
push usercbrindusan@mozilla.com
push dateWed, 12 Aug 2020 01:55:02 +0000
treeherderautoland@d95ae26b4a96 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer
bugs1658074
milestone81.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1658074, update numPages to reflect the number of copies the user has r=mstriemer Differential Revision: https://phabricator.services.mozilla.com/D86641
toolkit/components/printing/content/print.js
--- a/toolkit/components/printing/content/print.js
+++ b/toolkit/components/printing/content/print.js
@@ -590,25 +590,38 @@ class TwistySummary extends PrintUIContr
       open
         ? this.getAttribute("data-open-l10n-id")
         : this.getAttribute("data-closed-l10n-id")
     );
   }
 }
 customElements.define("twisty-summary", TwistySummary);
 
-class PageCount extends HTMLParagraphElement {
-  constructor() {
-    super();
+class PageCount extends PrintUIControlMixin(HTMLElement) {
+  initialize() {
+    super.initialize();
     document.addEventListener("page-count", this);
   }
 
-  handleEvent(e) {
-    let { numPages } = e.detail;
+  update(settings) {
+    this.numCopies = settings.numCopies;
+    this.render();
+  }
+
+  render() {
+    if (!this.numCopies || !this.numPages) {
+      return;
+    }
     document.l10n.setAttributes(this, "printui-sheets-count", {
-      sheetCount: numPages,
+      sheetCount: this.numPages * this.numCopies,
     });
     if (this.hidden) {
       document.l10n.translateElements([this]).then(() => (this.hidden = false));
     }
   }
+
+  handleEvent(e) {
+    let { numPages } = e.detail;
+    this.numPages = numPages;
+    this.render();
+  }
 }
-customElements.define("page-count", PageCount, { extends: "p" });
+customElements.define("page-count", PageCount);