- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 09 Feb 2012 17:36:35 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv25830/w3c/css/properties/css3
Modified Files:
Css3Style.java CssBackgroundColor.java CssColumnCount.java
CssColumnGap.java CssColumnWidth.java CssHeight.java
CssWidth.java
Added Files:
CssLetterSpacing.java CssWhiteSpace.java CssWordSpacing.java
Removed Files:
CssWhiteSpaceCSS3.java CssWordSpacingCSS3.java
Log Message:
various things: Use of BigIntegers to avoid limits, background-* are now avoiding multiplication of checks and properties in CssXStyles impls, various updates for other properties, use of a string reader for string input, added the possibility of not following links, prepared for aggregation of all uris parsed
Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- Css3Style.java 21 Oct 2011 01:49:10 -0000 1.15
+++ Css3Style.java 9 Feb 2012 17:36:32 -0000 1.16
@@ -114,8 +114,6 @@
public CssBackgroundSize cssBackgroundSize;
public CssBackgroundOrigin cssBackgroundOrigin;
CssTextDecorationCSS3 cssTextDecoration;
- CssWhiteSpaceCSS3 cssWhiteSpace;
- CssWordSpacingCSS3 cssWordSpacing;
CssAllSpaceTreatment cssAllSpaceTreatment;
CssHangingPunctuation cssHangingPunctuation;
CssLineGrid cssLineGrid;
@@ -977,24 +975,6 @@
return cssTextDecoration;
}
- public CssWhiteSpaceCSS3 getCssWhiteSpace() {
- if (cssWhiteSpace == null) {
- cssWhiteSpace =
- (CssWhiteSpaceCSS3) style.CascadingOrder(
- new CssWhiteSpaceCSS3(), style, selector);
- }
- return cssWhiteSpace;
- }
-
- public CssWordSpacingCSS3 getCssWordSpacing() {
- if (cssWordSpacing == null) {
- cssWordSpacing =
- (CssWordSpacingCSS3) style.CascadingOrder(
- new CssWordSpacingCSS3(), style, selector);
- }
- return cssWordSpacing;
- }
-
public CssAllSpaceTreatment getAllSpaceTreatment() {
if (cssAllSpaceTreatment == null) {
cssAllSpaceTreatment =
--- NEW FILE: CssLetterSpacing.java ---
// $Id: CssLetterSpacing.java,v 1.1 2012/02/09 17:36:32 ylafon Exp $
//
// (c) COPYRIGHT MIT, INRIA and Keio University, 2011
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css3;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssNumber;
import org.w3c.css.values.CssOperator;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
* @spec http://www.w3.org/TR/2011/WD-css3-text-20110901/#letter-spacing0
*/
public class CssLetterSpacing extends org.w3c.css.properties.css.CssLetterSpacing {
private CssValue value[] = new CssValue[3];
int nb_values;
private static CssIdent normal = CssIdent.getIdent("normal");
/**
* Create a new CssLetterSpacing.
*/
public CssLetterSpacing() {
value[0] = normal;
}
/**
* Create a new CssLetterSpacing with an expression
*
* @param expression The expression
* @throws org.w3c.css.util.InvalidParamException
* The expression is incorrect
*/
public CssLetterSpacing(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
nb_values = expression.getCount();
if (check && nb_values > 3) {
throw new InvalidParamException("unrecognize", ac);
}
for (int i = 0; i < nb_values; i++) {
CssValue val = expression.getValue();
setByUser();
switch (val.getType()) {
case CssTypes.CSS_NUMBER:
val = ((CssNumber) val).getLength();
case CssTypes.CSS_LENGTH:
value[i] = val;
break;
case CssTypes.CSS_PERCENTAGE:
value[i] = val;
break;
case CssTypes.CSS_IDENT:
if (inherit.equals(val)) {
// inherit can only be alone
if (nb_values > 1) {
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
value[i] = inherit;
break;
} else if (normal.equals(val)) {
value[i] = normal;
break;
}
default:
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
if (i+1 < nb_values && expression.getOperator() != CssOperator.SPACE) {
throw new InvalidParamException("operator", CssOperator.SPACE, ac);
}
expression.next();
}
}
public CssLetterSpacing(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
return value;
}
/**
* Returns true if this property is "softly" inherited
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
return value[0] == inherit;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
if (nb_values == 1) {
return value[0].toString();
}
StringBuilder sb = new StringBuilder();
for (int i=0; i < nb_values; i++) {
if (i > 0) {
sb.append(' ');
}
sb.append(value[i]);
}
return sb.toString();
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssLetterSpacing &&
value.equals(((CssLetterSpacing) property).value));
}
}
Index: CssHeight.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssHeight.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssHeight.java 27 Sep 2011 08:15:46 -0000 1.1
+++ CssHeight.java 9 Feb 2012 17:36:32 -0000 1.2
@@ -65,7 +65,7 @@
val = ((CssNumber) val).getLength();
case CssTypes.CSS_LENGTH:
lenVal = (CssLength) val;
- if (lenVal.floatValue() < 0.) {
+ if (!lenVal.isPositive()) {
throw new InvalidParamException("negative-value",
val.toString(), ac);
}
Index: CssColumnWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnWidth.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- CssColumnWidth.java 23 Oct 2011 14:42:32 -0000 1.10
+++ CssColumnWidth.java 9 Feb 2012 17:36:32 -0000 1.11
@@ -53,7 +53,6 @@
setByUser();
CssValue val = expression.getValue();
- Float value;
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
@@ -67,8 +66,8 @@
expression.getValue(),
getPropertyName(), ac);
case CssTypes.CSS_LENGTH:
- value = (Float) ((CssLength) val).get();
- if (value == null || value.floatValue() <= 0.0) {
+ CssLength l = (CssLength) val;
+ if (l == null || !l.isStrictlyPositive()) {
throw new InvalidParamException("strictly-positive",
expression.getValue(),
getPropertyName(), ac);
--- NEW FILE: CssWordSpacing.java ---
// $Id: CssWordSpacing.java,v 1.1 2012/02/09 17:36:33 ylafon Exp $
//
// (c) COPYRIGHT MIT, INRIA and Keio University, 2011
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css3;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssNumber;
import org.w3c.css.values.CssOperator;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
* @spec http://www.w3.org/TR/2011/WD-css3-text-20110901/#word-spacing0
*/
public class CssWordSpacing extends org.w3c.css.properties.css.CssWordSpacing {
private CssValue value[] = new CssValue[3];
int nb_values;
private static CssIdent normal = CssIdent.getIdent("normal");
/**
* Create a new CssWordSpacing.
*/
public CssWordSpacing() {
value[0] = normal;
}
/**
* Create a new CssWordSpacing with an expression
*
* @param expression The expression
* @throws org.w3c.css.util.InvalidParamException
* The expression is incorrect
*/
public CssWordSpacing(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
nb_values = expression.getCount();
if (check && nb_values > 3) {
throw new InvalidParamException("unrecognize", ac);
}
for (int i = 0; i < nb_values; i++) {
CssValue val = expression.getValue();
setByUser();
switch (val.getType()) {
case CssTypes.CSS_NUMBER:
val = ((CssNumber) val).getLength();
case CssTypes.CSS_LENGTH:
value[i] = val;
break;
case CssTypes.CSS_PERCENTAGE:
value[i] = val;
break;
case CssTypes.CSS_IDENT:
if (inherit.equals(val)) {
// inherit can only be alone
if (nb_values > 1) {
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
value[i] = inherit;
break;
} else if (normal.equals(val)) {
value[i] = normal;
break;
}
default:
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
if (i+1 < nb_values && expression.getOperator() != CssOperator.SPACE) {
throw new InvalidParamException("operator", CssOperator.SPACE, ac);
}
expression.next();
}
}
public CssWordSpacing(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
return value;
}
/**
* Returns true if this property is "softly" inherited
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
return value[0] == inherit;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
if (nb_values == 1) {
return value[0].toString();
}
StringBuilder sb = new StringBuilder();
for (int i=0; i < nb_values; i++) {
if (i > 0) {
sb.append(' ');
}
sb.append(value[i]);
}
return sb.toString();
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssWordSpacing &&
value.equals(((CssWordSpacing) property).value));
}
}
--- CssWordSpacingCSS3.java DELETED ---
Index: CssColumnCount.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnCount.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CssColumnCount.java 23 Oct 2011 14:42:32 -0000 1.9
+++ CssColumnCount.java 9 Feb 2012 17:36:32 -0000 1.10
@@ -59,7 +59,7 @@
throw new InvalidParamException("integer",
expression.getValue(), getPropertyName(), ac);
}
- if (num.getInt() <= 0) {
+ if (!num.isStrictlyPositive()) {
throw new InvalidParamException("strictly-positive",
expression.getValue(),
getPropertyName(), ac);
--- CssWhiteSpaceCSS3.java DELETED ---
Index: CssColumnGap.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssColumnGap.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- CssColumnGap.java 23 Oct 2011 14:42:32 -0000 1.8
+++ CssColumnGap.java 9 Feb 2012 17:36:32 -0000 1.9
@@ -46,7 +46,6 @@
boolean check) throws InvalidParamException {
setByUser();
CssValue val = expression.getValue();
- Float value;
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
@@ -56,8 +55,8 @@
case CssTypes.CSS_NUMBER:
val = ((CssNumber) val).getLength();
case CssTypes.CSS_LENGTH:
- value = (Float) ((CssLength) val).get();
- if (value == null || value.floatValue() < 0.0) {
+ CssLength l = (CssLength) val;
+ if (l == null || !l.isPositive()) {
throw new InvalidParamException("negative-value",
expression.getValue(),
getPropertyName(), ac);
--- NEW FILE: CssWhiteSpace.java ---
// $Id: CssWhiteSpace.java,v 1.1 2012/02/09 17:36:32 ylafon Exp $
//
// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css3;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import java.util.HashMap;
/**
* @version $Revision: 1.1 $
* @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/text.html#white-space-prop
*/
public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace {
CssValue value;
public static HashMap<String, CssIdent> allowed_values;
static {
allowed_values = new HashMap<String, CssIdent>();
String[] WHITESPACE = {
"normal", "pre", "nowrap", "pre-wrap", "pre-line"
};
for (String aWS : WHITESPACE) {
allowed_values.put(aWS, CssIdent.getIdent(aWS));
}
}
/*
* Create a new CssWhiteSpace
*/
public CssWhiteSpace() {
// TODO raise an error ?
value = initial;
}
/**
* Create a new CssWhiteSpace
*
* @param expression The expression for this property
* @throws org.w3c.css.util.InvalidParamException
* values are incorrect
*/
public CssWhiteSpace(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
CssValue val = expression.getValue();
setByUser();
if (val.getType() == CssTypes.CSS_IDENT) {
if (inherit.equals(val)) {
value = inherit;
} else {
value = allowed_values.get(val.toString());
}
if (value != null) {
expression.next();
return;
}
}
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
public CssWhiteSpace(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* Returns true if this property is "softly" inherited
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
return (inherit == value);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return value.toString();
}
}
Index: CssBackgroundColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssBackgroundColor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssBackgroundColor.java 4 Oct 2011 13:05:25 -0000 1.1
+++ CssBackgroundColor.java 9 Feb 2012 17:36:32 -0000 1.2
@@ -15,7 +15,7 @@
/**
* http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-color
- *
+ * <p/>
* Name: background-color
* Value: <color>
* Initial: transparent
@@ -24,7 +24,7 @@
* Percentages: N/A
* Media: visual
* Computed value: the computed color(s)
- *
+ * <p/>
* This property sets the background color of an element. The color is drawn
* behind any background images.
*/
@@ -36,13 +36,15 @@
* Create a new CssBackgroundColor
*/
public CssBackgroundColor() {
+ color = initial;
}
/**
* Create a new CssBackgroundColor
*
* @param expression The expression for this property
- * @throws org.w3c.css.util.InvalidParamException Values are incorrect
+ * @throws org.w3c.css.util.InvalidParamException
+ * Values are incorrect
*/
public CssBackgroundColor(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
@@ -62,7 +64,9 @@
// we use the latest version of CssColor, aka CSS3
// instead of using CSS21 colors + transparent per spec.
CssColor tcolor = new CssColor(ac, expression, check);
- color = tcolor.getColor();
+ // instead of using getColor, we get the value directly
+ // as we can have idents
+ color = tcolor.color;
} catch (InvalidParamException e) {
throw new InvalidParamException("value",
expression.getValue(),
@@ -87,6 +91,7 @@
public void set(CssValue col) {
color = col;
}
+
/**
* Returns the color
*/
Index: CssWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssWidth.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CssWidth.java 27 Sep 2011 08:15:46 -0000 1.1
+++ CssWidth.java 9 Feb 2012 17:36:33 -0000 1.2
@@ -65,7 +65,7 @@
val = ((CssNumber) val).getLength();
case CssTypes.CSS_LENGTH:
lenVal = (CssLength) val;
- if (lenVal.floatValue() < 0.) {
+ if (!lenVal.isPositive()) {
throw new InvalidParamException("negative-value",
val.toString(), ac);
}
Received on Thursday, 9 February 2012 17:36:42 UTC