Bug 1343507 - Search settings button moves to its own line with 150% zoom follow-up. r?florian draft
authorDrew Willcoxon <adw@mozilla.com>
Wed, 01 Mar 2017 06:31:40 -0800
changeset 490915 dfde0912705c760bd92ffc306caac19b5f474e52
parent 490871 34c6c2f302e7b48e3ad2cec575cbd34d423a9d32
child 547419 854adf1775df5c08e88eb3c0f209ea24814011f3
push id47272
push userdwillcoxon@mozilla.com
push dateWed, 01 Mar 2017 14:32:49 +0000
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>