Bug 1343507 - Search settings button moves to its own line with 150% zoom follow-up. r=florian
authorDrew Willcoxon <adw@mozilla.com>
Wed, 01 Mar 2017 06:31:40 -0800
changeset 374417 99aabb33581ad1f67728f3f20a04888d6efafb03
parent 374416 47c6c4caad99d65ff37e5494e253fd7d408d617b
child 374418 caacf82afba18ddcbab61f3cc486f9b98f98e279
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1343507
milestone54.0a1
Bug 1343507 - Search settings button moves to its own line with 150% zoom follow-up. r=florian MozReview-Commit-ID: LGSiMzW6AT9
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -1560,28 +1560,29 @@
             this.settingsButton.setAttribute("width", buttonWidth);
             if (rowCount == 1 && hasDummyItems) {
               // When there's only one row, make the compact settings button
               // hug the right edge of the panel.  It may not due to the panel's
               // width not being an integral multiple of the button width.  (See
               // the "There will be an emtpy area" comment above.)  Increase the
               // width of the last dummy item by the remainder.
               //
-              // There's one weird thing to guard against.  When layout pixels
-              // aren't an integral multiple of device pixels, the calculated
-              // remainder can end up being ~1px too big, at least on Windows,
-              // which pushes the settings button to a new row.  The remainder
-              // is integral, not a fraction, so that's not the problem.  To
-              // work around that, unscale the remainder, floor it, scale it
-              // back, and then floor that.
+              // There's one weird thing to guard against: when layout pixels
+              // aren't an integral multiple of device pixels, the settings
+              // button sometimes gets pushed to a new row, depending on the
+              // panel and button widths.  It's as if `remainder` is somehow
+              // too big, even though it's an integer.  To work around that,
+              // decrement the remainder if the scale is not an integer.
               let scale = window.QueryInterface(Ci.nsIInterfaceRequestor)
                                 .getInterface(Ci.nsIDOMWindowUtils)
                                 .screenPixelsPerCSSPixel;
               let remainder = panelWidth - (enginesPerRow * buttonWidth);
-              remainder = Math.floor(Math.floor(remainder * scale) / scale);
+              if (Math.floor(scale) != scale) {
+                remainder--;
+              }
               let width = remainder + buttonWidth;
               let lastDummyItem = this.settingsButton.previousSibling;
               lastDummyItem.setAttribute("width", width);
             }
           }
         ]]></body>
       </method>