99import org .w3c .css .util .ApplContext ;
1010import org .w3c .css .util .InvalidParamException ;
1111import org .w3c .css .values .CssExpression ;
12+ import org .w3c .css .values .CssIdent ;
13+ import org .w3c .css .values .CssTypes ;
1214import org .w3c .css .values .CssValue ;
1315import org .w3c .css .values .CssValueList ;
1416
1719import static org .w3c .css .values .CssOperator .SPACE ;
1820
1921/**
20- * @spec http ://www.w3.org/TR/2012/CR-css3-background-20120417/# border-color
22+ * @spec https ://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef- border-color
2123 */
2224public class CssBorderColor extends org .w3c .css .properties .css .CssBorderColor {
2325
@@ -37,8 +39,7 @@ public CssBorderColor() {
3739 * Does not check the number of values
3840 *
3941 * @param expression The expression for this property
40- * @throws org.w3c.css.util.InvalidParamException
41- * The expression is incorrect
42+ * @throws org.w3c.css.util.InvalidParamException The expression is incorrect
4243 */
4344 public CssBorderColor (ApplContext ac , CssExpression expression )
4445 throws InvalidParamException {
@@ -50,8 +51,7 @@ public CssBorderColor(ApplContext ac, CssExpression expression)
5051 *
5152 * @param expression The expression for this property
5253 * @param check set it to true to check the number of values
53- * @throws org.w3c.css.util.InvalidParamException
54- * The expression is incorrect
54+ * @throws org.w3c.css.util.InvalidParamException The expression is incorrect
5555 */
5656 public CssBorderColor (ApplContext ac , CssExpression expression ,
5757 boolean check ) throws InvalidParamException {
@@ -61,14 +61,17 @@ public CssBorderColor(ApplContext ac, CssExpression expression,
6161 setByUser ();
6262 CssValue val ;
6363 char op ;
64+ boolean isCssWide = false ;
6465
6566 ArrayList <CssValue > res = new ArrayList <CssValue >();
6667 while (res .size () < 4 && !expression .end ()) {
6768 val = expression .getValue ();
6869 op = expression .getOperator ();
6970
70- if (inherit .equals (val )) {
71- res .add (inherit );
71+ if ((val .getType () == CssTypes .CSS_IDENT ) && CssIdent .isCssWide (val .getIdent ())) {
72+ res .add (val );
73+ isCssWide = true ;
74+ value = val ;
7275 } else {
7376 try {
7477 CssExpression ex = new CssExpression ();
@@ -77,7 +80,7 @@ public CssBorderColor(ApplContext ac, CssExpression expression,
7780 CssColor tcolor = new CssColor (ac , ex , check );
7881 // instead of using getColor, we get the value directly
7982 // as we can have idents
80- res .add (tcolor .color );
83+ res .add (tcolor .getValue () );
8184 } catch (InvalidParamException e ) {
8285 throw new InvalidParamException ("value" ,
8386 val .toString (),
@@ -92,8 +95,10 @@ public CssBorderColor(ApplContext ac, CssExpression expression,
9295 }
9396 }
9497 // check that inherit is alone
95- if (res .size () > 1 && res .contains (inherit )) {
96- throw new InvalidParamException ("unrecognize" , ac );
98+ if (res .size () > 1 && isCssWide ) {
99+ throw new InvalidParamException ("value" ,
100+ value .toString (),
101+ getPropertyName (), ac );
97102 }
98103 value = (res .size () == 1 ) ? res .get (0 ) : new CssValueList (res );
99104
@@ -133,7 +138,9 @@ public CssBorderColor(ApplContext ac, CssExpression expression,
133138 * Check the border-*-color and returns a value.
134139 * It makes sense to do it only once for all the sides, so by having the code here.
135140 */
136- protected static CssValue parseBorderSideColor (ApplContext ac , CssExpression expression , boolean check , CssProperty caller ) throws InvalidParamException {
141+ protected static CssValue parseBorderSideColor (ApplContext ac , CssExpression expression ,
142+ boolean check , CssProperty caller )
143+ throws InvalidParamException {
137144
138145 if (check && expression .getCount () > 1 ) {
139146 throw new InvalidParamException ("unrecognize" , ac );
@@ -142,15 +149,15 @@ protected static CssValue parseBorderSideColor(ApplContext ac, CssExpression exp
142149 CssValue retval = null ;
143150 CssValue val = expression .getValue ();
144151
145- if (inherit . equals ( val )) {
146- retval = inherit ;
152+ if (( val . getType () == CssTypes . CSS_IDENT ) && CssIdent . isCssWide ( val . getIdent () )) {
153+ retval = val ;
147154 } else {
148155 try {
149156 // we use the latest version of CssColor, aka CSS3
150157 CssColor tcolor = new CssColor (ac , expression , check );
151158 // instead of using getColor, we get the value directly
152159 // as we can have idents
153- retval = tcolor .color ;
160+ retval = tcolor .getValue () ;
154161 } catch (InvalidParamException e ) {
155162 throw new InvalidParamException ("value" ,
156163 val .toString (),
0 commit comments