Bug 757371 part 2 - Improve correctness of nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet; r=ehsan

This commit is contained in:
Aryeh Gregor 2012-05-28 14:20:27 +03:00
parent d77f45134f
commit 4cad3af933
2 changed files with 25 additions and 15 deletions

View File

@ -213,8 +213,6 @@
"[[\"stylewithcss\",\"false\"],[\"bold\",\"\"]] \"<span style=\\\"font-weight: 700\\\">foo[barbaz</span>}\" queryCommandState(\"bold\") after":true,
"[[\"bold\",\"\"]] \"<span style=\\\"font-weight: 900\\\">foo[barbaz</span>}\" compare innerHTML":true,
"[[\"bold\",\"\"]] \"<span style=\\\"font-weight: 900\\\">foo[barbaz</span>}\" queryCommandState(\"bold\") after":true,
"[[\"stylewithcss\",\"true\"],[\"bold\",\"\"]] \"<h3>foo[bar]baz</h3>\" compare innerHTML":true,
"[[\"stylewithcss\",\"true\"],[\"bold\",\"\"]] \"<h3>foo[bar]baz</h3>\" queryCommandState(\"bold\") after":true,
"[[\"stylewithcss\",\"false\"],[\"bold\",\"\"]] \"<h3>foo[bar]baz</h3>\" compare innerHTML":true,
"[[\"stylewithcss\",\"false\"],[\"bold\",\"\"]] \"<h3>foo[bar]baz</h3>\" queryCommandState(\"bold\") after":true,
"[[\"stylewithcss\",\"true\"],[\"bold\",\"\"]] \"{<h3>foobar]baz</h3>\" compare innerHTML":true,
@ -1707,8 +1705,6 @@
"[[\"stylewithcss\",\"false\"],[\"forecolor\",\"cornsilk\"]] \"foo[bar]baz\" compare innerHTML":true,
"[[\"forecolor\",\"potato quiche\"]] \"foo[bar]baz\" compare innerHTML":true,
"[[\"forecolor\",\"potato quiche\"]] \"foo[bar]baz\" queryCommandValue(\"forecolor\") after":true,
"[[\"stylewithcss\",\"true\"],[\"forecolor\",\"transparent\"]] \"foo[bar]baz\" compare innerHTML":true,
"[[\"stylewithcss\",\"true\"],[\"forecolor\",\"transparent\"]] \"foo[bar]baz\" queryCommandValue(\"forecolor\") after":true,
"[[\"stylewithcss\",\"false\"],[\"forecolor\",\"transparent\"]] \"foo[bar]baz\" compare innerHTML":true,
"[[\"forecolor\",\"currentColor\"]] \"foo[bar]baz\": execCommand(\"forecolor\", false, \"currentColor\") return value":true,
"[[\"forecolor\",\"currentColor\"]] \"foo[bar]baz\" compare innerHTML":true,

View File

@ -1162,22 +1162,32 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
if (NS_ColorNameToRGB(htmlValueString, &rgba) ||
NS_HexToRGB(subStr, &rgba)) {
nsAutoString htmlColor, tmpStr;
htmlColor.AppendLiteral("rgb(");
NS_NAMED_LITERAL_STRING(comma, ", ");
if (NS_GET_A(rgba) != 255) {
// This should only be hit by the "transparent" keyword, which
// currently serializes to "transparent" (not "rgba(0, 0, 0, 0)").
MOZ_ASSERT(NS_GET_R(rgba) == 0 && NS_GET_G(rgba) == 0 &&
NS_GET_B(rgba) == 0 && NS_GET_A(rgba) == 0);
htmlColor.AppendLiteral("transparent");
} else {
htmlColor.AppendLiteral("rgb(");
tmpStr.AppendInt(NS_GET_R(rgba), 10);
htmlColor.Append(tmpStr + comma);
NS_NAMED_LITERAL_STRING(comma, ", ");
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_G(rgba), 10);
htmlColor.Append(tmpStr + comma);
tmpStr.AppendInt(NS_GET_R(rgba), 10);
htmlColor.Append(tmpStr + comma);
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_B(rgba), 10);
htmlColor.Append(tmpStr);
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_G(rgba), 10);
htmlColor.Append(tmpStr + comma);
tmpStr.Truncate();
tmpStr.AppendInt(NS_GET_B(rgba), 10);
htmlColor.Append(tmpStr);
htmlColor.Append(PRUnichar(')'));
}
htmlColor.Append(PRUnichar(')'));
aIsSet = htmlColor.Equals(valueString,
nsCaseInsensitiveStringComparator());
} else {
@ -1231,6 +1241,10 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode *aNode,
aIsSet = true;
}
if (htmlValueString.EqualsLiteral("-moz-editor-invert-value")) {
aIsSet = !aIsSet;
}
if (nsEditProperty::u == aHTMLProperty || nsEditProperty::strike == aHTMLProperty) {
// unfortunately, the value of the text-decoration property is not inherited.
// that means that we have to look at ancestors of node to see if they are underlined