Merge mozilla-inbound to mozilla-central. a=merge
authorCosmin Sabou <csabou@mozilla.com>
Tue, 14 May 2019 18:59:38 +0300
changeset 532620 b0645d43f221993cd1810a50c27abbf3a34f3055
parent 532601 230016dbba05b36ecc1ccada9abdc2d5370a0ae7 (current diff)
parent 532619 1327c28c7bd14cf2b4e8de9e6e33b19d7514a7f7 (diff)
child 532621 2659abca52029881f180395cc0edb45b5292d25d
child 532661 ca0a32144a35f52ab1fce6a348f4bd047542289b
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone68.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
Merge mozilla-inbound to mozilla-central. a=merge
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -139,18 +139,32 @@ static void TexSubImage2DWithUnpackSubim
 static void TexSubImage2DWithoutUnpackSubimage(
     GLContext* gl, GLenum target, GLint level, GLint xoffset, GLint yoffset,
     GLsizei width, GLsizei height, GLsizei stride, GLint pixelsize,
     GLenum format, GLenum type, const GLvoid* pixels) {
   // Not using the whole row of texture data and GL_UNPACK_ROW_LENGTH
   // isn't supported. We make a copy of the texture data we're using,
   // such that we're using the whole row of data in the copy. This turns
   // out to be more efficient than uploading row-by-row; see bug 698197.
-  unsigned char* newPixels =
-      new (fallible) unsigned char[width * height * pixelsize];
+
+  // Width and height are never more than 16384. At 16Ki*16Ki, 4bpp is 1GiB, but
+  // if we allow 8bpp (or higher) here, that's 2GiB, which would overflow on
+  // 32-bit.
+  MOZ_ASSERT(width <= 16384);
+  MOZ_ASSERT(height <= 16384);
+  MOZ_ASSERT(pixelsize < 8);
+
+  const auto size = CheckedInt<size_t>(width) * height * pixelsize;
+  if (!size.isValid()) {
+    // This should never happen, but we use a defensive check.
+    MOZ_ASSERT_UNREACHABLE("Unacceptable size calculated.!");
+    return;
+  }
+
+  unsigned char* newPixels = new (fallible) unsigned char[size.value()];
 
   if (newPixels) {
     unsigned char* rowDest = newPixels;
     const unsigned char* rowSource = (const unsigned char*)pixels;
     for (int h = 0; h < height; h++) {
       memcpy(rowDest, rowSource, width * pixelsize);
       rowDest += width * pixelsize;
       rowSource += stride;
@@ -235,18 +249,32 @@ static void TexImage2DHelper(GLContext* 
     if (!CanUploadNonPowerOfTwo(gl) &&
         (stride != width * pixelsize || !IsPowerOfTwo((uint32_t)width) ||
          !IsPowerOfTwo((uint32_t)height))) {
       // Pad out texture width and height to the next power of two
       // as we don't support/want non power of two texture uploads
       GLsizei paddedWidth = RoundUpPow2((uint32_t)width);
       GLsizei paddedHeight = RoundUpPow2((uint32_t)height);
 
-      GLvoid* paddedPixels =
-          new unsigned char[paddedWidth * paddedHeight * pixelsize];
+      // Width and height are never more than 16384. At 16Ki*16Ki, 4bpp is 1GiB,
+      // but if we allow 8bpp (or higher) here, that's 2GiB, which would
+      // overflow on 32-bit.
+      MOZ_ASSERT(width <= 16384);
+      MOZ_ASSERT(height <= 16384);
+      MOZ_ASSERT(pixelsize < 8);
+
+      const auto size =
+          CheckedInt<size_t>(paddedWidth) * paddedHeight * pixelsize;
+      if (!size.isValid()) {
+        // This should never happen, but we use a defensive check.
+        MOZ_ASSERT_UNREACHABLE("Unacceptable size calculated.!");
+        return;
+      }
+
+      GLvoid* paddedPixels = new unsigned char[size.value()];
 
       // Pad out texture data to be in a POT sized buffer for uploading to
       // a POT sized texture
       CopyAndPadTextureData(pixels, paddedPixels, width, height, paddedWidth,
                             paddedHeight, stride, pixelsize);
 
       gl->fPixelStorei(
           LOCAL_GL_UNPACK_ALIGNMENT,
@@ -378,23 +406,27 @@ SurfaceFormat UploadImageDataToTexture(
       format = LOCAL_GL_LUMINANCE;
       internalFormat = LOCAL_GL_LUMINANCE16;
       type = LOCAL_GL_UNSIGNED_SHORT;
       // We don't have a specific luminance shader
       surfaceFormat = SurfaceFormat::A8;
       pixelSize = 2;
       break;
     default:
-      NS_ASSERTION(false, "Unhandled image surface format!");
+      MOZ_ASSERT_UNREACHABLE("Unhandled image surface format!");
   }
 
   if (aOutUploadSize) {
     *aOutUploadSize = 0;
   }
 
+  if (surfaceFormat == gfx::SurfaceFormat::UNKNOWN) {
+    return gfx::SurfaceFormat::UNKNOWN;
+  }
+
   if (aNeedInit || !CanUploadSubTextures(gl)) {
     // If the texture needs initialized, or we are unable to
     // upload sub textures, then initialize and upload the entire
     // texture.
     TexImage2DHelper(gl, aTextureTarget, 0, internalFormat, aSize.width,
                      aSize.height, aStride, pixelSize, 0, format, type, aData);
 
     if (aOutUploadSize && aNeedInit) {
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -1227,17 +1227,17 @@ void nsPrintJob::ShowPrintProgress(bool 
         // Showing a print progress dialog when printing a modal window
         // isn't supported. See bug 301560.
         return;
       }
 
       nsCOMPtr<nsIWebProgressListener> printProgressListener;
 
       nsCOMPtr<nsIWebBrowserPrint> wbp(do_QueryInterface(mDocViewerPrint));
-      nsresult rv = printPromptService->ShowProgress(
+      nsresult rv = printPromptService->ShowPrintProgressDialog(
           domWin, wbp, printData->mPrintSettings, this, aIsForPrinting,
           getter_AddRefs(printProgressListener),
           getter_AddRefs(printData->mPrintProgressParams), &aDoNotify);
       if (NS_SUCCEEDED(rv)) {
         if (printProgressListener) {
           printData->mPrintProgressListeners.AppendObject(
               printProgressListener);
         }
--- a/toolkit/components/browser/nsIPrintingPromptService.idl
+++ b/toolkit/components/browser/nsIPrintingPromptService.idl
@@ -30,19 +30,19 @@ interface nsIPrintingPromptService : nsI
    *           native Print Dialog.
    *           If an embedder implemented service returns any error code (other than NS_ERROR_ABORT)
    *           printing will terminate.
    *
    *           Returning NS_OK assumes that the PrintSettings object was correctly filled in and
    *           if it does not have valid fields for printer name, etc. it may also terminate.
    *
    *           Defaults for platform service:           
-   *             showPrintDialog       - displays a native dialog
-   *             showPageSetup         - displays a XUL dialog
-   *             showProgress          - displays a XUL dialog
+   *             showPrintDialog           - displays a native dialog
+   *             showPrintProgressDialog   - displays a XUL dialog
+   *             showPageSetupDialog       - displays a XUL dialog
    *
    *           Summary for Windows Embedders:
    *             Stated once again: There is no "fallback" native platform support in GFX for the
    *             displaying of the native print dialog. The current default implementation for Windows
    *             display a native print dialog but a XUL-based progress dialog.
    *             If you wish to have a native progress dialog on Windows you will have to create and 
    *             register your own service.
    *  
@@ -63,31 +63,26 @@ interface nsIPrintingPromptService : nsI
    *                 before calling nsIWebBrowserPrint's Print method. If you stub out this service  
    *                 you MUST set "printSilent" to true, if you do not, Printing will terminate and an 
    *                 error dialog will be displayed.
    *
    *  Mac: The GFX layer still supports default toolkit behavior for displaying the Print Dialog.
    *       If an embedder implemented service returns NS_ERROR_NOT_IMPLEMENTED for "showPrintDialog"
    *       The toolkit will display the native print dialog.
    *
-   *       Defaults for platform service:           
-   *       Mac OS9: showPrintDialog       - displays a native dialog
-   *                showPageSetup         - displays a native dialog
-   *                showProgress          - displays a XUL dialog
-   *
-   *       Mac OSX: showPrintDialog       - displays a native dialog
-   *                showPageSetup         - displays a native dialog
-   *                showProgress          - not implemented (provided by OS)
+   *       Mac OSX: showPrintDialog           - displays a native dialog
+   *                showPrintProgressDialog   - not implemented (provided by OS)
+   *                showPageSetupDialog       - displays a native dialog
    *
    *  GTK: There are no native dialog for GTK.
    *
    *       Defaults for platform service:
-   *         showPrintDialog       - displays a native dialog
-   *         showPageSetup         - displays a native dialog
-   *         showProgress          - displays a XUL dialog
+   *         showPrintDialog           - displays a native dialog
+   *         showPrintProgressDialog   - displays a XUL dialog
+   *         showPageSetupDialog       - displays a native dialog
    *
    */
  
 
 
   /**
    *  Show the Print Dialog 
    *
@@ -110,33 +105,33 @@ interface nsIPrintingPromptService : nsI
    *  @param isForPrinting - true - for printing, false for print preview
    *  @param webProgressListener - additional listener can be registered for progress notifications
    *  @param printProgressParams - parameter object for passing progress state
    *  @param notifyOnOpen - this indicates that the observer will be notified when the progress
    *                        dialog has been opened. If false is returned it means the observer
    *                        (usually the caller) shouldn't wait
    *                        For Print Preview Progress there is intermediate progress
    */
-  void showProgress(in mozIDOMWindowProxy parent,
-                    in nsIWebBrowserPrint webBrowserPrint,
-                    in nsIPrintSettings printSettings,
-                    in nsIObserver openDialogObserver,
-                    in boolean isForPrinting,
-                    out nsIWebProgressListener webProgressListener,
-                    out nsIPrintProgressParams printProgressParams,
-                    out boolean notifyOnOpen);
+  void showPrintProgressDialog(in mozIDOMWindowProxy parent,
+                               in nsIWebBrowserPrint webBrowserPrint,
+                               in nsIPrintSettings printSettings,
+                               in nsIObserver openDialogObserver,
+                               in boolean isForPrinting,
+                               out nsIWebProgressListener webProgressListener,
+                               out nsIPrintProgressParams printProgressParams,
+                               out boolean notifyOnOpen);
 
   /**
-   *  Shows the print progress dialog
+   *  Shows the print page setup dialog
    *
    *  @param parent - a DOM windows the dialog will be parented to (required)
    *  @param printSettings - PrintSettings for page setup (required)
    */
-  void showPageSetup(in mozIDOMWindowProxy parent,
-                     in nsIPrintSettings printSettings);
+  void showPageSetupDialog(in mozIDOMWindowProxy parent,
+                           in nsIPrintSettings printSettings);
 
 };
 
 %{C++
 // {260FEDC5-524D-4aa6-9A41-E829F4C78B92}
 #define NS_PRINTINGPROMPTSERVICE_IID \
  {0x260fedc5, 0x524d, 0x4aa6, { 0x9a, 0x41, 0xe8, 0x29, 0xf4, 0xc7, 0x8b, 0x92}}
 %}
--- a/toolkit/components/printing/content/printUtils.js
+++ b/toolkit/components/printing/content/printUtils.js
@@ -82,17 +82,17 @@ var PrintUtils = {
    *
    * @return true on success, false on failure
    */
   showPageSetup() {
     try {
       var printSettings = this.getPrintSettings();
       var PRINTPROMPTSVC = Cc["@mozilla.org/embedcomp/printingprompt-service;1"]
                              .getService(Ci.nsIPrintingPromptService);
-      PRINTPROMPTSVC.showPageSetup(window, printSettings, null);
+      PRINTPROMPTSVC.showPageSetupDialog(window, printSettings, null);
       if (gSavePrintSettings) {
         // Page Setup data is a "native" setting on the Mac
         var PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
                       .getService(Ci.nsIPrintSettingsService);
         PSSVC.savePrintSettingsToPrefs(printSettings, true, printSettings.kInitSaveNativeData);
       }
     } catch (e) {
       dump("showPageSetup " + e + "\n");
@@ -212,18 +212,18 @@ var PrintUtils = {
     // automatically opened from the print engine because the XUL scrollbars in the PP window
     // will layout before the content window and a crash will occur.
     // Doing it all from script, means it lays out before hand and we can let printing do its own thing
     let PPROMPTSVC = Cc["@mozilla.org/embedcomp/printingprompt-service;1"]
                        .getService(Ci.nsIPrintingPromptService);
     // just in case we are already printing,
     // an error code could be returned if the Progress Dialog is already displayed
     try {
-      PPROMPTSVC.showProgress(window, null, printSettings, this._obsPP, false,
-                              this._webProgressPP, ppParams, notifyOnOpen);
+      PPROMPTSVC.showPrintProgressDialog(window, null, printSettings, this._obsPP, false,
+                                         this._webProgressPP, ppParams, notifyOnOpen);
       if (ppParams.value) {
         ppParams.value.docTitle = this._originalTitle;
         ppParams.value.docURL   = this._originalURL;
       }
 
       // this tells us whether we should continue on with PP or
       // wait for the callback via the observer
       if (!notifyOnOpen.value.valueOf() || this._webProgressPP.value == null) {
@@ -419,17 +419,17 @@ var PrintUtils = {
   *        References the current print preview browser that is being presented.
   */
   _ppBrowsers: new Set(),
   _currentPPBrowser: null,
 
   enterPrintPreview() {
     // Send a message to the print preview browser to initialize
     // print preview. If we happen to have gotten a print preview
-    // progress listener from nsIPrintingPromptService.showProgress
+    // progress listener from nsIPrintingPromptService.showPrintProgressDialog
     // in printPreview, we add listeners to feed that progress
     // listener.
     let ppBrowser = this._shouldSimplify ?
       this._listener.getSimplifiedPrintPreviewBrowser() :
       this._listener.getPrintPreviewBrowser();
     this._ppBrowsers.add(ppBrowser);
 
     // If we're switching from 'normal' print preview to 'simplified' print
--- a/toolkit/components/printingui/ipc/PrintingParent.cpp
+++ b/toolkit/components/printingui/ipc/PrintingParent.cpp
@@ -42,19 +42,20 @@ mozilla::ipc::IPCResult PrintingParent::
       static_cast<PrintProgressDialogParent*>(printProgressDialog);
   nsCOMPtr<nsIObserver> observer = dialogParent;
 
   nsCOMPtr<nsIWebProgressListener> printProgressListener;
   nsCOMPtr<nsIPrintProgressParams> printProgressParams;
 
   nsresult rv = NS_ERROR_INVALID_ARG;
   if (parentWin && pps) {
-    rv = pps->ShowProgress(parentWin, nullptr, nullptr, observer, isForPrinting,
-                           getter_AddRefs(printProgressListener),
-                           getter_AddRefs(printProgressParams), &notifyOnOpen);
+    rv = pps->ShowPrintProgressDialog(
+        parentWin, nullptr, nullptr, observer, isForPrinting,
+        getter_AddRefs(printProgressListener),
+        getter_AddRefs(printProgressParams), &notifyOnOpen);
   }
 
   if (NS_SUCCEEDED(rv)) {
     if (remotePrintJob) {
       // If we have a RemotePrintJob use that as a more general forwarder for
       // print progress listeners.
       static_cast<RemotePrintJobParent*>(remotePrintJob)
           ->RegisterListener(printProgressListener);
--- a/toolkit/components/printingui/ipc/nsPrintingProxy.cpp
+++ b/toolkit/components/printingui/ipc/nsPrintingProxy.cpp
@@ -116,17 +116,17 @@ nsPrintingProxy::ShowPrintDialog(mozIDOM
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = printSettingsSvc->DeserializeToPrintSettings(dialog->data(),
                                                     printSettings);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPrintingProxy::ShowProgress(
+nsPrintingProxy::ShowPrintProgressDialog(
     mozIDOMWindowProxy* parent,
     nsIWebBrowserPrint* webBrowserPrint,  // ok to be null
     nsIPrintSettings* printSettings,      // ok to be null
     nsIObserver* openDialogObserver,      // ok to be null
     bool isForPrinting, nsIWebProgressListener** webProgressListener,
     nsIPrintProgressParams** printProgressParams, bool* notifyOnOpen) {
   NS_ENSURE_ARG(parent);
   NS_ENSURE_ARG(webProgressListener);
@@ -171,18 +171,18 @@ nsPrintingProxy::ShowProgress(
     NS_ADDREF(*webProgressListener = dialogChild);
   }
   NS_ADDREF(*printProgressParams = dialogChild);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPrintingProxy::ShowPageSetup(mozIDOMWindowProxy* parent,
-                               nsIPrintSettings* printSettings) {
+nsPrintingProxy::ShowPageSetupDialog(mozIDOMWindowProxy* parent,
+                                     nsIPrintSettings* printSettings) {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 nsresult nsPrintingProxy::SavePrintSettings(nsIPrintSettings* aPS,
                                             bool aUsePrinterNamePrefix,
                                             uint32_t aFlags) {
   nsresult rv;
   nsCOMPtr<nsIPrintSettingsService> printSettingsSvc =
--- a/toolkit/components/printingui/nsPrintingPromptService.cpp
+++ b/toolkit/components/printingui/nsPrintingPromptService.cpp
@@ -75,17 +75,17 @@ nsPrintingPromptService::ShowPrintDialog
   if (dlgPrint)
     return dlgPrint->Show(nsPIDOMWindowOuter::From(parent), printSettings,
                           webBrowserPrint);
 
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsPrintingPromptService::ShowProgress(
+nsPrintingPromptService::ShowPrintProgressDialog(
     mozIDOMWindowProxy* parent,
     nsIWebBrowserPrint* webBrowserPrint,  // ok to be null
     nsIPrintSettings* printSettings,      // ok to be null
     nsIObserver* openDialogObserver,      // ok to be null
     bool isForPrinting, nsIWebProgressListener** webProgressListener,
     nsIPrintProgressParams** printProgressParams, bool* notifyOnOpen) {
 #if !defined(XP_MACOSX)
   NS_ENSURE_ARG(webProgressListener);
@@ -124,18 +124,18 @@ nsPrintingPromptService::ShowProgress(
 
   return NS_OK;
 #else
   return NS_ERROR_NOT_IMPLEMENTED;
 #endif
 }
 
 NS_IMETHODIMP
-nsPrintingPromptService::ShowPageSetup(mozIDOMWindowProxy* parent,
-                                       nsIPrintSettings* printSettings) {
+nsPrintingPromptService::ShowPageSetupDialog(mozIDOMWindowProxy* parent,
+                                             nsIPrintSettings* printSettings) {
   NS_ENSURE_ARG(printSettings);
 
   nsCOMPtr<nsIPrintDialogService> dlgPrint(
       do_GetService(NS_PRINTDIALOGSERVICE_CONTRACTID));
   if (dlgPrint)
     return dlgPrint->ShowPageSetup(nsPIDOMWindowOuter::From(parent),
                                    printSettings);