Suppress serialization of -moz-use-text-color in border shorthand in property getters just like we do in declaration serialization. (Bug 376075) r+sr=bzbarsky

This commit is contained in:
L. David Baron 2008-12-23 09:06:57 -05:00
parent c6bd080a7b
commit 5d32582baa
4 changed files with 48 additions and 14 deletions

View File

@ -730,11 +730,23 @@ nsCSSDeclaration::GetValue(nsCSSProperty aProperty,
nsCSSProps::kTypeTable[subprops[1]] == eCSSType_Value &&
nsCSSProps::kTypeTable[subprops[2]] == eCSSType_Value,
"type mismatch");
NS_ASSERTION(StringEndsWith(nsCSSProps::GetStringValue(subprops[2]),
NS_LITERAL_CSTRING("-color")) ||
StringEndsWith(nsCSSProps::GetStringValue(subprops[2]),
NS_LITERAL_CSTRING("-color-value")),
"third subprop must be the color property");
const nsCSSValue *colorValue =
static_cast<const nsCSSValue*>(data->StorageFor(subprops[2]));
PRBool isMozUseTextColor =
colorValue->GetUnit() == eCSSUnit_Enumerated &&
colorValue->GetIntValue() == NS_STYLE_COLOR_MOZ_USE_TEXT_COLOR;
if (!AppendValueToString(subprops[0], aValue) ||
!(aValue.Append(PRUnichar(' ')),
AppendValueToString(subprops[1], aValue)) ||
!(aValue.Append(PRUnichar(' ')),
AppendValueToString(subprops[2], aValue))) {
// Don't output a third value when it's -moz-use-text-color.
!(isMozUseTextColor ||
(aValue.Append(PRUnichar(' ')),
AppendValueToString(subprops[2], aValue)))) {
aValue.Truncate();
}
break;
@ -1033,11 +1045,11 @@ nsCSSDeclaration::TryBorderShorthand(nsAString & aString, PRUint32 aPropertiesSe
aString.Append(PRUnichar(' '));
AppendValueToString(eCSSProperty_border_top_style, aString);
aString.Append(PRUnichar(' '));
nsAutoString valueString;
AppendValueToString(eCSSProperty_border_top_color, valueString);
if (!valueString.EqualsLiteral("-moz-use-text-color")) {
aString.Append(PRUnichar(' '));
/* don't output this value, it's proprietary Mozilla and */
/* not intended to be exposed ; we can remove it from the */
/* values of the shorthand since this value represents the */

View File

@ -1349,6 +1349,7 @@ static const nsCSSProperty gBorderSubpropTable[] = {
static const nsCSSProperty gBorderBottomSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_bottom_width,
eCSSProperty_border_bottom_style,
eCSSProperty_border_bottom_color,
@ -1403,6 +1404,7 @@ static const nsCSSProperty gMozBorderStartColorSubpropTable[] = {
static const nsCSSProperty gMozBorderEndSubpropTable[] = {
// nsCSSDeclaration.cpp output the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_end_width_value,
eCSSProperty_border_end_style_value,
eCSSProperty_border_end_color_value,
@ -1418,6 +1420,7 @@ static const nsCSSProperty gMozBorderEndSubpropTable[] = {
static const nsCSSProperty gBorderLeftSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_left_width_value,
eCSSProperty_border_left_style_value,
eCSSProperty_border_left_color_value,
@ -1433,6 +1436,7 @@ static const nsCSSProperty gBorderLeftSubpropTable[] = {
static const nsCSSProperty gBorderRightSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_right_width_value,
eCSSProperty_border_right_style_value,
eCSSProperty_border_right_color_value,
@ -1448,6 +1452,7 @@ static const nsCSSProperty gBorderRightSubpropTable[] = {
static const nsCSSProperty gMozBorderStartSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_start_width_value,
eCSSProperty_border_start_style_value,
eCSSProperty_border_start_color_value,
@ -1509,6 +1514,7 @@ static const nsCSSProperty gMozBorderEndStyleSubpropTable[] = {
static const nsCSSProperty gBorderTopSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty_border_top_width,
eCSSProperty_border_top_style,
eCSSProperty_border_top_color,
@ -1636,13 +1642,16 @@ static const nsCSSProperty gMozMarginEndSubpropTable[] = {
static const nsCSSProperty gOutlineSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
eCSSProperty_outline_color,
eCSSProperty_outline_style,
// It also depends on the color being third.
eCSSProperty_outline_width,
eCSSProperty_outline_style,
eCSSProperty_outline_color,
eCSSProperty_UNKNOWN
};
static const nsCSSProperty gMozColumnRuleSubpropTable[] = {
// nsCSSDeclaration.cpp outputs the subproperties in this order.
// It also depends on the color being third.
eCSSProperty__moz_column_rule_width,
eCSSProperty__moz_column_rule_style,
eCSSProperty__moz_column_rule_color,

View File

@ -42,6 +42,28 @@ is(e.style.border, "", "should not be able to serialize border");
e.setAttribute("style", "border-width: 3px 3px 3px 3px; border-style: solid dashed; border-color: green");
is(e.style.border, "", "should not be able to serialize border");
// Test suppression of -moz-use-text-color in border shorthands.
e.setAttribute("style", "border: medium solid");
ok(e.style.border == "medium solid" ||
e.style.border == "solid medium",
"implied default color omitted serializing border");
ok(e.style.borderLeft == "medium solid" ||
e.style.borderLeft == "solid medium",
"implied default color omitted serializing border-left");
ok(e.style.cssText == "border: medium solid;" ||
e.style.cssText == "border: solid medium;",
"implied default color omitted serializing declaration");
e.setAttribute("style", "border-right: medium solid");
ok(e.style.borderRight == "medium solid" ||
e.style.borderRight == "solid medium",
"implied default color omitted serializing border-right");
ok(e.style.borderRight == "medium solid" ||
e.style.borderRight == "solid medium",
"implied default color omitted serializing border-right");
ok(e.style.cssText == "border-right: medium solid;" ||
e.style.cssText == "border-right: solid medium;",
"implied default color omitted serializing declaration");
</script>
</pre>

View File

@ -109,15 +109,6 @@ function xfail_ser_val(property, value)
if (property in gShorthandsWithoutCondensingSerialize)
return true;
// We output unneeded -moz-use-text-color only in the value getter and
// not the serialization.
// XXXbz is there any way we could actually filter for that, so that colors
// other than green could be used in the property database here?
if ((property.match(/^border(|-bottom|-left|-right|-top)$/) ||
property.match(/^-moz-border(|-start|-end)$/)) &&
!value.match(/(green|currentcolor)/i))
return true;
// We condense multiple values in the serialization, but not in the
// value getter.
if (property.match(/^(border-(color|style|width)|margin|padding)$/) &&