@@ -53,8 +53,10 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
5353 function_ = functionLC ;
5454
5555 LexicalUnit next = lu ;
56+ if (next == null ) {
57+ throw new DOMException (DOMException .SYNTAX_ERR , function_ + " requires at least three values." );
58+ }
5659
57- final boolean percentage = LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ();
5860 red_ = getPart (next );
5961
6062 next = next .getNextLexicalUnit ();
@@ -64,18 +66,22 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
6466
6567 commaSeparated_ = next .getLexicalUnitType () == LexicalUnitType .OPERATOR_COMMA ;
6668 if (commaSeparated_ ) {
69+ if (red_ .getLexicalUnitType () == LexicalUnitType .NONE ) {
70+ throw new DOMException (DOMException .SYNTAX_ERR ,
71+ function_ + " has to use blank as separator if none is used." );
72+ }
73+
6774 next = next .getNextLexicalUnit ();
6875 if (next == null ) {
6976 throw new DOMException (DOMException .SYNTAX_ERR , function_ + " requires at least three values." );
7077 }
7178
72- if (percentage && LexicalUnitType .PERCENTAGE != next .getLexicalUnitType ()) {
73- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
74- }
75- if (!percentage && LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()) {
76- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
77- }
7879 green_ = getPart (next );
80+ if (green_ .getLexicalUnitType () == LexicalUnitType .NONE ) {
81+ throw new DOMException (DOMException .SYNTAX_ERR ,
82+ function_ + " has to use blank as separator if none is used." );
83+ }
84+
7985 next = next .getNextLexicalUnit ();
8086 if (next == null ) {
8187 throw new DOMException (DOMException .SYNTAX_ERR , function_ + " requires at least three values." );
@@ -90,13 +96,11 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
9096 throw new DOMException (DOMException .SYNTAX_ERR , function_ + "b requires at least three values." );
9197 }
9298
93- if (percentage && LexicalUnitType .PERCENTAGE != next .getLexicalUnitType ()) {
94- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
95- }
96- if (!percentage && LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()) {
97- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
98- }
9999 blue_ = getPart (next );
100+ if (blue_ .getLexicalUnitType () == LexicalUnitType .NONE ) {
101+ throw new DOMException (DOMException .SYNTAX_ERR ,
102+ function_ + " has to use blank as separator if none is used." );
103+ }
100104
101105 next = next .getNextLexicalUnit ();
102106 if (next == null ) {
@@ -112,19 +116,18 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
112116 }
113117
114118 alpha_ = getPart (next );
119+ if (alpha_ .getLexicalUnitType () == LexicalUnitType .NONE ) {
120+ throw new DOMException (DOMException .SYNTAX_ERR ,
121+ function_ + " has to use blank as separator if none is used." );
122+ }
123+
115124 next = next .getNextLexicalUnit ();
116125 if (next != null ) {
117126 throw new DOMException (DOMException .SYNTAX_ERR , "Too many parameters for " + function_ + " function." );
118127 }
119128 return ;
120129 }
121130
122- if (percentage && LexicalUnitType .PERCENTAGE != next .getLexicalUnitType ()) {
123- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
124- }
125- if (!percentage && LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()) {
126- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
127- }
128131 green_ = getPart (next );
129132 next = next .getNextLexicalUnit ();
130133 if (next == null ) {
@@ -135,12 +138,6 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
135138 function_ + " requires consitent separators (blank or comma)." );
136139 }
137140
138- if (percentage && LexicalUnitType .PERCENTAGE != next .getLexicalUnitType ()) {
139- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
140- }
141- if (!percentage && LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()) {
142- throw new DOMException (DOMException .SYNTAX_ERR , function_ + " mixing numbers and percentages." );
143- }
144141 blue_ = getPart (next );
145142 next = next .getNextLexicalUnit ();
146143 if (next == null ) {
@@ -165,7 +162,8 @@ public RGBColorImpl(final String function, final LexicalUnit lu) throws DOMExcep
165162 private static CSSValueImpl getPart (final LexicalUnit next ) {
166163 if (LexicalUnitType .PERCENTAGE == next .getLexicalUnitType ()
167164 || LexicalUnitType .INTEGER == next .getLexicalUnitType ()
168- || LexicalUnitType .REAL == next .getLexicalUnitType ()) {
165+ || LexicalUnitType .REAL == next .getLexicalUnitType ()
166+ || LexicalUnitType .NONE == next .getLexicalUnitType ()) {
169167 return new CSSValueImpl (next , true );
170168 }
171169
0 commit comments