зеркало из https://github.com/mozilla/gecko-dev.git
Bug 461663 - 16 bits colour channel values should not have lower bits zeroed. r=gavin
This commit is contained in:
Родитель
5062385233
Коммит
95e41546c8
|
@ -451,7 +451,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COLOR_16_TO_8_BIT(_c) ((_c) >> 8)
|
#define COLOR_16_TO_8_BIT(_c) ((_c) >> 8)
|
||||||
#define COLOR_8_TO_16_BIT(_c) ((_c) << 8)
|
#define COLOR_8_TO_16_BIT(_c) ((_c) << 8 | (_c))
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
|
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
|
||||||
|
@ -480,37 +480,25 @@ nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
|
||||||
static void
|
static void
|
||||||
ColorToCString(PRUint32 aColor, nsCString& aResult)
|
ColorToCString(PRUint32 aColor, nsCString& aResult)
|
||||||
{
|
{
|
||||||
#if GTK_CHECK_VERSION(2,12,0)
|
|
||||||
GdkColor color;
|
|
||||||
color.red = COLOR_8_TO_16_BIT(aColor >> 16);
|
|
||||||
color.green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
|
|
||||||
color.blue = COLOR_8_TO_16_BIT(aColor & 0xff);
|
|
||||||
|
|
||||||
gchar *colorString = gdk_color_to_string(&color);
|
|
||||||
aResult.Assign(colorString);
|
|
||||||
g_free(colorString);
|
|
||||||
|
|
||||||
#else // GTK 2.12.0
|
|
||||||
|
|
||||||
// The #rrrrggggbbbb format is used to match gdk_color_to_string()
|
// The #rrrrggggbbbb format is used to match gdk_color_to_string()
|
||||||
char *buf = aResult.BeginWriting(13);
|
char *buf = aResult.BeginWriting(13);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PRUint8 red = (aColor >> 16);
|
PRUint16 red = COLOR_8_TO_16_BIT((aColor >> 16) & 0xff);
|
||||||
PRUint8 green = (aColor >> 8) & 0xff;
|
PRUint16 green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
|
||||||
PRUint8 blue = aColor & 0xff;
|
PRUint16 blue = COLOR_8_TO_16_BIT(aColor & 0xff);
|
||||||
|
|
||||||
PR_snprintf(buf, 14, "#%02x00%02x00%02x00", red, green, blue);
|
PR_snprintf(buf, 14, "#%04x%04x%04x", red, green, blue);
|
||||||
#endif // GTK 2.12.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
|
nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
|
||||||
{
|
{
|
||||||
|
NS_ASSERTION(aColor <= 0xffffff, "aColor has extra bits");
|
||||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||||
|
|
||||||
nsCString colorString;
|
nsCAutoString colorString;
|
||||||
ColorToCString(aColor, colorString);
|
ColorToCString(aColor, colorString);
|
||||||
|
|
||||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
|
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
|
||||||
|
|
|
@ -102,11 +102,11 @@ function run_test() {
|
||||||
checkGConfToShellColor("#ffffffffffff", "#FFFFFF");
|
checkGConfToShellColor("#ffffffffffff", "#FFFFFF");
|
||||||
|
|
||||||
checkShellToGConfColor("#000000", "#000000000000");
|
checkShellToGConfColor("#000000", "#000000000000");
|
||||||
checkShellToGConfColor("#0000FF", "#00000000ff00");
|
checkShellToGConfColor("#0000FF", "#00000000ffff");
|
||||||
checkShellToGConfColor("#FFFFFF", "#ff00ff00ff00");
|
checkShellToGConfColor("#FFFFFF", "#ffffffffffff");
|
||||||
checkShellToGConfColor("#0A0B0C", "#0a000b000c00");
|
checkShellToGConfColor("#0A0B0C", "#0a0a0b0b0c0c");
|
||||||
checkShellToGConfColor("#A0B0C0", "#a000b000c000");
|
checkShellToGConfColor("#A0B0C0", "#a0a0b0b0c0c0");
|
||||||
checkShellToGConfColor("#AABBCC", "#aa00bb00cc00");
|
checkShellToGConfColor("#AABBCC", "#aaaabbbbcccc");
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
gGConf.setString(GCONF_BG_COLOR_KEY, origGConfColor);
|
gGConf.setString(GCONF_BG_COLOR_KEY, origGConfColor);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче