Bug 1427512 - Followup fix for macOS test failure.
authorCameron McCormack <cam@mcc.id.au>
Fri, 12 Jan 2018 13:39:49 +0800
changeset 450713 3776f91840a4c641317b4719332a5103e317f6bb
parent 450712 5150651a530bb2d7b55fe86709d8c7e1de28de1e
child 450715 d2edd256c3aadb1cea48da0c8f62f725bd53cb76
child 450810 3db5dd3a6fe64dd31129fdaa2e2015b93801c675
push id8531
push userryanvm@gmail.com
push dateFri, 12 Jan 2018 16:47:01 +0000
treeherdermozilla-beta@0bc627ade5a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1427512
milestone59.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 1427512 - Followup fix for macOS test failure.
widget/cocoa/nsMenuItemIconX.mm
--- a/widget/cocoa/nsMenuItemIconX.mm
+++ b/widget/cocoa/nsMenuItemIconX.mm
@@ -187,21 +187,25 @@ nsMenuItemIconX::GetIconURI(nsIURI** aIc
 
   if (!hasImageAttr) {
     // Check if the icon has a specified image region so that it can be
     // cropped appropriately before being displayed.
     const nsRect& r = sc->StyleList()->mImageRegion;
 
     // Return NS_ERROR_FAILURE if the image region is invalid so the image
     // is not drawn, and behavior is similar to XUL menus.
-    if (r.X() < 0 || r.Y() < 0 || r.IsEmpty()) {
+    if (r.X() < 0 || r.Y() < 0 || r.Width() < 0 || r.Height() < 0) {
       return NS_ERROR_FAILURE;
     }
 
-    mImageRegionRect = r.ToNearestPixels(mozilla::AppUnitsPerCSSPixel());
+    // 'auto' is represented by a [0, 0, 0, 0] rect. Only set mImageRegionRect
+    // if we have some other value.
+    if (!r.IsEmpty()) {
+      mImageRegionRect = r.ToNearestPixels(mozilla::AppUnitsPerCSSPixel());
+    }
   }
 
   return NS_OK;
 }
 
 nsresult
 nsMenuItemIconX::LoadIcon(nsIURI* aIconURI)
 {