- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 02 Nov 2012 13:37:11 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1 In directory hutz:/tmp/cvs-serv7359/css1 Modified Files: Css1Style.java CssTextPropertiesConstants.java CssVerticalAlign.java Removed Files: CssVerticalAlignCSS1.java CssVerticalAlignMob.java CssVerticalAlignTV.java Log Message: vertical align per css1/2/21/3/tv/mobile Index: CssTextPropertiesConstants.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssTextPropertiesConstants.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- CssTextPropertiesConstants.java 5 Jan 2010 13:49:45 -0000 1.3 +++ CssTextPropertiesConstants.java 2 Nov 2012 13:37:08 -0000 1.4 @@ -19,16 +19,6 @@ public static String[] TEXTDECORATIONMOB = { "underline", "inherit" }; - public static String[] VERTICALALIGN = { - "auto", "use-script", "baseline", "sub", "super", "top", "text-top", - "central", "middle", "bottom", "text-bottom", "inherit", "initial" }; - - public static String[] VERTICALALIGNMOB = { - "baseline", "sub", "super", "inherit" }; - - public static String[] VERTICALALIGNTV = { - "baseline", "sub", "super", "top", "middle", "bottom", "inherit" }; - public static String[] TEXTTRANSFORM = { "none", "capitalize", "uppercase", "lowercase", "inherit" }; --- CssVerticalAlignTV.java DELETED --- Index: Css1Style.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- Css1Style.java 11 Oct 2012 13:17:36 -0000 1.46 +++ Css1Style.java 2 Nov 2012 13:37:08 -0000 1.47 @@ -28,6 +28,7 @@ import org.w3c.css.properties.css.CssTextDecoration; import org.w3c.css.properties.css.CssTextIndent; import org.w3c.css.properties.css.CssTextTransform; +import org.w3c.css.properties.css.CssVerticalAlign; import org.w3c.css.properties.css.CssZIndex; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; @@ -81,8 +82,7 @@ * vertical-align property */ public CssVerticalAlign cssVerticalAlign; - public CssVerticalAlignCSS1 cssVerticalAlignCSS1; - public CssVerticalAlignMob cssVerticalAlignMob; + /** * text-transform property */ @@ -224,10 +224,6 @@ * TV property */ public CssTextDecorationTV cssTextDecorationTV; - /** - * TV property - */ - public CssVerticalAlignTV cssVerticalAlignTV; public String[] emptyArray = {}; @@ -556,24 +552,6 @@ return cssVerticalAlign; } - public final CssVerticalAlignMob getVerticalAlignMob() { - if (cssVerticalAlignMob == null) { - cssVerticalAlignMob = - (CssVerticalAlignMob) style.CascadingOrder(new CssVerticalAlignMob(), - style, selector); - } - return cssVerticalAlignMob; - } - - public final CssVerticalAlignCSS1 getVerticalAlignCSS1() { - if (cssVerticalAlignCSS1 == null) { - cssVerticalAlignCSS1 = - (CssVerticalAlignCSS1) style.CascadingOrder(new CssVerticalAlignCSS1(), - style, selector); - } - return cssVerticalAlignCSS1; - } - /** * Get the text-transform property */ @@ -1257,17 +1235,6 @@ return cssTextDecorationTV; } - public final CssVerticalAlignTV getVerticalAlignTV() { - if (cssVerticalAlignTV == null) { - cssVerticalAlignTV = - (CssVerticalAlignTV) style.CascadingOrder(new CssVerticalAlignTV(), - style, selector); - } - - return cssVerticalAlignTV; - } - - /** * Find conflicts in this Style * For the 'font-family' property Index: CssVerticalAlign.java =================================================================== RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssVerticalAlign.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- CssVerticalAlign.java 5 Jan 2010 13:49:45 -0000 1.4 +++ CssVerticalAlign.java 2 Nov 2012 13:37:08 -0000 1.5 @@ -1,224 +1,94 @@ -// // $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.CssIdent; -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> - * 'vertical-align' - * </H4> - * <P> - * <EM>Value:</EM> baseline | sub | super | top | text-top | middle | bottom - * | text-bottom | <percentage> <BR> - * <EM>Initial:</EM> baseline<BR> - * <EM>Applies to:</EM> inline elements<BR> - * <EM>Inherited:</EM> no<BR> - * <EM>Percentage values:</EM> refer to the 'line-height' of the element - * itself<BR> - * <P> - * The property affects the vertical positioning of the element. One set of - * keywords is relative to the parent element: - * <DL> - * <DT> - * 'baseline' - * <DD> - * align the baseline of the element (or the bottom, if the element doesn't - * have a baseline) with the baseline of the parent - * <DT> - * 'middle' - * <DD> - * align the vertical midpoint of the element (typically an image) with the - * baseline plus half the x-height of the parent - * <DT> - * 'sub' - * <DD> - * subscript the element - * <DT> - * 'super' - * <DD> - * superscript the element - * <DT> - * 'text-top' - * <DD> - * align the top of the element with the top of the parent element's font - * <DT> - * 'text-bottom' - * <DD> - * align the bottom of the element with the bottom of the parent element's font - * </DL> - * <P> - * Another set of properties are relative to the formatted line that the element - * is a part of: - * <DL> - * <DT> - * 'top' - * <DD> - * align the top of the element with the tallest element on the line - * <DT> - * 'bottom' - * <DD> - * align the bottom of the element with the lowest element on the line - * </DL> - * <P> - * Using the 'top' and 'bottom' alignment, unsolvable situations can occur where - * element dependencies form a loop. - * <P> - * Percentage values refer to the value of the 'line-height' property of the - * element itself. They raise the baseline of the element (or the bottom, if - * it has no baseline) the specified amount above the baseline of the parent. - * Negative values are possible. E.g., a value of '-100%' will lower the element - * so that the baseline of the element ends up where the baseline of the next - * line should have been. This allows precise control over the vertical position - * of elements (such as images that are used in place of letters) that don't - * have a baseline. - * <P> - * It is expected that a future version of CSS will allow <length&t; - * as a value on this property. - * - * @version $Revision$ + * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#vertical-align */ -public class CssVerticalAlign extends CssProperty - implements CssTextPropertiesConstants { - - Object value; - - private static int[] hash_values; - - /** - * Create a new CssVerticalAlign - */ - public CssVerticalAlign() { - value = VERTICALALIGN[0]; - } +public class CssVerticalAlign extends org.w3c.css.properties.css.CssVerticalAlign { - /** - * Create a new CssVerticalAlign - * - * @param expression The expression for this property - * @exception InvalidParamException Values are incorrect - */ - public CssVerticalAlign(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { + private static CssIdent[] allowed_values; - if(check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); + static { + String id_values[] = {"baseline", "sub", "super", "top", "text-top", + "middle", "bottom", "text-bottom"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } } - CssValue val = expression.getValue(); - int hash = val.hashCode(); - - setByUser(); - - if (val instanceof CssIdent) { - for (int i = 0; i < VERTICALALIGN.length; i++) - if (hash_values[i] == hash) { - value = VERTICALALIGN[i]; - expression.next(); - return; + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } } - throw new InvalidParamException("value", - val.toString(), getPropertyName(), ac); - } else if (val instanceof CssPercentage) { - value = val; - expression.next(); - } else if (val instanceof CssLength) { - value = val; - expression.next(); - } else if (val instanceof CssNumber) { - value = ((CssNumber) val).getLength(); - expression.next(); - } else { - throw new InvalidParamException("value", - val.toString(), getPropertyName(), ac); + return null; } - } - - public CssVerticalAlign(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 "vertical-align"; - } - - /** - * 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.cssVerticalAlign != null) - style0.addRedefinitionWarning(ac, this); - style0.cssVerticalAlign = this; - } + /** + * Create a new CssVerticalAlign + */ + public CssVerticalAlign() { + } - /** - * 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).getVerticalAlign(); - } else { - return ((Css1Style) style).cssVerticalAlign; + /** + * 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 CssVerticalAlign(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 CssVerticalAlign && value.equals(((CssVerticalAlign) 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 CssVerticalAlign(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); - /** - * 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 value.equals(VERTICALALIGN[0]); - } + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - static { - hash_values = new int[VERTICALALIGN.length]; - for (int i=0; i<VERTICALALIGN.length; i++) - hash_values[i] = VERTICALALIGN[i].hashCode(); - } + switch (val.getType()) { + case CssTypes.CSS_PERCENTAGE: + value = val; + break; + case CssTypes.CSS_IDENT: + val = getMatchingIdent((CssIdent) val); + if (val != null) { + value = val; + break; + } + default: + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + expression.next(); + } } + --- CssVerticalAlignMob.java DELETED --- --- CssVerticalAlignCSS1.java DELETED ---
Received on Friday, 2 November 2012 13:37:13 UTC