Bug 1528108 - Drop support for PageThumbUtils.createCanvas with null window r=Standard8
authormonmanuela <manuela.monika97@gmail.com>
Fri, 15 Mar 2019 09:26:29 +0000
changeset 522024 77e55a8270d1dc6e24c55568f436977f052a0b7a
parent 522023 080df795170f98952d63dd362990cbe2eb35834f
child 522025 cb57c95a5e8261473504b04ec42a221b5ef5d2a5
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1528108
milestone67.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 1528108 - Drop support for PageThumbUtils.createCanvas with null window r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D22892
browser/modules/WindowsPreviewPerTab.jsm
toolkit/components/thumbnails/PageThumbUtils.jsm
toolkit/components/thumbnails/PageThumbs.jsm
--- a/browser/modules/WindowsPreviewPerTab.jsm
+++ b/browser/modules/WindowsPreviewPerTab.jsm
@@ -143,17 +143,17 @@ function PreviewController(win, tab) {
   this.win = win;
   this.tab = tab;
   this.linkedBrowser = tab.linkedBrowser;
   this.preview = this.win.createTabPreview(this);
 
   this.tab.addEventListener("TabAttrModified", this);
 
   XPCOMUtils.defineLazyGetter(this, "canvasPreview", function() {
-    let canvas = PageThumbs.createCanvas();
+    let canvas = PageThumbs.createCanvas(this.win);
     canvas.mozOpaque = true;
     return canvas;
   });
 }
 
 PreviewController.prototype = {
   QueryInterface: ChromeUtils.generateQI([Ci.nsITaskbarPreviewController]),
 
@@ -265,17 +265,17 @@ PreviewController.prototype = {
    */
   requestPreview(aTaskbarCallback) {
     // Grab a high res content preview
     this.resetCanvasPreview();
     this.updateCanvasPreview(true, (aPreviewCanvas) => {
       let winWidth = this.win.width;
       let winHeight = this.win.height;
 
-      let composite = PageThumbs.createCanvas();
+      let composite = PageThumbs.createCanvas(this.win);
 
       // Use transparency, Aero glass is drawn black without it.
       composite.mozOpaque = false;
 
       let ctx = composite.getContext("2d");
       let scale = this.screenPixelsPerCSSPixel / this.zoom;
 
       composite.width = winWidth * scale;
--- a/toolkit/components/thumbnails/PageThumbUtils.jsm
+++ b/toolkit/components/thumbnails/PageThumbUtils.jsm
@@ -16,27 +16,26 @@ ChromeUtils.defineModuleGetter(this, "Br
 
 var PageThumbUtils = {
   // The default background color for page thumbnails.
   THUMBNAIL_BG_COLOR: "#fff",
   // The namespace for thumbnail canvas elements.
   HTML_NAMESPACE: "http://www.w3.org/1999/xhtml",
 
   /**
-   * Creates a new canvas element in the context of aWindow, or if aWindow
-   * is undefined, in the context of hiddenDOMWindow.
+   * Creates a new canvas element in the context of aWindow.
    *
-   * @param aWindow (optional) The document of this window will be used to
-   *  create the canvas.  If not given, the hidden window will be used.
+   * @param aWindow The document of this window will be used to
+   *  create the canvas.
    * @param aWidth (optional) width of the canvas to create
    * @param aHeight (optional) height of the canvas to create
    * @return The newly created canvas.
    */
   createCanvas(aWindow, aWidth = 0, aHeight = 0) {
-    let doc = (aWindow || Services.appShell.hiddenDOMWindow).document;
+    let doc = aWindow.document;
     let canvas = doc.createElementNS(this.HTML_NAMESPACE, "canvas");
     canvas.mozOpaque = true;
     canvas.imageSmoothingEnabled = true;
     let [thumbnailWidth, thumbnailHeight] = this.getThumbnailSize(aWindow);
     canvas.width = aWidth ? aWidth : thumbnailWidth;
     canvas.height = aHeight ? aHeight : thumbnailHeight;
     return canvas;
   },
--- a/toolkit/components/thumbnails/PageThumbs.jsm
+++ b/toolkit/components/thumbnails/PageThumbs.jsm
@@ -158,17 +158,17 @@ var PageThumbs = {
    * @resolve {Blob} The thumbnail, as a Blob.
    */
   captureToBlob: function PageThumbs_captureToBlob(aBrowser) {
     if (!this._prefEnabled()) {
       return null;
     }
 
     return new Promise(resolve => {
-      let canvas = this.createCanvas(aBrowser.contentWindow);
+      let canvas = this.createCanvas(aBrowser.ownerGlobal);
       this.captureToCanvas(aBrowser, canvas, () => {
         canvas.toBlob(blob => {
           resolve(blob, this.contentType);
         });
       });
     });
   },
 
@@ -256,17 +256,17 @@ var PageThumbs = {
         aCanvas.getContext("2d").putImageData(imgData, 0, 0);
         if (aCallback) {
           aCallback(aCanvas);
         }
       })();
       return;
     }
     // The content is a local page, grab a thumbnail sync.
-    PageThumbUtils.createSnapshotThumbnail(aBrowser.contentWindow,
+    PageThumbUtils.createSnapshotThumbnail(aBrowser.ownerGlobal,
                                            aCanvas,
                                            aArgs);
 
     if (aCallback) {
       aCallback(aCanvas);
     }
   },