- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 09 Feb 2012 17:36:31 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv25830/w3c/css/properties/css1
Modified Files:
CSS1Default.properties Css1Style.java
CssBackgroundColorMob.java CssBackgroundTV.java CssBorder.java
CssBorderBottom.java CssBorderBottomColor.java
CssBorderBottomColorCSS1.java CssBorderBottomColorCSS2.java
CssBorderColor.java CssBorderFaceWidth.java
CssBorderFaceWidthCSS1.java CssBorderFaceWidthCSS2.java
CssBoxOffsetFace.java CssFontCSS2.java CssHeight.java
CssLetterSpacing.java CssWhiteSpace.java CssWidth.java
CssWordSpacing.java
Added Files:
CssBackground.java CssBackgroundAttachment.java
CssBackgroundColor.java CssBackgroundImage.java
CssBackgroundPosition.java CssBackgroundRepeat.java
Removed Files:
CssBackgroundAttachmentCSS1.java CssBackgroundCSS1.java
CssBackgroundColorCSS1.java CssBackgroundImageCSS1.java
CssBackgroundPositionCSS1.java CssBackgroundRepeatCSS1.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: CssBorder.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorder.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssBorder.java 27 Sep 2011 08:15:45 -0000 1.6
+++ CssBorder.java 9 Feb 2012 17:36:29 -0000 1.7
@@ -182,7 +182,7 @@
// top = new CssBorderTop(ac, expression);
/*
right = new CssBorderRight();
- bottom = new CssBorderBottom();
+ bottom = new CssBorderBottomCSS21();
left = new CssBorderLeft();*/
/*
right.width = new CssBorderRightWidth((CssBorderFaceWidth) top.width.get());
@@ -195,7 +195,7 @@
right.color = new CssBorderRightColor((CssBorderFaceColor) top.color.get());
left.color = new CssBorderLeftColor((CssBorderFaceColor) top.color.get());
- bottom.color = new CssBorderBottomColor((CssBorderFaceColor) top.color.get());
+ bottom.color = new CssBorderBottomColorCSS21((CssBorderFaceColor) top.color.get());
*/
}
--- CssBackgroundAttachmentCSS1.java DELETED ---
--- NEW FILE: CssBackgroundPosition.java ---
//
// $Id: CssBackgroundPosition.java,v 1.7 2012/02/09 17:36:28 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssStyle;
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.CssPercentage;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
import java.util.HashMap;
import static org.w3c.css.values.CssOperator.SPACE;
/**
* <H4>
* 'background-position'
* </H4>
* <p/>
* <EM>Value:</EM> [<percentage> | <length>]{1,2} | [top | center
* | bottom] || [left | center | right]<BR>
* <EM>Initial:</EM> 0% 0%<BR>
* <EM>Applies to:</EM> block-level and replaced elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> refer to the size of the element itself<BR>
* <P> If a background image has been specified, the value of
* 'background-position' specifies its initial position.
* <P> With a value pair of '0% 0%', the upper left corner of the image is
* placed in the upper left corner of the box that surrounds the content of
* the element (i.e., not the box that surrounds the padding, border or
* margin). A value pair of '100% 100%' places the lower right corner of the
* image in the lower right corner of the element. With a value pair of '14%
* 84%', the point 14% across and 84% down the image is to be placed at the
* point 14% across and 84% down the element.
* <P> With a value pair of '2cm 2cm', the upper left corner of the image is
* placed 2cm to the right and 2cm below the upper left corner of the element.
* <P> If only one percentage or length value is given, it sets the horizontal
* position only, the vertical position will be 50%. If two values are given,
* the horizontal position comes first. Combinations of length and percentage
* values are allowed, e.g. '50% 2cm'. Negative positions are allowed.
* <P> One can also use keyword values to indicate the position of the
* background image. Keywords cannot be combined with percentage values, or
* length values. The possible combinations of keywords and their
* interpretations are as follows:
* <p/>
* <UL>
* <LI>
* 'top left' and 'left top' both mean the same as '0% 0%'.
* <LI>
* 'top', 'top center' and 'center top' mean the same as '50% 0%'.
* <LI>
* 'right top' and 'top right' mean the same as '100% 0%'.
* <LI>
* 'left', 'left center' and 'center left' mean the same as '0% 50%'.
* <LI>
* 'center' and 'center center' mean the same as '50% 50%'.
* <LI>
* 'right', 'right center' and 'center right' mean the same as '100% 50%'.
* <LI>
* 'bottom left' and 'left bottom' mean the same as '0% 100%'.
* <LI>
* 'bottom', 'bottom center' and 'center bottom' mean the same as '50% 100%'.
* <LI>
* 'bottom right' and 'right bottom' mean the same as '100% 100%'.
* </UL>
* <p/>
* examples:
* <PRE>
* BODY { background: url(banner.jpeg) right top } / * 100% 0% * /
* BODY { background: url(banner.jpeg) top center } / * 50% 0% * /
* BODY { background: url(banner.jpeg) center } / * 50% 50% * /
* BODY { background: url(banner.jpeg) bottom } / * 50% 100% * /
* </PRE>
* <p/>
* If the background image is fixed with regard to the canvas (see the
* 'background-attachment' property above), the image is placed relative to
* the canvas instead of the element. E.g.:
* <PRE>
* BODY {
* background-image: url(logo.png);
* background-attachment: fixed;
* background-position: 100% 100%;
* }
* </PRE>
* <p/>
* In the example above, the image is placed in the lower right corner of the
* canvas.
*
* @version $Revision: 1.7 $
* @see org.w3c.css.properties.css.CssBackgroundAttachment
*/
public class CssBackgroundPosition extends org.w3c.css.properties.css.CssBackgroundPosition {
public static boolean checkMatchingIdent(CssIdent ident) {
return allowed_values.containsValue(ident);
}
private static final String propertyName = "background-position";
public static HashMap<String, CssIdent> allowed_values;
public static CssIdent center, top, bottom, left, right;
private static CssPercentage defaultPercent0, defaultPercent50;
private static CssPercentage defaultPercent100;
static {
top = CssIdent.getIdent("top");
bottom = CssIdent.getIdent("bottom");
left = CssIdent.getIdent("left");
right = CssIdent.getIdent("right");
center = CssIdent.getIdent("center");
allowed_values = new HashMap<String, CssIdent>();
allowed_values.put("top", top);
allowed_values.put("bottom", bottom);
allowed_values.put("left", left);
allowed_values.put("right", right);
allowed_values.put("center", center);
defaultPercent0 = new CssPercentage(0);
defaultPercent50 = new CssPercentage(50);
defaultPercent100 = new CssPercentage(100);
}
public CssValue value;
/**
* Create a new CssBackgroundPosition
*/
public CssBackgroundPosition() {
}
/**
* Creates a new CssBackgroundPosition
*
* @param expression The expression for this property
* @throws InvalidParamException Values are incorrect
*/
public CssBackgroundPosition(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
int nb_val = expression.getCount();
if (check && nb_val > 2) {
throw new InvalidParamException("unrecognize", ac);
}
setByUser();
setByUser();
CssValue val;
CssBackgroundPositionValue b_val = null;
char op;
// we just accumulate values and check at validation
while (!expression.end()) {
val = expression.getValue();
op = expression.getOperator();
if (inherit.equals(val)) {
if (expression.getCount() > 1) {
throw new InvalidParamException("value", val,
getPropertyName(), ac);
}
value = inherit;
expression.next();
return;
}
if (b_val == null) {
b_val = new CssBackgroundPositionValue();
}
// we will check later
b_val.add(val);
expression.next();
if (op != SPACE) {
throw new InvalidParamException("operator",
((new Character(op)).toString()), ac);
}
}
// if we reach the end in a value that can come in pair
if (b_val != null) {
check(b_val, ac);
value = b_val;
}
}
// check the value
public void check(CssBackgroundPositionValue v, ApplContext ac)
throws InvalidParamException {
int nb_keyword = 0;
int nb_percentage = 0;
int nb_length = 0;
int nb_values = v.value.size();
if (nb_values > 2) {
throw new InvalidParamException("unrecognize", ac);
}
// basic check
for (CssValue aValue : v.value) {
switch (aValue.getType()) {
case CssTypes.CSS_NUMBER:
aValue = ((CssNumber) aValue).getLength();
case CssTypes.CSS_LENGTH:
nb_length++;
break;
case CssTypes.CSS_PERCENTAGE:
nb_percentage++;
break;
case CssTypes.CSS_IDENT:
nb_keyword++;
break;
default:
throw new InvalidParamException("unrecognize", aValue,
ac);
}
}
// this is unnecessary complex, blame it on the CSS3 spec.
switch (nb_keyword) {
case 0:
// no keyword, so it's easy, it depends on the number
// of values :)
switch (nb_values) {
case 1:
// If only one value is specified, the second value
// is assumed to be 'center'.
v.horizontal = v.value.get(0);
if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
v.horizontal = defaultPercent0;
}
v.val_horizontal = v.horizontal;
v.val_vertical = defaultPercent50;
break;
case 2:
v.horizontal = v.value.get(0);
if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
v.horizontal = defaultPercent0;
}
v.val_horizontal = v.horizontal;
v.vertical = v.value.get(1);
if (v.vertical.getType() == CssTypes.CSS_NUMBER) {
v.vertical = defaultPercent0;
}
v.val_vertical = v.vertical;
break;
default:
// should never happen
throw new InvalidParamException("unrecognize",
ac);
}
break;
// we got one keyword... let's have fun...
case 1:
switch (nb_values) {
case 1:
CssIdent ident = (CssIdent) v.value.get(0);
// ugly as we need to set values for equality tests
v.val_vertical = defaultPercent50;
v.val_horizontal = defaultPercent50;
ident = allowed_values.get(ident.toString());
if (ident != null) {
if (isVertical(ident)) {
v.vertical = ident;
v.val_vertical = identToPercent(ident);
} else {
// horizontal || center
v.horizontal = ident;
v.val_horizontal = identToPercent(ident);
}
break;
}
throw new InvalidParamException("unrecognize",
ident, propertyName, ac);
case 2:
// one ident, two values... first MUST be horizontal
// and second vertical
CssValue val0 = v.value.get(0);
if (val0.getType() == CssTypes.CSS_IDENT) {
ident = allowed_values.get(val0.toString());
if (ident == null) {
throw new InvalidParamException("unrecognize",
ident, propertyName, ac);
}
if (isVertical(ident)) {
throw new InvalidParamException("incompatible",
ident, v.value.get(1), ac);
}
v.horizontal = ident;
v.val_horizontal = identToPercent(ident);
// and the vertical value...
v.vertical = v.value.get(1);
if (v.vertical.getType() == CssTypes.CSS_NUMBER) {
v.vertical = defaultPercent0;
}
v.val_vertical = v.vertical;
} else {
ident = allowed_values.get(v.value.get(1).toString());
if (ident == null) {
throw new InvalidParamException("unrecognize",
ident, propertyName, ac);
}
if (isHorizontal(ident)) {
throw new InvalidParamException("incompatible",
val0, v.value.get(1), ac);
}
v.vertical = ident;
v.val_vertical = identToPercent(ident);
// and the first value
v.horizontal = val0;
if (v.horizontal.getType() == CssTypes.CSS_NUMBER) {
v.horizontal = defaultPercent0;
}
v.val_horizontal = v.horizontal;
}
break;
default:
// one ident, 3 or 4 values is not allowed
throw new InvalidParamException("unrecognize",
ac);
}
break;
default:
// we got two keywords for two values, yeah!
CssIdent id1 = (CssIdent) v.value.get(0);
CssIdent id2 = (CssIdent) v.value.get(1);
if (((isVertical(id1) && isVertical(id2))) ||
(isHorizontal(id1) && isHorizontal(id2))) {
throw new InvalidParamException("incompatible",
id1, id2, ac);
}
if (isVertical(id1) || isHorizontal(id2)) {
v.horizontal = id2;
v.val_horizontal = identToPercent(id2);
v.vertical = id1;
v.val_vertical = identToPercent(id1);
} else {
v.horizontal = id1;
v.val_horizontal = identToPercent(id1);
v.vertical = id2;
v.val_vertical = identToPercent(id2);
}
}
}
public CssBackgroundPosition(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 (inherit == value);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return value.toString();
}
/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
if (cssBackground.position != null)
style.addRedefinitionWarning(ac, this);
cssBackground.position = this;
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackgroundPosition();
} else {
return ((Css1Style) style).cssBackground.position;
}
}
}
--- CssBackgroundRepeatCSS1.java DELETED ---
Index: CssBorderColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderColor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssBorderColor.java 27 Sep 2011 08:15:45 -0000 1.7
+++ CssBorderColor.java 9 Feb 2012 17:36:29 -0000 1.8
@@ -91,7 +91,7 @@
expression.next();
} else*/
top = new CssBorderTopColor(ac, expression);
- /*bottom = new CssBorderBottomColor((CssBorderFaceColor) top.get());
+ /*bottom = new CssBorderBottomColorCSS21((CssBorderFaceColor) top.get());
right = new CssBorderRightColor((CssBorderFaceColor) top.get());
left = new CssBorderLeftColor((CssBorderFaceColor) top.get());*/
break;
@@ -108,7 +108,7 @@
throw new InvalidParamException("unrecognize", ac);
}
right = new CssBorderRightColor(ac, expression);
- /*bottom = new CssBorderBottomColor((CssBorderFaceColor) top.get());
+ /*bottom = new CssBorderBottomColorCSS21((CssBorderFaceColor) top.get());
left = new CssBorderLeftColor((CssBorderFaceColor) right.get());*/
break;
case 3:
--- NEW FILE: CssBackgroundRepeat.java ---
//
// $Id: CssBackgroundRepeat.java,v 1.5 2012/02/09 17:36:29 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.*;
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;
/**
* <H4>
* <A NAME="background-repeat">5.3.4 'background-repeat'</A>
* </H4>
* <p/>
* <EM>Value:</EM> repeat | repeat-x | repeat-y | no-repeat<BR>
* <EM>Initial:</EM> repeat<BR>
* <EM>Applies to:</EM> all elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> N/A<BR>
* <p/>
* If a background image is specified, the value of 'background-repeat' determines
* how/if the image is repeated.
* <p/>
* A value of 'repeat' means that the image is repeated both horizontally and
* vertically. The 'repeat-x' ('repeat-y') value makes the image repeat horizontally
* (vertically), to create a single band of images from one side to the other.
* With a value of 'no-repeat', the image is not repeated.
* <PRE>
* BODY {
* background: red url(pendant.gif);
* background-repeat: repeat-y;
* }
* </PRE>
* <p/>
* In the example above, the image will only be repeated vertically.
*
* @version $Revision: 1.5 $
*/
public class CssBackgroundRepeat extends org.w3c.css.properties.css.CssBackgroundRepeat {
private static HashMap<String, CssIdent> allowed_values;
static {
allowed_values = new HashMap<String, CssIdent>();
String[] REPEAT = {"repeat", "repeat-x", "repeat-y", "no-repeat"};
for (String aREPEAT : REPEAT) {
allowed_values.put(aREPEAT, CssIdent.getIdent(aREPEAT));
}
}
public CssValue value;
/**
* Create a new CssBackgroundRepeat
*/
public CssBackgroundRepeat() {
value = repeat;
}
/**
* Set the value of the property
*
* @param expression The expression for this property
* @throws InvalidParamException The expression is incorrect
*/
public CssBackgroundRepeat(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) {
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
value = allowed_values.get(val.toString());
if (value == null) {
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
expression.next();
}
public CssBackgroundRepeat(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 false;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return value.toString();
}
/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
if (cssBackground.repeat != null)
style.addRedefinitionWarning(ac, this);
cssBackground.repeat = this;
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackgroundRepeat();
} else {
return ((Css1Style) style).cssBackground.repeat;
}
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssBackgroundRepeat &&
value == ((CssBackgroundRepeat) property).value);
}
/**
* Is the value of this property is a default value.
* It is used by all macro for the function <code>print</code>
*/
public boolean isDefault() {
return (repeat == value);
}
}
Index: CssBorderBottom.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderBottom.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBorderBottom.java 9 Sep 2011 12:16:43 -0000 1.5
+++ CssBorderBottom.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -145,7 +145,7 @@
if (style == null)
style = new CssBorderBottomStyle();
if (color == null)
- color = new CssBorderBottomColor();
+ color = new CssBorderBottomColorCSS21();
*/
}
--- CssBackgroundCSS1.java DELETED ---
Index: CssHeight.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssHeight.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssHeight.java 27 Sep 2011 08:15:45 -0000 1.5
+++ CssHeight.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -61,7 +61,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: CssBorderBottomColorCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderBottomColorCSS2.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssBorderBottomColorCSS2.java 9 Sep 2011 12:16:43 -0000 1.6
+++ CssBorderBottomColorCSS2.java 9 Feb 2012 17:36:29 -0000 1.7
@@ -29,7 +29,7 @@
}
/**
- * Create a new CssBorderBottomColor with an another CssBorderFaceColor
+ * Create a new CssBorderBottomColorCSS21 with an another CssBorderFaceColor
*
* @param another An another face.
*/
@@ -41,7 +41,7 @@
}
/**
- * Create a new CssBorderBottomColor
+ * Create a new CssBorderBottomColorCSS21
*
* @param expression The expression for this property.
* @exception InvalidParamException Values are incorrect
--- NEW FILE: CssBackground.java ---
//
// $Id: CssBackground.java,v 1.8 2012/02/09 17:36:28 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssBackgroundConstants;
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.CssOperator;
import org.w3c.css.values.CssValue;
/**
* <H4>
* <A NAME="background">5.3.7 'background'</A>
* </H4>
* <p/>
* <EM>Value:</EM> <background-color> || <background-image> ||
* <background-repeat> || <background-attachment> ||
* <background-position><BR>
* <EM>Initial:</EM> not defined for shorthand properties<BR>
* <EM>Applies to:</EM> all elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> allowed on <background-position><BR>
* <p/>
* The 'background' property is a shorthand property for setting the individual
* background properties (i.e., 'background-color', 'background-image',
* 'background-repeat', 'background-attachment' and 'background-position') at
* the same place in the style sheet.
* <p/>
* Possible values on the 'background' properties are the set of all possible
* values on the individual properties.
* <PRE>
* BODY { background: red }
* P { background: url(chess.png) gray 50% repeat fixed }
* </PRE>
* <P> The 'background' property always sets all the individual background
* properties. In the first rule of the above example, only a value for
* 'background-color' has been given and the other individual properties are
* set to their initial value. In the second rule, all individual properties
* have been specified.
*
* @version $Revision: 1.8 $
* @see org.w3c.css.properties.css.CssBackgroundColor
* @see org.w3c.css.properties.css.CssBackgroundImage
* @see org.w3c.css.properties.css.CssBackgroundRepeat
* @see org.w3c.css.properties.css.CssBackgroundAttachment
* @see org.w3c.css.properties.css.CssBackgroundPosition
*/
public class CssBackground extends org.w3c.css.properties.css.CssBackground
implements CssOperator, CssBackgroundConstants {
CssBackgroundColor color;
CssBackgroundImage image;
CssBackgroundRepeat repeat;
CssBackgroundAttachment attachment;
CssBackgroundPosition position;
boolean same;
/**
* Create a new CssBackground
*/
public CssBackground() {
}
/**
* Set the value of the property
*
* @param expression The expression for this property
* @throws InvalidParamException The expression is incorrect
*/
public CssBackground(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
CssValue val;
char op;
boolean find = true;
// too many values
if (check && expression.getCount() > 6) {
throw new InvalidParamException("unrecognize", ac);
}
setByUser();
while (find) {
find = false;
val = expression.getValue();
op = expression.getOperator();
if (val == null) {
break;
}
if (color == null) {
try {
color = new CssBackgroundColor(ac, expression);
find = true;
} catch (InvalidParamException e) {
}
}
if (!find && image == null) {
try {
image = new CssBackgroundImage(ac, expression);
find = true;
} catch (InvalidParamException e) {
// nothing to do, repeat will test this value
}
}
if (!find && repeat == null) {
try {
repeat = new CssBackgroundRepeat(ac, expression);
find = true;
} catch (InvalidParamException e) {
// nothing to do, attachment will test this value
}
}
if (!find && attachment == null) {
try {
attachment = new CssBackgroundAttachment(ac, expression);
find = true;
} catch (InvalidParamException e) {
// nothing to do, position will test this value
}
}
if (!find && position == null) {
try {
position = new CssBackgroundPosition(ac, expression);
find = true;
} catch (InvalidParamException e) {
// nothing to do
}
}
if (op != SPACE) {
throw new InvalidParamException("operator",
((new Character(op)).toString()),
ac);
}
if (check && !find && val != null) {
throw new InvalidParamException("unrecognize", ac);
}
}
/*
if (color == null)
color = new CssBackgroundColor();
if (image == null)
image = new CssBackgroundImage();
if (repeat == null)
repeat = new CssBackgroundRepeat();
if (attachment == null)
attachment = new CssBackgroundAttachment();
if (position == null)
position = new CssBackgroundPosition();
*/
}
public CssBackground(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
return color;
}
/**
* Returns the color
*/
public final CssValue getColor() {
if (color == null) {
return null;
} else {
return color.getColor();
}
}
/**
* Returns a string representation of the object.
*/
public String toString() {
StringBuilder sb = new StringBuilder();
boolean first = true;
if (color != null) {
sb.append(color);
first = false;
}
if (image != null) {
if (!first) {
sb.append(' ');
}
sb.append(image);
first = false;
}
if (repeat != null) {
if (!first) {
sb.append(' ');
}
first = false;
sb.append(repeat);
}
if (attachment != null) {
if (!first) {
sb.append(' ');
}
first = false;
sb.append(attachment);
}
if (position != null) {
if (!first) {
sb.append(' ');
}
first = false;
sb.append(position);
}
return sb.toString();
}
/**
* Set this property to be important.
* Overrides this method for a macro
*/
public void setImportant() {
super.setImportant();
if (color != null) {
color.important = true;
}
if (image != null) {
image.important = true;
}
if (repeat != null) {
repeat.important = true;
}
if (attachment != null) {
attachment.important = true;
}
if (position != null) {
position.important = true;
}
}
/**
* Returns true if this property is important.
* Overrides this method for a macro
*/
public boolean getImportant() {
return important && ((color == null || color.important) &&
(image == null || image.important) &&
(repeat == null || repeat.important) &&
(attachment == null || attachment.important) &&
(position == null || position.important));
}
/**
* Set the context.
* Overrides this method for a macro
*
* @see org.w3c.css.css.CssCascadingOrder#order
* @see org.w3c.css.css.StyleSheetParser#handleRule
*/
public void setSelectors(CssSelectors selector) {
super.setSelectors(selector);
if (color != null) {
color.setSelectors(selector);
}
if (image != null) {
image.setSelectors(selector);
}
if (repeat != null) {
repeat.setSelectors(selector);
}
if (attachment != null) {
attachment.setSelectors(selector);
}
if (position != null) {
position.setSelectors(selector);
}
}
/**
* Add this property to the CssStyle
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
((Css1Style) style).cssBackground.same = same;
((Css1Style) style).cssBackground.byUser = byUser;
if (color != null) {
color.addToStyle(ac, style);
}
if (image != null) {
image.addToStyle(ac, style);
}
if (repeat != null) {
repeat.addToStyle(ac, style);
}
if (attachment != null) {
attachment.addToStyle(ac, style);
}
if (position != null) {
position.addToStyle(ac, style);
}
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackground();
} else {
return ((Css1Style) style).cssBackground;
}
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return false; // FIXME
}
/**
* Update the source file and the line.
* Overrides this method for a macro
*
* @param line The line number where this property is defined
* @param source The source file where this property is defined
*/
public void setInfo(int line, String source) {
super.setInfo(line, source);
if (color != null) {
color.setInfo(line, source);
}
if (image != null) {
image.setInfo(line, source);
}
if (repeat != null) {
repeat.setInfo(line, source);
}
if (attachment != null) {
attachment.setInfo(line, source);
}
if (position != null) {
position.setInfo(line, source);
}
}
}
--- CssBackgroundPositionCSS1.java DELETED ---
Index: CssBorderFaceWidthCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderFaceWidthCSS1.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssBorderFaceWidthCSS1.java 5 Jan 2010 13:49:40 -0000 1.4
+++ CssBorderFaceWidthCSS1.java 9 Feb 2012 17:36:29 -0000 1.5
@@ -54,8 +54,8 @@
CssValue val = expression.getValue();
if (val instanceof CssLength) {
- float f = ((Float) val.get()).floatValue();
- if (f >= 0)
+ CssLength l = (CssLength) val;
+ if (l.isPositive())
this.value = val;
else
throw new InvalidParamException("negative-value", val.toString(), ac);
Index: CssBorderBottomColorCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderBottomColorCSS1.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBorderBottomColorCSS1.java 9 Sep 2011 12:16:43 -0000 1.5
+++ CssBorderBottomColorCSS1.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -29,7 +29,7 @@
}
/**
- * Create a new CssBorderBottomColor with an another CssBorderFaceColor
+ * Create a new CssBorderBottomColorCSS21 with an another CssBorderFaceColor
*
* @param another An another face.
*/
@@ -41,7 +41,7 @@
}
/**
- * Create a new CssBorderBottomColor
+ * Create a new CssBorderBottomColorCSS21
*
* @param expression The expression for this property.
* @exception InvalidParamException Values are incorrect
Index: CssBackgroundColorMob.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBackgroundColorMob.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBackgroundColorMob.java 29 Sep 2011 09:08:59 -0000 1.5
+++ CssBackgroundColorMob.java 9 Feb 2012 17:36:28 -0000 1.6
@@ -9,7 +9,7 @@
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
-import org.w3c.css.properties.css2.CssBackgroundColorCSS2;
+import org.w3c.css.properties.css2.CssBackgroundColor;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
@@ -155,8 +155,8 @@
* @param value The other property.
*/
public boolean equals(CssProperty property) {
- return (property instanceof CssBackgroundColorCSS2 && color != null &&
- color.equals( ((CssBackgroundColorCSS2) property).color));
+ return (property instanceof CssBackgroundColor && color != null &&
+ color.equals( ((CssBackgroundColor) property).color));
}
/**
--- CssBackgroundImageCSS1.java DELETED ---
Index: CssBoxOffsetFace.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBoxOffsetFace.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssBoxOffsetFace.java 5 Jan 2010 13:49:42 -0000 1.3
+++ CssBoxOffsetFace.java 9 Feb 2012 17:36:29 -0000 1.4
@@ -25,70 +25,70 @@
CssValue value;
- private static CssIdent auto = new CssIdent("auto");
+ private static CssIdent auto = CssIdent.getIdent("auto");
/**
* Create a new CssBoxOffsetFace
*/
public CssBoxOffsetFace() {
- value = auto;
+ value = auto;
}
/**
* Create a new CssBoxOffsetFace
*
* @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
+ * @throws InvalidParamException Values are incorrect
*/
public CssBoxOffsetFace(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- CssValue val = expression.getValue();
+ CssValue val = expression.getValue();
- setByUser();
+ setByUser();
- if (val.equals(inherit)) {
- value = inherit;
- expression.next();
- } else if (val.equals(auto)) {
- value = auto;
- expression.next();
- } else if (val instanceof CssLength || val instanceof CssPercentage) {
- value = val;
- expression.next();
- } else if (val instanceof CssNumber) {
- value = ((CssNumber) val).getLength();
- expression.next();
- } else if (val.equals(auto)) {
- value = auto;
- expression.next();
- } else {
- throw new InvalidParamException("value", val.toString(),
- getPropertyName(), ac);
- }
+ if (val.equals(inherit)) {
+ value = inherit;
+ expression.next();
+ } else if (val.equals(auto)) {
+ value = auto;
+ expression.next();
+ } else if (val instanceof CssLength || val instanceof CssPercentage) {
+ value = val;
+ expression.next();
+ } else if (val instanceof CssNumber) {
+ value = ((CssNumber) val).getLength();
+ expression.next();
+ } else if (val.equals(auto)) {
+ value = auto;
+ expression.next();
+ } else {
+ throw new InvalidParamException("value", val.toString(),
+ getPropertyName(), ac);
+ }
}
public CssBoxOffsetFace(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
- return value;
+ return value;
}
/**
* Returns the internal CssValue value.
*/
public CssValue getValue() {
- return value;
+ return value;
}
/**
@@ -96,17 +96,17 @@
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
- return value == inherit;
+ return value == inherit;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if(value != null) {
- return value.toString();
- }
- return "";
+ if (value != null) {
+ return value.toString();
+ }
+ return "";
}
/**
@@ -115,20 +115,20 @@
* @param side The other side.
*/
public boolean equals(CssBoxOffsetFace side) {
- if(value != null) {
- return value.equals(side.value);
- }
- return side == null;
+ if (value != null) {
+ return value.equals(side.value);
+ }
+ return side == null;
}
/**
* Is this property contains a default value.
*/
public boolean isDefault() {
- if (value != null && value != auto)
- return ((Float) value.get()).floatValue() == 0;
- else
- return false;
+ if (value != null && value != auto)
+ return ((Float) value.get()).floatValue() == 0;
+ else
+ return false;
}
}
Index: CssLetterSpacing.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssLetterSpacing.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssLetterSpacing.java 5 Jan 2010 13:49:43 -0000 1.4
+++ CssLetterSpacing.java 9 Feb 2012 17:36:29 -0000 1.5
@@ -1,4 +1,3 @@
-//
// $Id$
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
@@ -6,115 +5,76 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
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.CssLength;
import org.w3c.css.values.CssNumber;
+import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
- * <H4>
- * 'letter-spacing'
- * </H4>
- * <P>
- * <EM>Value:</EM> normal | <length> <BR>
- * <EM>Initial:</EM> normal<BR>
- * <EM>Applies to:</EM> all elements<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P> The length unit indicates an addition to the default space between
- * characters. Values can be negative, but there may be
- * implementation-specific limits. The UA is free to select the exact spacing
- * algorithm. The letter spacing may also be influenced by justification
- * (which is a value of the 'align' property).
- * <PRE>
- * BLOCKQUOTE { letter-spacing: 0.1em }
- * </PRE>
- * <P>
- * Here, the letter-spacing between each character in 'BLOCKQUOTE' elements
- * would be increased by '0.1em'.
- * <P>
- * With a value of 'normal', the UAs may change the space between letters to
- * justify text. This will not happen if 'letter-spacing' is explicitly set
- * to a <length> value:
- * <PRE>
- * BLOCKQUOTE { letter-spacing: 0 }
- * BLOCKQUOTE { letter-spacing: 0cm }
- * </PRE>
- * <P>
- * When the resultant space between two letters is not the same as the default
- * space, UAs should not use ligatures.
- *
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#letter-spacing
* @version $Revision$
*/
-public class CssLetterSpacing extends CssProperty {
+public class CssLetterSpacing extends org.w3c.css.properties.css.CssLetterSpacing {
- CssValue length;
- static CssIdent normal = new CssIdent("normal");
+ private CssValue value;
+ private static CssIdent normal = CssIdent.getIdent("normal");
/**
- * Create a new CssLetterSpacing
+ * Create a new CssLetterSpacing.
*/
public CssLetterSpacing() {
- length = normal;
+ value = normal;
}
/**
- * Create a new CssLetterSpacing
+ * Create a new CssLetterSpacing with an expression
*
- * @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
+ * @param expression The expression
+ * @throws InvalidParamException The expression is incorrect
*/
public CssLetterSpacing(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- setByUser();
+ CssValue val = expression.getValue();
- CssValue val = expression.getValue();
- if (val instanceof CssLength) {
- length = (CssLength) val;
- expression.next();
- } else if (val instanceof CssNumber) {
- length = ((CssNumber) val).getLength();
- expression.next();
- } else if (val.equals(inherit)) {
- length = inherit;
- expression.next();
- } else if (val.equals(normal)) {
- length = normal;
- expression.next();
- } else {
- throw new InvalidParamException("value",
- expression.getValue(),
- getPropertyName(), ac);
- }
+ setByUser();
+
+ switch (val.getType()) {
+ case CssTypes.CSS_NUMBER:
+ val = ((CssNumber) val).getLength();
+ case CssTypes.CSS_LENGTH:
+ value = val;
+ break;
+ case CssTypes.CSS_IDENT:
+ if (inherit.equals(val) || normal.equals(val)) {
+ value = val;
+ break;
+ }
+ default:
+ throw new InvalidParamException("value", expression.getValue(),
+ getPropertyName(), ac);
+ }
+ expression.next();
}
public CssLetterSpacing(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
- return length;
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "letter-spacing";
+ return value;
}
/**
@@ -122,50 +82,23 @@
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
- return length == inherit;
+ return value == inherit;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return length.toString();
- }
-
- /**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- Css1Style style0 = (Css1Style) style;
- if (style0.cssLetterSpacing != null)
- style0.addRedefinitionWarning(ac, this);
- style0.cssLetterSpacing = this;
- }
-
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getLetterSpacing();
- } else {
- return ((Css1Style) style).cssLetterSpacing;
- }
+ return value.toString();
}
/**
* Compares two properties for equality.
*
- * @param value The other property.
+ * @param property The other property.
*/
public boolean equals(CssProperty property) {
- return (property instanceof CssLetterSpacing &&
- length.equals(((CssLetterSpacing) property).length));
+ return (property instanceof CssLetterSpacing &&
+ value.equals(((CssLetterSpacing) property).value));
}
-
}
Index: CssBorderFaceWidthCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderFaceWidthCSS2.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssBorderFaceWidthCSS2.java 5 Jan 2010 13:49:41 -0000 1.6
+++ CssBorderFaceWidthCSS2.java 9 Feb 2012 17:36:29 -0000 1.7
@@ -13,6 +13,7 @@
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssLength;
import org.w3c.css.values.CssNumber;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
@@ -23,20 +24,21 @@
public class CssBorderFaceWidthCSS2 {
public static HashSet<CssIdent> acceptable_values;
+
static {
- acceptable_values = new HashSet<CssIdent>();
- acceptable_values.add(CssIdent.getIdent("thin"));
- acceptable_values.add(CssIdent.getIdent("medium"));
- acceptable_values.add(CssIdent.getIdent("thick"));
+ acceptable_values = new HashSet<CssIdent>();
+ acceptable_values.add(CssIdent.getIdent("thin"));
+ acceptable_values.add(CssIdent.getIdent("medium"));
+ acceptable_values.add(CssIdent.getIdent("thick"));
}
CssValue value;
-
+
/**
* Create a new CssBorderFaceWidthCSS2
*/
public CssBorderFaceWidthCSS2() {
- value = CssIdent.getIdent("medium");
+ value = CssIdent.getIdent("medium");
}
/**
@@ -45,72 +47,72 @@
* @param another The another side.
*/
public CssBorderFaceWidthCSS2(CssBorderFaceWidthCSS2 another) {
- value = another.value;
+ value = another.value;
}
/**
* Create a new CssBorderFaceWidth
*
* @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
+ * @throws InvalidParamException Values are incorrect
*/
public CssBorderFaceWidthCSS2(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- CssValue val = expression.getValue();
+ CssValue val = expression.getValue();
- switch (val.getType()) {
- case CssTypes.CSS_NUMBER:
- val = ((CssNumber) val).getLength();
- case CssTypes.CSS_LENGTH:
- float f = ((Float) val.get()).floatValue();
- if (f >= 0) {
- this.value = val;
- } else {
- throw new InvalidParamException("negative-value", val.toString(), ac);
- }
- break;
- case CssTypes.CSS_IDENT:
- CssIdent ci = (CssIdent) val;
- if (CssProperty.inherit.equals(ci)) {
- value = CssProperty.inherit;
- break;
- }
- if (acceptable_values.contains(ci)) {
- // use the cached version
- value = CssIdent.getIdent(ci.toString());
- break;
- }
- default:
- throw new InvalidParamException("value", val.toString(), "width", ac);
- }
- expression.next();
+ switch (val.getType()) {
+ case CssTypes.CSS_NUMBER:
+ val = ((CssNumber) val).getLength();
+ case CssTypes.CSS_LENGTH:
+ CssLength l = (CssLength) val;
+ if (l.isPositive()) {
+ this.value = val;
+ } else {
+ throw new InvalidParamException("negative-value", val.toString(), ac);
+ }
+ break;
+ case CssTypes.CSS_IDENT:
+ CssIdent ci = (CssIdent) val;
+ if (CssProperty.inherit.equals(ci)) {
+ value = CssProperty.inherit;
+ break;
+ }
+ if (acceptable_values.contains(ci)) {
+ // use the cached version
+ value = CssIdent.getIdent(ci.toString());
+ break;
+ }
+ default:
+ throw new InvalidParamException("value", val.toString(), "width", ac);
+ }
+ expression.next();
}
public CssBorderFaceWidthCSS2(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the internal value
*/
public CssValue getValue() {
- return value;
+ return value;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if(value != null) {
- return value.toString();
- }
- return "";
+ if (value != null) {
+ return value.toString();
+ }
+ return "";
}
/**
@@ -119,11 +121,10 @@
* @param value The another side.
*/
public boolean equals(CssBorderFaceWidthCSS2 another) {
- return value.equals(another.value); // FIXME
+ return value.equals(another.value); // FIXME
}
-
}
Index: CssBackgroundTV.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBackgroundTV.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBackgroundTV.java 9 Sep 2011 12:16:43 -0000 1.5
+++ CssBackgroundTV.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -10,10 +10,10 @@
import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssBackgroundConstants;
import org.w3c.css.properties.css.CssProperty;
-import org.w3c.css.properties.css2.CssBackgroundColorCSS2;
-import org.w3c.css.properties.css2.CssBackgroundImageCSS2;
-import org.w3c.css.properties.css2.CssBackgroundPositionCSS2;
-import org.w3c.css.properties.css2.CssBackgroundRepeatCSS2;
+import org.w3c.css.properties.css2.CssBackgroundColor;
+import org.w3c.css.properties.css2.CssBackgroundImage;
+import org.w3c.css.properties.css2.CssBackgroundPosition;
+import org.w3c.css.properties.css2.CssBackgroundRepeat;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.InvalidParamException;
import org.w3c.css.values.CssExpression;
@@ -59,15 +59,15 @@
public class CssBackgroundTV extends CssProperty
implements CssOperator, CssBackgroundConstants {
- CssBackgroundColorCSS2 color;
- CssBackgroundImageCSS2 image;
- CssBackgroundRepeatCSS2 repeat;
- CssBackgroundPositionCSS2 position;
+ CssBackgroundColor color;
+ CssBackgroundImage image;
+ CssBackgroundRepeat repeat;
+ CssBackgroundPosition position;
boolean same;
/**
- * Create a new CssBackgroundCSS2
+ * Create a new CssBackground
*/
public CssBackgroundTV() {
}
@@ -95,13 +95,13 @@
if(expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
- color = new CssBackgroundColorCSS2();
+ color = new CssBackgroundColor();
color.color = inherit;
- image = new CssBackgroundImageCSS2();
+ image = new CssBackgroundImage();
image.url = inherit;
- repeat = new CssBackgroundRepeatCSS2();
+ repeat = new CssBackgroundRepeat();
// repeat.repeat = REPEAT.length - 1;
- position = new CssBackgroundPositionCSS2();
+ position = new CssBackgroundPosition();
position.value = inherit;
same = true;
expression.next();
@@ -119,27 +119,27 @@
if (color == null) {
try {
- color = new CssBackgroundColorCSS2(ac, expression);
+ color = new CssBackgroundColor(ac, expression);
find = true;
} catch (InvalidParamException e) {
}
}
if (!find && image == null) {
try {
- image = new CssBackgroundImageCSS2(ac, expression);
+ image = new CssBackgroundImage(ac, expression);
find = true;
} catch (InvalidParamException e) {
}
}
if (!find && repeat == null) {
try {
- repeat = new CssBackgroundRepeatCSS2(ac, expression);
+ repeat = new CssBackgroundRepeat(ac, expression);
find = true;
} catch (InvalidParamException e) {
}
}
if (!find && position == null) {
- position = new CssBackgroundPositionCSS2(ac, expression);
+ position = new CssBackgroundPosition(ac, expression);
find = true;
}
if (op != SPACE) {
@@ -150,13 +150,13 @@
}
/*
if (color == null)
- color = new CssBackgroundColorCSS2();
+ color = new CssBackgroundColor();
if (image == null)
- image = new CssBackgroundImageCSS2();
+ image = new CssBackgroundImage();
if (repeat == null)
- repeat = new CssBackgroundRepeatCSS2();
+ repeat = new CssBackgroundRepeat();
if (position == null)
- position = new CssBackgroundPositionCSS2();
+ position = new CssBackgroundPosition();
*/
}
@@ -278,8 +278,8 @@
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
- ((Css1Style) style).cssBackgroundCSS2.same = same;
- ((Css1Style) style).cssBackgroundCSS2.byUser = byUser;
+ ((Css1Style) style).cssBackground.same = same;
+ ((Css1Style) style).cssBackground.byUser = byUser;
if(color != null) {
color.addToStyle(ac, style);
@@ -303,9 +303,9 @@
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
- return ((Css1Style) style).getBackgroundCSS2();
+ return ((Css1Style) style).getBackground();
} else {
- return ((Css1Style) style).cssBackgroundCSS2;
+ return ((Css1Style) style).cssBackground;
}
}
Index: CssWordSpacing.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssWordSpacing.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssWordSpacing.java 5 Jan 2010 13:49:46 -0000 1.4
+++ CssWordSpacing.java 9 Feb 2012 17:36:29 -0000 1.5
@@ -6,104 +6,76 @@
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
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.CssLength;
import org.w3c.css.values.CssNumber;
+import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
- * <H4>
- * 'word-spacing'
- * </H4>
- * <P>
- * <EM>Value:</EM> normal | <length> <BR>
- * <EM>Initial:</EM> normal<BR>
- * <EM>Applies to:</EM> all elements<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <P> The length unit indicates an addition to the default space between
- * words. Values can be negative, but there may be implementation-specific
- * limits. The UA is free to select the exact spacing algorithm. The word
- * spacing may also be influenced by justification (which is a value of the
- * 'align' property).
- * <PRE>
- * H1 { word-spacing: 0.4em }
- * </PRE>
- * <P>
- * Here, the word-spacing between each word in 'H1' elements would be increased
- * by '1em'.
- *
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#word-spacing
* @version $Revision$
*/
-public class CssWordSpacing extends CssProperty {
+public class CssWordSpacing extends org.w3c.css.properties.css.CssWordSpacing {
- private CssValue length;
- private static CssIdent normal = new CssIdent("normal");
+ private CssValue value;
+ private static CssIdent normal = CssIdent.getIdent("normal");
/**
* Create a new CssWordSpacing.
*/
public CssWordSpacing() {
- length = normal;
+ value = normal;
}
/**
* Create a new CssWordSpacing with an expression
*
* @param expression The expression
- * @exception InvalidParamException The expression is incorrect
+ * @throws InvalidParamException The expression is incorrect
*/
public CssWordSpacing(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- CssValue val = expression.getValue();
+ CssValue val = expression.getValue();
- setByUser();
+ setByUser();
- if (val instanceof CssLength) {
- length = (CssLength) val;
- expression.next();
- } else if (val instanceof CssNumber) {
- length = ((CssNumber) val).getLength();
- expression.next();
- } else if (val.equals(inherit)) {
- length = inherit;
- expression.next();
- } else if (val.equals(normal)) {
- length = normal;
- expression.next();
- } else {
- throw new InvalidParamException("value", expression.getValue(),
- getPropertyName(), ac);
- }
+ switch (val.getType()) {
+ case CssTypes.CSS_NUMBER:
+ val = ((CssNumber) val).getLength();
+ case CssTypes.CSS_LENGTH:
+ value = val;
+ break;
+ case CssTypes.CSS_IDENT:
+ if (inherit.equals(val) || normal.equals(val)) {
+ value = val;
+ break;
+ }
+ default:
+ throw new InvalidParamException("value", expression.getValue(),
+ getPropertyName(), ac);
+ }
+ expression.next();
}
public CssWordSpacing(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
- return length;
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "word-spacing";
+ return value;
}
/**
@@ -111,49 +83,23 @@
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
- return length == inherit;
+ return value == inherit;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return length.toString();
- }
-
- /**
- * Adds this property to a style.
- *
- * @param style The style.
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- Css1Style style0 = (Css1Style) style;
- if (style0.cssWordSpacing != null)
- style0.addRedefinitionWarning(ac, this);
- style0.cssWordSpacing = this;
- }
-
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getWordSpacing();
- } else {
- return ((Css1Style) style).cssWordSpacing;
- }
+ return value.toString();
}
/**
* Compares two properties for equality.
*
- * @param value The other property.
+ * @param property The other property.
*/
public boolean equals(CssProperty property) {
- return (property instanceof CssWordSpacing &&
- length.equals(((CssWordSpacing) property).length));
+ return (property instanceof CssWordSpacing &&
+ value.equals(((CssWordSpacing) property).value));
}
}
Index: CssBorderFaceWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderFaceWidth.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssBorderFaceWidth.java 5 Jan 2010 13:49:40 -0000 1.4
+++ CssBorderFaceWidth.java 9 Feb 2012 17:36:29 -0000 1.5
@@ -27,7 +27,7 @@
* Create a new CssBorderFaceWidth
*/
public CssBorderFaceWidth() {
- //value = medium;
+ //value = medium;
}
/**
@@ -36,62 +36,62 @@
* @param another The another side.
*/
public CssBorderFaceWidth(CssBorderFaceWidth another) {
- value = another.value;
+ value = another.value;
}
/**
* Create a new CssBorderFaceWidth
*
* @param expression The expression for this property
- * @exception InvalidParamException Values are incorrect
+ * @throws InvalidParamException Values are incorrect
*/
public CssBorderFaceWidth(ApplContext ac, CssExpression expression,
- boolean check) throws InvalidParamException {
+ boolean check) throws InvalidParamException {
- if(check && expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- CssValue val = expression.getValue();
- CssIdent initial = new CssIdent("initial");
+ CssValue val = expression.getValue();
+ CssIdent initial = new CssIdent("initial");
- if (val instanceof CssLength) {
- float f = ((Float) val.get()).floatValue();
- if (f >= 0)
- this.value = val;
- else
- throw new InvalidParamException("negative-value", val.toString(), ac);
- } else if (val instanceof CssNumber) {
- value = ((CssNumber) val).getLength();
- } else if (val instanceof CssPercentage) {
- value = val;
- } else if (val.equals(thin)) {
- value = thin;
- } else if (val.equals(medium)) {
- value = medium;
- } else if (val.equals(thick)) {
- value = thick;
- } else if (val.equals(initial)) {
- value = initial;
- } else if (val.equals(CssProperty.inherit)) {
- value = CssProperty.inherit;
- } else {
- throw new InvalidParamException("value", val.toString(), "width", ac);
- }
+ if (val instanceof CssLength) {
+ CssLength l = (CssLength) val;
+ if (l.isPositive()) {
+ this.value = val;
+ } else
+ throw new InvalidParamException("negative-value", val.toString(), ac);
+ } else if (val instanceof CssNumber) {
+ value = ((CssNumber) val).getLength();
+ } else if (val instanceof CssPercentage) {
+ value = val;
+ } else if (val.equals(thin)) {
+ value = thin;
+ } else if (val.equals(medium)) {
+ value = medium;
+ } else if (val.equals(thick)) {
+ value = thick;
+ } else if (val.equals(initial)) {
+ value = initial;
+ } else if (val.equals(CssProperty.inherit)) {
+ value = CssProperty.inherit;
+ } else {
+ throw new InvalidParamException("value", val.toString(), "width", ac);
+ }
- expression.next();
+ expression.next();
}
public CssBorderFaceWidth(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the internal value
*/
public CssValue getValue() {
- return value;
+ return value;
}
/**
@@ -99,11 +99,11 @@
*/
public String toString() {
- if (value != null) {
- return value.toString();
- } else {
- return "";
- }
+ if (value != null) {
+ return value.toString();
+ } else {
+ return "";
+ }
}
/**
@@ -112,7 +112,7 @@
* @param value The another side.
*/
public boolean equals(CssBorderFaceWidth another) {
- return value.equals(another.value); // FIXME
+ return value.equals(another.value); // FIXME
}
private static CssIdent thin = new CssIdent("thin");
Index: CssWhiteSpace.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssWhiteSpace.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssWhiteSpace.java 5 Jan 2010 13:49:46 -0000 1.5
+++ CssWhiteSpace.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -1,123 +1,70 @@
-//
// $Id$
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
-import org.w3c.css.parser.CssStyle;
-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.CssTypes;
import org.w3c.css.values.CssValue;
+import java.util.HashMap;
+
/**
- * <H4>
- * 'white-space'
- * </H4>
- * <P>
- * <EM>Value:</EM> normal | pre | nowrap<BR>
- * <EM>Initial:</EM> normal<BR>
- * <EM>Applies to:</EM> block-level elements<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- *
- * <P> This property declares how whitespace inside the element is handled:
- * the 'normal' way (where whitespace is collapsed), as 'pre' (which behaves
- * like the 'PRE' element in HTML) or as 'nowrap' (where wrapping is done only
- * through BR elements):
- *
- * <PRE>
- * PRE { white-space: pre }
- * P { white-space: normal }
- * </PRE>
- *
- * <P> The initial value of 'white-space' is 'normal', but a UA will typically
- * have default values for all HTML elements according to the suggested
- * rendering of elements in the HTML specification.
- *
* @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#white-space
*/
-public class CssWhiteSpace extends CssProperty {
+public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace {
- int value;
+ CssValue value;
- private static String[] WHITESPACE = {
- "normal", "pre", "nowrap", "inherit" };
- private static int[] hash_values;
+ public static HashMap<String, CssIdent> allowed_values;
- /**
- * Create a new CssWhiteSpace
- */
- public CssWhiteSpace() {
- // nothing to do
+ static {
+ allowed_values = new HashMap<String, CssIdent>();
+ String[] WHITESPACE = {
+ "normal", "pre", "nowrap"
+ };
+
+ for (String aWS : WHITESPACE) {
+ allowed_values.put(aWS, CssIdent.getIdent(aWS));
+ }
}
/**
* Create a new CssWhiteSpace
*
* @param expression The expression for this property
- * @exception InvalidParamException values are incorrect
+ * @throws 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();
+ throws InvalidParamException {
- setByUser();
+ if (check && expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- if ( val instanceof CssIdent) {
- int hash = val.hashCode();
- for (int i = 0; i < WHITESPACE.length; i++)
- if (hash_values[i] == hash) {
- value = i;
- expression.next();
- return;
- }
- }
+ CssValue val = expression.getValue();
+ setByUser();
- throw new InvalidParamException("value", expression.getValue(),
- getPropertyName(), ac);
+ if (val.getType() == CssTypes.CSS_IDENT) {
+ 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);
- }
-
- /**
- * @return Returns the value.
- */
- public int getValue() {
- return value;
- }
-
- /**
- * @param value The value to set.
- */
- public void setValue(int value) {
- this.value = value;
- }
-
- /**
- * Returns the value of this property
- */
- public Object get() {
- return WHITESPACE[value];
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "white-space";
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
@@ -125,55 +72,14 @@
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
- return value == (WHITESPACE.length - 1);
+ return (inherit == value);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- return WHITESPACE[value];
- }
-
- /**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- Css1Style style0 = (Css1Style) style;
- if (style0.cssWhiteSpace != null)
- style0.addRedefinitionWarning(ac, this);
- style0.cssWhiteSpace = this;
- }
-
- /**
- * Get this property in the style.
- *
- * @param style The style where the property is
- * @param resolve if true, resolve the style to find this property
- */
- public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getWhiteSpace();
- } else {
- return ((Css1Style) style).cssWhiteSpace;
- }
- }
-
- /**
- * Compares two properties for equality.
- *
- * @param value The other property.
- */
- public boolean equals(CssProperty property) {
- return (property instanceof CssWhiteSpace &&
- value == ((CssWhiteSpace) property).value);
+ return value.toString();
}
- static {
- hash_values = new int[WHITESPACE.length];
- for (int i = 0; i < WHITESPACE.length; i++)
- hash_values[i] = WHITESPACE[i].hashCode();
- }
}
--- NEW FILE: CssBackgroundAttachment.java ---
//
// $Id: CssBackgroundAttachment.java,v 1.6 2012/02/09 17:36:28 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssStyle;
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.CssTypes;
import org.w3c.css.values.CssValue;
import java.util.HashMap;
/**
* <H4>
* 'background-attachment'
* </H4>
* <p/>
* <EM>Value:</EM> scroll | fixed<BR>
* <EM>Initial:</EM> scroll<BR>
* <EM>Applies to:</EM> all elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> N/A<BR>
* <p/>
* If a background image is specified, the value of 'background-attachment'
* determines if it is fixed with regard to the canvas or if it scrolls along
* with the content.
* <PRE>
* BODY {
* background: red url(pendant.gif);
* background-repeat: repeat-y;
* background-attachment: fixed;
* }
* </PRE>
*
* @version $Revision: 1.6 $
*/
public class CssBackgroundAttachment extends org.w3c.css.properties.css.CssBackgroundAttachment {
private static HashMap<String, CssIdent> allowed_values;
private static CssIdent scroll;
static {
allowed_values = new HashMap<String, CssIdent>();
scroll = CssIdent.getIdent("scroll");
allowed_values.put("scroll", scroll);
allowed_values.put("fixed", CssIdent.getIdent("fixed"));
}
CssIdent value;
/**
* Create a new CssBackgroundAttachment
*/
public CssBackgroundAttachment() {
value = scroll;
}
/**
* Creates a new CssBackgroundAttachment
*
* @param expression The expression for this property
* @throws InvalidParamException Values are incorrect
*/
public CssBackgroundAttachment(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
setByUser();
CssValue val = expression.getValue();
if (val.getType() == CssTypes.CSS_IDENT) {
CssIdent new_val = allowed_values.get(val.toString());
if (new_val != null) {
value = new_val;
expression.next();
return;
}
}
throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
public CssBackgroundAttachment(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 false;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return value.toString();
}
/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
if (cssBackground.attachment != null)
style.addRedefinitionWarning(ac, this);
cssBackground.attachment = this;
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackgroundAttachment();
} else {
return ((Css1Style) style).cssBackground.attachment;
}
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssBackgroundAttachment &&
value == ((CssBackgroundAttachment) property).value);
}
/**
* Is the value of this property is a default value.
* It is used by all macro for the function <code>print</code>
*/
public boolean isDefault() {
return (scroll == value);
}
}
Index: CssFontCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssFontCSS2.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CssFontCSS2.java 9 Sep 2011 12:16:44 -0000 1.6
+++ CssFontCSS2.java 9 Feb 2012 17:36:29 -0000 1.7
@@ -19,51 +19,52 @@
import org.w3c.css.values.CssValue;
/**
- * <H4>
- * 'font'
- * </H4>
- * <P>
- * <EM>Value:</EM> [ <font-style> || <font-variant> ||
- * <font-weight> ]? <font-size> [ / <line-height> ]?
- * <font-family><BR>
- * <EM>Initial:</EM> not defined for shorthand properties<BR>
- * <EM>Applies to:</EM> all elements<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> allowed on <font-size> and
- * <line-height><BR>
- * <P>
- * The 'font' property is a shorthand property for setting
- * 'font-style',
- * 'font-variant',
- * 'font-weight',
- * 'font-size',
- * 'line-height' and
- * 'font-family' at the same place in the style sheet.
- * The syntax of this property is based on a traditional typographical
- * shorthand notation to set multiple properties related to fonts.
- * <P> For a definition of allowed and initial values, see the previously
- * defined properties. Properties for which no values are given are set to
- * their initial value.
- * <PRE>
- * P { font: 12pt/14pt sans-serif }
- * P { font: 80% sans-serif }
- * P { font: x-large/110% "new century schoolbook", serif }
- * P { font: bold italic large Palatino, serif }
- * P { font: normal small-caps 120%/120% fantasy }
- * </PRE>
- * <P> In the second rule, the font size percentage value ('80%') refers to
- * the font size of the parent element. In the third rule, the line height
- * percentage refers to the font size of the element itself.
- * <P> In the first three rules above, the 'font-style', 'font-variant' and
- * 'font-weight' are not explicitly mentioned, which means they are all three
- * set to their initial value ('normal'). The fourth rule sets the
- * 'font-weight' to 'bold', the 'font-style' to 'italic' and implicitly sets
- * 'font-variant' to 'normal'.
- * <P> The fifth rule sets the 'font-variant' ('small-caps'), the 'font-size'
- * (120% of the parent's font), the 'line-height' (120% times the font size)
- * and the 'font-family' ('fantasy'). It follows that the keyword 'normal'
- * applies to the two remaining properties: 'font-style' and 'font-weight'.
+ * <H4>
+ * 'font'
+ * </H4>
+ * <p/>
+ * <EM>Value:</EM> [ <font-style> || <font-variant> ||
+ * <font-weight> ]? <font-size> [ / <line-height> ]?
+ * <font-family><BR>
+ * <EM>Initial:</EM> not defined for shorthand properties<BR>
+ * <EM>Applies to:</EM> all elements<BR>
+ * <EM>Inherited:</EM> yes<BR>
+ * <EM>Percentage values:</EM> allowed on <font-size> and
+ * <line-height><BR>
+ * <p/>
+ * The 'font' property is a shorthand property for setting
+ * 'font-style',
+ * 'font-variant',
+ * 'font-weight',
+ * 'font-size',
+ * 'line-height' and
+ * 'font-family' at the same place in the style sheet.
+ * The syntax of this property is based on a traditional typographical
+ * shorthand notation to set multiple properties related to fonts.
+ * <P> For a definition of allowed and initial values, see the previously
+ * defined properties. Properties for which no values are given are set to
+ * their initial value.
+ * <PRE>
+ * P { font: 12pt/14pt sans-serif }
+ * P { font: 80% sans-serif }
+ * P { font: x-large/110% "new century schoolbook", serif }
+ * P { font: bold italic large Palatino, serif }
+ * P { font: normal small-caps 120%/120% fantasy }
+ * </PRE>
+ * <P> In the second rule, the font size percentage value ('80%') refers to
+ * the font size of the parent element. In the third rule, the line height
+ * percentage refers to the font size of the element itself.
+ * <P> In the first three rules above, the 'font-style', 'font-variant' and
+ * 'font-weight' are not explicitly mentioned, which means they are all three
+ * set to their initial value ('normal'). The fourth rule sets the
+ * 'font-weight' to 'bold', the 'font-style' to 'italic' and implicitly sets
+ * 'font-variant' to 'normal'.
+ * <P> The fifth rule sets the 'font-variant' ('small-caps'), the 'font-size'
+ * (120% of the parent's font), the 'line-height' (120% times the font size)
+ * and the 'font-family' ('fantasy'). It follows that the keyword 'normal'
+ * applies to the two remaining properties: 'font-style' and 'font-weight'.
*
+ * @version $Revision$
* @see CssFontStyle
* @see CssFontVariant
* @see CssFontWeight
@@ -72,20 +73,19 @@
* @see CssFontFamily
* @see CssPercentage
* @see CssLength
- * @version $Revision$
*/
public class CssFontCSS2 extends CssProperty
- implements CssOperator, CssFontConstant {
+ implements CssOperator, CssFontConstant {
CssValue value;
- CssFontStyleCSS2 fontStyle;
+ CssFontStyleCSS2 fontStyle;
CssFontVariantCSS2 fontVariant;
- CssFontWeightCSS2 fontWeight;
+ CssFontWeightCSS2 fontWeight;
- CssFontSizeCSS2 fontSize;
- CssLineHeightCSS2 lineHeight;
- CssFontFamilyCSS2 fontFamily;
+ CssFontSizeCSS2 fontSize;
+ CssLineHeightCSS2 lineHeight;
+ CssFontFamilyCSS2 fontFamily;
// internal hack for strings comparaison
private static int[] hash_values;
@@ -102,175 +102,197 @@
* Creates a new CssFont
*
* @param expression The expression for this property
- * @exception InvalidParamException The expression is incorrect
+ * @throws InvalidParamException The expression is incorrect
*/
public CssFontCSS2(ApplContext ac, CssExpression expression, boolean check)
- throws InvalidParamException {
+ throws InvalidParamException {
- CssValue val = expression.getValue();
- char op = SPACE;
- boolean find = true;
- int max_values = 3;
+ CssValue val = expression.getValue();
+ char op = SPACE;
+ boolean find = true;
+ int max_values = 3;
- int normalNb = 0;
+ int normalNb = 0;
- if (val instanceof CssIdent) {
- CssIdent ident = checkIdent((CssIdent) val);
- if (ident != null) {
- if(expression.getCount() > 1) {
- throw new InvalidParamException("unrecognize", ac);
- }
- value = ident;
- expression.next();
- return;
- } // else continue;
- }
+ if (val instanceof CssIdent) {
+ CssIdent ident = checkIdent((CssIdent) val);
+ if (ident != null) {
+ if (expression.getCount() > 1) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ value = ident;
+ expression.next();
+ return;
+ } // else continue;
+ }
- while (find && max_values-- > 0) {
- find = false;
- val = expression.getValue();
- op = expression.getOperator();
+ while (find && max_values-- > 0) {
+ find = false;
+ val = expression.getValue();
+ op = expression.getOperator();
- if (val == null) {
- throw new InvalidParamException("few-value", getPropertyName(), ac);
- }
+ if (val == null) {
+ throw new InvalidParamException("few-value", getPropertyName(), ac);
+ }
- if(val.equals(inherit)) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (val.equals(inherit)) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- if(val.equals(normal)) {
- normalNb++;
- expression.next();
- find = true;
- }
+ if (val.equals(normal)) {
+ normalNb++;
+ expression.next();
+ find = true;
+ }
- if (!find && fontStyle == null) {
- try {
- fontStyle = new CssFontStyleCSS2(ac, expression);
- find = true;
- } catch (InvalidParamException e) {
- }
- }
+ if (!find && fontStyle == null) {
+ try {
+ fontStyle = new CssFontStyleCSS2(ac, expression);
+ find = true;
+ } catch (InvalidParamException e) {
+ }
+ }
- if (!find && fontVariant == null) {
- try {
- fontVariant = new CssFontVariantCSS2(ac, expression);
- find = true;
- } catch (InvalidParamException e) {
- }
- }
+ if (!find && fontVariant == null) {
+ try {
+ fontVariant = new CssFontVariantCSS2(ac, expression);
+ find = true;
+ } catch (InvalidParamException e) {
+ }
+ }
- if (!find && fontWeight == null) {
- try {
- fontWeight = new CssFontWeightCSS2(ac, expression);
- find = true;
- } catch (InvalidParamException e) {
- // we have now (or not)
- // [ 'font-style' || 'font-variant' || 'font-weight' ]?
- //break;
- }
- }
+ if (!find && fontWeight == null) {
+ try {
+ fontWeight = new CssFontWeightCSS2(ac, expression);
+ find = true;
+ } catch (InvalidParamException e) {
+ // we have now (or not)
+ // [ 'font-style' || 'font-variant' || 'font-weight' ]?
+ //break;
+ }
+ }
- if (find && op != SPACE) {
- throw new InvalidParamException("operator",
- ((new Character(op)).toString()), ac);
- }
- }
+ if (find && op != SPACE) {
+ throw new InvalidParamException("operator",
+ ((new Character(op)).toString()), ac);
+ }
+ }
- // "normal" values
- CssExpression normalExpr = new CssExpression();
- normalExpr.addValue(normal);
+ // "normal" values
+ CssExpression normalExpr = new CssExpression();
+ normalExpr.addValue(normal);
- for(int i = 0; i < normalNb; i++) {
- if (fontStyle == null) {
- fontStyle = new CssFontStyleCSS2(ac, normalExpr);
- normalExpr.starts();
- }
- else if (fontVariant == null) {
- fontVariant = new CssFontVariantCSS2(ac, normalExpr);
- normalExpr.starts();
- }
- else if (fontWeight == null) {
- fontWeight = new CssFontWeightCSS2(ac, normalExpr);
- normalExpr.starts();
- }
- }
+ for (int i = 0; i < normalNb; i++) {
+ if (fontStyle == null) {
+ fontStyle = new CssFontStyleCSS2(ac, normalExpr);
+ normalExpr.starts();
+ } else if (fontVariant == null) {
+ fontVariant = new CssFontVariantCSS2(ac, normalExpr);
+ normalExpr.starts();
+ } else if (fontWeight == null) {
+ fontWeight = new CssFontWeightCSS2(ac, normalExpr);
+ normalExpr.starts();
+ }
+ }
- val = expression.getValue();
- op = expression.getOperator();
+ val = expression.getValue();
+ op = expression.getOperator();
- if (val == null) {
- throw new InvalidParamException("few-value", getPropertyName(), ac);
- }
+ if (val == null) {
+ throw new InvalidParamException("few-value", getPropertyName(), ac);
+ }
- if(val.equals(inherit)) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (val.equals(inherit)) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- fontSize = new CssFontSizeCSS2(ac, expression);
+ fontSize = new CssFontSizeCSS2(ac, expression);
- if (op == SLASH) {
- op = expression.getOperator();
- if(expression.getValue().equals(inherit)) {
- throw new InvalidParamException("unrecognize", ac);
- }
- lineHeight = new CssLineHeightCSS2(ac, expression);
- }
+ if (op == SLASH) {
+ op = expression.getOperator();
+ if (expression.getValue().equals(inherit)) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
+ lineHeight = new CssLineHeightCSS2(ac, expression);
+ }
- if(expression.getValue().equals(inherit)) {
- throw new InvalidParamException("unrecognize", ac);
- }
+ if (expression.getValue().equals(inherit)) {
+ throw new InvalidParamException("unrecognize", ac);
+ }
- if (op == SPACE && expression.getValue() != null) {
- fontFamily = new CssFontFamilyCSS2(ac, expression, true);
- } else {
- expression.starts();
- throw new InvalidParamException("few-value", expression.toString(), ac);
- }
- setByUser();
+ if (op == SPACE && expression.getValue() != null) {
+ fontFamily = new CssFontFamilyCSS2(ac, expression, true);
+ } else {
+ expression.starts();
+ throw new InvalidParamException("few-value", expression.toString(), ac);
+ }
+ setByUser();
}
public CssFontCSS2(ApplContext ac, CssExpression expression)
- throws InvalidParamException {
- this(ac, expression, false);
+ throws InvalidParamException {
+ this(ac, expression, false);
}
/**
* Returns the value of this property
*/
public Object get() {
- return null;
+ return null;
}
/**
* Returns a string representation of the object.
*/
public String toString() {
- if (value != null) {
- return value.toString();
- } else {
- String ret = "";
- if (fontStyle != null) {
- ret += " " + fontStyle;
- }
- if (fontVariant != null) {
- ret += " " + fontVariant;
- }
- if (fontWeight != null) {
- ret += " " + fontWeight;
- }
- if(fontSize != null) {
- ret += " " + fontSize;
- }
- if (lineHeight != null) {
- ret += "/" + lineHeight;
- }
- if (fontFamily.size() != 0) {
- ret += " " + fontFamily;
- }
- return ret.substring(1);
- }
+ if (value != null) {
+ return value.toString();
+ } else {
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ if (fontStyle != null) {
+ if (!first) {
+ sb.append(' ');
+ } else {
+ first = false;
+ }
+ sb.append(fontStyle.toString());
+ }
+ if (fontVariant != null) {
+ if (!first) {
+ sb.append(' ');
+ } else {
+ first = false;
+ }
+ sb.append(fontVariant.toString());
+ }
+ if (fontWeight != null) {
+ if (!first) {
+ sb.append(' ');
+ } else {
+ first = false;
+ }
+ sb.append(fontWeight.toString());
+ }
+ if (fontSize != null) {
+ if (!first) {
+ sb.append(' ');
+ } else {
+ first = false;
+ }
+ sb.append(fontSize.toString());
+ if (lineHeight != null) {
+ sb.append('/').append(lineHeight.toString());
+ }
+ }
+ if (fontFamily.size() != 0) {
+ if (!first) {
+ sb.append(' ');
+ }
+ sb.append(fontFamily.toString());
+ }
+ return sb.toString();
+ }
}
/**
@@ -278,21 +300,21 @@
* Overrides this method for a macro
*/
public void setImportant() {
- super.setImportant();
- if (value == null) {
- if(fontStyle != null)
- fontStyle.important = true;
- if(fontVariant != null)
- fontVariant.important = true;
- if(fontWeight != null)
- fontWeight.important = true;
- if(fontSize != null)
- fontSize.important = true;
- if(lineHeight != null)
- lineHeight.important = true;
- if(fontFamily != null)
- fontFamily.important = true;
- }
+ super.setImportant();
+ if (value == null) {
+ if (fontStyle != null)
+ fontStyle.important = true;
+ if (fontVariant != null)
+ fontVariant.important = true;
+ if (fontWeight != null)
+ fontWeight.important = true;
+ if (fontSize != null)
+ fontSize.important = true;
+ if (lineHeight != null)
+ lineHeight.important = true;
+ if (fontFamily != null)
+ fontFamily.important = true;
+ }
}
/**
@@ -300,16 +322,16 @@
* Overrides this method for a macro
*/
public boolean getImportant() {
- if (value != null) {
- return super.getImportant();
- } else {
- return ((fontStyle == null || fontStyle.important) &&
- (fontVariant == null || fontVariant.important) &&
- (fontWeight == null || fontWeight.important) &&
- (fontSize == null || fontSize.important) &&
- (lineHeight == null || lineHeight.important) &&
- (fontFamily == null || fontFamily.important));
- }
+ if (value != null) {
+ return super.getImportant();
+ } else {
+ return ((fontStyle == null || fontStyle.important) &&
+ (fontVariant == null || fontVariant.important) &&
+ (fontWeight == null || fontWeight.important) &&
+ (fontSize == null || fontSize.important) &&
+ (lineHeight == null || lineHeight.important) &&
+ (fontFamily == null || fontFamily.important));
+ }
}
/**
@@ -318,56 +340,56 @@
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
- if (value != null) {
- ((Css1Style) style).cssFontCSS2.value = value;
- } else {
- if(fontStyle != null)
- fontStyle.addToStyle(ac, style);
- if(fontVariant != null)
- fontVariant.addToStyle(ac, style);
- if(fontSize != null)
- fontSize.addToStyle(ac, style);
- if(fontWeight != null)
- fontWeight.addToStyle(ac, style);
- if(lineHeight != null)
- lineHeight.addToStyle(ac, style);
- if(fontFamily != null)
- fontFamily.addToStyle(ac, style);
- }
+ if (value != null) {
+ ((Css1Style) style).cssFontCSS2.value = value;
+ } else {
+ if (fontStyle != null)
+ fontStyle.addToStyle(ac, style);
+ if (fontVariant != null)
+ fontVariant.addToStyle(ac, style);
+ if (fontSize != null)
+ fontSize.addToStyle(ac, style);
+ if (fontWeight != null)
+ fontWeight.addToStyle(ac, style);
+ if (lineHeight != null)
+ lineHeight.addToStyle(ac, style);
+ if (fontFamily != null)
+ fontFamily.addToStyle(ac, style);
+ }
}
/**
* Update the source file and the line.
* Overrides this method for a macro
*
- * @param line The line number where this property is defined
+ * @param line The line number where this property is defined
* @param source The source file where this property is defined
*/
public void setInfo(int line, String source) {
- super.setInfo(line, source);
- if (value == null) {
- if(fontStyle != null)
- fontStyle.setInfo(line, source);
- if(fontVariant != null)
- fontVariant.setInfo(line, source);
- if(fontWeight != null)
- fontWeight.setInfo(line, source);
- if(fontSize != null)
- fontSize.setInfo(line, source);
- if(lineHeight != null)
- lineHeight.setInfo(line, source);
- if(fontFamily != null)
- fontFamily.setInfo(line, source);
- }
+ super.setInfo(line, source);
+ if (value == null) {
+ if (fontStyle != null)
+ fontStyle.setInfo(line, source);
+ if (fontVariant != null)
+ fontVariant.setInfo(line, source);
+ if (fontWeight != null)
+ fontWeight.setInfo(line, source);
+ if (fontSize != null)
+ fontSize.setInfo(line, source);
+ if (lineHeight != null)
+ lineHeight.setInfo(line, source);
+ if (fontFamily != null)
+ fontFamily.setInfo(line, source);
+ }
}
/**
* Compares two properties for equality.
*
- * @param value The other property.
+ * @param property The other property.
*/
public boolean equals(CssProperty property) {
- return false;
+ return false;
}
/**
@@ -378,63 +400,63 @@
* @see org.w3c.css.css.StyleSheetParser#handleRule
*/
public void setSelectors(CssSelectors selector) {
- super.setSelectors(selector);
- if (fontStyle != null) {
- fontStyle.setSelectors(selector);
- }
- if (fontVariant != null) {
- fontVariant.setSelectors(selector);
- }
- if (fontWeight != null) {
- fontWeight.setSelectors(selector);
- }
- if (fontSize != null) {
- fontSize.setSelectors(selector);
- }
- if (lineHeight != null) {
- lineHeight.setSelectors(selector);
- }
- if (fontFamily != null) {
- fontFamily.setSelectors(selector);
- }
+ super.setSelectors(selector);
+ if (fontStyle != null) {
+ fontStyle.setSelectors(selector);
+ }
+ if (fontVariant != null) {
+ fontVariant.setSelectors(selector);
+ }
+ if (fontWeight != null) {
+ fontWeight.setSelectors(selector);
+ }
+ if (fontSize != null) {
+ fontSize.setSelectors(selector);
+ }
+ if (lineHeight != null) {
+ lineHeight.setSelectors(selector);
+ }
+ if (fontFamily != null) {
+ fontFamily.setSelectors(selector);
+ }
}
/**
* Get this property in the style.
*
- * @param style The style where the property is
+ * @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
- if (resolve) {
- return ((Css1Style) style).getFontCSS2();
- } else {
- return ((Css1Style) style).cssFontCSS2;
- }
+ if (resolve) {
+ return ((Css1Style) style).getFontCSS2();
+ } else {
+ return ((Css1Style) style).cssFontCSS2;
+ }
}
/**
* Returns the name of this property
*/
public String getPropertyName() {
- return "font";
+ return "font";
}
private CssIdent checkIdent(CssIdent ident) {
- int hash = ident.hashCode();
- for (int i = 0; i < CssFontConstantCSS2.FONT.length; i++) {
- if (hash_values[i] == hash) {
- return ident;
- }
- }
+ int hash = ident.hashCode();
+ for (int i = 0; i < CssFontConstantCSS2.FONT.length; i++) {
+ if (hash_values[i] == hash) {
+ return ident;
+ }
+ }
- return null;
+ return null;
}
static {
- hash_values = new int[CssFontConstantCSS2.FONT.length];
- for (int i=0; i<CssFontConstantCSS2.FONT.length; i++)
- hash_values[i] = CssFontConstantCSS2.FONT[i].hashCode();
+ hash_values = new int[CssFontConstantCSS2.FONT.length];
+ for (int i = 0; i < CssFontConstantCSS2.FONT.length; i++)
+ hash_values[i] = CssFontConstantCSS2.FONT[i].hashCode();
}
}
Index: Css1Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- Css1Style.java 4 Oct 2011 13:05:24 -0000 1.24
+++ Css1Style.java 9 Feb 2012 17:36:28 -0000 1.25
@@ -9,24 +9,11 @@
import org.w3c.css.parser.CssSelectors;
import org.w3c.css.parser.CssStyle;
-import org.w3c.css.properties.css.CssBackground;
-import org.w3c.css.properties.css.CssBackgroundAttachment;
-import org.w3c.css.properties.css.CssBackgroundColor;
-import org.w3c.css.properties.css.CssBackgroundImage;
-import org.w3c.css.properties.css.CssBackgroundPosition;
-import org.w3c.css.properties.css.CssBackgroundRepeat;
import org.w3c.css.properties.css.CssDirection;
import org.w3c.css.properties.css.CssDisplay;
import org.w3c.css.properties.css.CssProperty;
import org.w3c.css.properties.css.CssZIndex;
-import org.w3c.css.properties.css2.CssBackgroundAttachmentCSS2;
-import org.w3c.css.properties.css2.CssBackgroundCSS2;
-import org.w3c.css.properties.css2.CssBackgroundColorCSS2;
-import org.w3c.css.properties.css2.CssBackgroundImageCSS2;
-import org.w3c.css.properties.css2.CssBackgroundPositionCSS2;
-import org.w3c.css.properties.css2.CssBackgroundRepeatCSS2;
import org.w3c.css.util.ApplContext;
-import org.w3c.css.util.CssVersion;
import org.w3c.css.util.Util;
import org.w3c.css.util.Warning;
import org.w3c.css.util.Warnings;
@@ -62,20 +49,18 @@
/**
* background properties
*/
- public CssBackground cssBackground = new CssBackground();
- public CssBackgroundCSS2 cssBackgroundCSS2 = new CssBackgroundCSS2();
- public CssBackgroundCSS1 cssBackgroundCSS1 = new CssBackgroundCSS1();
+ public org.w3c.css.properties.css.CssBackground cssBackground = new org.w3c.css.properties.css.CssBackground();
public CssBackgroundMob cssBackgroundMob = new CssBackgroundMob();
/* Text properties */
/**
* word-spacing property
*/
- public CssWordSpacing cssWordSpacing;
+ public org.w3c.css.properties.css.CssWordSpacing cssWordSpacing;
/**
* letter-spacing property
*/
- public CssLetterSpacing cssLetterSpacing;
+ public org.w3c.css.properties.css.CssLetterSpacing cssLetterSpacing;
/**
* text-decoration property
*/
@@ -213,7 +198,7 @@
/**
* white-space property
*/
- public CssWhiteSpace cssWhiteSpace;
+ public org.w3c.css.properties.css.CssWhiteSpace cssWhiteSpace;
/**
* list-style properties
*/
@@ -593,35 +578,15 @@
/**
* Get the background-color property
*/
- public final CssBackgroundColor getBackgroundColor() {
+ public final org.w3c.css.properties.css.CssBackgroundColor getBackgroundColor() {
if (cssBackground.color == null) {
cssBackground.color =
- (CssBackgroundColor) style.CascadingOrder(new CssBackgroundColor(),
+ (org.w3c.css.properties.css.CssBackgroundColor) style.CascadingOrder(new org.w3c.css.properties.css.CssBackgroundColor(),
style, selector);
}
return cssBackground.color;
}
- public final CssBackgroundColorCSS2 getBackgroundColorCSS2() {
- if (cssBackgroundCSS2.color == null) {
- cssBackgroundCSS2.color =
- (CssBackgroundColorCSS2) style.CascadingOrder(
- new CssBackgroundColorCSS2(),
- style, selector);
- }
- return cssBackgroundCSS2.color;
- }
-
- public final CssBackgroundColorCSS1 getBackgroundColorCSS1() {
- if (cssBackgroundCSS1.color == null) {
- cssBackgroundCSS1.color =
- (CssBackgroundColorCSS1) style.CascadingOrder(
- new CssBackgroundColorCSS1(),
- style, selector);
- }
- return cssBackgroundCSS1.color;
- }
-
public final CssBackgroundColorMob getBackgroundColorMob() {
if (cssBackgroundMob.color == null) {
cssBackgroundMob.color =
@@ -635,33 +600,15 @@
/**
* Get the background-image property
*/
- public final CssBackgroundImage getBackgroundImage() {
+ public final org.w3c.css.properties.css.CssBackgroundImage getBackgroundImage() {
if (cssBackground.image == null) {
cssBackground.image =
- (CssBackgroundImage) style.CascadingOrder(new CssBackgroundImage(),
+ (org.w3c.css.properties.css.CssBackgroundImage) style.CascadingOrder(new org.w3c.css.properties.css.CssBackgroundImage(),
style, selector);
}
return cssBackground.image;
}
- public final CssBackgroundImageCSS2 getBackgroundImageCSS2() {
- if (cssBackgroundCSS2.image == null) {
- cssBackgroundCSS2.image =
- (CssBackgroundImageCSS2) style.CascadingOrder(new CssBackgroundImageCSS2(),
- style, selector);
- }
- return cssBackgroundCSS2.image;
- }
-
- public final CssBackgroundImageCSS1 getBackgroundImageCSS1() {
- if (cssBackgroundCSS1.image == null) {
- cssBackgroundCSS1.image =
- (CssBackgroundImageCSS1) style.CascadingOrder(new CssBackgroundImageCSS1(),
- style, selector);
- }
- return cssBackgroundCSS1.image;
- }
-
public final CssBackgroundImageMob getBackgroundImageMob() {
if (cssBackgroundMob.image == null) {
cssBackgroundMob.image =
@@ -674,32 +621,16 @@
/**
* Get the background-repeat property
*/
- public final CssBackgroundRepeat getBackgroundRepeat() {
+ public final org.w3c.css.properties.css.CssBackgroundRepeat getBackgroundRepeat() {
if (cssBackground.repeat == null) {
cssBackground.repeat =
- (CssBackgroundRepeat) style.CascadingOrder(new CssBackgroundRepeat(),
+ (org.w3c.css.properties.css.CssBackgroundRepeat) style.CascadingOrder(new org.w3c.css.properties.css.CssBackgroundRepeat(),
style, selector);
}
return cssBackground.repeat;
}
- public final CssBackgroundRepeatCSS2 getBackgroundRepeatCSS2() {
- if (cssBackgroundCSS2.repeat == null) {
- cssBackgroundCSS2.repeat =
- (CssBackgroundRepeatCSS2) style.CascadingOrder(new CssBackgroundRepeatCSS2(),
- style, selector);
- }
- return cssBackgroundCSS2.repeat;
- }
-
- public final CssBackgroundRepeatCSS1 getBackgroundRepeatCSS1() {
- if (cssBackgroundCSS1.repeat == null) {
- cssBackgroundCSS1.repeat =
- (CssBackgroundRepeatCSS1) style.CascadingOrder(new CssBackgroundRepeatCSS1(),
- style, selector);
- }
- return cssBackgroundCSS1.repeat;
- }
+ // TODO this one has to go as well
public final CssBackgroundRepeatMob getBackgroundRepeatMob() {
if (cssBackgroundMob.repeat == null) {
@@ -713,33 +644,15 @@
/**
* Get the background-attachment property
*/
- public final CssBackgroundAttachment getBackgroundAttachment() {
+ public final org.w3c.css.properties.css.CssBackgroundAttachment getBackgroundAttachment() {
if (cssBackground.attachment == null) {
cssBackground.attachment =
- (CssBackgroundAttachment) style.CascadingOrder(new CssBackgroundAttachment(),
+ (org.w3c.css.properties.css.CssBackgroundAttachment) style.CascadingOrder(new org.w3c.css.properties.css.CssBackgroundAttachment(),
style, selector);
}
return cssBackground.attachment;
}
- public final CssBackgroundAttachmentCSS2 getBackgroundAttachmentCSS2() {
- if (cssBackgroundCSS2.attachment == null) {
- cssBackgroundCSS2.attachment =
- (CssBackgroundAttachmentCSS2) style.CascadingOrder(new CssBackgroundAttachmentCSS2(),
- style, selector);
- }
- return cssBackgroundCSS2.attachment;
- }
-
- public final CssBackgroundAttachmentCSS1 getBackgroundAttachmentCSS1() {
- if (cssBackgroundCSS1.attachment == null) {
- cssBackgroundCSS1.attachment =
- (CssBackgroundAttachmentCSS1) style.CascadingOrder(new CssBackgroundAttachmentCSS1(),
- style, selector);
- }
- return cssBackgroundCSS1.attachment;
- }
-
public final CssBackgroundAttachmentMob getBackgroundAttachmentMob() {
if (cssBackgroundMob.attachment == null) {
cssBackgroundMob.attachment =
@@ -752,33 +665,15 @@
/**
* Get the background-position property
*/
- public final CssBackgroundPosition getBackgroundPosition() {
+ public final org.w3c.css.properties.css.CssBackgroundPosition getBackgroundPosition() {
if (cssBackground.position == null) {
cssBackground.position =
- (CssBackgroundPosition) style.CascadingOrder(new CssBackgroundPosition(),
+ (org.w3c.css.properties.css.CssBackgroundPosition) style.CascadingOrder(new org.w3c.css.properties.css.CssBackgroundPosition(),
style, selector);
}
return cssBackground.position;
}
- public final CssBackgroundPositionCSS2 getBackgroundPositionCSS2() {
- if (cssBackgroundCSS2.position == null) {
- cssBackgroundCSS2.position =
- (CssBackgroundPositionCSS2) style.CascadingOrder(new CssBackgroundPositionCSS2(),
- style, selector);
- }
- return cssBackgroundCSS2.position;
- }
-
- public final CssBackgroundPositionCSS1 getBackgroundPositionCSS1() {
- if (cssBackgroundCSS1.position == null) {
- cssBackgroundCSS1.position =
- (CssBackgroundPositionCSS1) style.CascadingOrder(new CssBackgroundPositionCSS1(),
- style, selector);
- }
- return cssBackgroundCSS1.position;
- }
-
public final CssBackgroundPositionMob getBackgroundPositionMob() {
if (cssBackgroundMob.position == null) {
cssBackgroundMob.position =
@@ -791,7 +686,7 @@
/**
* Get the background property
*/
- public final CssBackground getBackground() {
+ public final org.w3c.css.properties.css.CssBackground getBackground() {
if (cssBackground.getColor() == null) {
cssBackground.color = getBackgroundColor();
}
@@ -810,44 +705,6 @@
return cssBackground;
}
- public final CssBackgroundCSS2 getBackgroundCSS2() {
- if (cssBackgroundCSS2.getColor() == null) {
- cssBackgroundCSS2.color = getBackgroundColorCSS2();
- }
- if (cssBackgroundCSS2.image == null) {
- cssBackgroundCSS2.image = getBackgroundImageCSS2();
- }
- if (cssBackgroundCSS2.repeat == null) {
- cssBackgroundCSS2.repeat = getBackgroundRepeatCSS2();
- }
- if (cssBackgroundCSS2.attachment == null) {
- cssBackgroundCSS2.attachment = getBackgroundAttachmentCSS2();
- }
- if (cssBackgroundCSS2.position == null) {
- cssBackgroundCSS2.position = getBackgroundPositionCSS2();
- }
- return cssBackgroundCSS2;
- }
-
- public final CssBackgroundCSS1 getBackgroundCSS1() {
- if (cssBackgroundCSS1.getColor() == null) {
- cssBackgroundCSS1.color = getBackgroundColorCSS1();
- }
- if (cssBackgroundCSS1.image == null) {
- cssBackgroundCSS1.image = getBackgroundImageCSS1();
- }
- if (cssBackgroundCSS1.repeat == null) {
- cssBackgroundCSS1.repeat = getBackgroundRepeatCSS1();
- }
- if (cssBackgroundCSS1.attachment == null) {
- cssBackgroundCSS1.attachment = getBackgroundAttachmentCSS1();
- }
- if (cssBackgroundCSS1.position == null) {
- cssBackgroundCSS1.position = getBackgroundPositionCSS1();
- }
- return cssBackgroundCSS1;
- }
-
public final CssBackgroundMob getBackgroundMob() {
if (cssBackgroundMob.getColor() == null) {
cssBackgroundMob.color = getBackgroundColorMob();
@@ -874,10 +731,10 @@
/**
* Get the word-spacing property
*/
- public final CssWordSpacing getWordSpacing() {
+ public final org.w3c.css.properties.css.CssWordSpacing getWordSpacing() {
if (cssWordSpacing == null) {
cssWordSpacing =
- (CssWordSpacing) style.CascadingOrder(new CssWordSpacing(),
+ (org.w3c.css.properties.css.CssWordSpacing) style.CascadingOrder(new org.w3c.css.properties.css.CssWordSpacing(),
style, selector);
}
return cssWordSpacing;
@@ -886,10 +743,10 @@
/**
* Get the letter-spacing property
*/
- public final CssLetterSpacing getLetterSpacing() {
+ public final org.w3c.css.properties.css.CssLetterSpacing getLetterSpacing() {
if (cssLetterSpacing == null) {
cssLetterSpacing =
- (CssLetterSpacing) style.CascadingOrder(new CssLetterSpacing(),
+ (org.w3c.css.properties.css.CssLetterSpacing) style.CascadingOrder(new org.w3c.css.properties.css.CssLetterSpacing(),
style, selector);
}
return cssLetterSpacing;
@@ -2117,10 +1974,10 @@
/**
* Get the white-space property
*/
- public final CssWhiteSpace getWhiteSpace() {
+ public final org.w3c.css.properties.css.CssWhiteSpace getWhiteSpace() {
if (cssWhiteSpace == null) {
cssWhiteSpace =
- (CssWhiteSpace) style.CascadingOrder(new CssWhiteSpace(),
+ (org.w3c.css.properties.css.CssWhiteSpace) style.CascadingOrder(new org.w3c.css.properties.css.CssWhiteSpace(),
style, selector);
}
return cssWhiteSpace;
@@ -2522,7 +2379,7 @@
} else {
CssValue color = cssBackground.getColor();
- if (!color.equals(CssBackgroundColor.transparent)) {
+ if (!color.equals(org.w3c.css.properties.css.CssBackgroundColor.transparent)) {
// It's better to have a color when a background is defined.
warnings.addWarning(new Warning(cssBackground.color,
"no-color", 2, emptyArray, ac));
@@ -2581,233 +2438,33 @@
warnings.addWarning(new Warning(cssBackground.color, "no-padding", 2));
}
*/
- } else if (cssBackgroundCSS1.getColor() != null) {
- org.w3c.css.properties.css.CssColor colorCSS1 = cssColor;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- if (sel.toString().equals(selector.toString())) {
- colorCSS1 = ((Css1Style) sel.getStyle()).cssColor;
- break;
- }
- }
- if (colorCSS1 != null) {
- if (cssBackgroundCSS1.getColor().equals(colorCSS1.getColor())) {
- // background and color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "same-colors", 1, colorCSS1, ac));
- } else if (cssBackgroundCSS1.getColor().equals(
- CssProperty.transparent)) {
-// It's better to have a background color with a color
- warnings.addWarning(new Warning(
- colorCSS1, "no-background-color", 2, emptyArray, ac));
- }
- } else {
- CssValue color = cssBackgroundCSS1.getColor();
-
- if (!color.equals(CssBackgroundColorCSS1.transparent)) {
- // It's better to have a color when a background is defined.
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "no-color", 2, emptyArray, ac));
- }
- }
-
- // Note : For borders, I don't look for inherited value.
- // So I can't find same colors in two differents contexts.
-
- if (cssBorderCSS1.getTop().getColor() != null) {
- CssValue color = cssBorderCSS1.getTop().getColor();
- if (cssBackgroundCSS1.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "same-colors", 1,
- cssBorderCSS1.getTop().color, ac));
- }
- }
- if (cssBorderCSS1.getRight().getColor() != null) {
- CssValue color = cssBorderCSS1.getRight().getColor();
- if (cssBackgroundCSS1.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "same-colors", 1,
- cssBorderCSS1.getRight().color, ac));
- }
- }
- if (cssBorderCSS1.getBottom().getColor() != null) {
- CssValue color = cssBorderCSS1.getBottom().getColor();
- if (cssBackgroundCSS1.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "same-colors", 1,
- cssBorderCSS1.getBottom().color, ac));
- }
- }
- if (cssBorderCSS1.getLeft().getColor() != null) {
- CssValue color = cssBorderCSS1.getLeft().getColor();
- if (cssBackgroundCSS1.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS1.color,
- "same-colors", 1,
- cssBorderCSS1.getLeft().color, ac));
- }
- }
- } else if (cssBackgroundCSS2.getColor() != null) {
- // TODO FIXME FUGLY because of existing code
- org.w3c.css.properties.css.CssColor colorCSS2 = cssColor;
+ } else if (cssColor != null) {
+ CssValue backgroundColor = null;
// we need to look if there is the same selector elsewhere
// containing a color definition
for (int i = 0; i < allSelectors.length; i++) {
CssSelectors sel = allSelectors[i];
- if (sel.toString().equals(selector.toString())) {
- colorCSS2 = ((Css1Style) sel.getStyle()).cssColor;
- break;
- }
- }
- if (colorCSS2 != null) {
- if (cssBackgroundCSS2.getColor().equals(colorCSS2.getColor())) {
- // background and color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "same-colors", 1, colorCSS2, ac));
- } else if (cssBackgroundCSS2.getColor().equals(
- CssProperty.transparent)) {
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(
- colorCSS2, "no-background-color", 2, ac));
- }
- } else {
- CssValue color = cssBackgroundCSS2.getColor();
-
- if (!color.equals(CssBackgroundColor.transparent)) {
- // It's better to have a color when a background is defined.
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "no-color", 2, emptyArray, ac));
- }
- }
-
- // Note : For borders, I don't look for inherited value.
- // So I can't find same colors in two differents contexts.
-
- if (cssBorderCSS2.getTop().getColor() != null) {
- CssValue color = cssBorderCSS2.getTop().getColor();
- if (color != CssProperty.inherit
- && cssBackgroundCSS2.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "same-colors", 1,
- cssBorderCSS2.getTop().color, ac));
- }
- }
- if (cssBorderCSS2.getRight().getColor() != null) {
- CssValue color = cssBorderCSS2.getRight().getColor();
- if (color != CssProperty.inherit
- && cssBackgroundCSS2.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "same-colors", 1,
- cssBorderCSS2.getRight().color, ac));
+ Css1Style style =
+ (Css1Style) sel.getStyle();
+ if (backgroundColor == null &&
+ sel.toString().equals(selector.toString())) {
+ backgroundColor = ((Css1Style) sel.getStyle()).
+ cssBackground.getColor();
}
- }
- if (cssBorderCSS2.getBottom().getColor() != null) {
- CssValue color = cssBorder.getBottom().getColor();
- if (color != CssProperty.inherit
- && cssBackgroundCSS2.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "same-colors", 1,
- cssBorderCSS2.getBottom().color, ac));
+ if (style.cssBackground.getColor() != null) {
+ if (style.cssBackground.getColor().equals(cssColor.getColor())) {
+ warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
+ new String[]{style.cssBackground.color.getSelectors().toString(),
+ cssColor.getSelectors().toString()}, ac));
+ }
}
}
- if (cssBorderCSS2.getLeft().getColor() != null) {
- CssValue color = cssBorderCSS2.getLeft().getColor();
- if (color != CssProperty.inherit
- && cssBackgroundCSS2.getColor().equals(color)) {
- // background and border-color can't have the same color
- warnings.addWarning(new Warning(cssBackgroundCSS2.color,
- "same-colors", 1,
- cssBorderCSS2.getLeft().color, ac));
- }
+ if (backgroundColor == null) {
+ // It's better to have a background color with a color
+ warnings.addWarning(new Warning(cssColor,
+ "no-background-color", 2, emptyArray, ac));
}
- } else if (cssColor != null) {
- if (ac.getCssVersion() == CssVersion.CSS3) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style =
- (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackground.getColor();
- }
- if (style.cssBackground.getColor() != null) {
- if (style.cssBackground.getColor().equals(cssColor.getColor())) {
- warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
- new String[]{style.cssBackground.color.getSelectors().toString(),
- cssColor.getSelectors().toString()}, ac));
- }
- }
- }
- if (backgroundColor == null) {
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColor,
- "no-background-color", 2, emptyArray, ac));
- }
- } else if (ac.getCssVersion() == CssVersion.CSS1) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style = (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackgroundCSS1.getColor();
- }
- if (style.cssBackgroundCSS1.getColor() != null) {
- if (style.cssBackgroundCSS1.getColor().equals(cssColor.getColor())) {
- warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
- new String[]{style.cssBackgroundCSS1.color.getSelectors().toString(),
- cssColor.getSelectors().toString()}, ac));
- }
- }
- }
- if (backgroundColor == null) {
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColor,
- "no-background-color", 2, emptyArray, ac));
- }
- } else if (ac.getCssVersion() == CssVersion.CSS2 || ac.getCssVersion() == CssVersion.CSS21) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style = (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackgroundCSS2.getColor();
- }
- if (style.cssBackgroundCSS2.getColor() != null) {
- if (style.cssBackgroundCSS2.getColor().equals(cssColor.getColor())) {
- warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
- new String[]{style.cssBackgroundCSS2.color.getSelectors().toString(),
- cssColor.getSelectors().toString()}, ac));
- }
- }
- }
- if (backgroundColor == null) {
- // FIXME background image
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColor,
- "no-background-color", 2, emptyArray, ac));
- }
- }
}
// now testing for % and length in padding and marging
@@ -2950,9 +2607,8 @@
break;
case CssTypes.CSS_LENGTH:
CssLength length = (CssLength) value;
- Float f = (Float) length.get();
// 0 is always 0, no need to check
- if (f.floatValue() != (float) 0.0) {
+ if (!length.isZero()) {
String unit = length.getUnit();
// per CSS21, section 4.3.2
// 'px', 'em', 'ex' are relative values
Index: CSS1Default.properties
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CSS1Default.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- CSS1Default.properties 23 Aug 2005 16:23:12 -0000 1.1
+++ CSS1Default.properties 9 Feb 2012 17:36:28 -0000 1.2
@@ -1,8 +1,5 @@
# inherited : true if this property is inherited ...
-background.inherited: false
-background-attachment.inherited:false
-
color.inherited: true
background-color.inherited: false
background-image.inherited: false
@@ -77,12 +74,10 @@
border-width.inherited: false
line-height.inherited: true
-content.inherited: false
quotes.inherited: true
content.inherited: false
counter-reset.inherited: false
counter-increment.inherited: false
-content.inherited: false
marker-offset.inherited: false
Index: CssBorderBottomColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderBottomColor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssBorderBottomColor.java 9 Sep 2011 12:16:43 -0000 1.5
+++ CssBorderBottomColor.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -22,14 +22,14 @@
CssBorderFaceColor face;
/**
- * Create a new CssBorderBottomColor
+ * Create a new CssBorderBottomColorCSS21
*/
public CssBorderBottomColor() {
face = new CssBorderFaceColor();
}
/**
- * Create a new CssBorderBottomColor with an another CssBorderFaceColor
+ * Create a new CssBorderBottomColorCSS21 with an another CssBorderFaceColor
*
* @param another An another face.
*/
@@ -41,7 +41,7 @@
}
/**
- * Create a new CssBorderBottomColor
+ * Create a new CssBorderBottomColorCSS21
*
* @param expression The expression for this property.
* @exception InvalidParamException Values are incorrect
--- NEW FILE: CssBackgroundImage.java ---
//
// $Id: CssBackgroundImage.java,v 1.6 2012/02/09 17:36:28 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssStyle;
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.CssTypes;
import org.w3c.css.values.CssValue;
/**
* <H4>
* 'background-image'
* </H4>
* <p/>
* <EM>Value:</EM> <url> | none<BR>
* <EM>Initial:</EM> none<BR>
* <EM>Applies to:</EM> all elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> N/A<BR>
* <P> This property sets the background image of an element. When setting a
* background image, one should also set a background color that will be used
* when the image is unavailable. When the image is available, it is overlaid
* on top of the background color.
* <PRE>
* BODY { background-image: url(marble.gif) }
* P { background-image: none }
* </PRE>
*
* @version $Revision: 1.6 $
*/
public class CssBackgroundImage extends org.w3c.css.properties.css.CssBackgroundImage {
CssValue url = null;
/**
* Create a new CssBackgroundImage
*/
public CssBackgroundImage() {
url = none;
}
/**
* Creates a new CssBackgroundImage
*
* @param expression The expression for this property
* @throws InvalidParamException Values are incorrect
*/
public CssBackgroundImage(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
setByUser();
CssValue val = expression.getValue();
switch (val.getType()) {
case CssTypes.CSS_URL:
url = val;
break;
case CssTypes.CSS_IDENT:
if (none.equals(val)) {
url = none;
break;
}
default:
throw new InvalidParamException("value", val,
getPropertyName(), ac);
}
expression.next();
}
public CssBackgroundImage(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return url.toString();
}
/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
if (cssBackground.image != null) {
style.addRedefinitionWarning(ac, this);
}
cssBackground.image = this;
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackgroundImage();
} else {
return ((Css1Style) style).cssBackground.image;
}
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return ((url == null && property == null) ||
(property instanceof CssBackgroundImage &&
url != null &&
url.equals(((CssBackgroundImage) property).url)));
}
}
Index: CssWidth.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssWidth.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CssWidth.java 27 Sep 2011 08:15:45 -0000 1.5
+++ CssWidth.java 9 Feb 2012 17:36:29 -0000 1.6
@@ -61,7 +61,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);
}
--- NEW FILE: CssBackgroundColor.java ---
//
// $Id: CssBackgroundColor.java,v 1.8 2012/02/09 17:36:28 ylafon Exp $
// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
// (c) COPYRIGHT MIT and INRIA, 1997.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.properties.css1;
import org.w3c.css.parser.CssStyle;
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.CssTypes;
import org.w3c.css.values.CssValue;
/**
* <H4>
* 'background-color'
* </H4>
* <p/>
* <EM>Value:</EM> <color> | transparent<BR>
* <EM>Initial:</EM> transparent<BR>
* <EM>Applies to:</EM> all elements<BR>
* <EM>Inherited:</EM> no<BR>
* <EM>Percentage values:</EM> N/A<BR>
* <p/>
* This property sets the background color of an element.
* <PRE>
* H1 { background-color: #F00 }
* </PRE>
*
* @version $Revision: 1.8 $
*/
public class CssBackgroundColor extends org.w3c.css.properties.css.CssBackgroundColor {
CssValue color;
/**
* Create a new CssBackgroundColor
*/
public CssBackgroundColor() {
color = transparent;
}
/**
* Create a new CssBackgroundColor
*
* @param expression The expression for this property
* @throws InvalidParamException Values are incorrect
*/
public CssBackgroundColor(ApplContext ac, CssExpression expression,
boolean check) throws InvalidParamException {
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
setByUser();
CssValue val = expression.getValue();
switch (val.getType()) {
case CssTypes.CSS_COLOR:
setColor(val);
break;
case CssTypes.CSS_IDENT:
if (transparent.equals(val)) {
setColor(transparent);
break;
}
if (inherit.equals(val)) {
setColor(inherit);
break;
}
setColor(new org.w3c.css.values.CssColor(ac,
(String) val.get()));
break;
default:
throw new InvalidParamException("value", val.toString(),
getPropertyName(), ac);
}
expression.next();
}
public CssBackgroundColor(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}
/**
* @param color The color to set.
*/
public void setColor(CssValue color) {
this.color = color;
}
/**
* Returns the value of this property
*/
public Object get() {
return color;
}
/**
* Returns the color
*/
public CssValue getColor() {
return color;
}
/**
* Returns true if this property is "softly" inherited
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
return color.equals(inherit);
}
/**
* Returns a string representation of the object.
*/
public String toString() {
return color.toString();
}
/**
* Add this property to the CssStyle.
*
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
org.w3c.css.properties.css.CssBackground cssBackground = ((Css1Style) style).cssBackground;
if (cssBackground.color != null)
style.addRedefinitionWarning(ac, this);
cssBackground.color = this;
}
/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css1Style) style).getBackgroundColor();
} else {
return ((Css1Style) style).cssBackground.color;
}
}
/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CssBackgroundColor &&
color.equals(((CssBackgroundColor) property).color));
}
/**
* Is the value of this property is a default value.
* It is used by all macro for the function <code>print</code>
*/
public boolean isDefault() {
return color == transparent;
}
}
--- CssBackgroundColorCSS1.java DELETED ---
Received on Thursday, 9 February 2012 17:37:13 UTC