Implement the HTML5 algorithm for parsing a legacy color value: do loose color parsing in all modes. (Bug 121738) r=sicking

This commit is contained in:
L. David Baron 2010-06-03 13:11:34 -07:00
parent c52c114b11
commit 7d1e9ef96f
3 changed files with 7 additions and 12 deletions

View File

@ -1164,12 +1164,7 @@ nsAttrValue::ParseColor(const nsAString& aString, nsIDocument* aDocument)
}
}
if (aDocument->GetCompatibilityMode() != eCompatibility_NavQuirks) {
return PR_FALSE;
}
// In compatibility mode, try LooseHexToRGB as a fallback for either
// of the above two possibilities.
// Use NS_LooseHexToRGB as a fallback if nothing above worked.
if (NS_LooseHexToRGB(colorStr, &color)) {
SetColorValue(color, aString);
return PR_TRUE;

View File

@ -15,7 +15,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=493881
</style>
</head>
<body>
<body id="body">
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=493881"
target="_blank" >Mozilla Bug 493881</a>

View File

@ -10,7 +10,7 @@ var legacyProps = ["fgColor", "bgColor", "linkColor", "vlinkColor", "alinkColor"
var testColors = ["blue", "silver", "green", "orange", "red"];
var rgbTestColors = ["rgb(255, 0, 0)", "rgb(192, 192, 192)", "rgb(0, 128, 0)", "rgb(255, 165, 0)", "rgb(255, 0, 0)"];
var idPropList = [ {id: "plaintext", prop: "color"},
{id: "plaintext", prop: "background-color"},
{id: "body", prop: "background-color"},
{id: "nonvisitedlink", prop: "color"},
{id: "visitedlink", prop: "color"} ];
var initialValues = [];
@ -58,13 +58,13 @@ addLoadEvent( function() {
"Unexpected value of " + legacyProps[i] + " after setting to undefined");
}
// Verify that setting legacy color props to undefined did not affect rendering
// (computed styles).
// Verify that setting legacy color props to undefined led to result
// of parsing undefined as a color.
for (i = 0; i < idPropList.length; i++) {
var style = window.getComputedStyle(document.getElementById(idPropList[i].id), null);
var color = style.getPropertyValue(idPropList[i].prop);
is(color, idPropList[i].initialComputedColor,
"element's style changed by setting legacy prop to undefined");
is(color, "rgb(0, 239, 14)",
"element's style should get result of parsing undefined as a color");
}
// Mark the test as finished.