Issue #1647 - Part 2: Implement VARIANT_OPACITY to correctly serialize.

Even though percentages are already treated as floats internally by the style system for computation purposes, you have to go out of your way to stop them from being read back out as percentages. What I do here amounts to storing the percentage token in the "wrong" container, the one normally used for floats. This allows a value that was read in as a percentage to be read back out as something else, which is normally prevented by the design of the style system.
This commit is contained in:
athenian200 2020-09-17 16:01:38 -05:00 committed by roytam1
commit fb8d9b8c78
6 changed files with 33 additions and 35 deletions

View file

@ -1579,21 +1579,6 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon
case eCSSUnit_Null:
return;
case eCSSUnit_Percent:
aField = aValue.GetPercentValue();
if (aFlags & SETFCT_POSITIVE) {
NS_ASSERTION(aField >= 0.0f, "negative value for positive-only property");
if (aField < 0.0f)
aField = 0.0f;
}
if (aFlags & SETFCT_OPACITY) {
if (aField < 0.0f)
aField = 0.0f;
if (aField > 1.0f)
aField = 1.0f;
}
return;
case eCSSUnit_Number:
aField = aValue.GetFloatValue();
if (aFlags & SETFCT_POSITIVE) {