From b862145e9c7f0802ea5fa7e02c003744dbca9ec2 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Wed, 16 Sep 2020 17:34:03 -0500 Subject: 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. --- layout/style/nsCSSPropList.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'layout/style/nsCSSPropList.h') diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index f62aa3827..906ed7ee0 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1703,7 +1703,7 @@ CSS_PROP_SVG( FillOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mFillOpacity), eStyleAnimType_float) @@ -1841,7 +1841,7 @@ CSS_PROP_SVGRESET( FloodOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleSVGReset, mFloodOpacity), eStyleAnimType_float) @@ -3070,7 +3070,7 @@ CSS_PROP_EFFECTS( CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR | CSS_PROPERTY_CREATES_STACKING_CONTEXT, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleEffects, mOpacity), eStyleAnimType_float) @@ -3761,7 +3761,7 @@ CSS_PROP_SVGRESET( StopOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleSVGReset, mStopOpacity), eStyleAnimType_float) @@ -3836,7 +3836,7 @@ CSS_PROP_SVG( StrokeOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mStrokeOpacity), eStyleAnimType_float) -- cgit v1.2.3 From f2866a5420b4645d888fc50b22f7cbdd8a178042 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Thu, 17 Sep 2020 16:01:38 -0500 Subject: 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. --- layout/style/nsCSSPropList.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'layout/style/nsCSSPropList.h') diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 906ed7ee0..890019245 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1703,7 +1703,7 @@ CSS_PROP_SVG( FillOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_INHERIT | VARIANT_OPACITY | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mFillOpacity), eStyleAnimType_float) @@ -1841,7 +1841,7 @@ CSS_PROP_SVGRESET( FloodOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleSVGReset, mFloodOpacity), eStyleAnimType_float) @@ -3070,7 +3070,7 @@ CSS_PROP_EFFECTS( CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR | CSS_PROPERTY_CREATES_STACKING_CONTEXT, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleEffects, mOpacity), eStyleAnimType_float) @@ -3761,7 +3761,7 @@ CSS_PROP_SVGRESET( StopOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleSVGReset, mStopOpacity), eStyleAnimType_float) @@ -3836,7 +3836,7 @@ CSS_PROP_SVG( StrokeOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_INHERIT | VARIANT_OPACITY | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mStrokeOpacity), eStyleAnimType_float) -- cgit v1.2.3