mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 461512 nsCSSColorUtils doesn't support alpha color (border color is always solid color if the border-style is groove, ridge, inset, outset) r+sr=roc
This commit is contained in:
parent
c93ba89fab
commit
275ce7e82a
@ -68,54 +68,10 @@
|
||||
|
||||
#define MAX_BRIGHTNESS 254
|
||||
#define MAX_DARKNESS 0
|
||||
|
||||
void NS_Get3DColors(nscolor aResult[2], nscolor aBackgroundColor)
|
||||
{
|
||||
int rb = NS_GET_R(aBackgroundColor);
|
||||
int gb = NS_GET_G(aBackgroundColor);
|
||||
int bb = NS_GET_B(aBackgroundColor);
|
||||
|
||||
int brightness = NS_GetBrightness(rb,gb,bb);
|
||||
|
||||
int f0, f1;
|
||||
if (brightness < COLOR_DARK_THRESHOLD) {
|
||||
f0 = COLOR_DARK_BS_FACTOR;
|
||||
f1 = COLOR_DARK_TS_FACTOR;
|
||||
} else if (brightness > COLOR_LIGHT_THRESHOLD) {
|
||||
f0 = COLOR_LITE_BS_FACTOR;
|
||||
f1 = COLOR_LITE_TS_FACTOR;
|
||||
} else {
|
||||
f0 = COLOR_DARK_BS_FACTOR +
|
||||
(brightness *
|
||||
(COLOR_LITE_BS_FACTOR - COLOR_DARK_BS_FACTOR) / MAX_COLOR);
|
||||
f1 = COLOR_DARK_TS_FACTOR +
|
||||
(brightness *
|
||||
(COLOR_LITE_TS_FACTOR - COLOR_DARK_TS_FACTOR) / MAX_COLOR);
|
||||
}
|
||||
|
||||
int r = rb - (f0 * rb / 100);
|
||||
int g = gb - (f0 * gb / 100);
|
||||
int b = bb - (f0 * bb / 100);
|
||||
aResult[0] = NS_RGB(r, g, b);
|
||||
if ((r == rb) && (g == gb) && (b == bb)) {
|
||||
aResult[0] = (aBackgroundColor == BLACK) ? DARK_GRAY : BLACK;
|
||||
}
|
||||
|
||||
r = rb + (f1 * (MAX_COLOR - rb) / 100);
|
||||
if (r > 255) r = 255;
|
||||
g = gb + (f1 * (MAX_COLOR - gb) / 100);
|
||||
if (g > 255) g = 255;
|
||||
b = bb + (f1 * (MAX_COLOR - bb) / 100);
|
||||
if (b > 255) b = 255;
|
||||
aResult[1] = NS_RGB(r, g, b);
|
||||
if ((r == rb) && (g == gb) && (b == bb)) {
|
||||
aResult[1] = (aBackgroundColor == WHITE) ? LIGHT_GRAY : WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
void NS_GetSpecial3DColors(nscolor aResult[2],
|
||||
nscolor aBackgroundColor,
|
||||
nscolor aBorderColor)
|
||||
nscolor aBackgroundColor,
|
||||
nscolor aBorderColor)
|
||||
{
|
||||
|
||||
PRUint8 f0, f1;
|
||||
@ -125,6 +81,8 @@ void NS_GetSpecial3DColors(nscolor aResult[2],
|
||||
PRUint8 gb = NS_GET_G(aBorderColor);
|
||||
PRUint8 bb = NS_GET_B(aBorderColor);
|
||||
|
||||
PRUint8 a = NS_GET_A(aBorderColor);
|
||||
|
||||
// This needs to be optimized.
|
||||
// Calculating background brightness again and again is
|
||||
// a waste of time!!!. Just calculate it only once.
|
||||
@ -169,12 +127,12 @@ void NS_GetSpecial3DColors(nscolor aResult[2],
|
||||
r = rb - (f0 * rb / 100);
|
||||
g = gb - (f0 * gb / 100);
|
||||
b = bb - (f0 * bb / 100);
|
||||
aResult[0] = NS_RGB(r, g, b);
|
||||
aResult[0] = NS_RGBA(r, g, b, a);
|
||||
|
||||
r = rb + (f1 * (MAX_COLOR - rb) / 100);
|
||||
g = gb + (f1 * (MAX_COLOR - gb) / 100);
|
||||
b = bb + (f1 * (MAX_COLOR - bb) / 100);
|
||||
aResult[1] = NS_RGB(r, g, b);
|
||||
aResult[1] = NS_RGBA(r, g, b, a);
|
||||
}
|
||||
|
||||
int NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue)
|
||||
@ -203,14 +161,14 @@ PRInt32 NS_GetLuminosity(nscolor aColor)
|
||||
|
||||
// Function to convert RGB color space into the HSV colorspace
|
||||
// Hue is the primary color defined from 0 to 359 degrees
|
||||
// Saturation is defined from 0 to 255. The higher the number.. the deeper the color
|
||||
// Value is the brightness of the color. 0 is black, 255 is white.
|
||||
void
|
||||
NS_RGB2HSV(nscolor aColor,PRUint16 &aHue,PRUint16 &aSat,PRUint16 &aValue)
|
||||
// Saturation is defined from 0 to 255. The higher the number.. the deeper
|
||||
// the color Value is the brightness of the color. 0 is black, 255 is white.
|
||||
void NS_RGB2HSV(nscolor aColor, PRUint16 &aHue, PRUint16 &aSat,
|
||||
PRUint16 &aValue, PRUint8 &aAlpha)
|
||||
{
|
||||
PRUint8 r,g,b;
|
||||
PRInt16 delta,min,max,r1,b1,g1;
|
||||
float hue;
|
||||
PRUint8 r, g, b;
|
||||
PRInt16 delta, min, max, r1, b1, g1;
|
||||
float hue;
|
||||
|
||||
r = NS_GET_R(aColor);
|
||||
g = NS_GET_G(aColor);
|
||||
@ -261,18 +219,20 @@ float hue;
|
||||
}
|
||||
|
||||
aHue = (PRUint16)hue;
|
||||
|
||||
aAlpha = NS_GET_A(aColor);
|
||||
}
|
||||
|
||||
// Function to convert HSV color space into the RGB colorspace
|
||||
// Hue is the primary color defined from 0 to 359 degrees
|
||||
// Saturation is defined from 0 to 255. The higher the number.. the deeper the color
|
||||
// Value is the brightness of the color. 0 is black, 255 is white.
|
||||
void
|
||||
NS_HSV2RGB(nscolor &aColor,PRUint16 aHue,PRUint16 aSat,PRUint16 aValue)
|
||||
// Saturation is defined from 0 to 255. The higher the number.. the deeper
|
||||
// the color Value is the brightness of the color. 0 is black, 255 is white.
|
||||
void NS_HSV2RGB(nscolor &aColor, PRUint16 aHue, PRUint16 aSat, PRUint16 aValue,
|
||||
PRUint8 aAlpha)
|
||||
{
|
||||
PRUint16 r=0,g=0,b=0;
|
||||
PRUint16 i,p,q,t;
|
||||
double h,f,percent;
|
||||
PRUint16 r = 0, g = 0, b = 0;
|
||||
PRUint16 i, p, q, t;
|
||||
double h, f, percent;
|
||||
|
||||
if ( aSat == 0 ){
|
||||
// achromatic color, no hue is defined
|
||||
@ -308,5 +268,5 @@ double h,f,percent;
|
||||
case 5: r = aValue; g = p; b = q;break;
|
||||
}
|
||||
}
|
||||
aColor = NS_RGB(r,g,b);
|
||||
aColor = NS_RGBA(r, g, b, aAlpha);
|
||||
}
|
||||
|
@ -49,11 +49,6 @@
|
||||
#define NS_LUMINOSITY_DIFFERENCE(a, b) \
|
||||
PR_ABS(NS_GetLuminosity(a) - NS_GetLuminosity(b))
|
||||
|
||||
// Weird color computing code stolen from winfe which was stolen
|
||||
// from the xfe which was written originally by Eric Bina. So there.
|
||||
// To determin colors based on the background brightness
|
||||
void NS_Get3DColors(nscolor aResult[2], nscolor aBackgroundColor);
|
||||
|
||||
// To determine colors based on the background brightness and border color
|
||||
void NS_GetSpecial3DColors(nscolor aResult[2],
|
||||
nscolor aBackgroundColor,
|
||||
@ -66,9 +61,12 @@ int NS_GetBrightness(PRUint8 aRed, PRUint8 aGreen, PRUint8 aBlue);
|
||||
// The range of return value is 0 to 255000.
|
||||
PRInt32 NS_GetLuminosity(nscolor aColor);
|
||||
|
||||
// function to convert from RGB color space to HSV color space
|
||||
void NS_RGB2HSV(nscolor aColor,PRUint16 &aHue,PRUint16 &aSat,PRUint16 &aValue);
|
||||
// function to convert from HSV color space to RGB color space
|
||||
void NS_HSV2RGB(nscolor &aColor,PRUint16 aHue,PRUint16 aSat,PRUint16 aValue);
|
||||
// function to convert from RGBA color space to HSVA color space
|
||||
void NS_RGB2HSV(nscolor aColor, PRUint16 &aHue, PRUint16 &aSat,
|
||||
PRUint16 &aValue, PRUint8 &aAlpha);
|
||||
|
||||
// function to convert from HSVA color space to RGBA color space
|
||||
void NS_HSV2RGB(nscolor &aColor, PRUint16 aHue, PRUint16 aSat, PRUint16 aValue,
|
||||
PRUint8 aAlpha);
|
||||
|
||||
#endif
|
||||
|
@ -366,31 +366,6 @@ MakeBevelColor(PRIntn whichSide, PRUint8 style,
|
||||
return theColor;
|
||||
}
|
||||
|
||||
nscolor
|
||||
nsCSSRendering::TransformColor(nscolor aMapColor,PRBool aNoBackGround)
|
||||
{
|
||||
PRUint16 hue,sat,value;
|
||||
nscolor newcolor;
|
||||
|
||||
newcolor = aMapColor;
|
||||
if (PR_TRUE == aNoBackGround){
|
||||
// convert the RBG to HSV so we can get the lightness (which is the v)
|
||||
NS_RGB2HSV(newcolor,hue,sat,value);
|
||||
// The goal here is to send white to black while letting colored
|
||||
// stuff stay colored... So we adopt the following approach.
|
||||
// Something with sat = 0 should end up with value = 0. Something
|
||||
// with a high sat can end up with a high value and it's ok.... At
|
||||
// the same time, we don't want to make things lighter. Do
|
||||
// something simple, since it seems to work.
|
||||
if (value > sat) {
|
||||
value = sat;
|
||||
// convert this color back into the RGB color space.
|
||||
NS_HSV2RGB(newcolor,hue,sat,value);
|
||||
}
|
||||
}
|
||||
return newcolor;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Thebes Border Rendering Code Start
|
||||
|
||||
|
@ -181,13 +181,6 @@ struct nsCSSRendering {
|
||||
nscoord aStartBevelOffset = 0,
|
||||
PRUint8 aEndBevelSide = 0,
|
||||
nscoord aEndBevelOffset = 0);
|
||||
/**
|
||||
* transform a color to a color that will show up on a printer if needed
|
||||
* aMapColor - color to evaluate
|
||||
* aIsPrinter - Is this a printing device
|
||||
* return - the transformed color
|
||||
*/
|
||||
static nscolor TransformColor(nscolor aMapColor,PRBool aNoBackGround);
|
||||
|
||||
/**
|
||||
* Function for painting the decoration lines for the text.
|
||||
|
@ -2809,14 +2809,14 @@ EnsureDifferentColors(nscolor colorA, nscolor colorB)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// TODO delete nsCSSRendering::TransformColor because we're moving it here
|
||||
static nscolor
|
||||
DarkenColor(nscolor aColor)
|
||||
{
|
||||
PRUint16 hue,sat,value;
|
||||
PRUint16 hue, sat, value;
|
||||
PRUint8 alpha;
|
||||
|
||||
// convert the RBG to HSV so we can get the lightness (which is the v)
|
||||
NS_RGB2HSV(aColor,hue,sat,value);
|
||||
NS_RGB2HSV(aColor, hue, sat, value, alpha);
|
||||
|
||||
// The goal here is to send white to black while letting colored
|
||||
// stuff stay colored... So we adopt the following approach.
|
||||
@ -2827,7 +2827,7 @@ DarkenColor(nscolor aColor)
|
||||
if (value > sat) {
|
||||
value = sat;
|
||||
// convert this color back into the RGB color space.
|
||||
NS_HSV2RGB(aColor,hue,sat,value);
|
||||
NS_HSV2RGB(aColor, hue, sat, value, alpha);
|
||||
}
|
||||
return aColor;
|
||||
}
|
||||
|
18
layout/reftests/bugs/461512-1-ref.html
Normal file
18
layout/reftests/bugs/461512-1-ref.html
Normal file
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body { background-color: white; opacity: 0.5; }
|
||||
p { border: 10px solid rgb(10%, 20%, 30%);
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p style="border-style: solid;"> </p>
|
||||
<p style="border-style: dashed;"> </p>
|
||||
<!-- <p style="border-style: dotted;"> </p> -->
|
||||
<p style="border-style: double;"> </p>
|
||||
<p style="border-style: ridge;"> </p>
|
||||
<p style="border-style: groove;"> </p>
|
||||
<p style="border-style: inset;"> </p>
|
||||
<p style="border-style: outset;"> </p>
|
||||
</body>
|
||||
</html>
|
18
layout/reftests/bugs/461512-1.html
Normal file
18
layout/reftests/bugs/461512-1.html
Normal file
@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body { background-color: white; }
|
||||
p { border: 10px solid rgba(10%, 20%, 30%, 0.5);
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p style="border-style: solid;"> </p>
|
||||
<p style="border-style: dashed;"> </p>
|
||||
<!-- <p style="border-style: dotted;"> </p> -->
|
||||
<p style="border-style: double;"> </p>
|
||||
<p style="border-style: ridge;"> </p>
|
||||
<p style="border-style: groove;"> </p>
|
||||
<p style="border-style: inset;"> </p>
|
||||
<p style="border-style: outset;"> </p>
|
||||
</body>
|
||||
</html>
|
@ -929,3 +929,4 @@ fails == 441259-2.html 441259-2-ref.html # bug 441400
|
||||
== 455280-1.xhtml 455280-1-ref.xhtml
|
||||
fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 456147.xul 456147-ref.html # bug 456147, but not caused by it
|
||||
== 456484-1.html 456484-1-ref.html
|
||||
== 461512-1.html 461512-1-ref.html
|
||||
|
Loading…
Reference in New Issue
Block a user