W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2012

2002/css-validator/org/w3c/css/properties/css3 Css3Style.java,1.47,1.48 CssLineBreak.java,1.3,1.4

From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 31 Aug 2012 09:39:52 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1T7Nhg-0005WJ-Ak@lionel-hutz.w3.org>
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css3
In directory hutz:/tmp/cvs-serv21157/css3

Modified Files:
	Css3Style.java CssLineBreak.java 
Log Message:
line-break per http://www.w3.org/TR/2012/WD-css3-text-20120814/#line-break1

Index: Css3Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/Css3Style.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- Css3Style.java	30 Aug 2012 13:10:28 -0000	1.47
+++ Css3Style.java	31 Aug 2012 09:39:50 -0000	1.48
@@ -42,6 +42,8 @@
 import org.w3c.css.properties.css.CssOpacity;
 import org.w3c.css.properties.css.CssOverflowWrap;
 import org.w3c.css.properties.css.CssWordBreak;
+import org.w3c.css.properties.css.CssLineBreak;
+
 import org.w3c.css.util.ApplContext;
 import org.w3c.css.util.Util;
 import org.w3c.css.util.Warning;
@@ -66,7 +68,6 @@
 	CssAlignmentBaseLine cssAlignmentBaseLine;
 	CssAlignmentAdjust cssAlignmentAdjust;
 	CssBaselineShift cssBaselineShift;
-	CssLineBreak cssLineBreak;
 	CssTextSpace cssTextSpace;
 	CssTextEndOverflow cssTextEndOverflow;
 	CssTextAfterOverflow cssTextAfterOverflow;
@@ -138,6 +139,7 @@
 	public CssOverflowWrap cssOverflowWrap;
 	public CssWordBreak cssWordBreak;
 	public CssHyphens cssHyphens;
+	public CssLineBreak cssLineBreak;
 
 	CssDropInitialAfterAdjust cssDropInitialAfterAdjust;
 	CssDropInitialAfterAlign cssDropInitialAfterAlign;

Index: CssLineBreak.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css3/CssLineBreak.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- CssLineBreak.java	5 Jan 2010 13:49:53 -0000	1.3
+++ CssLineBreak.java	31 Aug 2012 09:39:50 -0000	1.4
@@ -1,155 +1,89 @@
-//
 // $Id$
-// From Sijtsche de Jong (sy.de.jong@let.rug.nl)
+// Author: Yves Lafon <ylafon@w3.org>
 //
-// (c) COPYRIGHT 1995-2000  World Wide Web Consortium (MIT, INRIA, Keio University)
-// Please first read the full copyright statement at
-// http://www.w3.org/Consortium/Legal/copyright-software-19980720
-
+// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012.
+// Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.css.properties.css3;
 
-import org.w3c.css.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;
 
 /**
- *  <P>
- *  <EM>Value:</EM> normal || strict || inherit<BR>
- *  <EM>Initial:</EM>normal<BR>
- *  <EM>Applies to:</EM>all elements<BR>
- *  <EM>Inherited:</EM>yes<BR>
- *  <EM>Percentages:</EM>no<BR>
- *  <EM>Media:</EM>:visual
- *  <P>
- *  This property selects the set of line breaking rules to be used for text. The values described below are especially useful to CJK authors, but the property itself is open to other, not yet specified settings for non-CJK
-authors as well.
+ * @spec http://www.w3.org/TR/2012/WD-css3-text-20120814/#line-break1
  */
