- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 27 Sep 2011 08:15:47 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1 In directory hutz:/tmp/cvs-serv13381/org/w3c/css/properties/css1 Modified Files: Css1Style.java CssBorder.java CssBorderColor.java CssBorderColorCSS2.java CssCounterIncrement.java CssCounterReset.java CssHeight.java CssMargin.java CssPadding.java CssQuotes.java CssWidth.java Log Message: width and height, including css3 value initial Index: CssMargin.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMargin.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CssMargin.java 9 Sep 2011 12:16:45 -0000 1.6 +++ CssMargin.java 27 Sep 2011 08:15:45 -0000 1.7 @@ -76,7 +76,7 @@ public CssMargin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - //CssValue val = expression.getValue(); + //CssValue val = expression.floatValue(); setByUser(); /*if (val.equals(inherit)) { Index: CssBorder.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorder.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssBorder.java 9 Sep 2011 12:16:43 -0000 1.5 +++ CssBorder.java 27 Sep 2011 08:15:45 -0000 1.6 @@ -98,7 +98,7 @@ new CssBorderBottomColor((CssBorderFaceColor) c.get()); } /* - CssValue val = expression.getValue(); + CssValue val = expression.floatValue(); char op = SPACE; boolean find = true; @@ -108,7 +108,7 @@ while (find) { find = false; - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); if (val == null) Index: CssCounterIncrement.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssCounterIncrement.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssCounterIncrement.java 5 Jan 2010 13:49:42 -0000 1.3 +++ CssCounterIncrement.java 27 Sep 2011 08:15:45 -0000 1.4 @@ -103,7 +103,7 @@ counter++; if (counter < expression.getCount()) { values.addElement(val); - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); if ((op == CssOperator.SPACE) && (val instanceof CssNumber) @@ -111,19 +111,19 @@ // nothing } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } values.addElement(val); expression.next(); counter++; - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); }*/ Index: CssBorderColorCSS2.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderColorCSS2.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- CssBorderColorCSS2.java 9 Sep 2011 12:16:44 -0000 1.7 +++ CssBorderColorCSS2.java 27 Sep 2011 08:15:45 -0000 1.8 @@ -85,7 +85,7 @@ switch (expression.getCount()) { case 1: setTop(new CssBorderTopColorCSS2(ac, expression)); - /* val = expression.getValue(); + /* val = expression.floatValue(); if (val.equals(transparent)) { top = new CssBorderTopColorCSS2(); top.face.face = transparent; Index: CssQuotes.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssQuotes.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssQuotes.java 5 Jan 2010 13:49:45 -0000 1.3 +++ CssQuotes.java 27 Sep 2011 08:15:45 -0000 1.4 @@ -107,25 +107,25 @@ values.addElement(val); expression.next(); counter++; - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); if ((op == CssOperator.SPACE) && (val instanceof CssString)) { // nothing } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } values.addElement(val); expression.next(); counter++; - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); } */ Index: CssBorderColor.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderColor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- CssBorderColor.java 9 Sep 2011 12:16:44 -0000 1.6 +++ CssBorderColor.java 27 Sep 2011 08:15:45 -0000 1.7 @@ -79,7 +79,7 @@ switch (expression.getCount()) { case 1: - //CssValue val = expression.getValue(); + //CssValue val = expression.floatValue(); //if (val.equals(transparent)) { // obsolete, transparent is a color value now //top = new CssBorderTopColor(); //top.face.face = transparent; Index: CssHeight.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssHeight.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssHeight.java 5 Jan 2010 13:49:43 -0000 1.4 +++ CssHeight.java 27 Sep 2011 08:15:45 -0000 1.5 @@ -1,12 +1,9 @@ -// // $Id$ -// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // -// (c) COPYRIGHT MIT and INRIA, 1997. +// (c) COPYRIGHT MIT, ERCIM and Keio University // 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; @@ -15,105 +12,89 @@ import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; +import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; /** - * <H4> - * 'height' - * </H4> - * <P> - * <EM>Value:</EM> <length> | auto <BR> - * <EM>Initial:</EM> auto<BR> - * <EM>Applies to:</EM> block-level and replaced elements<BR> - * <EM>Inherited:</EM> no<BR> - * <EM>Percentage values:</EM> N/A<BR> - * <P> - * This property can be applied to text, but it is most useful with replaced - * elements such as images. The height is to be enforced by scaling the image - * if necessary. When scaling, the aspect ratio of the image is preserved if - * the 'width' property is 'auto'. - * <P> - * Example: - * <PRE> - * IMG.icon { height: 100px } - * </PRE> - * <P> - * If the 'width' and 'height' of a replaced element are both 'auto', these - * properties will be set to the intrinsic dimensions of the element. - * <P> - * If applied to a textual element, the height can be enforced with e.g. a - * scrollbar. - * <P> - * Negative values are not allowed. * @version $Revision$ + * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#height */ -public class CssHeight extends CssProperty { - - CssValue value; +public class CssHeight extends org.w3c.css.properties.css.CssHeight { - private static CssIdent auto = new CssIdent("auto"); + CssLength lenVal; + CssPercentage perVal; + CssIdent identVal; /** * Create a new CssHeight */ public CssHeight() { - value = auto; } /** - * Create a new CssHeight + * Create a new CssHeight. * * @param expression The expression for this property - * @exception InvalidParamException The expression is incorrect + * @throws InvalidParamException Values are incorrect */ public CssHeight(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + 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(); - if (val.equals(inherit)) { - value = inherit; - } else if (val instanceof CssLength || val instanceof CssPercentage) { - float f = ((Float) val.get()).floatValue(); - if (f < 0) { - throw new InvalidParamException("negative-value", - val.toString(), ac); - } - value = val; - } else if (val.equals(auto)) { - value = auto; - } else if (val instanceof CssNumber) { - value = ((CssNumber) val).getLength(); - } else { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } + setByUser(); - expression.next(); + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent ident = (CssIdent) val; + if (auto.equals(val)) { + identVal = auto; + } else { + throw new InvalidParamException("unrecognize", ac); + } + break; + case CssTypes.CSS_NUMBER: + val = ((CssNumber) val).getLength(); + case CssTypes.CSS_LENGTH: + lenVal = (CssLength) val; + if (lenVal.floatValue() < 0.) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + break; + case CssTypes.CSS_PERCENTAGE: + perVal = (CssPercentage) val; + if (perVal.floatValue() < 0.) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + break; + default: + throw new InvalidParamException("value", val, getPropertyName(), ac); + } + expression.next(); } public CssHeight(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); + throws InvalidParamException { + this(ac, expression, false); } /** - * Returns the value of this property + * Returns the value of this property. */ public Object get() { - return value; - } - - /** - * Returns the name of this property - */ - public String getPropertyName() { - return "height"; + if (identVal != null) { + return identVal; + } + if (perVal != null) { + return perVal; + } + return lenVal; } /** @@ -121,50 +102,43 @@ * e.g. his value equals inherit */ public boolean isSoftlyInherited() { - return value == inherit; + return identVal == inherit; } /** * 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) { - Css1Style style0 = (Css1Style) style; - if (style0.cssHeight != null) - style0.addRedefinitionWarning(ac, this); - style0.cssHeight = 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).getHeight(); - } else { - return ((Css1Style) style).cssHeight; - } + if (identVal != null) { + return identVal.toString(); + } + if (perVal != null) { + return perVal.toString(); + } + if (lenVal != null) { + return lenVal.toString(); + } + // the default + return auto.toString(); } /** * Compares two properties for equality. * - * @param value The other property. + * @param property The other property. */ public boolean equals(CssProperty property) { - return (property instanceof CssHeight && - value.equals(((CssHeight) property).value)); + try { + CssHeight h = (CssHeight) property; + return (identVal == h.identVal) && + ((perVal == null && h.perVal == null) || + (perVal != null && perVal.equals(h.perVal))) && + ((lenVal == null && h.lenVal == null) || + (lenVal != null && lenVal.equals(h.lenVal))); + + } catch (ClassCastException ex) { + return false; + } } /** @@ -172,7 +146,7 @@ * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { - return value == auto; + return identVal == auto; } } Index: Css1Style.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Css1Style.java 11 Sep 2011 20:30:22 -0000 1.22 +++ Css1Style.java 27 Sep 2011 08:15:45 -0000 1.23 @@ -9,7 +9,6 @@ import org.w3c.css.parser.CssSelectors; import org.w3c.css.parser.CssStyle; -import org.w3c.css.properties.css.CssAzimuth; import org.w3c.css.properties.css.CssBackground; import org.w3c.css.properties.css.CssBackgroundAttachment; import org.w3c.css.properties.css.CssBackgroundColor; @@ -18,7 +17,6 @@ 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.CssElevation; import org.w3c.css.properties.css.CssProperty; import org.w3c.css.properties.css.CssZIndex; import org.w3c.css.properties.css2.CssBackgroundAttachmentCSS2; @@ -128,7 +126,7 @@ /** * width property */ - public CssWidth cssWidth; + public org.w3c.css.properties.css.CssWidth cssWidth; public CssWidthMob cssWidthMob; /** @@ -156,7 +154,7 @@ /** * height property */ - public CssHeight cssHeight; + public org.w3c.css.properties.css.CssHeight cssHeight; public CssHeightMob cssHeightMob; /** * float property @@ -1838,10 +1836,10 @@ /** * Get the width property */ - public final CssWidth getWidth() { + public final org.w3c.css.properties.css.CssWidth getWidth() { if (cssWidth == null) { cssWidth = - (CssWidth) style.CascadingOrder(new CssWidth(), style, selector); + (org.w3c.css.properties.css.CssWidth) style.CascadingOrder(new CssWidth(), style, selector); } return cssWidth; } @@ -1933,10 +1931,10 @@ /** * Get the height property */ - public final CssHeight getHeight() { + public final org.w3c.css.properties.css.CssHeight getHeight() { if (cssHeight == null) { cssHeight = - (CssHeight) style.CascadingOrder(new CssHeight(), style, selector); + (org.w3c.css.properties.css.CssHeight) style.CascadingOrder(new org.w3c.css.properties.css.CssHeight(), style, selector); } return cssHeight; } @@ -2959,7 +2957,7 @@ case CssTypes.CSS_PERCENTAGE: // FIXME, it depends on the unit of the parent in the cascade. CssPercentage percent = (CssPercentage) value; - if (percent.getValue() != (float) 0.0) { + if (percent.floatValue() != (float) 0.0) { relative = true; } break; Index: CssCounterReset.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssCounterReset.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssCounterReset.java 5 Jan 2010 13:49:42 -0000 1.3 +++ CssCounterReset.java 27 Sep 2011 08:15:45 -0000 1.4 @@ -104,7 +104,7 @@ counter++; if (counter < expression.getCount()) { values.addElement(val); - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); if ((op == CssOperator.SPACE) && (val instanceof CssNumber) @@ -112,19 +112,19 @@ // nothing } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } } } else { throw new InvalidParamException("value", - expression.getValue(), + expression.floatValue(), getPropertyName(), ac); } values.addElement(val); expression.next(); counter++; - val = expression.getValue(); + val = expression.floatValue(); op = expression.getOperator(); }*/ } Index: CssWidth.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssWidth.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssWidth.java 5 Jan 2010 13:49:46 -0000 1.4 +++ CssWidth.java 27 Sep 2011 08:15:45 -0000 1.5 @@ -1,12 +1,9 @@ -// // $Id$ -// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // -// (c) COPYRIGHT MIT and INRIA, 1997. +// (c) COPYRIGHT MIT, ERCIM and Keio University // 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; @@ -15,103 +12,89 @@ import org.w3c.css.values.CssLength; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; +import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; /** - * <H4> - * 'width' - * </H4> - * <P> - * <EM>Value:</EM> <length> | <percentage> | auto <BR> - * <EM>Initial:</EM> auto<BR> - * <EM>Applies to:</EM> block-level and replaced elements<BR> - * <EM>Inherited:</EM> no<BR> - * <EM>Percentage values:</EM> refer to parent element's width<BR> - * <P> - * This property can be applied to text elements, but it is most useful with - * replaced elements such as images. The width is to be enforced by scaling - * the image if necessary. When scaling, the aspect ratio of the image is preserved - * if the 'height' property is 'auto'. - * <P> - * Example: - * <PRE> - * IMG.icon { width: 100px } - * </PRE> - * <P> - * If the 'width' and 'height' of a replaced element are both 'auto', these - * properties will be set to the intrinsic dimensions of the element. - * <P> - * Negative values are not allowed. * @version $Revision$ + * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#width */ -public class CssWidth extends CssProperty { - - CssValue value; +public class CssWidth extends org.w3c.css.properties.css.CssWidth { - private static CssIdent auto = new CssIdent("auto"); + CssLength lenVal; + CssPercentage perVal; + CssIdent identVal; /** * Create a new CssWidth */ public CssWidth() { - value = auto; } /** * Create a new CssWidth. * * @param expression The expression for this property - * @exception InvalidParamException Values are incorrect + * @throws InvalidParamException Values are incorrect */ public CssWidth(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { - - if(check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } + throws InvalidParamException { - CssValue val = expression.getValue(); + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - setByUser(); + CssValue val = expression.getValue(); - if (val.equals(inherit)) { - value = inherit; - } else if (val instanceof CssLength || val instanceof CssPercentage) { - float f = ((Float) val.get()).floatValue(); - if (f < 0) { - throw new InvalidParamException("negative-value", - val.toString(), ac); - } - value = val; - } else if (val.equals(auto)) { - value = auto; - } else if (val instanceof CssNumber) { - value = ((CssNumber) val).getLength(); - } else { - throw new InvalidParamException("value", val, - getPropertyName(), ac); - } + setByUser(); - expression.next(); + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent ident = (CssIdent) val; + if (auto.equals(val)) { + identVal = auto; + } else { + throw new InvalidParamException("unrecognize", ac); + } + break; + case CssTypes.CSS_NUMBER: + val = ((CssNumber) val).getLength(); + case CssTypes.CSS_LENGTH: + lenVal = (CssLength) val; + if (lenVal.floatValue() < 0.) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + break; + case CssTypes.CSS_PERCENTAGE: + perVal = (CssPercentage) val; + if (perVal.floatValue() < 0.) { + throw new InvalidParamException("negative-value", + val.toString(), ac); + } + break; + default: + throw new InvalidParamException("value", val, getPropertyName(), ac); + } + expression.next(); } public CssWidth(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; - } - - /** - * Returns the name of this property. - */ - public String getPropertyName() { - return "width"; + if (identVal != null) { + return identVal; + } + if (perVal != null) { + return perVal; + } + return lenVal; } /** @@ -119,50 +102,43 @@ * e.g. his value equals inherit */ public boolean isSoftlyInherited() { - return value == inherit; + return identVal == inherit; } /** * 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) { - Css1Style style0 = (Css1Style) style; - if (style0.cssWidth != null) - style0.addRedefinitionWarning(ac, this); - style0.cssWidth = 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).getWidth(); - } else { - return ((Css1Style) style).cssWidth; - } + if (identVal != null) { + return identVal.toString(); + } + if (perVal != null) { + return perVal.toString(); + } + if (lenVal != null) { + return lenVal.toString(); + } + // the default + return auto.toString(); } /** * Compares two properties for equality. * - * @param value The other property. + * @param property The other property. */ public boolean equals(CssProperty property) { - return (property instanceof CssWidth && value.equals(((CssWidth) property).value)); + try { + CssWidth w = (CssWidth) property; + return (identVal == w.identVal) && + ((perVal == null && w.perVal == null) || + (perVal != null && perVal.equals(w.perVal))) && + ((lenVal == null && w.lenVal == null) || + (lenVal != null && lenVal.equals(w.lenVal))); + + } catch (ClassCastException ex) { + return false; + } } /** @@ -170,7 +146,7 @@ * It is used by all macro for the function <code>print</code> */ public boolean isDefault() { - return value == auto; + return identVal == auto; } } Index: CssPadding.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssPadding.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- CssPadding.java 9 Sep 2011 12:16:45 -0000 1.5 +++ CssPadding.java 27 Sep 2011 08:15:45 -0000 1.6 @@ -72,7 +72,7 @@ */ public CssPadding(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - //CssValue val = expression.getValue(); + //CssValue val = expression.floatValue(); setByUser(); /*if (val.equals(inherit)) {
Received on Tuesday, 27 September 2011 08:15:57 UTC