- From: Yves Lafon via cvs-syncmail <cvsmail@w3.org>
- Date: Tue, 04 Oct 2011 13:05:26 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/properties/css1
In directory hutz:/tmp/cvs-serv17942/org/w3c/css/properties/css1
Modified Files:
Css1Style.java CssBackgroundCSS1.java
CssBorderFaceColorCSS1.java CssBorderFaceColorCSS2.java
CssColor.java
Removed Files:
CssColorCSS1.java CssColorCSS2.java
Log Message:
some reordering to have only one background-color to check in checkConflicts (like what was done for CssColors
--- CssColorCSS2.java DELETED ---
Index: CssBorderFaceColorCSS2.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderFaceColorCSS2.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CssBorderFaceColorCSS2.java 29 Sep 2011 09:08:59 -0000 1.7
+++ CssBorderFaceColorCSS2.java 4 Oct 2011 13:05:24 -0000 1.8
@@ -32,8 +32,8 @@
*
* @param color A color property
*/
- public CssBorderFaceColorCSS2(org.w3c.css.properties.css1.CssColorCSS2 color) {
- face = color.color;
+ public CssBorderFaceColorCSS2(org.w3c.css.properties.css.CssColor color) {
+ face = color.getColor();
}
/**
Index: Css1Style.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/Css1Style.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Css1Style.java 27 Sep 2011 08:15:45 -0000 1.23
+++ Css1Style.java 4 Oct 2011 13:05:24 -0000 1.24
@@ -26,6 +26,7 @@
import org.w3c.css.properties.css2.CssBackgroundPositionCSS2;
import org.w3c.css.properties.css2.CssBackgroundRepeatCSS2;
import org.w3c.css.util.ApplContext;
+import org.w3c.css.util.CssVersion;
import org.w3c.css.util.Util;
import org.w3c.css.util.Warning;
import org.w3c.css.util.Warnings;
@@ -56,9 +57,8 @@
/**
* Color property
*/
- public CssColor cssColor;
- public CssColorCSS2 cssColorCSS2;
- public CssColorCSS1 cssColorCSS1;
+ public org.w3c.css.properties.css.CssColor cssColor;
+
/**
* background properties
*/
@@ -582,30 +582,14 @@
/**
* Get the color property
*/
- public final CssColor getColor() {
+ public final org.w3c.css.properties.css.CssColor getColor() {
if (cssColor == null) {
- cssColor = (CssColor)
+ cssColor = (org.w3c.css.properties.css.CssColor)
style.CascadingOrder(new CssColor(), style, selector);
}
return cssColor;
}
- public final CssColorCSS2 getColorCSS2() {
- if (cssColorCSS2 == null) {
- cssColorCSS2 = (CssColorCSS2)
- style.CascadingOrder(new CssColorCSS2(), style, selector);
- }
- return cssColorCSS2;
- }
-
- public final CssColorCSS1 getColorCSS1() {
- if (cssColorCSS1 == null) {
- cssColorCSS1 = (CssColorCSS1)
- style.CascadingOrder(new CssColorCSS1(), style, selector);
- }
- return cssColorCSS1;
- }
-
/**
* Get the background-color property
*/
@@ -2514,7 +2498,7 @@
}
if (cssBackground.getColor() != null) {
- CssColor colorCSS3 = cssColor;
+ org.w3c.css.properties.css.CssColor colorCSS3 = cssColor;
// we need to look if there is the same selector elsewhere
// containing a color definition
for (int i = 0; i < allSelectors.length; i++) {
@@ -2598,13 +2582,13 @@
}
*/
} else if (cssBackgroundCSS1.getColor() != null) {
- CssColorCSS1 colorCSS1 = cssColorCSS1;
+ org.w3c.css.properties.css.CssColor colorCSS1 = cssColor;
// we need to look if there is the same selector elsewhere
// containing a color definition
for (int i = 0; i < allSelectors.length; i++) {
CssSelectors sel = allSelectors[i];
if (sel.toString().equals(selector.toString())) {
- colorCSS1 = ((Css1Style) sel.getStyle()).cssColorCSS1;
+ colorCSS1 = ((Css1Style) sel.getStyle()).cssColor;
break;
}
}
@@ -2669,13 +2653,14 @@
}
}
} else if (cssBackgroundCSS2.getColor() != null) {
- CssColorCSS2 colorCSS2 = cssColorCSS2;
+ // TODO FIXME FUGLY because of existing code
+ org.w3c.css.properties.css.CssColor colorCSS2 = cssColor;
// we need to look if there is the same selector elsewhere
// containing a color definition
for (int i = 0; i < allSelectors.length; i++) {
CssSelectors sel = allSelectors[i];
if (sel.toString().equals(selector.toString())) {
- colorCSS2 = ((Css1Style) sel.getStyle()).cssColorCSS2;
+ colorCSS2 = ((Css1Style) sel.getStyle()).cssColor;
break;
}
}
@@ -2745,81 +2730,83 @@
}
} else if (cssColor != null) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style =
- (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackground.getColor();
- }
- if (style.cssBackground.getColor() != null) {
- if (style.cssBackground.getColor().equals(cssColor.getColor())) {
- warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
- new String[]{style.cssBackground.color.getSelectors().toString(),
- cssColor.getSelectors().toString()}, ac));
+ if (ac.getCssVersion() == CssVersion.CSS3) {
+ CssValue backgroundColor = null;
+ // we need to look if there is the same selector elsewhere
+ // containing a color definition
+ for (int i = 0; i < allSelectors.length; i++) {
+ CssSelectors sel = allSelectors[i];
+ Css1Style style =
+ (Css1Style) sel.getStyle();
+ if (backgroundColor == null &&
+ sel.toString().equals(selector.toString())) {
+ backgroundColor = ((Css1Style) sel.getStyle()).
+ cssBackground.getColor();
+ }
+ if (style.cssBackground.getColor() != null) {
+ if (style.cssBackground.getColor().equals(cssColor.getColor())) {
+ warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
+ new String[]{style.cssBackground.color.getSelectors().toString(),
+ cssColor.getSelectors().toString()}, ac));
+ }
}
}
- }
- if (backgroundColor == null) {
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColor,
- "no-background-color", 2, emptyArray, ac));
- }
- } else if (cssColorCSS1 != null) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style = (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackgroundCSS1.getColor();
+ if (backgroundColor == null) {
+ // It's better to have a background color with a color
+ warnings.addWarning(new Warning(cssColor,
+ "no-background-color", 2, emptyArray, ac));
}
- if (style.cssBackgroundCSS1.getColor() != null) {
- if (style.cssBackgroundCSS1.getColor().equals(cssColorCSS1.getColor())) {
- warnings.addWarning(new Warning(cssColorCSS1, "same-colors2", 1,
- new String[]{style.cssBackgroundCSS1.color.getSelectors().toString(),
- cssColorCSS1.getSelectors().toString()}, ac));
+ } else if (ac.getCssVersion() == CssVersion.CSS1) {
+ CssValue backgroundColor = null;
+ // we need to look if there is the same selector elsewhere
+ // containing a color definition
+ for (int i = 0; i < allSelectors.length; i++) {
+ CssSelectors sel = allSelectors[i];
+ Css1Style style = (Css1Style) sel.getStyle();
+ if (backgroundColor == null &&
+ sel.toString().equals(selector.toString())) {
+ backgroundColor = ((Css1Style) sel.getStyle()).
+ cssBackgroundCSS1.getColor();
+ }
+ if (style.cssBackgroundCSS1.getColor() != null) {
+ if (style.cssBackgroundCSS1.getColor().equals(cssColor.getColor())) {
+ warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
+ new String[]{style.cssBackgroundCSS1.color.getSelectors().toString(),
+ cssColor.getSelectors().toString()}, ac));
+ }
}
}
- }
- if (backgroundColor == null) {
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColorCSS1,
- "no-background-color", 2, emptyArray, ac));
- }
- } else if (cssColorCSS2 != null) {
- CssValue backgroundColor = null;
- // we need to look if there is the same selector elsewhere
- // containing a color definition
- for (int i = 0; i < allSelectors.length; i++) {
- CssSelectors sel = allSelectors[i];
- Css1Style style = (Css1Style) sel.getStyle();
- if (backgroundColor == null &&
- sel.toString().equals(selector.toString())) {
- backgroundColor = ((Css1Style) sel.getStyle()).
- cssBackgroundCSS2.getColor();
+ if (backgroundColor == null) {
+ // It's better to have a background color with a color
+ warnings.addWarning(new Warning(cssColor,
+ "no-background-color", 2, emptyArray, ac));
}
- if (style.cssBackgroundCSS2.getColor() != null) {
- if (style.cssBackgroundCSS2.getColor().equals(cssColorCSS2.getColor())) {
- warnings.addWarning(new Warning(cssColorCSS2, "same-colors2", 1,
- new String[]{style.cssBackgroundCSS2.color.getSelectors().toString(),
- cssColorCSS2.getSelectors().toString()}, ac));
+ } else if (ac.getCssVersion() == CssVersion.CSS2 || ac.getCssVersion() == CssVersion.CSS21) {
+ CssValue backgroundColor = null;
+ // we need to look if there is the same selector elsewhere
+ // containing a color definition
+ for (int i = 0; i < allSelectors.length; i++) {
+ CssSelectors sel = allSelectors[i];
+ Css1Style style = (Css1Style) sel.getStyle();
+ if (backgroundColor == null &&
+ sel.toString().equals(selector.toString())) {
+ backgroundColor = ((Css1Style) sel.getStyle()).
+ cssBackgroundCSS2.getColor();
+ }
+ if (style.cssBackgroundCSS2.getColor() != null) {
+ if (style.cssBackgroundCSS2.getColor().equals(cssColor.getColor())) {
+ warnings.addWarning(new Warning(cssColor, "same-colors2", 1,
+ new String[]{style.cssBackgroundCSS2.color.getSelectors().toString(),
+ cssColor.getSelectors().toString()}, ac));
+ }
}
}
- }
- if (backgroundColor == null) {
- // FIXME background image
- // It's better to have a background color with a color
- warnings.addWarning(new Warning(cssColorCSS2,
- "no-background-color", 2, emptyArray, ac));
+ if (backgroundColor == null) {
+ // FIXME background image
+ // It's better to have a background color with a color
+ warnings.addWarning(new Warning(cssColor,
+ "no-background-color", 2, emptyArray, ac));
+ }
}
}
Index: CssColor.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssColor.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- CssColor.java 29 Sep 2011 09:08:59 -0000 1.12
+++ CssColor.java 4 Oct 2011 13:05:24 -0000 1.13
@@ -1,123 +1,60 @@
-//
// $Id$
-// From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr)
//
-// (c) COPYRIGHT MIT and INRIA, 1997.
+// (c) COPYRIGHT MIT,ERCIM and Keio University, 2011
// 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.CssFunction;
-import org.w3c.css.values.CssOperator;
import org.w3c.css.values.CssTypes;
import org.w3c.css.values.CssValue;
/**
- * <H4>
- * 'color'
- * </H4>
- * <p/>
- * <EM>Value:</EM> <color><BR>
- * <EM>Initial:</EM> UA specific<BR>
- * <EM>Applies to:</EM> all elements<BR>
- * <EM>Inherited:</EM> yes<BR>
- * <EM>Percentage values:</EM> N/A<BR>
- * <p/>
- * This property describes the text color of an element (often referred to as
- * the <EM>foreground</EM> color). There are different ways to specify red:
- * <PRE>
- * EM { color: red } /* natural language * /
- * EM { color: rgb(255,0,0) } /* RGB range 0-255 * /
- * </PRE>
- *
* @version $Revision$
+ * @spec http://www.w3.org/TR/2008/REC-CSS1-20080411/#color
*/
-public class CssColor extends CssProperty implements CssOperator {
+public class CssColor extends org.w3c.css.properties.css.CssColor {
- CssValue color;
- org.w3c.css.values.CssColor tempcolor = new org.w3c.css.values.CssColor();
+ org.w3c.css.values.CssColor color;
String attrvalue = null;
+ boolean inherited;
/**
* Create a new CssColor
*/
public CssColor() {
- color = inherit;
}
/**
* Set the value of the property
*
* @param expression The expression for this property
- * @throws InvalidParamException Values are incorrect
+ * @throws org.w3c.css.util.InvalidParamException
+ * Values are incorrect
*/
public CssColor(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
-
if (check && expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
CssValue val = expression.getValue();
setByUser();
-
switch (val.getType()) {
case CssTypes.CSS_IDENT:
- if (inherit.equals(val)) {
- color = inherit;
- break;
- }
color = new org.w3c.css.values.CssColor(ac, (String) val.get());
- // color = new org.w3c.css.values.CssColor();
break;
+ // in the parser, rgb func and hexval func generate a CssColor directly
+ // so, no need for a CSS_FUNCTION case
case CssTypes.CSS_COLOR:
- color = val;
- break;
- case CssTypes.CSS_FUNCTION:
- CssFunction attr = (CssFunction) val;
- CssExpression params = attr.getParameters();
- String fname = attr.getName();
-
- if (fname.equals("attr")) {
- CssValue v1 = params.getValue();
- params.next();
- CssValue v2 = params.getValue();
- if ((params.getCount() != 2)) {
- throw new InvalidParamException("value",
- params.getValue(),
- getPropertyName(), ac);
- } else if (v1.getType() != CssTypes.CSS_IDENT) {
- throw new InvalidParamException("value",
- params.getValue(),
- getPropertyName(), ac);
-
- } else if (!(v2.toString().equals("color"))) {
- throw new InvalidParamException("value",
- params.getValue(),
- getPropertyName(), ac);
- } else {
- attrvalue = "attr(" + v1 + ", " + v2 + ")";
- }
- } else if (fname.equals("rgba")) {
- tempcolor.setRGBAColor(params, ac);
- color = tempcolor;
- } else if (fname.equals("hsl")) {
- tempcolor.setHSLColor(params, ac);
- color = tempcolor;
- } else if (fname.equals("hsla")) {
- tempcolor.setHSLAColor(params, ac);
- color = tempcolor;
- } else if (fname.equals("atsc-rgba")) {
- tempcolor.setATSCRGBAColor(params, ac);
- color = tempcolor;
- } else {
- throw new InvalidParamException("value",
- params.getValue(),
+ try {
+ color = (org.w3c.css.values.CssColor) val;
+ } catch (ClassCastException ex) {
+ // as we checked the type, it can't happen
+ throw new InvalidParamException("value", expression.getValue(),
getPropertyName(), ac);
}
break;
@@ -144,15 +81,7 @@
* Returns the color
*/
public org.w3c.css.values.CssColor getColor() {
- if (color.equals(inherit)) {
- /*
- System.err.println("[ERROR] org.w3c.css.properties.CssColor");
- System.err.println("[ERROR] value is inherited");
- */
- return null;
- } else {
- return (org.w3c.css.values.CssColor) color;
- }
+ return color;
}
/**
@@ -160,7 +89,7 @@
* e.g. his value equals inherit
*/
public boolean isSoftlyInherited() {
- return color.equals(inherit);
+ return false;
}
/**
@@ -175,47 +104,17 @@
}
/**
- * Add this property to the CssStyle.
- *
- * @param style The CssStyle
- */
- public void addToStyle(ApplContext ac, CssStyle style) {
- Css1Style style0 = (Css1Style) style;
- if (style0.cssColor != null) {
- style0.addRedefinitionWarning(ac, this);
- }
- style0.cssColor = 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).getColor();
- } else {
- return ((Css1Style) style).cssColor;
- }
- }
-
- /**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
- return (property instanceof CssColor &&
- color.equals(((CssColor) property).color));
- }
-
- /**
- * Returns the name of this property
- */
- public String getPropertyName() {
- return "color";
+ CssColor other;
+ try {
+ other = (CssColor) property;
+ return (color.equals(other.color));
+ } catch (ClassCastException ex) {
+ return false;
+ }
}
-
}
--- CssColorCSS1.java DELETED ---
Index: CssBorderFaceColorCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBorderFaceColorCSS1.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CssBorderFaceColorCSS1.java 29 Sep 2011 09:08:59 -0000 1.4
+++ CssBorderFaceColorCSS1.java 4 Oct 2011 13:05:24 -0000 1.5
@@ -31,8 +31,8 @@
*
* @param color A color property
*/
- public CssBorderFaceColorCSS1(org.w3c.css.properties.css1.CssColorCSS1 color) {
- face = color.color;
+ public CssBorderFaceColorCSS1(org.w3c.css.properties.css.CssColor color) {
+ face = color.getColor();
}
/**
Index: CssBackgroundCSS1.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/properties/css1/CssBackgroundCSS1.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- CssBackgroundCSS1.java 9 Sep 2011 12:16:43 -0000 1.8
+++ CssBackgroundCSS1.java 4 Oct 2011 13:05:24 -0000 1.9
@@ -231,6 +231,7 @@
* Overrides this method for a macro
*/
public void setImportant() {
+ super.setImportant();
if (color != null) {
color.important = true;
}
@@ -253,7 +254,7 @@
* Overrides this method for a macro
*/
public boolean getImportant() {
- return ((color == null || color.important) &&
+ return important && ((color == null || color.important) &&
(image == null || image.important) &&
(repeat == null || repeat.important) &&
(attachment == null || attachment.important) &&
@@ -292,8 +293,8 @@
* @param style The CssStyle
*/
public void addToStyle(ApplContext ac, CssStyle style) {
- ((Css1Style) style).cssBackgroundCSS1.same = same;
- ((Css1Style) style).cssBackgroundCSS1.byUser = byUser;
+ ((Css1Style) style).cssBackground.same = same;
+ ((Css1Style) style).cssBackground.byUser = byUser;
if (color != null) {
color.addToStyle(ac, style);
@@ -320,9 +321,9 @@
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
- return ((Css1Style) style).getBackgroundCSS1();
+ return ((Css1Style) style).getBackground();
} else {
- return ((Css1Style) style).cssBackgroundCSS1;
+ return ((Css1Style) style).cssBackground;
}
}
Received on Tuesday, 4 October 2011 13:05:38 UTC