mshtml: Store known colors as RGB.
This commit is contained in:
parent
bbd925ddfe
commit
9a264e546c
@ -63,45 +63,57 @@ static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
|
|||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
LPCWSTR keyword;
|
LPCWSTR keyword;
|
||||||
const WCHAR hexstr[8];
|
DWORD rgb;
|
||||||
} keyword_table[] = {
|
} keyword_table[] = {
|
||||||
{aquaW, {'#','0','0','f','f','f','f',0}},
|
{aquaW, 0x00ffff},
|
||||||
{blackW, {'#','0','0','0','0','0','0',0}},
|
{blackW, 0x000000},
|
||||||
{blueW, {'#','0','0','0','0','f','f',0}},
|
{blueW, 0x0000ff},
|
||||||
{fuchsiaW, {'#','f','f','0','0','f','f',0}},
|
{fuchsiaW, 0xff00ff},
|
||||||
{grayW, {'#','8','0','8','0','8','0',0}},
|
{grayW, 0x808080},
|
||||||
{greenW, {'#','0','0','8','0','0','0',0}},
|
{greenW, 0x008000},
|
||||||
{limeW, {'#','0','0','f','f','0','0',0}},
|
{limeW, 0x00ff00},
|
||||||
{maroonW, {'#','8','0','0','0','0','0',0}},
|
{maroonW, 0x800000},
|
||||||
{navyW, {'#','0','0','0','0','8','0',0}},
|
{navyW, 0x000080},
|
||||||
{oliveW, {'#','8','0','8','0','0','0',0}},
|
{oliveW, 0x808000},
|
||||||
{purpleW, {'#','8','0','0','0','8','0',0}},
|
{purpleW, 0x800080},
|
||||||
{redW, {'#','f','f','0','0','0','0',0}},
|
{redW, 0xff0000},
|
||||||
{silverW, {'#','c','0','c','0','c','0',0}},
|
{silverW, 0xc0c0c0},
|
||||||
{tealW, {'#','0','0','8','0','8','0',0}},
|
{tealW, 0x008080},
|
||||||
{whiteW, {'#','f','f','f','f','f','f',0}},
|
{whiteW, 0xffffff},
|
||||||
{yellowW, {'#','f','f','f','f','0','0',0}}
|
{yellowW, 0xffff00}
|
||||||
};
|
};
|
||||||
|
|
||||||
static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
|
static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
|
||||||
{
|
{
|
||||||
int i;
|
int i, rgb = -1;
|
||||||
|
|
||||||
|
static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
|
||||||
|
|
||||||
if(!color || *color == '#') {
|
if(!color || *color == '#') {
|
||||||
*ret = SysAllocString(color);
|
*ret = SysAllocString(color);
|
||||||
return *ret ? S_OK : E_OUTOFMEMORY;
|
return *ret ? S_OK : E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(*color != '#') {
|
||||||
for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
|
for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
|
||||||
if(!strcmpiW(color, keyword_table[i].keyword)) {
|
if(!strcmpiW(color, keyword_table[i].keyword))
|
||||||
*ret = SysAllocString(keyword_table[i].hexstr);
|
rgb = keyword_table[i].rgb;
|
||||||
return *ret ? S_OK : E_OUTOFMEMORY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(rgb == -1) {
|
||||||
WARN("unknown color %s\n", debugstr_w(color));
|
WARN("unknown color %s\n", debugstr_w(color));
|
||||||
*ret = SysAllocString(color);
|
*ret = SysAllocString(color);
|
||||||
return *ret ? S_OK : E_OUTOFMEMORY;
|
return *ret ? S_OK : E_OUTOFMEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ret = SysAllocStringLen(NULL, 7);
|
||||||
|
if(!*ret)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
|
||||||
|
|
||||||
|
TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
|
static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user