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)

This commit is contained in:
mozilla.mano%sent.com 2005-02-28 12:52:48 +00:00
Родитель 77f519f3bc
Коммит 45f5128d83
5 изменённых файлов: 32 добавлений и 12 удалений

Просмотреть файл

@ -19,6 +19,7 @@
# #
# Contributor(s): # Contributor(s):
# Ben Goodger <ben@mozilla.org> # Ben Goodger <ben@mozilla.org>
# Asaf Romano <mozilla.mano@sent.com>
# #
# Alternatively, the contents of this file may be used under the terms of # 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 # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -35,6 +36,7 @@
# ***** END LICENSE BLOCK ***** # ***** END LICENSE BLOCK *****
const kDefaultFontType = "font.default.%LANG%";
const kFontNameFmtSerif = "font.name.serif.%LANG%"; const kFontNameFmtSerif = "font.name.serif.%LANG%";
const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%"; const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%";
const kFontNameListFmtSerif = "font.name-list.serif.%LANG%"; const kFontNameListFmtSerif = "font.name-list.serif.%LANG%";
@ -53,8 +55,8 @@ var gContentPane = {
_rebuildFonts: function () _rebuildFonts: function ()
{ {
var langGroupPref = document.getElementById("font.language.group"); var langGroupPref = document.getElementById("font.language.group");
var isSerifPref = document.getElementById("font.default"); this._selectLanguageGroup(langGroupPref.value,
this._selectLanguageGroup(langGroupPref.value, isSerifPref.value == "serif"); this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif");
}, },
_selectLanguageGroup: function (aLanguageGroup, aIsSerif) _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 () writeEnableImagesPref: function ()
{ {
var enableImages = document.getElementById("enableImages"); var enableImages = document.getElementById("enableImages");

Просмотреть файл

@ -62,7 +62,6 @@
name="dom.disable_window_status_change" name="dom.disable_window_status_change"
type="bool" onchange="gContentPane.annoyancesPrefChanged();"/> type="bool" onchange="gContentPane.annoyancesPrefChanged();"/>
<preference id="font.language.group" name="font.language.group" type="wstring" onchange="gContentPane._rebuildFonts();"/> <preference id="font.language.group" name="font.language.group" type="wstring" onchange="gContentPane._rebuildFonts();"/>
<preference id="font.default" name="font.default" type="string" onchange="gContentPane._rebuildFonts();"/>
<preference id="pref.advanced.images.disable_button.view_image" <preference id="pref.advanced.images.disable_button.view_image"
name="pref.advanced.images.disable_button.view_image" name="pref.advanced.images.disable_button.view_image"
type="bool"/> type="bool"/>

Просмотреть файл

@ -96,19 +96,22 @@ var FontBuilder = {
// All-Fonts list, so walk both lists side-by-side, skipping values we've // All-Fonts list, so walk both lists side-by-side, skipping values we've
// already created menu items for. // already created menu items for.
var builtItem = separator ? separator.nextSibling : popup.firstChild; var builtItem = separator ? separator.nextSibling : popup.firstChild;
var builtItemValue = builtItem ? builtItem.getAttribute("value") : null;
separator = document.createElement("menuseparator"); separator = document.createElement("menuseparator");
popup.appendChild(separator); popup.appendChild(separator);
for (i = 0; i < this._allFonts.length; ++i) { 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 = document.createElement("menuitem");
menuitem.setAttribute("value", this._allFonts[i]); menuitem.setAttribute("value", this._allFonts[i]);
menuitem.setAttribute("label", this._allFonts[i]); menuitem.setAttribute("label", this._allFonts[i]);
popup.appendChild(menuitem); popup.appendChild(menuitem);
} }
else else {
builtItem = builtItem.nextSibling; builtItem = builtItem.nextSibling;
builtItemValue = builtItem ? builtItem.getAttribute("value") : null;
}
} }
} }
aMenuList.appendChild(popup); aMenuList.appendChild(popup);

Просмотреть файл

@ -19,6 +19,7 @@
# #
# Contributor(s): # Contributor(s):
# Ben Goodger <ben@mozilla.org> # Ben Goodger <ben@mozilla.org>
# Asaf Romano <mozilla.mano@sent.com>
# #
# Alternatively, the contents of this file may be used under the terms of # 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 # either the GNU General Public License Version 2 or later (the "GPL"), or
@ -36,6 +37,7 @@
# browser.display.languageList LOCK ALL when LOCKED # browser.display.languageList LOCK ALL when LOCKED
const kDefaultFontType = "font.default.%LANG%";
const kFontNameFmtSerif = "font.name.serif.%LANG%"; const kFontNameFmtSerif = "font.name.serif.%LANG%";
const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%"; const kFontNameFmtSansSerif = "font.name.sans-serif.%LANG%";
const kFontNameFmtMonospace = "font.name.monospace.%LANG%"; const kFontNameFmtMonospace = "font.name.monospace.%LANG%";
@ -49,7 +51,8 @@ const kFontMinSizeFmt = "font.minimum-size.%LANG%";
var gFontsDialog = { var gFontsDialog = {
_selectLanguageGroup: function (aLanguageGroup) _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: kFontNameFmtSansSerif, type: "unichar", element: "sans-serif", fonttype: "sans-serif" },
{ format: kFontNameFmtMonospace, type: "unichar", element: "monospace", fonttype: "monospace" }, { format: kFontNameFmtMonospace, type: "unichar", element: "monospace", fonttype: "monospace" },
{ format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" }, { format: kFontNameListFmtSerif, type: "unichar", element: null, fonttype: "serif" },
@ -65,9 +68,9 @@ var gFontsDialog = {
preference = document.createElement("preference"); preference = document.createElement("preference");
var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup); var name = prefs[i].format.replace(/%LANG%/, aLanguageGroup);
preference.id = name; preference.id = name;
preference.setAttribute("name", name);
preference.setAttribute("type", prefs[i].type);
preferences.appendChild(preference); preferences.appendChild(preference);
preference.name = name;
preference.type = prefs[i].type;
} }
if (!prefs[i].element) if (!prefs[i].element)

Просмотреть файл

@ -52,7 +52,6 @@
<preferences id="fontPreferences"> <preferences id="fontPreferences">
<preference id="font.language.group" name="font.language.group" type="wstring"/> <preference id="font.language.group" name="font.language.group" type="wstring"/>
<preference id="font.default" name="font.default" type="string"/>
<preference id="browser.display.screen_resolution" <preference id="browser.display.screen_resolution"
name="browser.display.screen_resolution" name="browser.display.screen_resolution"
type="int"/> type="int"/>
@ -113,8 +112,7 @@
<hbox align="center" pack="end"> <hbox align="center" pack="end">
<label accesskey="&proportional.accesskey;" control="proportionalFont">&proportional.label;</label> <label accesskey="&proportional.accesskey;" control="proportionalFont">&proportional.label;</label>
</hbox> </hbox>
<menulist id="proportionalFont" flex="1" style="width: 0px;" <menulist id="defaultFontType" flex="1" style="width: 0px;">
preference="font.default">
<menupopup> <menupopup>
<menuitem value="serif" label="&useDefaultFontSerif.label;"/> <menuitem value="serif" label="&useDefaultFontSerif.label;"/>
<menuitem value="sans-serif" label="&useDefaultFontSansSerif.label;"/> <menuitem value="sans-serif" label="&useDefaultFontSansSerif.label;"/>