Bug 1506835 - Resize browser languages dialog when error appears r=jaws
authorMark Striemer <mstriemer@mozilla.com>
Fri, 30 Nov 2018 19:37:41 +0000
changeset 505537 5f0040d4be16cc77f49209551a4f7d03697a98fc
parent 505536 d244292c2a127fafda775e1db5e0a8e4decea5ff
child 505538 dddf315cfaa2d25019b82b8dcfebe88850ed27be
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1506835
milestone65.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 1506835 - Resize browser languages dialog when error appears r=jaws *** Differential Revision: https://phabricator.services.mozilla.com/D12985
browser/components/preferences/browserLanguages.js
browser/components/preferences/browserLanguages.xul
browser/components/preferences/in-content/subdialogs.js
browser/themes/shared/incontentprefs/preferences.inc.css
--- a/browser/components/preferences/browserLanguages.js
+++ b/browser/components/preferences/browserLanguages.js
@@ -506,25 +506,30 @@ var gBrowserLanguagesDialog = {
       await Promise.all(addonInfos.map(
         info => installFromUrl(info.sourceURI.spec)));
     } catch (e) {
       Cu.reportError(e);
     }
   },
 
   showError() {
-    document.querySelectorAll(".warning-message-separator")
-      .forEach(separator => separator.classList.add("thin"));
     document.getElementById("warning-message").hidden = false;
     this._availableLocales.enableWithMessageId("browser-languages-select-language");
+
+    // The height has likely changed, find our SubDialog and tell it to resize.
+    requestAnimationFrame(() => {
+      let dialogs = window.opener.gSubDialog._dialogs;
+      let index = dialogs.findIndex(d => d._frame.contentDocument == document);
+      if (index != -1) {
+        dialogs[index].resizeDialog();
+      }
+    });
   },
 
   hideError() {
-    document.querySelectorAll(".warning-message-separator")
-      .forEach(separator => separator.classList.remove("thin"));
     document.getElementById("warning-message").hidden = true;
   },
 
   getSelectedLocales() {
     return this._selectedLocales.items.map(item => item.value);
   },
 
   async selectedLocaleRemoved(item) {
--- a/browser/components/preferences/browserLanguages.xul
+++ b/browser/components/preferences/browserLanguages.xul
@@ -53,15 +53,13 @@
         </menulist>
         <button id="add"
                 class="add-browser-language action-button"
                 data-l10n-id="languages-customize-add"
                 disabled="true"/>
       </row>
     </rows>
   </grid>
-  <separator class="warning-message-separator"/>
   <hbox id="warning-message" class="message-bar message-bar-warning" hidden="true">
     <image class="message-bar-icon"/>
     <description class="message-bar-description" data-l10n-id="browser-languages-error"/>
   </hbox>
-  <separator class="warning-message-separator"/>
 </dialog>
--- a/browser/components/preferences/in-content/subdialogs.js
+++ b/browser/components/preferences/in-content/subdialogs.js
@@ -274,16 +274,20 @@ SubDialog.prototype = {
     // Some subdialogs may want to perform additional, asynchronous steps during initializations.
     //
     // In that case, we expect them to define a Promise which will delay measuring
     // until the promise is fulfilled.
     if (aEvent.target.contentDocument.mozSubdialogReady) {
       await aEvent.target.contentDocument.mozSubdialogReady;
     }
 
+    await this.resizeDialog();
+  },
+
+  async resizeDialog() {
     // Do this on load to wait for the CSS to load and apply before calculating the size.
     let docEl = this._frame.contentDocument.documentElement;
 
     let titleBarHeight = this._titleBar.clientHeight +
                          parseFloat(getComputedStyle(this._titleBar).borderBottomWidth);
 
     // These are deduced from styles which we don't change, so it's safe to get them now:
     let boxHorizontalBorder = 2 * parseFloat(getComputedStyle(this._box).borderLeftWidth);
--- a/browser/themes/shared/incontentprefs/preferences.inc.css
+++ b/browser/themes/shared/incontentprefs/preferences.inc.css
@@ -852,30 +852,34 @@ menulist[indicator=true] > menupopup men
   margin-inline-start: 0;
 }
 
 #LanguagesDialog > .dialog-button-box > .dialog-button[dlgtype="accept"],
 #BrowserLanguagesDialog > .dialog-button-box > .dialog-button[dlgtype="accept"] {
   margin-inline-end: 0;
 }
 
-#requestedLocales {
-  min-height: 200px;
+#selectedLocales {
+  height: 150px;
 }
 
 #availableLanguages,
 #availableLocales {
   margin: 0;
   margin-inline-end: 4px;
 }
 
 #warning-message > .message-bar-description {
   width: 32em;
 }
 
+#warning-message {
+  margin-top: 8px;
+}
+
 .add-web-language,
 .add-browser-language {
   margin: 0;
   margin-inline-start: 4px;
 }
 
 .action-button {
   margin-inline-end: 0;