+public class CssLineBreak extends org.w3c.css.properties.css.CssLineBreak {
 
-public class CssLineBreak extends CssProperty {
-
-    CssValue linebreak;
-
-    CssIdent normal = new CssIdent("normal");
-    CssIdent strict = new CssIdent("strict");
-
-    /**
-     * Create a new CssLineBreak
-     */
-    public CssLineBreak() {
-	linebreak = normal;
-    }
-
-    /**
-     * Create a new CssLineBreak
-     *
-     * @param expression The expression for this property
-     * @exception InvalidParamException Incorrect value
-     */
-    public CssLineBreak(ApplContext ac, CssExpression expression,
-	    boolean check) throws InvalidParamException {
-
-	setByUser();
-	CssValue val = expression.getValue();
+	private static CssIdent[] allowed_values;
 
-	if (val.equals(normal)) {
-	    linebreak = normal;
-	    expression.next();
-	}
-	else if (val.equals(strict)) {
-	    linebreak = strict;
-	    expression.next();
-	}
-	else if (val.equals(inherit)) {
-	    linebreak = inherit;
-	    expression.next();
-	}
-	else {
-	    throw new InvalidParamException("value", expression.getValue(),
-					    getPropertyName(), ac);
+	static {
+		String id_values[] = {"auto", "loose", "normal", "strict"};
+		allowed_values = new CssIdent[id_values.length];
+		int i = 0;
+		for (String s : id_values) {
+			allowed_values[i++] = CssIdent.getIdent(s);
+		}
 	}
-    }
 
-    public CssLineBreak(ApplContext ac, CssExpression expression)
-	    throws InvalidParamException {
-	this(ac, expression, false);
-    }
-
-    /**
-     * Add this property to the CssStyle
-     *
-     * @param style The CssStyle
-     */
-    public void addToStyle(ApplContext ac, CssStyle style) {
-	if (((Css3Style) style).cssLineBreak != null)
-	    style.addRedefinitionWarning(ac, this);
-	((Css3Style) style).cssLineBreak = 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 ((Css3Style) style).getLineBreak();
-	}
-	else {
-	    return ((Css3Style) style).cssLineBreak;
+	public static CssIdent getMatchingIdent(CssIdent ident) {
+		for (CssIdent id : allowed_values) {
+			if (id.equals(ident)) {
+				return id;
+			}
+		}
+		return null;
 	}
-    }
 
-    /**
-     * Compares two properties for equality.
-     *
-     * @param value The other property.
-     */
-    public boolean equals(CssProperty property) {
-	return (property instanceof CssLineBreak &&
-		linebreak.equals(((CssLineBreak) property).linebreak));
-    }
-
-    /**
-     * Returns the name of this property
-     */
-    public String getPropertyName() {
-	return "line-break";
-    }
+	/**
+	 * Create a new CssLineBreak
+	 */
+	public CssLineBreak() {
+		value = initial;
+	}
 
-    /**
-     * Returns the value of this property
-     */
-    public Object get() {
-	return linebreak;
-    }
+	/**
+	 * Creates a new CssLineBreak
+	 *
+	 * @param expression The expression for this property
+	 * @throws org.w3c.css.util.InvalidParamException
+	 *          Expressions are incorrect
+	 */
+	public CssLineBreak(ApplContext ac, CssExpression expression, boolean check)
+			throws InvalidParamException {
+		setByUser();
+		CssValue val = expression.getValue();
 
-    /**
-     * Returns true if this property is "softly" inherited
-     */
-    public boolean isSoftlyInherited() {
-	return linebreak.equals(inherit);
-    }
+		if (check && expression.getCount() > 1) {
+			throw new InvalidParamException("unrecognize", ac);
+		}
 
-    /**
-     * Returns a string representation of the object
-     */
-    public String toString() {
-	return linebreak.toString();
-    }
+		if (val.getType() != CssTypes.CSS_IDENT) {
+			throw new InvalidParamException("value",
+					expression.getValue(),
+					getPropertyName(), ac);
+		}
+		// ident, so inherit, or allowed value
+		if (inherit.equals(val)) {
+			value = inherit;
+		} else {
+			val = getMatchingIdent((CssIdent) val);
+			if (val == null) {
+				throw new InvalidParamException("value",
+						expression.getValue(),
+						getPropertyName(), ac);
+			}
+			value = val;
+		}
+		expression.next();
+	}
 
-    /**
-     * Is the value of this property a default value
-     * It is used by alle macro for the function <code>print</code>
-     */
-    public boolean isDefault() {
-	return linebreak == normal;
-    }
+	public CssLineBreak(ApplContext ac, CssExpression expression)
+			throws InvalidParamException {
+		this(ac, expression, false);
+	}
 
 }
 
-
Received on Friday, 31 August 2012 09:39:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:51 UTC