зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug #4434
This commit is contained in:
Родитель
aa92be47b0
Коммит
55ab03b515
|
@ -1396,7 +1396,11 @@ nsGenericHTMLElement::ParseColor(const nsString& aString,
|
|||
}
|
||||
}
|
||||
|
||||
#if XXX_no_nav_compat
|
||||
// XXX Nav doesn't map illegal values to zero, at least not for color names.
|
||||
// Changing it so we ignore the illegal values rather than whack the color to
|
||||
// black, which in the case of a background color makes the document unreadable
|
||||
//#if XXX_no_nav_compat
|
||||
#if 1
|
||||
// Illegal values are mapped to empty
|
||||
aResult.SetEmptyValue();
|
||||
return PR_FALSE;
|
||||
|
@ -1911,10 +1915,13 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes
|
|||
char cbuf[40];
|
||||
buffer.ToCString(cbuf, sizeof(cbuf));
|
||||
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
|
||||
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
nscolor backgroundColor;
|
||||
if (NS_ColorNameToRGB(cbuf, &backgroundColor)) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mBackgroundColor = backgroundColor;
|
||||
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -618,16 +618,14 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static nscolor ColorNameToRGB(const nsHTMLValue& aValue)
|
||||
static PRBool ColorNameToRGB(const nsHTMLValue& aValue, nscolor* aColor)
|
||||
{
|
||||
nsAutoString buffer;
|
||||
aValue.GetStringValue(buffer);
|
||||
char cbuf[40];
|
||||
buffer.ToCString(cbuf, sizeof(cbuf));
|
||||
|
||||
nscolor color;
|
||||
NS_ColorNameToRGB(cbuf, &color);
|
||||
return color;
|
||||
return NS_ColorNameToRGB(cbuf, aColor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -646,9 +644,12 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
color->mColor = value.GetColorValue();
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mColor = ColorNameToRGB(value);
|
||||
nscolor backgroundColor;
|
||||
if (ColorNameToRGB(value, &backgroundColor)) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mColor = backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
|
@ -667,7 +668,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
||||
|
@ -675,7 +679,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetActiveLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetActiveLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
||||
|
@ -683,7 +690,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetVisitedLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetVisitedLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(styleSheet);
|
||||
}
|
||||
|
|
|
@ -1396,7 +1396,11 @@ nsGenericHTMLElement::ParseColor(const nsString& aString,
|
|||
}
|
||||
}
|
||||
|
||||
#if XXX_no_nav_compat
|
||||
// XXX Nav doesn't map illegal values to zero, at least not for color names.
|
||||
// Changing it so we ignore the illegal values rather than whack the color to
|
||||
// black, which in the case of a background color makes the document unreadable
|
||||
//#if XXX_no_nav_compat
|
||||
#if 1
|
||||
// Illegal values are mapped to empty
|
||||
aResult.SetEmptyValue();
|
||||
return PR_FALSE;
|
||||
|
@ -1911,10 +1915,13 @@ nsGenericHTMLElement::MapBackgroundAttributesInto(nsIHTMLAttributes* aAttributes
|
|||
char cbuf[40];
|
||||
buffer.ToCString(cbuf, sizeof(cbuf));
|
||||
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
NS_ColorNameToRGB(cbuf, &(color->mBackgroundColor));
|
||||
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
nscolor backgroundColor;
|
||||
if (NS_ColorNameToRGB(cbuf, &backgroundColor)) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mBackgroundColor = backgroundColor;
|
||||
color->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -618,16 +618,14 @@ nsHTMLBodyElement::AttributeToString(nsIAtom* aAttribute,
|
|||
return mInner.AttributeToString(aAttribute, aValue, aResult);
|
||||
}
|
||||
|
||||
static nscolor ColorNameToRGB(const nsHTMLValue& aValue)
|
||||
static PRBool ColorNameToRGB(const nsHTMLValue& aValue, nscolor* aColor)
|
||||
{
|
||||
nsAutoString buffer;
|
||||
aValue.GetStringValue(buffer);
|
||||
char cbuf[40];
|
||||
buffer.ToCString(cbuf, sizeof(cbuf));
|
||||
|
||||
nscolor color;
|
||||
NS_ColorNameToRGB(cbuf, &color);
|
||||
return color;
|
||||
return NS_ColorNameToRGB(cbuf, aColor);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -646,9 +644,12 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
color->mColor = value.GetColorValue();
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mColor = ColorNameToRGB(value);
|
||||
nscolor backgroundColor;
|
||||
if (ColorNameToRGB(value, &backgroundColor)) {
|
||||
nsStyleColor* color = (nsStyleColor*)
|
||||
aContext->GetMutableStyleData(eStyleStruct_Color);
|
||||
color->mColor = backgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
|
@ -667,7 +668,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::alink, value);
|
||||
|
@ -675,7 +679,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetActiveLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetActiveLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetActiveLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
|
||||
aAttributes->GetAttribute(nsHTMLAtoms::vlink, value);
|
||||
|
@ -683,7 +690,10 @@ MapAttributesInto(nsIHTMLAttributes* aAttributes,
|
|||
styleSheet->SetVisitedLinkColor(value.GetColorValue());
|
||||
}
|
||||
else if (eHTMLUnit_String == value.GetUnit()) {
|
||||
styleSheet->SetVisitedLinkColor(ColorNameToRGB(value));
|
||||
nscolor linkColor;
|
||||
if (ColorNameToRGB(value, &linkColor)) {
|
||||
styleSheet->SetVisitedLinkColor(linkColor);
|
||||
}
|
||||
}
|
||||
NS_RELEASE(styleSheet);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче