From 45f5128d831b9579ef29119f236f9112fb4fb9e1 Mon Sep 17 00:00:00 2001 From: "mozilla.mano%sent.com" Date: Mon, 28 Feb 2005 12:52:48 +0000 Subject: [PATCH] Font dialog regressions fix: Bug 283678 - Serif / Sans-serif pref ui doesn't work; Bug 283869 - crash after trying to change font prefs; Bug 283945 - empty font lists for some languages. r=ben. (patch from bug 283678) --- browser/components/preferences/content.js | 21 +++++++++++++++++-- browser/components/preferences/content.xul | 1 - browser/components/preferences/fontbuilder.js | 9 +++++--- browser/components/preferences/fonts.js | 9 +++++--- browser/components/preferences/fonts.xul | 4 +--- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/browser/components/preferences/content.js b/browser/components/preferences/content.js index ef7cd7480c32..163b38ec6f86 100644 --- a/browser/components/preferences/content.js +++ b/browser/components/preferences/content.js @@ -19,6 +19,7 @@ # # Contributor(s): # Ben Goodger +# Asaf Romano # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -35,6 +36,7 @@ # ***** END LICENSE BLOCK ***** +const kDefaultFontType = "font.default.%LANG%"; const kFontNameFmtSerif = "font.name.serif.%LANG%"; const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%"; const kFontNameListFmtSerif = "font.name-list.serif.%LANG%"; @@ -53,8 +55,8 @@ var gContentPane = { _rebuildFonts: function () { var langGroupPref = document.getElementById("font.language.group"); - var isSerifPref = document.getElementById("font.default"); - this._selectLanguageGroup(langGroupPref.value, isSerifPref.value == "serif"); + this._selectLanguageGroup(langGroupPref.value, + this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif"); }, _selectLanguageGroup: function (aLanguageGroup, aIsSerif) @@ -98,6 +100,21 @@ var gContentPane = { } }, + _readDefaultFontTypeForLanguage: function (aLanguageGroup) + { + var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup); + var preference = document.getElementById(defaultFontTypePref); + if (!preference) { + preference = document.createElement("preference"); + preference.id = defaultFontTypePref; + preference.setAttribute("name", defaultFontTypePref); + preference.setAttribute("type", "string"); + preference.setAttribute("onchange", "gContentPane._rebuildFonts();"); + document.getElementById("contentPreferences").appendChild(preference); + } + return preference.value; + }, + writeEnableImagesPref: function () { var enableImages = document.getElementById("enableImages"); diff --git a/browser/components/preferences/content.xul b/browser/components/preferences/content.xul index fdf1422bc209..a3303d887722 100644 --- a/browser/components/preferences/content.xul +++ b/browser/components/preferences/content.xul @@ -62,7 +62,6 @@ name="dom.disable_window_status_change" type="bool" onchange="gContentPane.annoyancesPrefChanged();"/> - diff --git a/browser/components/preferences/fontbuilder.js b/browser/components/preferences/fontbuilder.js index 79112ff12766..aa5e4a3ed93c 100644 --- a/browser/components/preferences/fontbuilder.js +++ b/browser/components/preferences/fontbuilder.js @@ -96,19 +96,22 @@ var FontBuilder = { // All-Fonts list, so walk both lists side-by-side, skipping values we've // already created menu items for. var builtItem = separator ? separator.nextSibling : popup.firstChild; - + var builtItemValue = builtItem ? builtItem.getAttribute("value") : null; + separator = document.createElement("menuseparator"); popup.appendChild(separator); for (i = 0; i < this._allFonts.length; ++i) { - if (this._allFonts[i] != builtItem.getAttribute("value")) { + if (this._allFonts[i] != builtItemValue) { menuitem = document.createElement("menuitem"); menuitem.setAttribute("value", this._allFonts[i]); menuitem.setAttribute("label", this._allFonts[i]); popup.appendChild(menuitem); } - else + else { builtItem = builtItem.nextSibling; + builtItemValue = builtItem ? builtItem.getAttribute("value") : null; + } } } aMenuList.appendChild(popup); diff --git a/browser/components/preferences/fonts.js b/browser/components/preferences/fonts.js index d56bf53eb9ed..80daa60f849d 100644 --- a/browser/components/preferences/fonts.js +++ b/browser/components/preferences/fonts.js @@ -19,6 +19,7 @@ # # Contributor(s): # Ben Goodger +# Asaf Romano # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -36,6 +37,7 @@ # browser.display.languageList LOCK ALL when LOCKED +const kDefaultFontType = "font.default.%LANG%"; const kFontNameFmtSerif = "font.name.serif.%LANG%"; const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%"; const kFontNameFmtMonospace = "font.name.monospace.%LANG%"; @@ -49,7 +51,8 @@ const kFontMinSizeFmt = "font.minimum-size.%LANG%"; var gFontsDialog = { _selectLanguageGroup: function (aLanguageGroup) { - var prefs = [{ format: kFontNameFmtSerif, type: "unichar", element: "serif", fonttype: "serif" }, + var prefs = [{ format: kDefaultFontType, type: "string", element: "defaultFontType", fonttype: null}, + { format: kFontNameFmtSerif, type: "unichar", element: "serif", fonttype: "serif" }, { format: kFontNameFmtSansSerif, type: "unichar", element: "sans-serif", fonttype: "sans-serif" }, { format: kFontNameFmtMonospace, type: "unichar", element: "monospace", fonttype: "monospace" }, { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, @@ -65,9 +68,9 @@ var gFontsDialog = { preference = document.createElement("preference"); var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup); preference.id = name; + preference.setAttribute("name", name); + preference.setAttribute("type", prefs[i].type); preferences.appendChild(preference); - preference.name = name; - preference.type = prefs[i].type; } if (!prefs[i].element) diff --git a/browser/components/preferences/fonts.xul b/browser/components/preferences/fonts.xul index b76f8935a44c..7c7a2a78f67d 100644 --- a/browser/components/preferences/fonts.xul +++ b/browser/components/preferences/fonts.xul @@ -52,7 +52,6 @@ - @@ -113,8 +112,7 @@ - +