2002/css-validator/org/w3c/css/properties/css1 Css1Style.java,1.36,1.37 CssMargin.java,1.7,1.8 CssMarginBottom.java,1.4,1.5 CssMarginLeft.java,1.4,1.5 CssMarginRight.java,1.4,1.5 CssMarginTop.java,1.4,1.5

Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv695/css1

Modified Files:
	Css1Style.java CssMargin.java CssMarginBottom.java 
	CssMarginLeft.java CssMarginRight.java CssMarginTop.java 
Log Message:
margin-* per css1/css2/css21/css3-box

Index: CssMargin.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMargin.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssMargin.java	27 Sep 2011 08:15:45 -0000	1.7
+++ CssMargin.java	26 Sep 2012 08:43:53 -0000	1.8
@@ -1,367 +1,167 @@
-//
 // $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.CssSelectors;
-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.CssOperator;
-
-/**
- *   <H4>
- *     &nbsp;&nbsp; 'margin'
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> [ &lt;length&gt; | &lt;percentage&gt; | auto ]{1,4} <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> refer to parent element's width<BR>
- *   <P>
- *   The 'margin' property is a shorthand property for setting 'margin-top',
- *   'margin-right' 'margin-bottom' and 'margin-left' at the same place in the
- *   style sheet.
- *   <P>
- *   If four length values are specified they apply to top, right, bottom and
- *   left respectively. If there is only one value, it applies to all sides, if
- *   there are two or three, the missing values are taken from the opposite side.
- *   <PRE>
- *   BODY { margin: 2em } / * all margins set to 2em * /
- *   BODY { margin: 1em 2em } / * top &amp; bottom = 1em, right &amp; left = 2em * /
- *   BODY { margin: 1em 2em 3em } / * top=1em, right=2em, bottom=3em, left=2em * /
- * </PRE>
- *   <P>
- *   The last rule of the example above is equivalent to the example below:
- *   <PRE>
- *   BODY {
- *     margin-top: 1em;
- *     margin-right: 2em;
- *     margin-bottom: 3em;
- *     margin-left: 2em;        / * copied from opposite side (right) * /
- *   }
- * </PRE>
- *   <P>
- *   Negative margin values are allowed, but there may be implementation-specific
- *   limits.
- * @version $Revision$
- */
-public class CssMargin extends CssProperty implements CssOperator {
-
-    CssMarginTop top;
-    CssMarginBottom bottom;
-    CssMarginRight right;
-    CssMarginLeft left;
+import org.w3c.css.values.CssIdent;
+import org.w3c.css.values.CssLength;
+import org.w3c.css.values.CssTypes;
+import org.w3c.css.values.CssValue;
+import org.w3c.css.values.CssValueList;
 
-    boolean inheritedValue;
+import java.util.ArrayList;
 
-    /**
-     * Create a new CssMargin
-     */
-    public CssMargin() {
-    }
+import static org.w3c.css.values.CssOperator.SPACE;
 
-    /**
-     * Create a new CssMargin
-     *
-     * @param expression The expression for this property
-     * @exception InvalidParamException Values are incorrect
-     */
-    public CssMargin(ApplContext ac, CssExpression expression, boolean check)
-	throws InvalidParamException {
+/**
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#margin
+ */
+public class CssMargin extends org.w3c.css.properties.css.CssMargin {
 
-	//CssValue val = expression.floatValue();
-	setByUser();
+	public static final CssIdent auto = CssIdent.getIdent("auto");
 
-	/*if (val.equals(inherit)) {
-	    inheritedValue = true;
-	    top = new CssMarginTop();
-	    top.value = inherit;
-	    bottom = new CssMarginBottom();
-	    bottom.value = inherit;
-	    right = new CssMarginRight();
-	    right.value = inherit;
-	    left = new CssMarginLeft();
-	    left.value = inherit;
-	}*/
-	switch (expression.getCount()) {
-	case 1:
-	    top = new CssMarginTop(ac, expression);
-	    /*bottom = new CssMarginBottom(top);
-	    right = new CssMarginRight(top);
-	    left = new CssMarginLeft(top);*/
-	    break;
-	case 2:
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    top = new CssMarginTop(ac, expression);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    right = new CssMarginRight(ac, expression);
-	    /*bottom = new CssMarginBottom(top);
-	    left = new CssMarginLeft(right);*/
-	    break;
-	case 3:
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    top = new CssMarginTop(ac, expression);
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    right = new CssMarginRight(ac, expression);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    bottom = new CssMarginBottom(ac, expression);
-	    //left = new CssMarginLeft(right);
-	    break;
-	case 4:
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    top = new CssMarginTop(ac, expression);
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    right = new CssMarginRight(ac, expression);
-	    if (expression.getOperator() != SPACE)
-		throw new InvalidParamException("operator",
-			((new Character(expression.getOperator())).toString()),
-			ac);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    bottom = new CssMarginBottom(ac, expression);
-	    if(expression.getValue().equals(inherit)) {
-		throw new InvalidParamException("unrecognize", ac);
-	    }
-	    left = new CssMarginLeft(ac, expression);
-	    break;
-	default:
-	    if(check)
-		throw new InvalidParamException("unrecognize", ac);
+	/**
+	 * Create a new CssMargin
+	 */
+	public CssMargin() {
 	}
-    }
-
-    public CssMargin(ApplContext ac, CssExpression expression)
-	throws InvalidParamException {
-	this(ac, expression, false);
-    }
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-	return top;
-    }
-
-    /**
-     * Returns the top property
-     */
-    public CssMarginTop getTop() {
-	return top;
-    }
 
-    /**
-     * Returns the right property
-     */
-    public CssMarginRight getRight() {
-	return right;
-    }
+	/**
+	 * Set the value of the property<br/>
+	 * Does not check the number of values
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMargin(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
-    /**
-     * Returns the bottom property
-     */
-    public CssMarginBottom getBottom() {
-	return bottom;
-    }
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @param check      set it to true to check the number of values
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMargin(ApplContext ac, CssExpression expression,
+					 boolean check) throws InvalidParamException {
+		if (check && expression.getCount() > 4) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
+		CssValue val;
+		char op;
+		ArrayList<CssValue> v = new ArrayList<CssValue>();
 
-    /**
-     * Returns the left property
-     */
-    public CssMarginLeft getLeft() {
-	return left;
-    }
+		while (!expression.end()) {
+			val = expression.getValue();
+			op = expression.getOperator();
 
-    /**
-     * Returns the name of this property
-     */
-    public String getPropertyName() {
-	return "margin";
-    }
+			switch (val.getType()) {
+				case CssTypes.CSS_NUMBER:
+					CssLength l = val.getLength();
+				case CssTypes.CSS_LENGTH:
+				case CssTypes.CSS_PERCENTAGE:
+					v.add(val);
+					break;
+				case CssTypes.CSS_IDENT:
+					if (auto.equals(val)) {
+						v.add(auto);
+						break;
+					}
+				default:
+					throw new InvalidParamException("value",
+							val.toString(),
+							getPropertyName(), ac);
+			}
+			if (op != SPACE) {
+				throw new InvalidParamException("operator",
+						((new Character(op)).toString()), ac);
 
-    /**
-     * Returns a string representation of the object.
-     */
-    public String toString() {
-	if (inheritedValue) {
-	    return inherit.toString();
-	}
-        String result = "";
-        // top should never be null
-        if(top != null) result += top;
-        if(right != null) result += " " + right;
-        if(bottom != null) result += " " + bottom;
-        if(left != null) result += " " + left;
-        return result;
-	/*if (right.value.equals(left.value)) {
-	    if (top.value.equals(bottom.value)) {
-		if (top.value.equals(right.value)) {
-		    return top.toString();
-		} else {
-		    return top + " " + right;
+			}
+			expression.next();
 		}
-	    } else {
-		return top + " " + right + " " + bottom;
-	    }
-	} else {
-	    return top + " " + right + " " + bottom + " " + left;
-	}*/
-    }
+		// now we check the number of values...
+		marginBottom = new CssMarginBottom();
+		marginLeft = new CssMarginLeft();
+		marginTop = new CssMarginTop();
+		marginRight = new CssMarginRight();
 
-    /**
-     * Set this property to be important.
-     * Overrides this method for a macro
-     */
-    public void setImportant() {
-	if(top != null) {
-	    top.important = true;
-	}
-	if(right != null) {
-	    right.important = true;
-	}
-	if(bottom != null) {
-	    bottom.important = true;
-	}
-	if(left != null) {
-	    left.important = true;
+		switch (v.size()) {
+			case 1:
+				marginTop.value = v.get(0);
+				marginRight.value = v.get(0);
+				marginBottom.value = v.get(0);
+				marginLeft.value = v.get(0);
+				break;
+			case 2:
+				marginTop.value = v.get(0);
+				marginRight.value = v.get(1);
+				marginBottom.value = v.get(0);
+				marginLeft.value = v.get(1);
+				break;
+			case 3:
+				marginTop.value = v.get(0);
+				marginRight.value = v.get(1);
+				marginBottom.value = v.get(2);
+				marginLeft.value = v.get(1);
+				break;
+			case 4:
+				marginTop.value = v.get(0);
+				marginRight.value = v.get(1);
+				marginBottom.value = v.get(2);
+				marginLeft.value = v.get(3);
+				break;
+			default:
+				// can't happen unless we are not checking
+				// the size
+				throw new InvalidParamException("unrecognize", ac);
+		}
+		value = new CssValueList(v);
 	}
-    }
 
-    /**
-     * Returns true if this property is important.
-     * Overrides this method for a macro
-     */
-    public boolean getImportant() {
-	return ((top == null || top.important) &&
-		(right == null || right.important) &&
-		(bottom == null || bottom.important) &&
-		(left == null || left.important));
-    }
+	// for use by individual margin-* properties
 
-    /**
-     * 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 (top != null) {
-	    top.setSelectors(selector);
-	}
-	if (right != null) {
-	    right.setSelectors(selector);
-	}
-	if (bottom != null) {
-	    bottom.setSelectors(selector);
-	}
-	if (left != null) {
-	    left.setSelectors(selector);
-	}
-    }
+	protected static CssValue checkValue(ApplContext ac,
+										 CssExpression expression,
+										 boolean check, CssProperty caller)
+			throws InvalidParamException {
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
+		CssValue val;
+		char op;
 
-    /**
-     * Add this property to the CssStyle
-     *
-     * @param style The CssStyle
-     */
-    public void addToStyle(ApplContext ac, CssStyle style) {
-	((Css1Style) style).cssMargin.inheritedValue = inheritedValue;
-	if(top != null) {
-	    top.addToStyle(ac, style);
-	}
-	if(right != null) {
-	    right.addToStyle(ac, style);
-	}
-	if(bottom != null) {
-	    bottom.addToStyle(ac, style);
-	}
-	if(left != null) {
-	    left.addToStyle(ac, style);
-	}
-    }
+		val = expression.getValue();
+		op = expression.getOperator();
 
-    /**
-     * 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).getMargin();
-	} else {
-	    return ((Css1Style) style).cssMargin;
+		switch (val.getType()) {
+			case CssTypes.CSS_NUMBER:
+				CssLength l = val.getLength();
+			case CssTypes.CSS_LENGTH:
+			case CssTypes.CSS_PERCENTAGE:
+				expression.next();
+				return val;
+			case CssTypes.CSS_IDENT:
+				if (auto.equals(val)) {
+					expression.next();
+					return auto;
+				}
+				// if not inherit, or not an ident
+				// let it flow to the exception
+		}
+		throw new InvalidParamException("value",
+				val.toString(),
+				caller.getPropertyName(), ac);
 	}
-    }
-
-    /**
-     * 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);
-	// it assumes that values exists, that may not be the case
-	// always. What would be the cause of that, an invalid clause?
-	// in this case a proper exception should be sent
-	// So... a FIXME
-	if(top != null) top.setInfo(line, source);
-	if(right != null) right.setInfo(line, source);
-	if(bottom != null) bottom.setInfo(line, source);
-	if(left != null) left.setInfo(line, source);
-    }
-
-    /**
-     * Compares two properties for equality.
-     *
-     * @param value The other property.
-     */
-    public boolean equals(CssProperty property) {
-	return false;
-    }
-
 }

Index: CssMarginBottom.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMarginBottom.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssMarginBottom.java	5 Jan 2010 13:49:44 -0000	1.4
+++ CssMarginBottom.java	26 Sep 2012 08:43:53 -0000	1.5
@@ -1,112 +1,50 @@
-//
 // $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;
 
 /**
- *   <H4>
- *     &nbsp;&nbsp; 'margin-bottom'
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> &lt;length&gt; | &lt;percentage&gt; | auto<BR>
- *   <EM>Initial:</EM> 0<BR>
- *   <EM>Applies to:</EM> all elements<BR>
- *   <EM>Inherited:</EM> no<BR>
- *   <EM>Percentage values:</EM> refer to parent element's width<BR>
- *   <P>
- *   This property sets the bottom margin of an element:
- *   <PRE>
- *   H1 { margin-bottom: 3px }
- * </PRE>
- *   <P>
- *   A negative value is allowed, but there may be implementation-specific limits.
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#margin-bottom
  */
-public class CssMarginBottom extends CssMarginSide {
-
-  /**
-   * Create a new CssMarginBottom
-   */
-  public CssMarginBottom() {
-    super();
-  }
-
-  /**
-   * Create a new CssMarginBottom with an another CssMarginSide
-   *
-   * @param another The another side.
-   */
-  public CssMarginBottom(CssMarginSide another) {
-    super(another);
-  }
-
-  /**
-   * Create a new CssMarginBottom
-   *
-   * @param expression The expression for this porperty.
-   * @exception InvalidParamException Values are incorrect
-   */
-  public CssMarginBottom(ApplContext ac, CssExpression expression)
-    throws InvalidParamException {
-      super(ac, expression);
-  }
-
-  public CssMarginBottom(ApplContext ac, CssExpression expression, boolean check)
-	throws InvalidParamException {
-      super(ac, expression, check);
-  }
-
-  /**
-   * Returns the name of this property
-   */
-  public String getPropertyName() {
-    return "margin-bottom";
-  }
+public class CssMarginBottom extends org.w3c.css.properties.css.CssMarginBottom {
 
-  /**
-   * Add this property to the CssStyle.
-   *
-   * @param style The CssStyle
-   */
-  public void addToStyle(ApplContext ac, CssStyle style) {
-    Css1Style style0 = (Css1Style) style;
-    if (style0.cssMargin.bottom != null) {
-      style0.addRedefinitionWarning(ac, this);
-    }
-    style0.cssMargin.bottom = this;
-  }
+	/**
+	 * Create a new CssMarginBottom
+	 */
+	public CssMarginBottom() {
+	}
 
-  /**
-   * 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).getMarginBottom();
-    } else {
-      return ((Css1Style) style).cssMargin.getBottom();
-    }
-  }
+	/**
+	 * Set the value of the property<br/>
+	 * Does not check the number of values
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginBottom(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 CssMarginBottom &&
-	    value.equals(((CssMarginBottom) property).value));
-  }
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @param check      set it to true to check the number of values
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginBottom(ApplContext ac, CssExpression expression,
+						   boolean check) throws InvalidParamException {
+		setByUser();
+		value = CssMargin.checkValue(ac, expression, check, this);
+	}
 
 }

Index: Css1Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- Css1Style.java	25 Sep 2012 20:01:36 -0000	1.36
+++ Css1Style.java	26 Sep 2012 08:43:53 -0000	1.37
@@ -22,6 +22,11 @@
 import org.w3c.css.properties.css.CssPaddingRight;
 import org.w3c.css.properties.css.CssPaddingBottom;
 import org.w3c.css.properties.css.CssPadding;
+import org.w3c.css.properties.css.CssMargin;
+import org.w3c.css.properties.css.CssMarginTop;
+import org.w3c.css.properties.css.CssMarginBottom;
+import org.w3c.css.properties.css.CssMarginLeft;
+import org.w3c.css.properties.css.CssMarginRight;
 
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.InvalidParamException;
@@ -689,62 +694,62 @@
 	 * Get the margin-top property
 	 */
 	public final CssMarginTop getMarginTop() {
-		if (cssMargin.top == null) {
-			cssMargin.top =
+		if (cssMargin.marginTop == null) {
+			cssMargin.marginTop =
 					(CssMarginTop) style.CascadingOrder(new CssMarginTop(),
 							style, selector);
 		}
-		return cssMargin.top;
+		return cssMargin.marginTop;
 	}
 
 	/**
 	 * Get the margin-right property
 	 */
 	public final CssMarginRight getMarginRight() {
-		if (cssMargin.right == null) {
-			cssMargin.right =
+		if (cssMargin.marginRight == null) {
+			cssMargin.marginRight =
 					(CssMarginRight) style.CascadingOrder(new CssMarginRight(),
 							style, selector);
 		}
-		return cssMargin.right;
+		return cssMargin.marginRight;
 	}
 
 	/**
 	 * Get the margin-bottom property
 	 */
 	public final CssMarginBottom getMarginBottom() {
-		if (cssMargin.bottom == null) {
-			cssMargin.bottom =
+		if (cssMargin.marginBottom == null) {
+			cssMargin.marginBottom =
 					(CssMarginBottom) style.CascadingOrder(new CssMarginBottom(),
 							style, selector);
 		}
-		return cssMargin.bottom;
+		return cssMargin.marginBottom;
 	}
 
 	/**
 	 * Get the margin-left property
 	 */
 	public final CssMarginLeft getMarginLeft() {
-		if (cssMargin.left == null) {
-			cssMargin.left =
+		if (cssMargin.marginLeft == null) {
+			cssMargin.marginLeft =
 					(CssMarginLeft) style.CascadingOrder(new CssMarginLeft(),
 							style, selector);
 		}
-		return cssMargin.left;
+		return cssMargin.marginLeft;
 	}
 
 	/**
 	 * Get the margin property
 	 */
 	public final CssMargin getMargin() {
-		if (cssMargin.top == null)
-			cssMargin.top = getMarginTop();
-		if (cssMargin.right == null)
-			cssMargin.right = getMarginRight();
-		if (cssMargin.bottom == null)
-			cssMargin.bottom = getMarginBottom();
-		if (cssMargin.left == null)
-			cssMargin.left = getMarginLeft();
+		if (cssMargin.marginTop == null)
+			cssMargin.marginTop = getMarginTop();
+		if (cssMargin.marginRight == null)
+			cssMargin.marginRight = getMarginRight();
+		if (cssMargin.marginBottom == null)
+			cssMargin.marginBottom = getMarginBottom();
+		if (cssMargin.marginLeft == null)
+			cssMargin.marginLeft = getMarginLeft();
 		return cssMargin;
 	}
 
@@ -1644,13 +1649,13 @@
 		RelativeAndAbsolute checker = new RelativeAndAbsolute();
 		CssProperty info = null;
 
-		if (cssMargin.getTop() != null) {
-			info = cssMargin.getTop();
-			checker.compute(cssMargin.getTop().getValue());
+		if (cssMargin.marginTop != null) {
+			info = cssMargin.marginTop;
+			checker.compute(cssMargin.marginTop.value);
 		}
-		if (cssMargin.getBottom() != null) {
-			info = cssMargin.getBottom();
-			checker.compute(cssMargin.getBottom().getValue());
+		if (cssMargin.marginBottom != null) {
+			info = cssMargin.marginBottom;
+			checker.compute(cssMargin.marginBottom.value);
 		}
 		if (checker.isNotRobust()) {
 			warnings.addWarning(new Warning(info.getSourceFile(),
@@ -1660,13 +1665,13 @@
 		}
 		checker.reset();
 
-		if (cssMargin.getRight() != null) {
-			info = cssMargin.getRight();
-			checker.compute(cssMargin.getRight().getValue());
+		if (cssMargin.marginRight != null) {
+			info = cssMargin.marginRight;
+			checker.compute(cssMargin.marginRight.value);
 		}
-		if (cssMargin.getLeft() != null) {
-			info = cssMargin.getLeft();
-			checker.compute(cssMargin.getLeft().getValue());
+		if (cssMargin.marginLeft != null) {
+			info = cssMargin.marginLeft;
+			checker.compute(cssMargin.marginLeft.value);
 		}
 		if (checker.isNotRobust()) {
 			warnings.addWarning(new Warning(info.getSourceFile(),

Index: CssMarginRight.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMarginRight.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssMarginRight.java	5 Jan 2010 13:49:44 -0000	1.4
+++ CssMarginRight.java	26 Sep 2012 08:43:53 -0000	1.5
@@ -1,110 +1,49 @@
-//
 // $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;
 
 /**
- *   <H4>
- *     &nbsp;&nbsp; 'margin-right'
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> &lt;length&gt; | &lt;percentage&gt; | auto<BR>
- *   <EM>Initial:</EM> 0<BR>
- *   <EM>Applies to:</EM> all elements<BR>
- *   <EM>Inherited:</EM> no<BR>
- *   <EM>Percentage values:</EM> refer to parent element's width<BR>
- *   <P>
- *   This property sets the right margin of an element:
- *   <PRE>
- *   H1 { margin-right: 12.3% }
- * </PRE>
- *   <P> A negative value is allowed, but there may be implementation-specific
- *   limits.
- *
- * @version $Revision$ */
-public class CssMarginRight extends CssMarginSide {
-
-  /**
-   * Create a new CssMarginRight
-   */
-  public CssMarginRight() {
-    super();
-  }
-
-  /**
-   * Create a new CssMarginRight with an another CssMarginSide
-   * @param another The another side.
-   */
-  public CssMarginRight(CssMarginSide another) {
-    super(another);
-  }
-
-  /**
-   * Create a new CssMarginRight
-   *
-   * @param expression The expression for this property.
-   * @exception InvalidParamException Values are incorrect
-   */
-  public CssMarginRight(ApplContext ac, CssExpression expression)
-  	throws InvalidParamException {
-      super(ac, expression);
-  }
-
-  public CssMarginRight(ApplContext ac, CssExpression expression, boolean check)
-	throws InvalidParamException {
-      super(ac, expression, check);
-  }
-
-  /**
-   * Returns the name of this property
-   */
-  public String getPropertyName() {
-    return "margin-right";
-  }
-
-  /**
-   * Add this property to the CssStyle.
-   *
-   * @param style The CssStyle
-   */
-  public void addToStyle(ApplContext ac, CssStyle style) {
-    Css1Style style0 = (Css1Style) style;
-    if (style0.cssMargin.right != null)
-      style0.addRedefinitionWarning(ac, this);
-    style0.cssMargin.right = this;
-  }
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#margin-right
+ */
+public class CssMarginRight extends org.w3c.css.properties.css.CssMarginRight {
 
-  /**
-   * 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).getMarginRight();
-    } else {
-      return ((Css1Style) style).cssMargin.getRight();
-    }
-  }
+	/**
+	 * Create a new CssMarginRight
+	 */
+	public CssMarginRight() {
+	}
 
-  /**
-   * Compares two properties for equality.
-   *
-   * @param value The other property.
-   */
-  public boolean equals(CssProperty property) {
-    return (property instanceof CssMarginRight &&
-	    value.equals(((CssMarginRight) property).value));
-  }
+	/**
+	 * Set the value of the property<br/>
+	 * Does not check the number of values
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginRight(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @param check      set it to true to check the number of values
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginRight(ApplContext ac, CssExpression expression,
+						  boolean check) throws InvalidParamException {
+		setByUser();
+		value = CssMargin.checkValue(ac, expression, check, this);
+	}
 }

Index: CssMarginLeft.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMarginLeft.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssMarginLeft.java	5 Jan 2010 13:49:44 -0000	1.4
+++ CssMarginLeft.java	26 Sep 2012 08:43:53 -0000	1.5
@@ -1,111 +1,50 @@
-//
 // $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;
 
 /**
- *   <H4>
- *     &nbsp;&nbsp; 'margin-left'
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> &lt;length&gt; | &lt;percentage&gt; | auto<BR>
- *   <EM>Initial:</EM> 0<BR>
- *   <EM>Applies to:</EM> all elements<BR>
- *   <EM>Inherited:</EM> no<BR>
- *   <EM>Percentage values:</EM> refer to parent element's width<BR>
- *   <P>
- *   This property sets the left margin of an element:
- *   <PRE>
- *   H1 { margin-left: 2em }
- * </PRE>
- *   <P>
- *   A negative value is allowed, but there may be implementation-specific limits.
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#margin-left
  */
-public class CssMarginLeft extends CssMarginSide {
-
-  /**
-   * Create a new CssMarginLeft
-   */
-  public CssMarginLeft() {
-    super();
-  }
-
-  /**
-   * Create a new CssMarginLeft with an another CssMarginSide
-   *
-   * @param another The another side.
-   */
-  public CssMarginLeft(CssMarginSide another) {
-    super(another);
-  }
-
-  /**
-   * Create a new CssMarginLeft
-   *
-   * @param expression The expression foir this property.
-   * @exception InvalidParamException Values are incorrect
-   */
-  public CssMarginLeft(ApplContext ac, CssExpression expression)
-  	throws InvalidParamException {
-      super(ac, expression);
-  }
-
-  public CssMarginLeft(ApplContext ac, CssExpression expression, boolean check)
-	throws InvalidParamException {
-      super(ac, expression, check);
-  }
-
-  /**
-   * Returns the name of this property
-   */
-  public String getPropertyName() {
-    return "margin-left";
-  }
+public class CssMarginLeft extends org.w3c.css.properties.css.CssMarginLeft {
 
-  /**
-   * Add this property to the CssStyle.
-   *
-   * @param style The CssStyle
-   */
-  public void addToStyle(ApplContext ac, CssStyle style) {
-    Css1Style style0 = (Css1Style) style;
-    if (style0.cssMargin.left != null)
-      style0.addRedefinitionWarning(ac, this);
-    style0.cssMargin.left = this;
-  }
+	/**
+	 * Create a new CssMarginLeft
+	 */
+	public CssMarginLeft() {
+	}
 
-  /**
-   * 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).getMarginLeft();
-    } else {
-      return ((Css1Style) style).cssMargin.getLeft();
-    }
-  }
+	/**
+	 * Set the value of the property<br/>
+	 * Does not check the number of values
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginLeft(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 CssMarginLeft &&
-	    value.equals(((CssMarginLeft) property).value));
-  }
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @param check      set it to true to check the number of values
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginLeft(ApplContext ac, CssExpression expression,
+						 boolean check) throws InvalidParamException {
+		setByUser();
+		value = CssMargin.checkValue(ac, expression, check, this);
+	}
 
 }

Index: CssMarginTop.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssMarginTop.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssMarginTop.java	5 Jan 2010 13:49:44 -0000	1.4
+++ CssMarginTop.java	26 Sep 2012 08:43:53 -0000	1.5
@@ -1,110 +1,49 @@
-//
 // $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;
 
 /**
- *   <H4>
- *     &nbsp;&nbsp; 'margin-top'
- *   </H4>
- *   <P>
- *   <EM>Value:</EM> &lt;length&gt; | &lt;percentage&gt; | auto<BR>
- *   <EM>Initial:</EM> 0<BR>
- *   <EM>Applies to:</EM> all elements<BR>
- *   <EM>Inherited:</EM> no<BR>
- *   <EM>Percentage values:</EM> refer to parent element's width<BR>
- *   <P>
- *   This property sets the top margin of an element:
- *   <PRE>
- *   H1 { margin-top: 2em }
- * </PRE>
- *   <P>
- *   A negative value is allowed, but there may be implementation-specific limits.
- * @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#margin-top
  */
-public class CssMarginTop extends CssMarginSide {
-
-  /**
-   * Create a new CssMarginTop
-   */
-  public CssMarginTop() {
-    super();
-  }
-
-  /**
-   * Create a new CssMarginTop with an another CssMarginSide
-   *
-   * @param another The another side
-   */
-  public CssMarginTop(CssMarginSide another) {
-    super(another);
-  }
-
-  /**
-   * Create a new CssMarginTop
-   *
-   * @param expression The expression for this property.
-   * @exception InvalidParamException Values are incorrect
-   */
-  public CssMarginTop(ApplContext ac, CssExpression expression)
-  	throws InvalidParamException {
-    super(ac, expression);
-  }
-
-  public CssMarginTop(ApplContext ac, CssExpression expression, boolean check)
-  	throws InvalidParamException {
-      super(ac, expression, check);
-    }
-
-  /**
-   * Returns the name of this property
-   */
-  public String getPropertyName() {
-    return "margin-top";
-  }
-
-  /**
-   * Add this property to the CssStyle.
-   *
-   * @param style The CssStyle
-   */
-  public void addToStyle(ApplContext ac, CssStyle style) {
-    Css1Style style0 = (Css1Style) style;
-    if (style0.cssMargin.top != null)
-      style0.addRedefinitionWarning(ac, this);
-    style0.cssMargin.top = this;
-  }
+public class CssMarginTop extends org.w3c.css.properties.css.CssMarginTop {
 
-  /**
-   * 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).getMarginTop();
-    } else {
-      return ((Css1Style) style).cssMargin.getTop();
-    }
-  }
+	/**
+	 * Create a new CssMarginTop
+	 */
+	public CssMarginTop() {
+	}
 
-  /**
-   * Compares two properties for equality.
-   *
-   * @param value The other property.
-   */
-  public boolean equals(CssProperty property) {
-    return (property instanceof CssMarginTop && value.equals(((CssMarginTop) property).value));
-  }
+	/**
+	 * Set the value of the property<br/>
+	 * Does not check the number of values
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginTop(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
+	/**
+	 * Set the value of the property
+	 *
+	 * @param expression The expression for this property
+	 * @param check      set it to true to check the number of values
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          The expression is incorrect
+	 */
+	public CssMarginTop(ApplContext ac, CssExpression expression,
+						boolean check) throws InvalidParamException {
+		setByUser();
+		value = CssMargin.checkValue(ac, expression, check, this);
+	}
 }

Received on Wednesday, 26 September 2012 08:43:57 UTC