Bug 1047586 - warn about large fonts, r=jaws

This commit is contained in:
Gijs Kruitbosch 2015-02-13 21:29:39 +00:00
parent 9128db61ec
commit 5ff7c86ea7
3 changed files with 37 additions and 1 deletions

View File

@ -108,6 +108,37 @@ var gFontsDialog = {
{
var useDocumentFonts = document.getElementById("useDocumentFonts");
return useDocumentFonts.checked ? 1 : 0;
}
},
onBeforeAccept: function ()
{
// Only care in in-content prefs
if (!window.frameElement) {
return true;
}
let preferences = document.querySelectorAll("preference[id*='font.minimum-size']");
// It would be good if we could avoid touching languages the pref pages won't use, but
// unfortunately the language group APIs (deducing language groups from language codes)
// are C++ - only. So we just check all the things the user touched:
// Don't care about anything up to 24px, or if this value is the same as set previously:
preferences = Array.filter(preferences, prefEl => {
return prefEl.value > 24 && prefEl.value != prefEl.valueFromPreferences;
});
if (!preferences.length) {
return;
}
let strings = document.getElementById("bundlePreferences");
let title = strings.getString("veryLargeMinimumFontTitle");
let confirmLabel = strings.getString("acceptVeryLargeMinimumFont");
let warningMessage = strings.getString("veryLargeMinimumFontWarning");
let {Services} = Components.utils.import("resource://gre/modules/Services.jsm", {});
let flags = Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL |
Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING |
Services.prompt.BUTTON_POS_1_DEFAULT;
let buttonChosen = Services.prompt.confirmEx(window, title, warningMessage, flags, confirmLabel, null, "", "", {});
return buttonChosen == 0;
},
};

View File

@ -17,6 +17,7 @@
title="&fontsDialog.title;"
dlgbuttons="accept,cancel,help"
ondialoghelp="openPrefsHelp()"
onbeforeaccept="return gFontsDialog.onBeforeAccept();"
style="">
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>

View File

@ -13,6 +13,10 @@ phishBeforeText=Selecting this option will send the address of web pages you are
labelDefaultFont=Default (%S)
veryLargeMinimumFontTitle=Large minimum font size
veryLargeMinimumFontWarning=You have selected a very large minimum font size (more than 24 pixels). This may make it difficult or impossible to use some important configuration pages like this one.
acceptVeryLargeMinimumFont=Keep my changes anyway
#### Permissions Manager
cookiepermissionstext=You can specify which websites are always or never allowed to use cookies. Type the exact address of the site you want to manage and then click Block, Allow for Session, or Allow.