@@ -36,6 +36,7 @@ public final int getType() {
3636 LAB lab = null ;
3737 LCH lch = null ;
3838 DeviceCMYK cmyk = null ;
39+ LightDark lightdark = null ;
3940
4041 boolean contains_variable = false ;
4142
@@ -114,6 +115,24 @@ public String toString() {
114115 return "*invalid*" ;
115116 }
116117
118+ public void setLightDark (ApplContext ac , CssExpression exp )
119+ throws InvalidParamException {
120+ if ((exp == null ) || (exp .getCount () != 2 )) {
121+ throw new InvalidParamException ("invalid-color" , ac );
122+ }
123+ LightDark ld = new LightDark ();
124+ CssValue l = exp .getValue ();
125+ char op = exp .getOperator ();
126+ if (l == null || op != COMMA ) {
127+ throw new InvalidParamException ("invalid-color" , ac );
128+ }
129+ exp .next ();
130+ CssValue d = exp .getValue ();
131+ ld .setLight (ac , l );
132+ ld .setDark (ac , d );
133+ this .lightdark = ld ;
134+ exp .next ();
135+ }
117136
118137 public void setRGBColor (ApplContext ac , CssExpression exp )
119138 throws InvalidParamException {
@@ -1379,5 +1398,20 @@ public void setDeviceCMYKColor(ApplContext ac, CssExpression exp)
13791398 }
13801399 }
13811400
1401+ /**
1402+ * Parse a LightDark color.
1403+ * format: light-dark( <color>, <color>) [ / <alpha-value> ]? ) |
1404+ */
1405+ public void setLightDarkColor (ApplContext ac , CssExpression exp )
1406+ throws InvalidParamException {
1407+ // light-dark defined in CSS3 and onward
1408+ if (ac .getCssVersion ().compareTo (CssVersion .CSS3 ) < 0 ) {
1409+ StringBuilder sb = new StringBuilder ();
1410+ sb .append ("light-dark(" ).append (exp .toStringFromStart ()).append (')' );
1411+ throw new InvalidParamException ("notversion" , sb .toString (),
1412+ ac .getCssVersionString (), ac );
1413+ }
1414+ lightdark = new LightDark ();
1415+ }
13821416}
13831417
0 commit comments