Backed out 3 changesets (bug 1678487) for causing reftest failures.

CLOSED TREE

Backed out changeset f6519420f910 (bug 1678487)
Backed out changeset 9beae015d19b (bug 1678487)
Backed out changeset 029cc10d2477 (bug 1678487)
This commit is contained in:
Mihai Alexandru Michis
2021-02-13 05:18:54 +02:00
parent 8adcb5b8a0
commit 5576d0f08a
16 changed files with 384 additions and 220 deletions

View File

@@ -177,13 +177,24 @@ static qcms_transform* gCMSRGBATransform = nullptr;
static qcms_transform* gCMSBGRATransform = nullptr;
static bool gCMSInitialized = false;
static CMSMode gCMSMode = CMSMode::Off;
static eCMSMode gCMSMode = eCMSMode_Off;
static void ShutdownCMS();
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/SourceSurfaceCairo.h"
/* Class to listen for pref changes so that chrome code can dynamically
force sRGB as an output profile. See Bug #452125. */
class SRGBOverrideObserver final : public nsIObserver,
public nsSupportsWeakReference {
~SRGBOverrideObserver() = default;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
};
/// This override of the LogForwarder, initially used for the critical graphics
/// errors, is sending the log to the crash annotations as well, but only
/// if the capacity set with the method below is >= 2. We always retain the
@@ -394,6 +405,8 @@ void CrashStatsLogForwarder::CrashAction(LogReason aReason) {
}
}
NS_IMPL_ISUPPORTS(SRGBOverrideObserver, nsIObserver, nsISupportsWeakReference)
#define GFX_DOWNLOADABLE_FONTS_ENABLED "gfx.downloadable_fonts.enabled"
#define GFX_PREF_FALLBACK_USE_CMAPS \
@@ -411,8 +424,27 @@ void CrashStatsLogForwarder::CrashAction(LogReason aReason) {
#define BIDI_NUMERAL_PREF "bidi.numeral"
#define GFX_PREF_CMS_FORCE_SRGB "gfx.color_management.force_srgb"
#define FONT_VARIATIONS_PREF "layout.css.font-variations.enabled"
NS_IMETHODIMP
SRGBOverrideObserver::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* someData) {
NS_ASSERTION(NS_strcmp(someData, (u"" GFX_PREF_CMS_FORCE_SRGB)) == 0,
"Restarting CMS on wrong pref!");
ShutdownCMS();
// Update current cms profile.
gfxPlatform::CreateCMSOutputProfile();
// FIXME(aosmond): This is also racy for the transforms but the pref is only
// used for dev purposes. It can be made a static pref in a followup once the
// dependency on it is removed from the gtest suite (see bug 1620600).
gfxPlatform::GetCMSRGBTransform();
gfxPlatform::GetCMSRGBATransform();
gfxPlatform::GetCMSBGRATransform();
return NS_OK;
}
static const char* kObservedPrefs[] = {"gfx.downloadable_fonts.",
"gfx.font_rendering.", BIDI_NUMERAL_PREF,
nullptr};
@@ -995,6 +1027,13 @@ void gfxPlatform::Init() {
MOZ_CRASH("Could not initialize gfxFontCache");
}
/* Create and register our CMS Override observer. */
gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver,
GFX_PREF_CMS_FORCE_SRGB);
Preferences::RegisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
GLContext::PlatformStartup();
Preferences::RegisterCallbackAndCall(RecordingPrefChanged,
@@ -1240,6 +1279,13 @@ void gfxPlatform::Shutdown() {
// Free the various non-null transforms and loaded profiles
ShutdownCMS();
/* Unregister our CMS Override callback. */
NS_ASSERTION(gPlatform->mSRGBOverrideObserver,
"mSRGBOverrideObserver has alreay gone");
Preferences::RemoveObserver(gPlatform->mSRGBOverrideObserver,
GFX_PREF_CMS_FORCE_SRGB);
gPlatform->mSRGBOverrideObserver = nullptr;
Preferences::UnregisterPrefixCallbacks(FontPrefChanged, kObservedPrefs);
NS_ASSERTION(gPlatform->mMemoryPressureObserver,
@@ -2021,11 +2067,11 @@ bool gfxPlatform::OffMainThreadCompositingEnabled() {
return UsesOffMainThreadCompositing();
}
CMSMode gfxPlatform::GetCMSMode() {
eCMSMode gfxPlatform::GetCMSMode() {
if (!gCMSInitialized) {
int32_t mode = StaticPrefs::gfx_color_management_mode();
if (mode >= 0 && mode < int32_t(CMSMode::AllCount)) {
gCMSMode = CMSMode(mode);
if (mode >= 0 && mode < eCMSMode_AllCount) {
gCMSMode = static_cast<eCMSMode>(mode);
}
bool enableV4 = StaticPrefs::gfx_color_management_enablev4();
@@ -2037,7 +2083,7 @@ CMSMode gfxPlatform::GetCMSMode() {
return gCMSMode;
}
void gfxPlatform::SetCMSModeOverride(CMSMode aMode) {
void gfxPlatform::SetCMSModeOverride(eCMSMode aMode) {
MOZ_ASSERT(gCMSInitialized);
gCMSMode = aMode;
}
@@ -2120,7 +2166,7 @@ void gfxPlatform::CreateCMSOutputProfile() {
of this preference, which means nsIPrefBranch::GetBoolPref will
typically throw (and leave its out-param untouched).
*/
if (StaticPrefs::gfx_color_management_force_srgb()) {
if (Preferences::GetBool(GFX_PREF_CMS_FORCE_SRGB, false)) {
gCMSOutputProfile = GetCMSsRGBProfile();
}
@@ -2283,7 +2329,7 @@ static void ShutdownCMS() {
}
// Reset the state variables
gCMSMode = CMSMode::Off;
gCMSMode = eCMSMode_Off;
gCMSInitialized = false;
}

View File

@@ -74,11 +74,11 @@ class SystemFontListEntry;
} \
} while (0)
enum class CMSMode : int32_t {
Off = 0, // No color management
All = 1, // Color manage everything
TaggedOnly = 2, // Color manage tagged Images Only
AllCount = 3
enum eCMSMode {
eCMSMode_Off = 0, // No color management
eCMSMode_All = 1, // Color manage everything
eCMSMode_TaggedOnly = 2, // Color manage tagged Images Only
eCMSMode_AllCount = 3
};
enum eGfxLog {
@@ -530,12 +530,12 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
/**
* Are we going to try color management?
*/
static CMSMode GetCMSMode();
static eCMSMode GetCMSMode();
/**
* Used only for testing. Override the pref setting.
*/
static void SetCMSModeOverride(CMSMode aMode);
static void SetCMSModeOverride(eCMSMode aMode);
/**
* Determines the rendering intent for color management.
@@ -983,6 +983,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
static bool IsDXP016Blocked();
RefPtr<gfxASurface> mScreenReferenceSurface;
nsCOMPtr<nsIObserver> mSRGBOverrideObserver;
RefPtr<mozilla::layers::MemoryPressureObserver> mMemoryPressureObserver;
// The preferred draw target backend to use for canvas

View File

@@ -1464,7 +1464,7 @@ DeviceColor ToDeviceColor(const sRGBColor& aColor) {
// need to return the same object from all return points in this function. We
// could declare a local Color variable and use that, but we might as well
// just use aColor.
if (gfxPlatform::GetCMSMode() == CMSMode::All) {
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
qcms_transform* transform = gfxPlatform::GetCMSRGBTransform();
if (transform) {
return gfxPlatform::TransformPixel(aColor, transform);

View File

@@ -318,10 +318,10 @@ struct StyleRGBA;
namespace gfx {
/**
* If the CMS mode is CMSMode::All, these functions transform the passed
* color to a device color using the transform returned by
* gfxPlatform::GetCMSRGBTransform(). If the CMS mode is some other value, the
* color is returned unchanged (other than a type change to Moz2D Color, if
* If the CMS mode is eCMSMode_All, these functions transform the passed
* color to a device color using the transform returened by gfxPlatform::
* GetCMSRGBTransform(). If the CMS mode is some other value, the color is
* returned unchanged (other than a type change to Moz2D Color, if
* applicable).
*/
DeviceColor ToDeviceColor(const sRGBColor& aColor);

View File

@@ -95,7 +95,7 @@ void Decoder::SetSurfaceFlags(SurfaceFlags aSurfaceFlags) {
MOZ_ASSERT(!mInitialized);
mSurfaceFlags = aSurfaceFlags;
if (mSurfaceFlags & SurfaceFlags::NO_COLORSPACE_CONVERSION) {
mCMSMode = CMSMode::Off;
mCMSMode = eCMSMode_Off;
}
}

View File

@@ -20,8 +20,6 @@
#include "SurfaceFlags.h"
#include "qcms.h"
enum class CMSMode : int32_t;
namespace mozilla {
namespace Telemetry {
@@ -569,7 +567,7 @@ class Decoder {
uint8_t* mImageData; // Pointer to image data in BGRA/X
uint32_t mImageDataLength;
CMSMode mCMSMode;
uint32_t mCMSMode;
private:
RefPtr<RasterImage> mImage;

View File

@@ -717,7 +717,7 @@ LexerTransition<nsBMPDecoder::State> nsBMPDecoder::ReadBitfields(
mBytesPerColor = (mH.mBIHSize == InfoHeaderLength::WIN_V2) ? 3 : 4;
}
if (mCMSMode != CMSMode::Off) {
if (mCMSMode != eCMSMode_Off) {
switch (mH.mCsType) {
case InfoColorSpace::EMBEDDED:
return SeekColorProfile(aLength);

View File

@@ -410,7 +410,7 @@ void nsGIFDecoder2::ConvertColormap(uint32_t* aColormap, uint32_t aColors) {
}
// Apply CMS transformation if enabled and available
if (mCMSMode == CMSMode::All) {
if (mCMSMode == eCMSMode_All) {
qcms_transform* transform = GetCMSsRGBTransform(SurfaceFormat::R8G8B8);
if (transform) {
qcms_transform_data(transform, aColormap, aColormap, aColors);

View File

@@ -58,7 +58,7 @@ LexerTransition<nsIconDecoder::State> nsIconDecoder::ReadHeader(
// premultiplied, so we can't support the surface flags with icons right now.
SurfacePipeFlags pipeFlags = SurfacePipeFlags();
if (transform) {
if (mCMSMode == CMSMode::All) {
if (mCMSMode == eCMSMode_All) {
mTransform = GetCMSsRGBTransform(format);
}

View File

@@ -283,7 +283,7 @@ LexerTransition<nsJPEGDecoder::State> nsJPEGDecoder::ReadJPEGData(
return Transition::TerminateFailure();
}
if (mCMSMode != CMSMode::Off) {
if (mCMSMode != eCMSMode_Off) {
if ((mInProfile = GetICCProfile(mInfo)) != nullptr &&
GetCMSOutputProfile()) {
uint32_t profileSpace = qcms_profile_get_color_space(mInProfile);
@@ -326,7 +326,7 @@ LexerTransition<nsJPEGDecoder::State> nsJPEGDecoder::ReadJPEGData(
GetCMSOutputProfile(),
outputType, (qcms_intent)intent);
}
} else if (mCMSMode == CMSMode::All) {
} else if (mCMSMode == eCMSMode_All) {
mTransform = GetCMSsRGBTransform(SurfaceFormat::OS_RGBX);
}
}

View File

@@ -308,7 +308,7 @@ nsresult nsPNGDecoder::InitInternal() {
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
// Ignore unused chunks
if (mCMSMode == CMSMode::Off || IsMetadataDecode()) {
if (mCMSMode == eCMSMode_Off || IsMetadataDecode()) {
png_set_keep_unknown_chunks(mPNG, 1, color_chunks, 2);
}
@@ -584,7 +584,7 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
uint32_t intent = -1;
bool sRGBTag = false;
if (!decoder->IsMetadataDecode()) {
if (decoder->mCMSMode != CMSMode::Off) {
if (decoder->mCMSMode != eCMSMode_Off) {
intent = gfxPlatform::GetRenderingIntent();
uint32_t pIntent =
decoder->ReadColorProfile(png_ptr, info_ptr, color_type, &sRGBTag);
@@ -597,7 +597,7 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
png_set_gray_to_rgb(png_ptr);
// only do gamma correction if CMS isn't entirely disabled
if (decoder->mCMSMode != CMSMode::Off) {
if (decoder->mCMSMode != eCMSMode_Off) {
PNGDoGammaCorrection(png_ptr, info_ptr);
}
}
@@ -685,8 +685,8 @@ void nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr) {
decoder->mTransform = qcms_transform_create(decoder->mInProfile, inType,
decoder->GetCMSOutputProfile(),
outType, (qcms_intent)intent);
} else if ((sRGBTag && decoder->mCMSMode == CMSMode::TaggedOnly) ||
decoder->mCMSMode == CMSMode::All) {
} else if ((sRGBTag && decoder->mCMSMode == eCMSMode_TaggedOnly) ||
decoder->mCMSMode == eCMSMode_All) {
// If the transform happens with SurfacePipe, it will be in RGBA if we
// have an alpha channel, because the swizzle and premultiplication
// happens after color management. Otherwise it will be in OS_RGBA because

View File

@@ -299,8 +299,8 @@ void nsWebPDecoder::ApplyColorProfile(const char* aProfile, size_t aLength) {
MOZ_ASSERT(!mGotColorProfile);
mGotColorProfile = true;
if (mCMSMode == CMSMode::Off || !GetCMSOutputProfile() ||
(mCMSMode == CMSMode::TaggedOnly && !aProfile)) {
if (mCMSMode == eCMSMode_Off || !GetCMSOutputProfile() ||
(mCMSMode == eCMSMode_TaggedOnly && !aProfile)) {
return;
}

View File

@@ -56,7 +56,7 @@ AutoInitializeImageLib::AutoInitializeImageLib() {
// Ensure we always color manage images with gtests.
gfxPlatform::GetCMSMode();
gfxPlatform::SetCMSModeOverride(CMSMode::All);
gfxPlatform::SetCMSModeOverride(eCMSMode_All);
// Depending on initialization order, it is possible that our pref changes
// have not taken effect yet because there are pending gfx-related events on

View File

@@ -4145,18 +4145,13 @@
#endif
mirror: always
- name: gfx.color_management.force_srgb
type: RelaxedAtomicBool
value: false
mirror: always
- name: gfx.color_management.enablev4
type: RelaxedAtomicBool
value: false
mirror: always
# 0 = Off, 1 = Full, 2 = Tagged Images Only.
# See CMSMode in gfx/thebes/gfxPlatform.h.
# See eCMSMode in gfx/thebes/gfxPlatform.h.
- name: gfx.color_management.mode
type: RelaxedAtomicInt32
value: 2

View File

@@ -509,12 +509,10 @@ nsXPLookAndFeel::~nsXPLookAndFeel() {
sInstance = nullptr;
}
static bool IsSpecialColor(LookAndFeel::ColorID aID, nscolor aColor) {
using ColorID = LookAndFeel::ColorID;
bool nsXPLookAndFeel::IsSpecialColor(ColorID aID, nscolor& aColor) {
switch (aID) {
case ColorID::TextSelectForeground:
return aColor == NS_DONT_CHANGE_COLOR;
return (aColor == NS_DONT_CHANGE_COLOR);
case ColorID::IMESelectedRawTextBackground:
case ColorID::IMESelectedConvertedTextBackground:
case ColorID::IMERawInputBackground:
@@ -530,19 +528,16 @@ static bool IsSpecialColor(LookAndFeel::ColorID aID, nscolor aColor) {
case ColorID::SpellCheckerUnderline:
return NS_IS_SELECTION_SPECIAL_COLOR(aColor);
default:
break;
/*
* In GetColor(), every color that is not a special color is color
* corrected. Use false to make other colors color corrected.
*/
return false;
}
/*
* In GetColor(), every color that is not a special color is color
* corrected. Use false to make other colors color corrected.
*/
return false;
}
// Returns whether there is a CSS color name for this color.
static bool ColorIsCSSAccessible(LookAndFeel::ColorID aID) {
using ColorID = LookAndFeel::ColorID;
bool nsXPLookAndFeel::ColorIsNotCSSAccessible(ColorID aID) {
switch (aID) {
case ColorID::WindowBackground:
case ColorID::WindowForeground:
@@ -573,209 +568,338 @@ static bool ColorIsCSSAccessible(LookAndFeel::ColorID aID) {
case ColorID::IMESelectedConvertedTextForeground:
case ColorID::IMESelectedConvertedTextUnderline:
case ColorID::SpellCheckerUnderline:
return false;
return true;
default:
break;
}
return true;
return false;
}
nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID) {
nscolor result = NS_RGB(0xFF, 0xFF, 0xFF);
// The stand-in colors are taken from the Windows 7 Aero theme
// except Mac-specific colors which are taken from Mac OS 10.7.
#define COLOR(name_, r, g, b) \
case ColorID::name_: \
return NS_RGB(r, g, b);
switch (aID) {
// CSS 2 colors:
COLOR(Activeborder, 0xB4, 0xB4, 0xB4)
COLOR(Activecaption, 0x99, 0xB4, 0xD1)
COLOR(Appworkspace, 0xAB, 0xAB, 0xAB)
COLOR(Background, 0x00, 0x00, 0x00)
COLOR(Buttonface, 0xF0, 0xF0, 0xF0)
COLOR(Buttonhighlight, 0xFF, 0xFF, 0xFF)
COLOR(Buttonshadow, 0xA0, 0xA0, 0xA0)
COLOR(Buttontext, 0x00, 0x00, 0x00)
COLOR(Captiontext, 0x00, 0x00, 0x00)
COLOR(Graytext, 0x6D, 0x6D, 0x6D)
COLOR(Highlight, 0x33, 0x99, 0xFF)
COLOR(Highlighttext, 0xFF, 0xFF, 0xFF)
COLOR(Inactiveborder, 0xF4, 0xF7, 0xFC)
COLOR(Inactivecaption, 0xBF, 0xCD, 0xDB)
COLOR(Inactivecaptiontext, 0x43, 0x4E, 0x54)
COLOR(Infobackground, 0xFF, 0xFF, 0xE1)
COLOR(Infotext, 0x00, 0x00, 0x00)
COLOR(Menu, 0xF0, 0xF0, 0xF0)
COLOR(Menutext, 0x00, 0x00, 0x00)
COLOR(Scrollbar, 0xC8, 0xC8, 0xC8)
COLOR(Threeddarkshadow, 0x69, 0x69, 0x69)
COLOR(Threedface, 0xF0, 0xF0, 0xF0)
COLOR(Threedhighlight, 0xFF, 0xFF, 0xFF)
COLOR(Threedlightshadow, 0xE3, 0xE3, 0xE3)
COLOR(Threedshadow, 0xA0, 0xA0, 0xA0)
COLOR(Window, 0xFF, 0xFF, 0xFF)
COLOR(Windowframe, 0x64, 0x64, 0x64)
COLOR(Windowtext, 0x00, 0x00, 0x00)
COLOR(MozButtondefault, 0x69, 0x69, 0x69)
COLOR(Field, 0xFF, 0xFF, 0xFF)
COLOR(Fieldtext, 0x00, 0x00, 0x00)
COLOR(MozDialog, 0xF0, 0xF0, 0xF0)
COLOR(MozDialogtext, 0x00, 0x00, 0x00)
COLOR(MozColheadertext, 0x00, 0x00, 0x00)
COLOR(MozColheaderhovertext, 0x00, 0x00, 0x00)
COLOR(MozDragtargetzone, 0xFF, 0xFF, 0xFF)
COLOR(MozCellhighlight, 0xF0, 0xF0, 0xF0)
COLOR(MozCellhighlighttext, 0x00, 0x00, 0x00)
COLOR(MozHtmlCellhighlight, 0x33, 0x99, 0xFF)
COLOR(MozHtmlCellhighlighttext, 0xFF, 0xFF, 0xFF)
COLOR(MozButtonhoverface, 0xF0, 0xF0, 0xF0)
COLOR(MozGtkButtonactivetext, 0x00, 0x00, 0x00)
COLOR(MozButtonhovertext, 0x00, 0x00, 0x00)
COLOR(MozMenuhover, 0x33, 0x99, 0xFF)
COLOR(MozMenuhovertext, 0x00, 0x00, 0x00)
COLOR(MozMenubartext, 0x00, 0x00, 0x00)
COLOR(MozMenubarhovertext, 0x00, 0x00, 0x00)
COLOR(MozOddtreerow, 0xFF, 0xFF, 0xFF)
COLOR(MozMacChromeActive, 0xB2, 0xB2, 0xB2)
COLOR(MozMacChromeInactive, 0xE1, 0xE1, 0xE1)
COLOR(MozMacFocusring, 0x60, 0x9D, 0xD7)
COLOR(MozMacMenuselect, 0x38, 0x75, 0xD7)
COLOR(MozMacMenushadow, 0xA3, 0xA3, 0xA3)
COLOR(MozMacMenutextdisable, 0x88, 0x88, 0x88)
COLOR(MozMacMenutextselect, 0xFF, 0xFF, 0xFF)
COLOR(MozMacDisabledtoolbartext, 0x3F, 0x3F, 0x3F)
COLOR(MozMacSecondaryhighlight, 0xD4, 0xD4, 0xD4)
COLOR(MozMacVibrancyLight, 0xf7, 0xf7, 0xf7)
COLOR(MozMacVibrantTitlebarLight, 0xf7, 0xf7, 0xf7)
COLOR(MozMacVibrancyDark, 0x28, 0x28, 0x28)
COLOR(MozMacVibrantTitlebarDark, 0x28, 0x28, 0x28)
COLOR(MozMacMenupopup, 0xe6, 0xe6, 0xe6)
COLOR(MozMacMenuitem, 0xe6, 0xe6, 0xe6)
COLOR(MozMacActiveMenuitem, 0x0a, 0x64, 0xdc)
COLOR(MozMacSourceList, 0xf7, 0xf7, 0xf7)
COLOR(MozMacSourceListSelection, 0xc8, 0xc8, 0xc8)
COLOR(MozMacActiveSourceListSelection, 0x0a, 0x64, 0xdc)
COLOR(MozMacTooltip, 0xf7, 0xf7, 0xf7)
// Seems to be the default color (hardcoded because of bug 1065998)
COLOR(MozWinAccentcolor, 0x9E, 0x9E, 0x9E)
COLOR(MozWinAccentcolortext, 0x00, 0x00, 0x00)
COLOR(MozWinMediatext, 0xFF, 0xFF, 0xFF)
COLOR(MozWinCommunicationstext, 0xFF, 0xFF, 0xFF)
COLOR(MozNativehyperlinktext, 0x00, 0x66, 0xCC)
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
COLOR(MozCombobox, 0xFF, 0xFF, 0xFF)
default:
case ColorID::Activeborder:
result = NS_RGB(0xB4, 0xB4, 0xB4);
break;
}
return NS_RGB(0xFF, 0xFF, 0xFF);
}
// Uncomment the #define below if you want to debug system color use in a skin
// that uses them. When set, it will make all system color pairs that are
// appropriate for foreground/background pairing the same. This means if the
// skin is using system colors correctly you will not be able to see *any* text.
//
// #define DEBUG_SYSTEM_COLOR_USE
#ifdef DEBUG_SYSTEM_COLOR_USE
static nsresult SystemColorUseDebuggingColor(LookAndFeel::ColorID aID,
nscolor& aResult) {
using ColorID = LookAndFeel::ColorID;
switch (aID) {
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case ColorID::Activecaption:
// active window caption background
case ColorID::Captiontext:
// text in active window caption
aResult = NS_RGB(0xff, 0x00, 0x00);
result = NS_RGB(0x99, 0xB4, 0xD1);
break;
case ColorID::Highlight:
// background of selected item
case ColorID::Highlighttext:
// text of selected item
aResult = NS_RGB(0xff, 0xff, 0x00);
case ColorID::Appworkspace:
result = NS_RGB(0xAB, 0xAB, 0xAB);
break;
case ColorID::Inactivecaption:
// inactive window caption
case ColorID::Inactivecaptiontext:
// text in inactive window caption
aResult = NS_RGB(0x66, 0x66, 0x00);
case ColorID::Background:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Infobackground:
// tooltip background color
case ColorID::Infotext:
// tooltip text color
aResult = NS_RGB(0x00, 0xff, 0x00);
break;
case ColorID::Menu:
// menu background
case ColorID::Menutext:
// menu text
aResult = NS_RGB(0x00, 0xff, 0xff);
break;
case ColorID::Threedface:
case ColorID::Buttonface:
// 3-D face color
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Buttonhighlight:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Buttonshadow:
result = NS_RGB(0xA0, 0xA0, 0xA0);
break;
case ColorID::Buttontext:
// text on push buttons
aResult = NS_RGB(0x00, 0x66, 0x66);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Captiontext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Graytext:
result = NS_RGB(0x6D, 0x6D, 0x6D);
break;
case ColorID::Highlight:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::Highlighttext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Inactiveborder:
result = NS_RGB(0xF4, 0xF7, 0xFC);
break;
case ColorID::Inactivecaption:
result = NS_RGB(0xBF, 0xCD, 0xDB);
break;
case ColorID::Inactivecaptiontext:
result = NS_RGB(0x43, 0x4E, 0x54);
break;
case ColorID::Infobackground:
result = NS_RGB(0xFF, 0xFF, 0xE1);
break;
case ColorID::Infotext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Menu:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Menutext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::Scrollbar:
result = NS_RGB(0xC8, 0xC8, 0xC8);
break;
case ColorID::Threeddarkshadow:
result = NS_RGB(0x69, 0x69, 0x69);
break;
case ColorID::Threedface:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::Threedhighlight:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Threedlightshadow:
result = NS_RGB(0xE3, 0xE3, 0xE3);
break;
case ColorID::Threedshadow:
result = NS_RGB(0xA0, 0xA0, 0xA0);
break;
case ColorID::Window:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Windowframe:
result = NS_RGB(0x64, 0x64, 0x64);
break;
case ColorID::Windowtext:
aResult = NS_RGB(0x00, 0x00, 0xff);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozButtondefault:
result = NS_RGB(0x69, 0x69, 0x69);
break;
// from the CSS3 working draft (not yet finalized)
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
case ColorID::Field:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::Fieldtext:
aResult = NS_RGB(0xff, 0x00, 0xff);
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozDialog:
case ColorID::MozDialogtext:
aResult = NS_RGB(0x66, 0x00, 0x66);
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozDialogtext:
case ColorID::MozColheadertext:
case ColorID::MozColheaderhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozDragtargetzone:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozCellhighlight:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozCellhighlighttext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozHtmlCellhighlight:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::MozHtmlCellhighlighttext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozButtonhoverface:
result = NS_RGB(0xF0, 0xF0, 0xF0);
break;
case ColorID::MozGtkButtonactivetext:
case ColorID::MozButtonhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenuhover:
result = NS_RGB(0x33, 0x99, 0xFF);
break;
case ColorID::MozMenuhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenubartext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozMenubarhovertext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozOddtreerow:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozMacChromeActive:
result = NS_RGB(0xB2, 0xB2, 0xB2);
break;
case ColorID::MozMacChromeInactive:
result = NS_RGB(0xE1, 0xE1, 0xE1);
break;
case ColorID::MozMacFocusring:
result = NS_RGB(0x60, 0x9D, 0xD7);
break;
case ColorID::MozMacMenuselect:
result = NS_RGB(0x38, 0x75, 0xD7);
break;
case ColorID::MozMacMenushadow:
result = NS_RGB(0xA3, 0xA3, 0xA3);
break;
case ColorID::MozMacMenutextdisable:
result = NS_RGB(0x88, 0x88, 0x88);
break;
case ColorID::MozMacMenutextselect:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozMacDisabledtoolbartext:
result = NS_RGB(0x3F, 0x3F, 0x3F);
break;
case ColorID::MozMacSecondaryhighlight:
result = NS_RGB(0xD4, 0xD4, 0xD4);
break;
case ColorID::MozMacVibrancyLight:
case ColorID::MozMacVibrantTitlebarLight:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozMacVibrancyDark:
case ColorID::MozMacVibrantTitlebarDark:
result = NS_RGB(0x28, 0x28, 0x28);
break;
case ColorID::MozMacMenupopup:
result = NS_RGB(0xe6, 0xe6, 0xe6);
break;
case ColorID::MozMacMenuitem:
result = NS_RGB(0xe6, 0xe6, 0xe6);
break;
case ColorID::MozMacActiveMenuitem:
result = NS_RGB(0x0a, 0x64, 0xdc);
break;
case ColorID::MozMacSourceList:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozMacSourceListSelection:
result = NS_RGB(0xc8, 0xc8, 0xc8);
break;
case ColorID::MozMacActiveSourceListSelection:
result = NS_RGB(0x0a, 0x64, 0xdc);
break;
case ColorID::MozMacTooltip:
result = NS_RGB(0xf7, 0xf7, 0xf7);
break;
case ColorID::MozWinAccentcolor:
// Seems to be the default color (hardcoded because of bug 1065998)
result = NS_RGB(0x9E, 0x9E, 0x9E);
break;
case ColorID::MozWinAccentcolortext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozWinMediatext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozWinCommunicationstext:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozNativehyperlinktext:
result = NS_RGB(0x00, 0x66, 0xCC);
break;
case ColorID::MozComboboxtext:
result = NS_RGB(0x00, 0x00, 0x00);
break;
case ColorID::MozCombobox:
result = NS_RGB(0xFF, 0xFF, 0xFF);
break;
default:
return NS_ERROR_NOT_AVAILABLE;
break;
}
return NS_OK;
return result;
}
#endif
//
// All these routines will return NS_OK if they have a value,
// in which case the nsLookAndFeel should use that value;
// otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
// platform-specific nsLookAndFeel should use its own values instead.
//
nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
bool aUseStandinsForNativeColors,
nscolor& aResult) {
if (!sInitialized) {
Init();
}
if (!sInitialized) Init();
// define DEBUG_SYSTEM_COLOR_USE if you want to debug system color
// use in a skin that uses them. When set, it will make all system
// color pairs that are appropriate for foreground/background
// pairing the same. This means if the skin is using system colors
// correctly you will not be able to see *any* text.
#undef DEBUG_SYSTEM_COLOR_USE
#ifdef DEBUG_SYSTEM_COLOR_USE
if (NS_SUCCEEDED(SystemColorUseDebuggingColor(aID, aResult))) {
return NS_OK;
}
#endif
{
nsresult rv = NS_OK;
switch (aID) {
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case ColorID::Activecaption:
// active window caption background
case ColorID::Captiontext:
// text in active window caption
aResult = NS_RGB(0xff, 0x00, 0x00);
break;
// We only use standins for colors that we can access via CSS.
aUseStandinsForNativeColors =
aUseStandinsForNativeColors && ColorIsCSSAccessible(aID);
case ColorID::Highlight:
// background of selected item
case ColorID::Highlighttext:
// text of selected item
aResult = NS_RGB(0xff, 0xff, 0x00);
break;
case ColorID::Inactivecaption:
// inactive window caption
case ColorID::Inactivecaptiontext:
// text in inactive window caption
aResult = NS_RGB(0x66, 0x66, 0x00);
break;
case ColorID::Infobackground:
// tooltip background color
case ColorID::Infotext:
// tooltip text color
aResult = NS_RGB(0x00, 0xff, 0x00);
break;
case ColorID::Menu:
// menu background
case ColorID::Menutext:
// menu text
aResult = NS_RGB(0x00, 0xff, 0xff);
break;
case ColorID::Threedface:
case ColorID::Buttonface:
// 3-D face color
case ColorID::Buttontext:
// text on push buttons
aResult = NS_RGB(0x00, 0x66, 0x66);
break;
case ColorID::Window:
case ColorID::Windowtext:
aResult = NS_RGB(0x00, 0x00, 0xff);
break;
// from the CSS3 working draft (not yet finalized)
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
case ColorID::Field:
case ColorID::Fieldtext:
aResult = NS_RGB(0xff, 0x00, 0xff);
break;
case ColorID::MozDialog:
case ColorID::MozDialogtext:
aResult = NS_RGB(0x66, 0x00, 0x66);
break;
default:
rv = NS_ERROR_NOT_AVAILABLE;
}
if (NS_SUCCEEDED(rv)) return rv;
}
#endif // DEBUG_SYSTEM_COLOR_USE
if (aUseStandinsForNativeColors && ColorIsNotCSSAccessible(aID)) {
aUseStandinsForNativeColors = false;
}
if (!aUseStandinsForNativeColors && IS_COLOR_CACHED(aID)) {
aResult = sCachedColors[uint32_t(aID)];
@@ -824,11 +948,9 @@ nsresult nsXPLookAndFeel::GetColorValue(ColorID aID,
}
if (NS_SUCCEEDED(NativeGetColor(aID, aResult))) {
// TODO(bug 1678487): We should color-correct style colors as well when in
// the traversal.
if (!mozilla::ServoStyleSet::IsInServoTraversal()) {
MOZ_ASSERT(NS_IsMainThread());
if (gfxPlatform::GetCMSMode() == CMSMode::All &&
if ((gfxPlatform::GetCMSMode() == eCMSMode_All) &&
!IsSpecialColor(aID, aResult)) {
qcms_transform* transform = gfxPlatform::GetCMSInverseRGBTransform();
if (transform) {

View File

@@ -103,10 +103,12 @@ class nsXPLookAndFeel : public mozilla::LookAndFeel {
static void IntPrefChanged(nsLookAndFeelIntPref* data);
static void FloatPrefChanged(nsLookAndFeelFloatPref* data);
static void ColorPrefChanged(unsigned int index, const char* prefName);
static nscolor GetStandinForNativeColor(ColorID);
void InitFromPref(nsLookAndFeelIntPref* aPref);
void InitFromPref(nsLookAndFeelFloatPref* aPref);
void InitColorFromPref(int32_t aIndex);
bool IsSpecialColor(ColorID aID, nscolor& aColor);
bool ColorIsNotCSSAccessible(ColorID aID);
nscolor GetStandinForNativeColor(ColorID aID);
void RecordTelemetry();
virtual void RecordLookAndFeelSpecificTelemetry() {}