Bug 639134 - change document color pref to tristate, r=dbaron

This commit is contained in:
Gijs Kruitbosch 2014-11-27 19:06:14 +00:00
Родитель d7e1bf838d
Коммит d1d9d27161
4 изменённых файлов: 33 добавлений и 11 удалений

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

@ -614,6 +614,14 @@ nsPresContext::GetDocumentColorPreferences()
int32_t useAccessibilityTheme = 0;
bool usePrefColors = true;
bool isChromeDocShell = false;
static int32_t sDocumentColorsSetting;
static bool sDocumentColorsSettingPrefCached = false;
if (!sDocumentColorsSettingPrefCached) {
sDocumentColorsSettingPrefCached = true;
Preferences::AddIntVarCache(&sDocumentColorsSetting,
"browser.display.document_color_use",
0);
}
nsIDocument* doc = mDocument->GetDisplayDocument();
if (doc && doc->GetDocShell()) {
@ -669,9 +677,21 @@ nsPresContext::GetDocumentColorPreferences()
mBackgroundColor = NS_ComposeColors(NS_RGB(0xFF, 0xFF, 0xFF),
mBackgroundColor);
mUseDocumentColors = !useAccessibilityTheme &&
Preferences::GetBool("browser.display.use_document_colors",
mUseDocumentColors);
// Now deal with the pref:
// 0 = default: always, except in high contrast mode
// 1 = always
// 2 = never
if (sDocumentColorsSetting == 1) {
mUseDocumentColors = true;
} else if (sDocumentColorsSetting == 2) {
mUseDocumentColors = isChromeDocShell || mIsChromeOriginImage;
} else {
MOZ_ASSERT(!useAccessibilityTheme ||
!(isChromeDocShell || mIsChromeOriginImage),
"The accessibility theme should only be on for non-chrome");
mUseDocumentColors = !useAccessibilityTheme;
}
}
void

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

@ -80,8 +80,7 @@ class ContainerLayer;
// supported values for cached bool types
enum nsPresContext_CachedBoolPrefType {
kPresContext_UseDocumentColors = 1,
kPresContext_UseDocumentFonts,
kPresContext_UseDocumentFonts = 1,
kPresContext_UnderlineLinks
};
@ -378,8 +377,6 @@ public:
switch (aPrefType) {
case kPresContext_UseDocumentFonts:
return mUseDocumentFonts;
case kPresContext_UseDocumentColors:
return mUseDocumentColors;
case kPresContext_UnderlineLinks:
return mUnderlineLinks;
default:
@ -846,7 +843,9 @@ public:
// Is it OK to let the page specify colors and backgrounds?
bool UseDocumentColors() const {
return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome() || IsChromeOriginImage();
MOZ_ASSERT(mUseDocumentColors || !(IsChrome() || IsChromeOriginImage()),
"We should never have a chrome doc or image that can't use its colors.");
return mUseDocumentColors;
}
// Explicitly enable and disable paint flashing.

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

@ -50,7 +50,7 @@ var cs5 = getComputedStyle(document.getElementById("five"), "");
var cs6 = getComputedStyle(document.getElementById("six"), "");
var cs7 = getComputedStyle(document.getElementById("seven"), "");
SpecialPowers.pushPrefEnv({'set': [['browser.display.use_document_colors', true]]}, part1);
SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 1]]}, part1);
var transparentBackgroundColor;
var inputBackgroundColor, inputColor, inputBorderTopColor;
@ -121,7 +121,7 @@ function part1()
inputBorderRightColor = cs4.borderRightColor;
inputBorderLeftColor = cs4.borderLeftColor;
inputBorderBottomColor = cs4.borderBottomColor;
SpecialPowers.pushPrefEnv({'set': [['browser.display.use_document_colors', false]]}, part2);
SpecialPowers.pushPrefEnv({'set': [['browser.display.document_color_use', 2]]}, part2);
}
function part2()

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

@ -177,7 +177,10 @@ pref("browser.sessionhistory.max_total_viewers", -1);
pref("ui.use_native_colors", true);
pref("ui.click_hold_context_menus", false);
pref("browser.display.use_document_fonts", 1); // 0 = never, 1 = quick, 2 = always
pref("browser.display.use_document_colors", true);
// 0 = default: always, except in high contrast mode
// 1 = always
// 2 = never
pref("browser.display.document_color_use", 0);
pref("browser.display.use_system_colors", false);
pref("browser.display.foreground_color", "#000000");
pref("browser.display.background_color", "#FFFFFF");