Bug 983689 - Preferences window is not constrained by screen size and cut off on netbooks. r=Ratty, a=Ratty
authorrsx11m <rsx11m.pub@gmail.com>
Tue, 24 May 2016 21:35:07 -0500
changeset 24894 a90c9c5b546db9d8a38c97c9100ccc0023b872b7
parent 24893 06c3aadde9bf312e681fd0e12bb253075b204b5a
child 24895 6b5d77e05325d3d6f3fd8d0bbb47a1b0b3d236e9
push id1657
push userclokep@gmail.com
push dateMon, 06 Jun 2016 19:50:21 +0000
treeherdercomm-beta@9fac989284b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ratty
bugs983689
Bug 983689 - Preferences window is not constrained by screen size and cut off on netbooks. r=Ratty, a=Ratty
suite/common/bindings/prefwindow.xml
suite/common/communicator.css
suite/common/pref/preferences.js
suite/common/pref/preferences.xul
--- a/suite/common/bindings/prefwindow.xml
+++ b/suite/common/bindings/prefwindow.xml
@@ -372,20 +372,23 @@
 
               // mark selected pane in navigation tree
               var index = this._navigationTree.contentView
                               .getIndexOfItem(aPane.preftreeitem);
               this._navigationTree.view.selection.select(index);
             }
           }
           this.setPaneTitle(aPane);
-          if (this.scrollHeight > window.innerHeight)
-            window.innerHeight = this.scrollHeight;
-          if (this.scrollWidth > window.innerWidth)
-            window.innerWidth = this.scrollWidth;
+          if (this.getAttribute("overflow") != "auto")
+          {
+            if (this.scrollHeight > window.innerHeight)
+              window.innerHeight = this.scrollHeight;
+            if (this.scrollWidth > window.innerWidth)
+              window.innerWidth = this.scrollWidth;
+          }
         ]]>
         </body>
       </method>
 
     <!-- copied from contextHelp.js
          Locate existing help window for this helpFileURI. -->
       <method name="locateHelpWindow">
         <parameter name="helpFileURI"/>
--- a/suite/common/communicator.css
+++ b/suite/common/communicator.css
@@ -115,16 +115,21 @@ findbar {
   -moz-binding: url("chrome://communicator/content/bindings/findbar.xml#findbar");
 }
 
 prefwindow > .paneDeckContainer,
 prefpane > .content-box {
   overflow: visible;
 }
 
+prefwindow[overflow="auto"] > .paneDeckContainer,
+prefwindow[overflow="auto"] prefpane > .content-box {
+  overflow: auto;
+}
+
 .statusbarpanel-backgroundbox {
   -moz-binding: url("chrome://communicator/content/bindings/general.xml#statusbarpanel-backgroundbox");
 }
 
 textbox[enablehistory="true"] > .autocomplete-history-dropmarker {
   display: -moz-box;
 }
 
--- a/suite/common/pref/preferences.js
+++ b/suite/common/pref/preferences.js
@@ -1,16 +1,38 @@
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // The content of this file is loaded into the scope of the
 // prefwindow and will be available to all prefpanes!
 
+function OnLoad()
+{
+  // Make sure that the preferences window fits the screen.
+  let dialog    = document.documentElement;
+  let curHeight = dialog.scrollHeight;
+  let curWidth  = dialog.scrollWidth;
+
+  // Leave some space for desktop toolbar and window decoration.
+  let maxHeight = window.screen.availHeight - 48;
+  let maxWidth  = window.screen.availWidth  - 24;
+
+  // Trigger overflow situation within 40px for bug 868495 expansions.
+  let setHeight = curHeight > maxHeight - 40 ? maxHeight : curHeight;
+  let setWidth  = curWidth  > maxWidth ? maxWidth : curWidth;
+
+  if (setHeight == curHeight && setWidth == curWidth)
+    dialog.setAttribute("overflow", "visible");
+
+  window.innerHeight = setHeight;
+  window.innerWidth  = setWidth;
+}
+
 function EnableElementById(aElementId, aEnable, aFocus)
 {
   EnableElement(document.getElementById(aElementId), aEnable, aFocus);
 }
 
 function EnableElement(aElement, aEnable, aFocus)
 {
   let pref = document.getElementById(aElement.getAttribute("preference"));
--- a/suite/common/pref/preferences.xul
+++ b/suite/common/pref/preferences.xul
@@ -14,16 +14,18 @@
   <!ENTITY % dtdPrefs    SYSTEM "chrome://communicator/locale/pref/preferences.dtd"> %dtdPrefs;
   <!ENTITY % dtdPlatform SYSTEM "chrome://communicator-platform/locale/pref/platformPrefOverlay.dtd"> %dtdPlatform;
 ]>
 
 <prefwindow id="prefDialog" 
             xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
             title="&prefWindow.title;" 
             style="&prefWindow.size;"
+            overflow="auto"
+            onload="OnLoad();"
             windowtype="mozilla:preferences"
             buttons="accept,cancel,help"
             autopanes="true"> 
 
   <script type="application/javascript" src="chrome://communicator/content/pref/preferences.js"/>
   <!-- Used by pref-smartupdate, pref-privatedata, pref-cookies, pref-images, pref-popups and pref-passwords, as well as pref-sync (gSyncUtils.*open* -> openUILinkIn) -->
   <script type="application/javascript" src="chrome://communicator/content/utilityOverlay.js"/>
   <script type="application/javascript" src="chrome://communicator/content/tasksOverlay.js"/>