|
@@ -0,0 +1,161 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Frank-Rainer Grahl <frgrahl@gmx.net>
|
|
|
+# Date 1717784005 -7200
|
|
|
+# Parent 5b694f62d1fbdab4f6a442b7da0885e1837ed628
|
|
|
+Bug 1437393 - Add missing brackets around one liners. r=IanN a= IanN
|
|
|
+
|
|
|
+Also make sure statements are confined to 80 columns. Only the prefs are not.
|
|
|
+
|
|
|
+diff --git a/suite/components/pref/content/pref-fonts.js b/suite/components/pref/content/pref-fonts.js
|
|
|
+--- a/suite/components/pref/content/pref-fonts.js
|
|
|
++++ b/suite/components/pref/content/pref-fonts.js
|
|
|
+@@ -1,43 +1,45 @@
|
|
|
+-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
+ /* 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/. */
|
|
|
++ * 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/. */
|
|
|
+
|
|
|
+ var gFontsDialog = {
|
|
|
+ _disabled: false,
|
|
|
+ _enumerator: null,
|
|
|
+ get enumerator() {
|
|
|
+ if (!this._enumerator) {
|
|
|
+ this._enumerator = Cc["@mozilla.org/gfx/fontenumerator;1"]
|
|
|
+ .createInstance(Ci.nsIFontEnumerator);
|
|
|
+ }
|
|
|
+ return this._enumerator;
|
|
|
+ },
|
|
|
+
|
|
|
+ _allFonts: null,
|
|
|
+ async buildFontList(aLanguage, aFontType, aMenuList) {
|
|
|
+ // Reset the list
|
|
|
+- while (aMenuList.hasChildNodes())
|
|
|
++ while (aMenuList.hasChildNodes()) {
|
|
|
+ aMenuList.firstChild.remove();
|
|
|
++ }
|
|
|
+
|
|
|
+ let defaultFont = null;
|
|
|
+ // Load Font Lists
|
|
|
+- let fonts = await this.enumerator.EnumerateFontsAsync(aLanguage, aFontType);
|
|
|
++ let fonts = await this.enumerator.EnumerateFontsAsync(aLanguage,
|
|
|
++ aFontType);
|
|
|
+ if (fonts.length > 0) {
|
|
|
+ defaultFont = this.enumerator.getDefaultFont(aLanguage, aFontType);
|
|
|
+ } else {
|
|
|
+ fonts = await this.enumerator.EnumerateFontsAsync(aLanguage, "");
|
|
|
+ if (fonts.length > 0)
|
|
|
+ defaultFont = this.enumerator.getDefaultFont(aLanguage, "");
|
|
|
+ }
|
|
|
+
|
|
|
+- if (!this._allFonts)
|
|
|
++ if (!this._allFonts) {
|
|
|
+ this._allFonts = await this.enumerator.EnumerateAllFontsAsync({});
|
|
|
++ }
|
|
|
+
|
|
|
+ // Build the UI for the Default Font and Fonts for this CSS type.
|
|
|
+ const popup = document.createElement("menupopup");
|
|
|
+ let separator;
|
|
|
+ let menuitem;
|
|
|
+ if (fonts.length > 0) {
|
|
|
+ const bundlePrefs = document.getElementById("bundle_prefutilities");
|
|
|
+ let defaultLabel = defaultFont ?
|
|
|
+@@ -89,29 +91,29 @@ var gFontsDialog = {
|
|
|
+ // - there is no setting
|
|
|
+ // - the font selected by the user is no longer present (e.g. deleted from
|
|
|
+ // fonts folder)
|
|
|
+ const preference = document.getElementById(aElement.getAttribute("preference"));
|
|
|
+ if (preference.value) {
|
|
|
+ let fontItems = aElement.getElementsByAttribute("value", preference.value);
|
|
|
+
|
|
|
+ // There is a setting that actually is in the list. Respect it.
|
|
|
+- if (fontItems.length)
|
|
|
++ if (fontItems.length) {
|
|
|
+ return undefined;
|
|
|
++ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Otherwise, use "default" font of current system which is computed
|
|
|
+ // with "font.name-list.*". If "font.name.*" is empty string, it means
|
|
|
+ // "default". So, return empty string in this case.
|
|
|
+ return "";
|
|
|
+ },
|
|
|
+
|
|
|
+ _selectLanguageGroupPromise: Promise.resolve(),
|
|
|
+
|
|
|
+-
|
|
|
+ _selectLanguageGroup(aLanguageGroup) {
|
|
|
+ this._selectLanguageGroupPromise = (async () => {
|
|
|
+ // Avoid overlapping language group selections by awaiting the resolution
|
|
|
+ // of the previous one. We do this because this function is re-entrant,
|
|
|
+ // as inserting <preference> elements into the DOM sometimes triggers a
|
|
|
+ // call back into this function. And since this function is also
|
|
|
+ // asynchronous, that call can enter this function before the previous
|
|
|
+ // run has completed, which would corrupt the font menulists. Awaiting
|
|
|
+@@ -139,55 +141,60 @@ var gFontsDialog = {
|
|
|
+ if (!preference) {
|
|
|
+ preference = document.createElement("preference");
|
|
|
+ preference.id = name;
|
|
|
+ preference.setAttribute("name", name);
|
|
|
+ preference.setAttribute("type", prefs[i].type);
|
|
|
+ preferences.appendChild(preference);
|
|
|
+ }
|
|
|
+
|
|
|
+- if (!prefs[i].element)
|
|
|
++ if (!prefs[i].element) {
|
|
|
+ continue;
|
|
|
++ }
|
|
|
+
|
|
|
+ var element = document.getElementById(prefs[i].element);
|
|
|
+ if (element) {
|
|
|
+ element.setAttribute("preference", preference.id);
|
|
|
+
|
|
|
+ if (prefs[i].fonttype) {
|
|
|
+ // Set an empty label so it does not jump when items are added.
|
|
|
+ element.setAttribute("label", "");
|
|
|
+- await this.buildFontList(aLanguageGroup, prefs[i].fonttype, element);
|
|
|
++ await this.buildFontList(aLanguageGroup, prefs[i].fonttype,
|
|
|
++ element);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Unless the panel is locked, make sure these elements are not
|
|
|
+ // disabled just in case they were in the last language group.
|
|
|
+ element.disabled = this._disabled;
|
|
|
+ preference.setElementValue(element);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })().catch(Cu.reportError);
|
|
|
+ },
|
|
|
+
|
|
|
+ readFontLanguageGroup() {
|
|
|
+- this._disabled = document.getElementById("browser.display.languageList").locked;
|
|
|
++ this._disabled = document.getElementById("browser.display.languageList")
|
|
|
++ .locked;
|
|
|
+ var languagePref = document.getElementById("font.language.group");
|
|
|
+- if (this._disabled)
|
|
|
++ if (this._disabled) {
|
|
|
+ languagePref.disabled = true;
|
|
|
++ }
|
|
|
+ this._selectLanguageGroup(languagePref.value);
|
|
|
+ return undefined;
|
|
|
+ },
|
|
|
+
|
|
|
+ readFontPref(aElement, aDefaultValue) {
|
|
|
+ // Check to see if preference value exists,
|
|
|
+ // if not return given default value.
|
|
|
+ var preference = document.getElementById(aElement.getAttribute("preference"));
|
|
|
+ return preference.value || aDefaultValue;
|
|
|
+ },
|
|
|
+
|
|
|
+ readUseDocumentFonts() {
|
|
|
+- var preference = document.getElementById("browser.display.use_document_fonts");
|
|
|
++ var preference =
|
|
|
++ document.getElementById("browser.display.use_document_fonts");
|
|
|
+ return preference.value == 1;
|
|
|
+ },
|
|
|
+
|
|
|
+ writeUseDocumentFonts(aUseDocumentFonts) {
|
|
|
+ return aUseDocumentFonts.checked ? 1 : 0;
|
|
|
+ },
|
|
|
+ };
|