summaryrefslogtreecommitdiff
path: root/layout/style/nsRuleNode.cpp
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2020-09-16 17:34:03 -0500
committerathenian200 <athenian200@outlook.com>2020-09-16 17:34:03 -0500
commit51764ac7228e723054bf304a381cc83d9067f10a (patch)
treee6b61358823507787f44880848cfcdf0de30b985 /layout/style/nsRuleNode.cpp
parent1f65f171aa7bc29523654a1dbea770907e6195ac (diff)
downloaduxp-51764ac7228e723054bf304a381cc83d9067f10a.tar.gz
Issue #1647 - Part 1: Implement percentage for CSS opacity keywords
This preliminary step allows percentages to be computed and display correctly, but unfortunately it fails a test after changing VARIANT_HN to VARIANT_HPN because that allows values to be serialized as percentages. However, not doing this means percentages are rejected as valid values for the user to input. The way the style system is setup makes it hard to change this for opacity without changing it for everything else, especially since some code-saving speed hacks in Bug 636029 and Bug 441367 that make a lot of assumptions about this stuff very rigid.
Diffstat (limited to 'layout/style/nsRuleNode.cpp')
-rw-r--r--layout/style/nsRuleNode.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp
index a0f65c069c..ea0db5b304 100644
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1577,6 +1577,21 @@ 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) {