- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 03 Sep 2012 20:34:45 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1 In directory hutz:/tmp/cvs-serv13993/css1 Modified Files: Css1Style.java CssTextIndent.java Log Message: reimplementation of text-indent Index: CssTextIndent.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssTextIndent.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssTextIndent.java 5 Jan 2010 13:49:45 -0000 1.4 +++ CssTextIndent.java 3 Sep 2012 20:34:43 -0000 1.5 @@ -1,151 +1,69 @@ -// // $Id$ -// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) +// Author: Yves Lafon <ylafon@w3.org> // -// (c) COPYRIGHT MIT and INRIA, 1997. +// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012. // 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.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> - * 'text-indent' - * </H4> - * <P> - * <EM>Value:</EM> <length> | <percentage><BR> - * <EM>Initial:</EM> 0<BR> - * <EM>Applies to:</EM> block-level elements<BR> - * <EM>Inherited:</EM> yes<BR> - * <EM>Percentage values:</EM> refer to parent element's width<BR> - * <P> - * The property specifies the indentation that appears before the first formatted - * line. The value of 'text-indent' may be negative, but there may be - * implementation-specific limits. An indentation is not inserted in the middle - * of an element that was broken by another (such as 'BR' in HTML). - * <P> - * Example: - * <PRE> - * P { text-indent: 3em } - * </PRE> - * @version $Revision$ + * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#text-indent */ -public class CssTextIndent extends CssProperty { - - CssValue value = new CssLength(); - - /** - * Create a new CssTextIndent - */ - public CssTextIndent() { - } - - /** - * Create a new CssTextIndent - * - * @param expression The expression for this property - * @exception InvalidParamException Values are incorrect - */ - public CssTextIndent(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { - - if(check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - - CssValue val = expression.getValue(); - - setByUser(); +public class CssTextIndent extends org.w3c.css.properties.css.CssTextIndent { - if (val.equals(inherit)) { - value = inherit; - } else if (val instanceof CssLength || val instanceof CssPercentage) { - value = val; - } else if (val instanceof CssNumber) { - value = ((CssNumber) val).getLength(); - } else { - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); + /** + * Create a new CssTextIndent + */ + public CssTextIndent() { } - expression.next(); - } - - public CssTextIndent(ApplContext ac, CssExpression expression) - 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 "text-indent"; - } + /** + * Creates a new CssTextIndent + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssTextIndent(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); - /** - * Returns true if this property is "softly" inherited - * e.g. his value equals inherit - */ - public boolean isSoftlyInherited() { - return value == inherit; - } + CssValue val; + char op; - /** - * Returns a string representation of the object. - */ - public String toString() { - return value.toString(); - } + val = expression.getValue(); + op = expression.getOperator(); - /** - * Add this property to the CssStyle. - * - * @param style The CssStyle - */ - public void addToStyle(ApplContext ac, CssStyle style) { - Css1Style style0 = (Css1Style) style; - if (style0.cssTextIndent != null) - style0.addRedefinitionWarning(ac, this); - style0.cssTextIndent = this; - } + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val = ((CssNumber) val).getLength(); + case CssTypes.CSS_LENGTH: + value = val; + break; + case CssTypes.CSS_PERCENTAGE: + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + expression.next(); + } - /** - * 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).getTextIndent(); - } else { - return ((Css1Style) style).cssTextIndent; + public CssTextIndent(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); } - } - /** - * Compares two properties for equality. - * - * @param value The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssTextIndent && - value.equals(((CssTextIndent) property).value)); - } } + Index: Css1Style.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Css1Style.java 3 Sep 2012 15:07:05 -0000 1.31 +++ Css1Style.java 3 Sep 2012 20:34:43 -0000 1.32 @@ -15,6 +15,7 @@ import org.w3c.css.properties.css.CssZIndex; import org.w3c.css.properties.css.CssTextTransform; import org.w3c.css.properties.css.CssTextAlign; +import org.w3c.css.properties.css.CssTextIndent; import org.w3c.css.util.ApplContext; import org.w3c.css.util.Util;
Received on Monday, 3 September 2012 20:34:47 UTC