gfx/cairo/zero-sized.patch
author Gijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 16 Jan 2020 17:41:25 +0000
changeset 571219 80536bfbcd6902b1cf9a5a1302735eb9fe7b0024
parent 26419 1effb72d30cf6b7701485e450b87bddcb7e9891d
permissions -rw-r--r--
Bug 1609466 - offer 'open with' options even when Windows is clueless about the mimetype, r=bzbarsky a=RyanVM We currently fail to offer 'open with' options for application/zip mimetype .zip files, because out of the box, the Windows registry does not contain mimetype entries for application/zip. In fact, it contains comparatively few entries, and right now we bail out with an empty mime info object if we cannot find the server-provided mimetype in the registry (or cannot find an associated extension for that mimetype). Prior to the changes from bug 1597985, we would first try to find a handler based on the default extension for the mimetype, and used the file extension if that failed. The changes in this commit will cause us to fetch the default file extension for the mimetype, but continue with the provided extension if no mimetype information is available, restoring functionality in the case where Windows has no mimetype information. Differential Revision: https://phabricator.services.mozilla.com/D60139

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index e9e544d..cde68a1 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -324,8 +324,8 @@ _cairo_image_surface_create_with_pixman_format (unsigned char		*data,
     cairo_surface_t *surface;
     pixman_image_t *pixman_image;
 
-    pixman_image = pixman_image_create_bits (pixman_format, width, height,
-					     (uint32_t *) data, stride);
+    pixman_image = pixman_image_create_bits (pixman_format, width ? width : 1, height ? height : 1,
+					     (uint32_t *) data, stride ? stride : 4);
 
     if (unlikely (pixman_image == NULL))
 	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index f86a133..ddcb600 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -675,7 +675,8 @@ _get_image_surface (cairo_xlib_surface_t    *surface,
 
 	pixmap = XCreatePixmap (surface->dpy,
 				surface->drawable,
-				extents.width, extents.height,
+				extents.width <= 0 ? 1 : extents.width,
+				extents.height <= 0 ? 1 : extents.height,
 				surface->depth);
 	if (pixmap) {
 	    XCopyArea (surface->dpy, surface->drawable, pixmap, surface->gc,
@@ -686,7 +687,8 @@ _get_image_surface (cairo_xlib_surface_t    *surface,
 	    ximage = XGetImage (surface->dpy,
 				pixmap,
 				0, 0,
-				extents.width, extents.height,
+				extents.width <= 0 ? 1 : extents.width,
+				extents.height <= 0 ? 1 : extents.height,
 				AllPlanes, ZPixmap);
 
 	    XFreePixmap (surface->dpy, pixmap);