From 0d31406850787b5ada85de9ce8d09875898fd8dd Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 09:45:50 +0200 Subject: [PATCH 01/82] Revert "no need to care about inherit in css3 anymore" as inherit might happen in a dynamic value resolution This reverts commit 96b18e8a25ffdb43f619c27bc1260b9d855db52e. --- org/w3c/css/properties/css3/CssScrollbarWidth.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/org/w3c/css/properties/css3/CssScrollbarWidth.java b/org/w3c/css/properties/css3/CssScrollbarWidth.java index bc6ce080e..d4d0e9384 100644 --- a/org/w3c/css/properties/css3/CssScrollbarWidth.java +++ b/org/w3c/css/properties/css3/CssScrollbarWidth.java @@ -66,10 +66,15 @@ public CssScrollbarWidth(ApplContext ac, CssExpression expression, boolean check switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent ident = getAllowedIdent(val.getIdent()); - if (ident != null) { + if (inherit.equals(val)) { value = val; break; + } else { + CssIdent ident = getAllowedIdent(val.getIdent()); + if (ident != null) { + value = val; + break; + } } // let it fail default: From 0329205d2135dfc36d106cc581620a9e489fe820 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 10:17:20 +0200 Subject: [PATCH 02/82] more casting issues fixed --- org/w3c/css/properties/css3/CssBorder.java | 6 +++--- org/w3c/css/properties/css3/CssColor.java | 4 ++-- org/w3c/css/properties/css3/CssDisplay.java | 19 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBorder.java b/org/w3c/css/properties/css3/CssBorder.java index c6509d04c..570f63e23 100644 --- a/org/w3c/css/properties/css3/CssBorder.java +++ b/org/w3c/css/properties/css3/CssBorder.java @@ -129,14 +129,14 @@ protected static SideValues parseBorderSide(ApplContext ac, CssExpression expres break; case CssTypes.CSS_HASH_IDENT: org.w3c.css.values.CssColor c = new org.w3c.css.values.CssColor(); - c.setShortRGBColor(ac, val.toString()); - _color = c; + c.setShortRGBColor(ac, val.getHashIdent().toString()); + _color = val; break; case CssTypes.CSS_COLOR: _color = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (transparent.equals(id)) { _color = transparent; break; diff --git a/org/w3c/css/properties/css3/CssColor.java b/org/w3c/css/properties/css3/CssColor.java index 3eac48cff..57246c6b4 100644 --- a/org/w3c/css/properties/css3/CssColor.java +++ b/org/w3c/css/properties/css3/CssColor.java @@ -56,8 +56,8 @@ public CssColor(ApplContext ac, CssExpression expression, boolean check) } break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { color = new org.w3c.css.values.CssColor(ac, val.getIdent().toString()); } diff --git a/org/w3c/css/properties/css3/CssDisplay.java b/org/w3c/css/properties/css3/CssDisplay.java index f7842b430..757b05f3a 100644 --- a/org/w3c/css/properties/css3/CssDisplay.java +++ b/org/w3c/css/properties/css3/CssDisplay.java @@ -106,8 +106,7 @@ public CssDisplay() { * @param ac The context * @param expression The expression for this property * @param check true if explicit check is needed - * @throws org.w3c.css.util.InvalidParamException - * Values are incorect + * @throws org.w3c.css.util.InvalidParamException Values are incorect */ public CssDisplay(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -135,19 +134,19 @@ public CssDisplay(ApplContext ac, CssExpression expression, op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id_val = (CssIdent) val; + CssIdent id_val = val.getIdent(); id = null; // let's check the values which can occur only once. if (count == 1) { if (inherit.equals(id_val)) { id = inherit; - value = inherit; + value = val; } else if ((id = getMatchingIdentInArray(id_val, display_box)) != null) { - value = id; + value = val; } else if ((id = getMatchingIdentInArray(id_val, display_internal)) != null) { - value = id; + value = val; } else if ((id = getMatchingIdentInArray(id_val, display_legacy)) != null) { - value = id; + value = val; } } if (id == null) { @@ -156,7 +155,7 @@ public CssDisplay(ApplContext ac, CssExpression expression, if (id != null) { if (!outside) { outside = true; - v.add(id); + v.add(val); } else { throw new InvalidParamException("value", id_val, getPropertyName(), ac); @@ -168,7 +167,7 @@ public CssDisplay(ApplContext ac, CssExpression expression, if (!listitem && (!inside || flow)) { listitem = true; - v.add(id); + v.add(val); } else { throw new InvalidParamException("value", id_val, getPropertyName(), ac); @@ -180,7 +179,7 @@ public CssDisplay(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", id_val, getPropertyName(), ac); } - v.add(id); + v.add(val); inside = true; flow = (getMatchingIdentInArray(id_val, display_flow) != null); } From 0ea7224ce3a595fccf568d4b04175e6a379edc59 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 10:18:07 +0200 Subject: [PATCH 03/82] revert defaults, how can this be fixed properly... --- org/w3c/css/values/CssCalc.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/values/CssCalc.java b/org/w3c/css/values/CssCalc.java index 0b8356b95..03dd21e5d 100644 --- a/org/w3c/css/values/CssCalc.java +++ b/org/w3c/css/values/CssCalc.java @@ -300,7 +300,7 @@ public boolean isInteger() { */ public boolean isPositive() { // TODO do our best... - return false; + return true; } /** @@ -309,7 +309,7 @@ public boolean isPositive() { * @return a boolean */ public boolean isStrictlyPositive() { - return false; + return true; // TODO do our best... } @@ -320,7 +320,7 @@ public boolean isStrictlyPositive() { */ public boolean isZero() { // TODO do our best... - return false; + return true; } From 4c5ecd4a7cbf3c0a5e0c38a04fd76aaf92db815c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 10:21:28 +0200 Subject: [PATCH 04/82] add way to access the stylesheet from the main context --- org/w3c/css/css/DocumentParser.java | 6 +++--- org/w3c/css/css/HTMLParserStyleSheetHandler.java | 3 ++- org/w3c/css/css/StyleSheetParser.java | 4 ++++ org/w3c/css/css/TagSoupStyleSheetHandler.java | 4 ++-- org/w3c/css/css/XMLStyleSheetHandler.java | 3 ++- org/w3c/css/servlet/CssValidator.java | 4 ++-- org/w3c/css/util/ApplContext.java | 10 ++++++++++ 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/org/w3c/css/css/DocumentParser.java b/org/w3c/css/css/DocumentParser.java index e43e8a193..03a9366c7 100644 --- a/org/w3c/css/css/DocumentParser.java +++ b/org/w3c/css/css/DocumentParser.java @@ -51,7 +51,7 @@ public DocumentParser(ApplContext ac, Reader reader, String urlString, MimeType mediatype = MimeType.TEXT_CSS; } if (mediatype.match(MimeType.TEXT_CSS) == MimeType.MATCH_SPECIFIC_SUBTYPE) { - StyleSheetParser csshandler = new StyleSheetParser(); + StyleSheetParser csshandler = new StyleSheetParser(ac); csshandler.parseStyleSheet(ac, reader, htmlURL); style = csshandler.getStyleSheet(); } else if (mediatype.match(MimeType.TEXT_HTML) == MimeType.MATCH_SPECIFIC_SUBTYPE) { @@ -88,7 +88,7 @@ public DocumentParser(ApplContext ac, String urlString) throws Exception { if (!"http".equals(urlProtocol) && !"https".equals(urlProtocol)) { if (urlLower.endsWith(".css")) { - StyleSheetParser parser = new StyleSheetParser(); + StyleSheetParser parser = new StyleSheetParser(ac); parser.parseURL(ac, htmlURL, null, null, media, StyleSheetOrigin.AUTHOR); style = parser.getStyleSheet(); } else if (urlLower.endsWith(".html") || urlLower.endsWith(".htm") || @@ -157,7 +157,7 @@ public DocumentParser(ApplContext ac, String urlString) throws Exception { style.setType("text/html"); } } else if (contentType.match(MimeType.TEXT_CSS) == MimeType.MATCH_SPECIFIC_SUBTYPE) { - StyleSheetParser parser = new StyleSheetParser(); + StyleSheetParser parser = new StyleSheetParser(ac); parser.parseURL(ac, htmlURL, null, null, media, StyleSheetOrigin.AUTHOR); style = parser.getStyleSheet(); } else if ((contentType.match(MimeType.TEXT_XML) == MimeType.MATCH_SPECIFIC_SUBTYPE) diff --git a/org/w3c/css/css/HTMLParserStyleSheetHandler.java b/org/w3c/css/css/HTMLParserStyleSheetHandler.java index 00a5d6782..6c3c89472 100644 --- a/org/w3c/css/css/HTMLParserStyleSheetHandler.java +++ b/org/w3c/css/css/HTMLParserStyleSheetHandler.java @@ -68,7 +68,7 @@ public class HTMLParserStyleSheetHandler implements ContentHandler, LexicalHandl boolean isHTML5; // StyleSheet styleSheet = new StyleSheet(); - StyleSheetParser styleSheetParser = new StyleSheetParser(); + StyleSheetParser styleSheetParser = null; boolean inStyle = false; String media = null; @@ -88,6 +88,7 @@ public HTMLParserStyleSheetHandler(URL baseURI, ApplContext ac) { this.documentURI = baseURI; this.baseURI = baseURI; this.ac = ac; + this.styleSheetParser = new StyleSheetParser(ac); } public void setDocumentLocator(Locator locator) { diff --git a/org/w3c/css/css/StyleSheetParser.java b/org/w3c/css/css/StyleSheetParser.java index ab8096002..e88592e08 100644 --- a/org/w3c/css/css/StyleSheetParser.java +++ b/org/w3c/css/css/StyleSheetParser.java @@ -61,6 +61,10 @@ public final class StyleSheetParser CssFouffa cssFouffa; StyleSheet style = new StyleSheet(); + public StyleSheetParser(ApplContext ac) { + ac.setStyleSheet(getStyleSheet()); + } + public void reInit() { style = new StyleSheet(); } diff --git a/org/w3c/css/css/TagSoupStyleSheetHandler.java b/org/w3c/css/css/TagSoupStyleSheetHandler.java index 7a792fb96..41e90aedc 100644 --- a/org/w3c/css/css/TagSoupStyleSheetHandler.java +++ b/org/w3c/css/css/TagSoupStyleSheetHandler.java @@ -64,8 +64,7 @@ public class TagSoupStyleSheetHandler implements ContentHandler, LexicalHandler, URL documentURI = null; URL baseURI = null; - // StyleSheet styleSheet = new StyleSheet(); - StyleSheetParser styleSheetParser = new StyleSheetParser(); + StyleSheetParser styleSheetParser = null; boolean inStyle = false; String media = null; @@ -85,6 +84,7 @@ public TagSoupStyleSheetHandler(URL baseURI, ApplContext ac) { this.documentURI = baseURI; this.baseURI = baseURI; this.ac = ac; + this.styleSheetParser = new StyleSheetParser(ac); } public void setDocumentLocator(Locator locator) { diff --git a/org/w3c/css/css/XMLStyleSheetHandler.java b/org/w3c/css/css/XMLStyleSheetHandler.java index eddc92ca3..b6213a48d 100644 --- a/org/w3c/css/css/XMLStyleSheetHandler.java +++ b/org/w3c/css/css/XMLStyleSheetHandler.java @@ -67,7 +67,7 @@ public class XMLStyleSheetHandler implements ContentHandler, LexicalHandler, URL baseURI = null; // StyleSheet styleSheet = new StyleSheet(); - StyleSheetParser styleSheetParser = new StyleSheetParser(); + StyleSheetParser styleSheetParser = null; boolean inStyle = false; @@ -90,6 +90,7 @@ public XMLStyleSheetHandler(URL baseURI, ApplContext ac) { this.documentURI = baseURI; this.baseURI = baseURI; this.ac = ac; + this.styleSheetParser = new StyleSheetParser(ac); } public void setDocumentLocator(Locator locator) { diff --git a/org/w3c/css/servlet/CssValidator.java b/org/w3c/css/servlet/CssValidator.java index 5252f85f2..e02521022 100644 --- a/org/w3c/css/servlet/CssValidator.java +++ b/org/w3c/css/servlet/CssValidator.java @@ -417,7 +417,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse res) if ("css".equals(type) || ("none".equals(type) && isCSS(text))) { // if CSS: - parser = new StyleSheetParser(); + parser = new StyleSheetParser(ac); parser.parseStyleElement(ac, is, null, usermedium, new URL(fileName), 0); @@ -716,7 +716,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse res) ac.setFakeURL(fileName); if (isCSS) { //if CSS: - parser = new StyleSheetParser(); + parser = new StyleSheetParser(ac); parser.parseStyleElement(ac, is, null, ac.getMedium(), new URL(fileName), 0); diff --git a/org/w3c/css/util/ApplContext.java b/org/w3c/css/util/ApplContext.java index 566fb56ce..7b87bb9c1 100644 --- a/org/w3c/css/util/ApplContext.java +++ b/org/w3c/css/util/ApplContext.java @@ -9,6 +9,7 @@ package org.w3c.css.util; +import org.w3c.css.css.StyleSheet; import org.w3c.css.parser.Frame; import org.w3c.www.http.HttpAcceptCharset; import org.w3c.www.http.HttpAcceptCharsetList; @@ -75,6 +76,7 @@ private BomEncoding() { String lang; Messages msgs; Frame frame; + StyleSheet styleSheet = null; CssVersion version = CssVersion.getDefault(); CssProfile profile = CssProfile.NONE; String input; @@ -149,6 +151,14 @@ public Frame getFrame() { return frame; } + public void setStyleSheet(StyleSheet styleSheet) { + this.styleSheet = styleSheet; + } + + public StyleSheet getStyleSheet() { + return styleSheet; + } + public Class getCssSelectorsStyle() { return cssselectorstyle; } From e1dacb02505a77ca5130ca8d00f785afb63454a1 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 10:21:56 +0200 Subject: [PATCH 05/82] fix size when expression is not set --- org/w3c/css/values/CssVariableDefinition.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org/w3c/css/values/CssVariableDefinition.java b/org/w3c/css/values/CssVariableDefinition.java index fecb739d5..08caf3e6d 100644 --- a/org/w3c/css/values/CssVariableDefinition.java +++ b/org/w3c/css/values/CssVariableDefinition.java @@ -24,7 +24,10 @@ public final int getType() { } public int size() { - return expression.getCount(); + if (expression != null) { + return expression.getCount(); + } + return 0; } /** From 2772a7ee23d0a3ca9fcfb2dcb95d5f89a7fe75db Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 10:23:29 +0200 Subject: [PATCH 06/82] redo variable resolution, moved to a more global place for all variable definitions --- org/w3c/css/css/StyleSheet.java | 24 +++++++++++++++++-- org/w3c/css/properties/css3/Css3Style.java | 16 ------------- .../properties/css3/CssCustomProperty.java | 6 +++-- org/w3c/css/values/CssVariable.java | 18 ++++++++++++++ 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/org/w3c/css/css/StyleSheet.java b/org/w3c/css/css/StyleSheet.java index c4013d877..65d3848eb 100644 --- a/org/w3c/css/css/StyleSheet.java +++ b/org/w3c/css/css/StyleSheet.java @@ -11,6 +11,7 @@ import org.w3c.css.parser.CssSelectors; import org.w3c.css.parser.CssStyle; import org.w3c.css.parser.Errors; +import org.w3c.css.properties.css.CssCustomProperty; import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.Util; @@ -37,16 +38,18 @@ public class StyleSheet { private boolean doNotAddRule; private boolean doNotAddAtRule; private static final boolean debug = false; + private HashMap customProperties; /** * Create a new StyleSheet. */ public StyleSheet() { - rules = new HashMap(); + rules = new HashMap<>(); errors = new Errors(); warnings = new Warnings(); cascading = new CssCascadingOrder(); - atRuleList = new ArrayList(); + atRuleList = new ArrayList<>(); + customProperties = new HashMap<>(); } public void setWarningLevel(int warningLevel) { @@ -94,6 +97,23 @@ public void addProperty(CssSelectors selector, CssProperty property) { getContext(selector).addProperty(property, warnings); } + /** + * lookup a custom property + * @param s, the name of the property + * @return a CssCustomProperty or null if not found + */ + public CssCustomProperty getCustomProperty(String s) { + return customProperties.get(s); + } + + // we are not adding custom property in addProperty, as we want to be + public CssCustomProperty addCustomProperty(String s, CssCustomProperty p, boolean force) { + if (force) { + return customProperties.put(s, p); + } + return customProperties.putIfAbsent(s, p); + } + public void remove(CssSelectors selector) { rules.remove(selector); } diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 4f238b2de..11575db99 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -90,7 +90,6 @@ import org.w3c.css.properties.css.CssColumns; import org.w3c.css.properties.css.CssContain; import org.w3c.css.properties.css.CssCounterSet; -import org.w3c.css.properties.css.CssCustomProperty; import org.w3c.css.properties.css.CssDominantBaseline; import org.w3c.css.properties.css.CssFilter; import org.w3c.css.properties.css.CssFlex; @@ -301,12 +300,8 @@ import org.w3c.css.util.Warning; import org.w3c.css.util.Warnings; -import java.util.HashMap; - public class Css3Style extends ATSCStyle { - public HashMap customProperties = new HashMap<>(); - public org.w3c.css.properties.css.counterstyle.CssSpeakAs counterStyleCssSpeakAs; public CssSystem counterStyleCssSystem; public CssFallback counterStyleCssFallback; @@ -3351,17 +3346,6 @@ private void findConflictsBlockElements(ApplContext ac, Warnings warnings, } } - public CssCustomProperty getCustomProperty(String s) { - return customProperties.get(s); - } - - public CssCustomProperty addCustomProperty(String s, CssCustomProperty p, boolean force) { - if (force) { - return customProperties.put(s, p); - } - return customProperties.putIfAbsent(s, p); - } - /** * Find conflicts in this Style * diff --git a/org/w3c/css/properties/css3/CssCustomProperty.java b/org/w3c/css/properties/css3/CssCustomProperty.java index 87709c729..4bf7867ec 100644 --- a/org/w3c/css/properties/css3/CssCustomProperty.java +++ b/org/w3c/css/properties/css3/CssCustomProperty.java @@ -5,6 +5,7 @@ // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; +import org.w3c.css.css.StyleSheet; import org.w3c.css.parser.CssStyle; import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; @@ -31,8 +32,9 @@ public CssCustomProperty(ApplContext ac, String variablename, String unparsed_ex @Override public void addToStyle(ApplContext ac, CssStyle style) { - Css3Style s = (Css3Style) style; - CssProperty p = s.addCustomProperty(getPropertyName(), this, false); + StyleSheet s = ac.getStyleSheet(); + assert s != null; + CssCustomProperty p = (CssCustomProperty) s.addCustomProperty(getPropertyName(), this, false); if (p != null) { // duplicate def // add a warning? diff --git a/org/w3c/css/values/CssVariable.java b/org/w3c/css/values/CssVariable.java index ab9ea31ce..103f5a9d7 100644 --- a/org/w3c/css/values/CssVariable.java +++ b/org/w3c/css/values/CssVariable.java @@ -6,6 +6,8 @@ package org.w3c.css.values; +import org.w3c.css.css.StyleSheet; +import org.w3c.css.properties.css.CssCustomProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; @@ -26,6 +28,22 @@ public final int getRawType() { public final int getType() { if (computed_type == CssTypes.CSS_UNKNOWN) { + if (ac != null) { + StyleSheet s = ac.getStyleSheet(); + if (s != null) { + CssCustomProperty cp = s.getCustomProperty(variable_name); + if (cp != null) { + CssVariableDefinition vd = (CssVariableDefinition) cp.value; + if (vd != null) { + if (vd.size() == 1) { + _exp_value = vd.expression.getValue(); + computed_type = _exp_value.getType(); + return computed_type; + } + } + } + } + } return type; } return computed_type; From abee1f95166b3132a8b3e6dadeab6c8d8abc5b39 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 11:06:07 +0200 Subject: [PATCH 07/82] added relevant check functions to delegate value check, proper fix of 0ea7224ce3a595fccf568d4b04175e6a379edc59 for the specific check case --- org/w3c/css/values/CssVariable.java | 78 +++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/org/w3c/css/values/CssVariable.java b/org/w3c/css/values/CssVariable.java index 103f5a9d7..45daabf5e 100644 --- a/org/w3c/css/values/CssVariable.java +++ b/org/w3c/css/values/CssVariable.java @@ -150,6 +150,84 @@ public CssCheckableValue getCheckableValue() { throw new ClassCastException("unknown"); } + /** + * check if the value is positive or null + * + * @param ac the validation context + * @param callername the String value of the caller (property / media query / ...) + * @throws InvalidParamException + */ + @Override + public void checkPositiveness(ApplContext ac, String callername) + throws InvalidParamException { + if (_isCheckableType(computed_type)) { + _exp_value.getCheckableValue().checkPositiveness(ac, callername); + } + } + + /** + * check if the value is strictly positive + * + * @param ac the validation context + * @param callername the property the value is defined in + * @throws org.w3c.css.util.InvalidParamException + */ + @Override + public void checkStrictPositiveness(ApplContext ac, String callername) + throws InvalidParamException { + if (_isCheckableType(computed_type)) { + _exp_value.getCheckableValue().checkStrictPositiveness(ac, callername); + } + } + + /** + * check if the value is equal to zero + * + * @param ac the validation context + * @param callername the property the value is defined in + * @throws InvalidParamException + */ + @Override + public void checkEqualsZero(ApplContext ac, String callername) + throws InvalidParamException { + if (_isCheckableType(computed_type)) { + _exp_value.getCheckableValue().checkEqualsZero(ac, callername); + } + } + + /** + * warn if the value is not positive or null + * + * @param ac the validation context + * @param callername the property the value is defined in + */ + @Override + public boolean warnPositiveness(ApplContext ac, String callername) { + if (_isCheckableType(computed_type)) { + try { + return _exp_value.getCheckableValue().warnPositiveness(ac, callername); + } catch (InvalidParamException e) { + } + } + return false; + } + + /** + * warn if the value is not zero + * + * @param ac the validation context + * @param callername the property the value is defined in + */ + public boolean warnEqualsZero(ApplContext ac, String callername) { + if (_isCheckableType(computed_type)) { + try { + return _exp_value.getCheckableValue().warnEqualsZero(ac, callername); + } catch (InvalidParamException e) { + } + } + return false; + } + @Override public boolean isPositive() { if (_isCheckableType(computed_type)) { From 8bd48370efcd0b867c0388360f0bf95fb71c1098 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 11:06:19 +0200 Subject: [PATCH 08/82] more casting issues --- org/w3c/css/properties/css3/CssZIndex.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/properties/css3/CssZIndex.java b/org/w3c/css/properties/css3/CssZIndex.java index 09ee2c1d5..7075b9eb3 100644 --- a/org/w3c/css/properties/css3/CssZIndex.java +++ b/org/w3c/css/properties/css3/CssZIndex.java @@ -53,12 +53,12 @@ public CssZIndex(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent ide = (CssIdent) val; + CssIdent ide = val.getIdent(); if (inherit.equals(ide)) { - value = inherit; + value = val; break; } else if (auto.equals(ide)) { - value = auto; + value = val; break; } default: From 7e6e9949e760509929ba03d364177aa506ce0cca Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 11:45:14 +0200 Subject: [PATCH 09/82] casting issue + use proper value instead of ident (might use getRawType to make it better, though --- .../css/properties/css3/CssVoiceBalance.java | 8 ++--- .../css/properties/css3/CssVoiceDuration.java | 8 ++--- .../css/properties/css3/CssVoiceFamily.java | 16 +++++----- .../css/properties/css3/CssVoicePitch.java | 4 +-- .../css/properties/css3/CssVoiceRange.java | 4 +-- org/w3c/css/properties/css3/CssVoiceRate.java | 31 ++++++++----------- .../css/properties/css3/CssVoiceStress.java | 11 +++---- .../css/properties/css3/CssVoiceVolume.java | 14 ++++----- org/w3c/css/properties/css3/CssVolume.java | 2 +- 9 files changed, 46 insertions(+), 52 deletions(-) diff --git a/org/w3c/css/properties/css3/CssVoiceBalance.java b/org/w3c/css/properties/css3/CssVoiceBalance.java index 4aad6a9a2..a91ecb159 100644 --- a/org/w3c/css/properties/css3/CssVoiceBalance.java +++ b/org/w3c/css/properties/css3/CssVoiceBalance.java @@ -72,13 +72,13 @@ public CssVoiceBalance(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { - value = inherit; + value = val; break; } - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssVoiceDuration.java b/org/w3c/css/properties/css3/CssVoiceDuration.java index 682b9ea21..d93e9ec95 100644 --- a/org/w3c/css/properties/css3/CssVoiceDuration.java +++ b/org/w3c/css/properties/css3/CssVoiceDuration.java @@ -58,12 +58,12 @@ public CssVoiceDuration(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; break; } - if (auto.equals(val)) { - value = auto; + if (auto.equals(val.getIdent())) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssVoiceFamily.java b/org/w3c/css/properties/css3/CssVoiceFamily.java index f6ecccbf6..6e61f7fb2 100644 --- a/org/w3c/css/properties/css3/CssVoiceFamily.java +++ b/org/w3c/css/properties/css3/CssVoiceFamily.java @@ -132,14 +132,14 @@ private void checkExpression(ApplContext ac, ArrayList curval, CssIdent ageVal = null; CssValue numVal = null; CssValue nameVal = null; - ArrayList identl = null; + ArrayList identl = null; // so we can have a generic voice or a string or an ident list... // let's triage things... that will require extra checks (again) // at the end *sigh* for (CssValue val : values) { if (ageVal == null && nameVal == null && val.getType() == CssTypes.CSS_IDENT) { - ageVal = getAge((CssIdent) val); + ageVal = getAge(val.getIdent()); if (ageVal != null) { continue; } @@ -155,22 +155,24 @@ private void checkExpression(ApplContext ac, ArrayList curval, nameVal = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { + // FIXME need to do better here val = inherit; } else if (preserve.equals(id)) { + // FIXME need to do better here val = preserve; } if (nameVal == null) { nameVal = val; - identl = new ArrayList(); + identl = new ArrayList<>(); } if (identl == null) { // else we got a string before... throw new InvalidParamException("value", val, getPropertyName(), ac); } - identl.add((CssIdent) val); + identl.add(val.getIdent()); break; case CssTypes.CSS_NUMBER: CssCheckableValue n = val.getCheckableValue(); @@ -191,7 +193,7 @@ private void checkExpression(ApplContext ac, ArrayList curval, getPropertyName(), ac); } if (nameVal.getType() == CssTypes.CSS_IDENT) { - hasGenericVoiceFamily = (getGenericVoiceName((CssIdent) nameVal) != null); + hasGenericVoiceFamily = (getGenericVoiceName(nameVal.getIdent()) != null); } curval.add(nameVal); @@ -215,7 +217,7 @@ private void checkExpression(ApplContext ac, ArrayList curval, if (identl.size() > 1) { ac.getFrame().addWarning("with-space", 1); } else { - hasGenericVoiceFamily = (getGenericVoiceName(identl.get(0)) != null); + hasGenericVoiceFamily = (getGenericVoiceName(identl.get(0).getIdent()) != null); } } } diff --git a/org/w3c/css/properties/css3/CssVoicePitch.java b/org/w3c/css/properties/css3/CssVoicePitch.java index 06c0e87d1..95ab7dbb2 100644 --- a/org/w3c/css/properties/css3/CssVoicePitch.java +++ b/org/w3c/css/properties/css3/CssVoicePitch.java @@ -86,7 +86,7 @@ public CssVoicePitch(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); @@ -95,7 +95,7 @@ public CssVoicePitch(ApplContext ac, CssExpression expression, boolean check) break; } if (identVal == null) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (absolute.equals(id)) { identVal = absolute; value = absolute; diff --git a/org/w3c/css/properties/css3/CssVoiceRange.java b/org/w3c/css/properties/css3/CssVoiceRange.java index 5afaddb26..f8aa466b1 100644 --- a/org/w3c/css/properties/css3/CssVoiceRange.java +++ b/org/w3c/css/properties/css3/CssVoiceRange.java @@ -86,7 +86,7 @@ public CssVoiceRange(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); @@ -95,7 +95,7 @@ public CssVoiceRange(ApplContext ac, CssExpression expression, boolean check) break; } if (identVal == null) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (absolute.equals(id)) { identVal = absolute; value = absolute; diff --git a/org/w3c/css/properties/css3/CssVoiceRate.java b/org/w3c/css/properties/css3/CssVoiceRate.java index fb2a7e484..343ae04bf 100644 --- a/org/w3c/css/properties/css3/CssVoiceRate.java +++ b/org/w3c/css/properties/css3/CssVoiceRate.java @@ -54,8 +54,7 @@ public CssVoiceRate() { * Creates a new CssVoiceRate * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssVoiceRate(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -85,21 +84,19 @@ public CssVoiceRate(ApplContext ac, CssExpression expression, boolean check) pctValue = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); } - value = inherit; + ideValue = inherit; break; } else { - if (ideValue == null) { - ideValue = getAllowedIdent(id); - if (ideValue != null) { - break; - } + if ((ideValue == null) && (getAllowedIdent(id) != null)) { + ideValue = val; + break; } } default: @@ -114,16 +111,14 @@ public CssVoiceRate(ApplContext ac, CssExpression expression, boolean check) expression.next(); } // now check what we have... - if (value != inherit) { - ArrayList v = new ArrayList(2); - if (ideValue != null) { - v.add(ideValue); - } - if (pctValue != null) { - v.add(pctValue); - } - value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + ArrayList v = new ArrayList(2); + if (ideValue != null) { + v.add(ideValue); + } + if (pctValue != null) { + v.add(pctValue); } + value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } public CssVoiceRate(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssVoiceStress.java b/org/w3c/css/properties/css3/CssVoiceStress.java index e3489cbd7..db60b0caf 100644 --- a/org/w3c/css/properties/css3/CssVoiceStress.java +++ b/org/w3c/css/properties/css3/CssVoiceStress.java @@ -48,8 +48,7 @@ public CssVoiceStress() { * Creates a new CssVoiceStress * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssVoiceStress(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,16 +64,16 @@ public CssVoiceStress(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { - value = inherit; + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssVoiceVolume.java b/org/w3c/css/properties/css3/CssVoiceVolume.java index 99e7390e9..dbc7b2cba 100644 --- a/org/w3c/css/properties/css3/CssVoiceVolume.java +++ b/org/w3c/css/properties/css3/CssVoiceVolume.java @@ -87,14 +87,14 @@ public CssVoiceVolume(ApplContext ac, CssExpression expression, boolean check) dbValue = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, getPropertyName(), ac); } - value = inherit; + value = val; break; } else if (silent.equals(id)) { if (expression.getCount() > 1) { @@ -102,14 +102,12 @@ public CssVoiceVolume(ApplContext ac, CssExpression expression, boolean check) silent, getPropertyName(), ac); } - value = silent; + value = val; break; } else { - if (ideValue == null) { - ideValue = getAllowedIdent(id); - if (ideValue != null) { - break; - } + if ((ideValue == null) && (getAllowedIdent(id) != null)) { + ideValue = val; + break; } } default: diff --git a/org/w3c/css/properties/css3/CssVolume.java b/org/w3c/css/properties/css3/CssVolume.java index fcfedde39..1356e2283 100644 --- a/org/w3c/css/properties/css3/CssVolume.java +++ b/org/w3c/css/properties/css3/CssVolume.java @@ -84,7 +84,7 @@ public CssVolume(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { value = inherit; break; From d969b44f2148feb3c2f73d2cee0111f69491c75a Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 11:57:44 +0200 Subject: [PATCH 10/82] cast issue+ updated ref --- org/w3c/css/properties/css3/CssVisibility.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/org/w3c/css/properties/css3/CssVisibility.java b/org/w3c/css/properties/css3/CssVisibility.java index c53284dbb..54eea235c 100644 --- a/org/w3c/css/properties/css3/CssVisibility.java +++ b/org/w3c/css/properties/css3/CssVisibility.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#visibility + * @spec https://www.w3.org/TR/2021/CRD-css-display-3-20210903/#propdef-visibility */ public class CssVisibility extends org.w3c.css.properties.css.CssVisibility { @@ -68,17 +68,13 @@ public CssVisibility(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("value", val, getPropertyName(), ac); } - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { + CssIdent id = val.getIdent(); + if (!inherit.equals(id) && (getAllowedIdent(id) == null)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); - } } + value = val; expression.next(); } From 809ab35eae80f9219eb8a0370820cb0970b698c3 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 15:04:10 +0200 Subject: [PATCH 11/82] cast issue (continuing...) + updated per https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-vertical-align --- .../css/properties/css3/CssVerticalAlign.java | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/org/w3c/css/properties/css3/CssVerticalAlign.java b/org/w3c/css/properties/css3/CssVerticalAlign.java index 59e1c97e5..f4e83cc8a 100644 --- a/org/w3c/css/properties/css3/CssVerticalAlign.java +++ b/org/w3c/css/properties/css3/CssVerticalAlign.java @@ -17,10 +17,30 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#propdef-vertical-align + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-vertical-align */ public class CssVerticalAlign extends org.w3c.css.properties.css.CssVerticalAlign { + public static final CssIdent[] allowed_values; + + static { + String[] _allowed_values = {"first", "last"}; + int i = 0; + allowed_values = new CssIdent[_allowed_values.length]; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static final CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + /** * Create a new CssVerticalAlign */ @@ -33,23 +53,23 @@ public CssVerticalAlign() { * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssVerticalAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 2) { + if (check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } - ArrayList v = new ArrayList<>(2); + ArrayList v = new ArrayList<>(3); setByUser(); char op; CssValue val; CssIdent res; boolean got_shift = false; boolean got_alignment = false; + boolean got_baseline_source = false; while (!expression.end()) { val = expression.getValue(); @@ -68,20 +88,28 @@ public CssVerticalAlign(ApplContext ac, CssExpression expression, v.add(val); break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { // inherit can only be alone if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - value = inherit; + value = val; break; } + if (!got_baseline_source) { + res = getAllowedIdent(id); + if (res != null) { + v.add(val); + got_baseline_source = true; + break; + } + } if (!got_shift) { res = CssBaselineShift.getAllowedIdent(id); if (res != null) { - v.add(res); + v.add(val); got_shift = true; break; } @@ -90,7 +118,7 @@ public CssVerticalAlign(ApplContext ac, CssExpression expression, res = CssAlignmentBaseline.getAllowedIdent(id); if (res != null) { got_alignment = true; - v.add(res); + v.add(val); break; } } @@ -105,7 +133,7 @@ public CssVerticalAlign(ApplContext ac, CssExpression expression, } expression.next(); } - if (value != inherit) { + if (!v.isEmpty()) { value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } } From 939efde4723f1d0c062042ae554c992a765eea4f Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 15:12:11 +0200 Subject: [PATCH 12/82] cast issue (cont.) + ref --- .../css/properties/css3/CssUnicodeBidi.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/org/w3c/css/properties/css3/CssUnicodeBidi.java b/org/w3c/css/properties/css3/CssUnicodeBidi.java index da20d576d..37c95a9fa 100644 --- a/org/w3c/css/properties/css3/CssUnicodeBidi.java +++ b/org/w3c/css/properties/css3/CssUnicodeBidi.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2019/REC-css-writing-modes-3-20191210/#propdef-unicode-bidi + * @spec https://www.w3.org/TR/2019/CR-css-writing-modes-4-20190730/#propdef-unicode-bidi */ public class CssUnicodeBidi extends org.w3c.css.properties.css.CssUnicodeBidi { @@ -50,8 +50,7 @@ public CssUnicodeBidi() { * Creates a new CssUnicodeBidi * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssUnicodeBidi(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -70,17 +69,13 @@ public CssUnicodeBidi(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("value", val, getPropertyName(), ac); } - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!inherit.equals(id) || (getAllowedIdent(id) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; expression.next(); } From f0885762f3136ff2c55c3f8be4a381358aedfd5f Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 15:21:01 +0200 Subject: [PATCH 13/82] casting issue + use proper value instead of ident (might use getRawType to make it better, though) --- org/w3c/css/properties/css3/CssTransition.java | 2 +- org/w3c/css/properties/css3/CssTransitionDelay.java | 2 +- .../css/properties/css3/CssTransitionDuration.java | 2 +- .../css/properties/css3/CssTransitionProperty.java | 7 +++---- .../properties/css3/CssTransitionTimingFunction.java | 11 +++++------ 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTransition.java b/org/w3c/css/properties/css3/CssTransition.java index cc8232a6a..ef2d05020 100644 --- a/org/w3c/css/properties/css3/CssTransition.java +++ b/org/w3c/css/properties/css3/CssTransition.java @@ -199,7 +199,7 @@ private CssTransitionValue checkLayer(ApplContext ac, val.toString(), caller.getPropertyName(), ac); case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("unrecognize", ac); diff --git a/org/w3c/css/properties/css3/CssTransitionDelay.java b/org/w3c/css/properties/css3/CssTransitionDelay.java index 33509d961..be0e68693 100644 --- a/org/w3c/css/properties/css3/CssTransitionDelay.java +++ b/org/w3c/css/properties/css3/CssTransitionDelay.java @@ -52,7 +52,7 @@ public CssTransitionDelay(ApplContext ac, CssExpression expression, boolean chec values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { gotinherit = true; values.add(inherit); break; diff --git a/org/w3c/css/properties/css3/CssTransitionDuration.java b/org/w3c/css/properties/css3/CssTransitionDuration.java index f4c152114..38608d57a 100644 --- a/org/w3c/css/properties/css3/CssTransitionDuration.java +++ b/org/w3c/css/properties/css3/CssTransitionDuration.java @@ -55,7 +55,7 @@ public CssTransitionDuration(ApplContext ac, CssExpression expression, boolean c values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { gotinherit = true; values.add(inherit); break; diff --git a/org/w3c/css/properties/css3/CssTransitionProperty.java b/org/w3c/css/properties/css3/CssTransitionProperty.java index e6c27568f..1dff7bd96 100644 --- a/org/w3c/css/properties/css3/CssTransitionProperty.java +++ b/org/w3c/css/properties/css3/CssTransitionProperty.java @@ -49,8 +49,7 @@ public static CssIdent getAllowedIdent(ApplContext ac, CssIdent ident) { * Creates a new CssTransitionProperty * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTransitionProperty(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -67,12 +66,12 @@ public CssTransitionProperty(ApplContext ac, CssExpression expression, boolean c op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { singleVal = true; sValue = inherit; values.add(inherit); } else { - CssIdent ident = getAllowedIdent(ac, (CssIdent) val); + CssIdent ident = getAllowedIdent(ac, val.getIdent()); if (ident == none) { singleVal = true; sValue = none; diff --git a/org/w3c/css/properties/css3/CssTransitionTimingFunction.java b/org/w3c/css/properties/css3/CssTransitionTimingFunction.java index 2111f0464..b64d1870b 100644 --- a/org/w3c/css/properties/css3/CssTransitionTimingFunction.java +++ b/org/w3c/css/properties/css3/CssTransitionTimingFunction.java @@ -65,8 +65,7 @@ public CssTransitionTimingFunction() { * Creates a new CssTransitionTimingFunction * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTransitionTimingFunction(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -87,13 +86,13 @@ public CssTransitionTimingFunction(ApplContext ac, CssExpression expression, boo values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { singleVal = true; sValue = inherit; values.add(inherit); break; } else { - CssIdent id = getAllowedIdent((CssIdent) val); + CssIdent id = getAllowedIdent(val.getIdent()); if (id != null) { values.add(id); break; @@ -163,9 +162,9 @@ private static CssValue parseStepsFunction(ApplContext ac, CssExpression funcpar val.toString(), caller.getPropertyName(), ac); } - if (start.equals(val)) { + if (start.equals(val.getIdent())) { values.add(start); - } else if (end.equals(val)) { + } else if (end.equals(val.getIdent())) { values.add(end); } else { // unrecognized ident From 77b2e245a0708e58aa6cc2d8d94d57e0d4ddf3d6 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 15:48:13 +0200 Subject: [PATCH 14/82] check based on resolved value --- org/w3c/css/properties/css3/CssTop.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTop.java b/org/w3c/css/properties/css3/CssTop.java index 9cd2dd3b9..01821a700 100644 --- a/org/w3c/css/properties/css3/CssTop.java +++ b/org/w3c/css/properties/css3/CssTop.java @@ -73,13 +73,13 @@ protected static CssValue parseTop(ApplContext ac, expression.next(); return val; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { expression.next(); return inherit; } - if (auto.equals(val)) { + if (auto.equals(val.getIdent())) { expression.next(); - return auto; + return val; } // if not inherit, or not an ident // let it flow to the exception From d32e2c5b7be85bad9260be7fdaed042dfc2e9f1b Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 17:49:53 +0200 Subject: [PATCH 15/82] casting issue (cont) --- .../css/properties/css3/CssTextTransform.java | 14 +++++------ org/w3c/css/properties/css3/CssTransform.java | 12 ++++------ .../css/properties/css3/CssTransformBox.java | 24 +++++++------------ .../properties/css3/CssTransformStyle.java | 19 ++++++--------- 4 files changed, 27 insertions(+), 42 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextTransform.java b/org/w3c/css/properties/css3/CssTextTransform.java index 2301c3e33..679216949 100644 --- a/org/w3c/css/properties/css3/CssTextTransform.java +++ b/org/w3c/css/properties/css3/CssTextTransform.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#text-transform-property + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-transform */ public class CssTextTransform extends org.w3c.css.properties.css.CssTextTransform { @@ -85,30 +85,28 @@ public CssTextTransform(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } values.add(inherit); - } else if (none.equals(val)) { + } else if (none.equals(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } values.add(none); - } else if (fullWidth.equals(val) && !got_full_width) { + } else if (fullWidth.equals(val.getIdent()) && !got_full_width) { got_full_width = true; values.add(fullWidth); - } else if (fullSizeKana.equals(val) && !got_full_size_kana) { + } else if (fullSizeKana.equals(val.getIdent()) && !got_full_size_kana) { got_full_size_kana = true; values.add(fullSizeKana); } else if (!got_action) { - got_action = true; - val = getMatchingActionIdent((CssIdent) val); - if (val == null) { + if (getMatchingActionIdent(val.getIdent()) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssTransform.java b/org/w3c/css/properties/css3/CssTransform.java index d9962f01c..4ed68d2e4 100644 --- a/org/w3c/css/properties/css3/CssTransform.java +++ b/org/w3c/css/properties/css3/CssTransform.java @@ -61,8 +61,7 @@ public CssTransform() { * Creates a new CssTransform * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTransform(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -83,7 +82,7 @@ public CssTransform(ApplContext ac, CssExpression expression, boolean check) values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { singleVal = true; sValue = inherit; values.add(inherit); @@ -256,10 +255,9 @@ private static void parseOneX(ApplContext ac, CssExpression expression, if (val.getType() == CssTypes.CSS_NUMBER) { if (type == CssTypes.CSS_LENGTH || type == CssTypes.CSS_ANGLE) { // if not zero, it will fail - if (val.getNumber().isZero()) { - expression.next(); - return; - } + val.getCheckableValue().checkEqualsZero(ac, caller.getPropertyName()); + expression.next(); + return; } } if (val.getType() != type) { diff --git a/org/w3c/css/properties/css3/CssTransformBox.java b/org/w3c/css/properties/css3/CssTransformBox.java index c538e1dcc..36523c77d 100644 --- a/org/w3c/css/properties/css3/CssTransformBox.java +++ b/org/w3c/css/properties/css3/CssTransformBox.java @@ -62,8 +62,7 @@ public CssTransformBox() { * Creates a new CssTransformOrigin * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssTransformBox(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -79,19 +78,14 @@ public CssTransformBox(ApplContext ac, CssExpression expression, val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + + CssIdent ident = val.getIdent(); + if (!inherit.equals(ident) && (getAllowedValue(ident) == null)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssTransformStyle.java b/org/w3c/css/properties/css3/CssTransformStyle.java index 8c07a3eaa..4ae3e87e6 100644 --- a/org/w3c/css/properties/css3/CssTransformStyle.java +++ b/org/w3c/css/properties/css3/CssTransformStyle.java @@ -48,8 +48,7 @@ public CssTransformStyle() { * Creates a new CssTransformStyle * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTransformStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,17 +65,13 @@ public CssTransformStyle(ApplContext ac, CssExpression expression, boolean check 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; + CssIdent id = val.getIdent(); + if (!inherit.equals(id) && (getMatchingIdent(id) == null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } From 31c357fa46f46a8784f4f51a486164991402971d Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 18:29:28 +0200 Subject: [PATCH 16/82] updated to https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#propdef-text-overflow --- .../css/properties/css3/CssTextOverflow.java | 64 +++++-------------- 1 file changed, 17 insertions(+), 47 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextOverflow.java b/org/w3c/css/properties/css3/CssTextOverflow.java index 0842fdae8..be8052362 100644 --- a/org/w3c/css/properties/css3/CssTextOverflow.java +++ b/org/w3c/css/properties/css3/CssTextOverflow.java @@ -11,14 +11,9 @@ import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -import org.w3c.css.values.CssValueList; - -import java.util.ArrayList; - -import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2015/CR-css-ui-3-20150707/#propdef-text-overflow + * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#text-overflow */ public class CssTextOverflow extends org.w3c.css.properties.css.CssTextOverflow { @@ -53,59 +48,34 @@ public CssTextOverflow() { * Creates a new CssTextOverflow * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextOverflow(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - - if (check && expression.getCount() > 2) { + if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - setByUser(); CssValue val; char op; - ArrayList values = new ArrayList<>(4); - - while (!expression.end()) { - val = expression.getValue(); - op = expression.getOperator(); - switch (val.getType()) { - case CssTypes.CSS_STRING: - values.add(val); - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("value", - inherit.toString(), - getPropertyName(), ac); - } - values.add(inherit); - break; - } - CssIdent match = getAllowedIdent((CssIdent) val); - if (match != null) { - values.add(match); - break; - } - // unrecognized, let it fail - default: - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - if (op != SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - expression.next(); + val = expression.getValue(); + op = expression.getOperator(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent id = val.getIdent(); + if (!inherit.equals(id) && (getAllowedIdent(id) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } - value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + value = val; + expression.next(); } public CssTextOverflow(ApplContext ac, CssExpression expression) From 2e2cc50501e4d7616b65ea82f4248023414403c6 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 18:29:51 +0200 Subject: [PATCH 17/82] casting issue (cont) --- org/w3c/css/properties/css3/CssTextOverflow.java | 2 +- org/w3c/css/properties/css3/CssTextSizeAdjust.java | 12 +++++++----- org/w3c/css/properties/css3/CssTouchAction.java | 14 +++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextOverflow.java b/org/w3c/css/properties/css3/CssTextOverflow.java index be8052362..581427024 100644 --- a/org/w3c/css/properties/css3/CssTextOverflow.java +++ b/org/w3c/css/properties/css3/CssTextOverflow.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#text-overflow + * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#propdef-text-overflow */ public class CssTextOverflow extends org.w3c.css.properties.css.CssTextOverflow { diff --git a/org/w3c/css/properties/css3/CssTextSizeAdjust.java b/org/w3c/css/properties/css3/CssTextSizeAdjust.java index 9975e5600..2fa49bd36 100644 --- a/org/w3c/css/properties/css3/CssTextSizeAdjust.java +++ b/org/w3c/css/properties/css3/CssTextSizeAdjust.java @@ -68,15 +68,17 @@ public CssTextSizeAdjust(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { - value = inherit; + value = val; + break; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; + break; } case CssTypes.CSS_NUMBER: val.getCheckableValue().checkEqualsZero(ac, this); @@ -95,7 +97,7 @@ public CssTextSizeAdjust(ApplContext ac, CssExpression expression) } public boolean isDefault() { - return ((value == auto) || (value == initial)); + return ((auto.equals(value)) || (initial.equals(value))); } } diff --git a/org/w3c/css/properties/css3/CssTouchAction.java b/org/w3c/css/properties/css3/CssTouchAction.java index f0cc09d6d..8d71c7754 100644 --- a/org/w3c/css/properties/css3/CssTouchAction.java +++ b/org/w3c/css/properties/css3/CssTouchAction.java @@ -17,7 +17,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2016/WD-pointerevents2-20160719/#the-touch-action-css-property + * @spec https://www.w3.org/TR/2021/WD-pointerevents3-20210901/#the-touch-action-css-property * @spec https://compat.spec.whatwg.org/#touch-action */ @@ -122,14 +122,14 @@ public CssTouchAction(ApplContext ac, CssExpression expression, val.toString(), getPropertyName(), ac); } - id = (CssIdent) val; + id = val.getIdent(); if (id.equals(inherit)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); expression.next(); continue; } @@ -141,7 +141,7 @@ public CssTouchAction(ApplContext ac, CssExpression expression, expression.getValue(), getPropertyName(), ac); } - values.add(ident); + values.add(val); expression.next(); continue; } @@ -155,7 +155,7 @@ public CssTouchAction(ApplContext ac, CssExpression expression, getPropertyName(), ac); } got_horizontal = true; - values.add(ident); + values.add(val); expression.next(); continue; } @@ -168,7 +168,7 @@ public CssTouchAction(ApplContext ac, CssExpression expression, getPropertyName(), ac); } got_vertical = true; - values.add(ident); + values.add(val); expression.next(); continue; } @@ -180,7 +180,7 @@ public CssTouchAction(ApplContext ac, CssExpression expression, getPropertyName(), ac); } got_pinch_zoom = true; - values.add(pinch_zoom); + values.add(val); expression.next(); continue; } From f415054804cd7a2d1cc33a2cd5866367d8424747 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 18:57:42 +0200 Subject: [PATCH 18/82] casting issue (cont) --- .../css/properties/css3/CssTextIndent.java | 13 +++++----- .../css/properties/css3/CssTextJustify.java | 22 +++++++---------- .../properties/css3/CssTextOrientation.java | 24 ++++++------------- 3 files changed, 22 insertions(+), 37 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextIndent.java b/org/w3c/css/properties/css3/CssTextIndent.java index f578ba603..f178a99d8 100644 --- a/org/w3c/css/properties/css3/CssTextIndent.java +++ b/org/w3c/css/properties/css3/CssTextIndent.java @@ -16,7 +16,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-text-indent + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-indent */ public class CssTextIndent extends org.w3c.css.properties.css.CssTextIndent { @@ -38,8 +38,7 @@ public CssTextIndent() { * Creates a new CssTextIndent * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextIndent(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -77,7 +76,7 @@ public CssTextIndent(ApplContext ac, CssExpression expression, boolean check) } break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { value = inherit; if (check && expression.getCount() > 1) { @@ -86,11 +85,11 @@ public CssTextIndent(ApplContext ac, CssExpression expression, boolean check) break; } if (hangVal == null && hanging.equals(ident)) { - hangVal = hanging; + hangVal = val; break; } if (eachVal == null && each_line.equals(ident)) { - eachVal = each_line; + eachVal = val; break; } default: @@ -109,7 +108,7 @@ public CssTextIndent(ApplContext ac, CssExpression expression, boolean check) if (expression.getCount() == 1) { value = sizeVal; } else { - ArrayList v = new ArrayList(4); + ArrayList v = new ArrayList<>(4); v.add(sizeVal); if (hangVal != null) { v.add(hangVal); diff --git a/org/w3c/css/properties/css3/CssTextJustify.java b/org/w3c/css/properties/css3/CssTextJustify.java index 9c003dc8b..f2354b57c 100644 --- a/org/w3c/css/properties/css3/CssTextJustify.java +++ b/org/w3c/css/properties/css3/CssTextJustify.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#text-justify-property + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-justify */ public class CssTextJustify extends org.w3c.css.properties.css.CssTextJustify { @@ -48,8 +48,7 @@ public CssTextJustify() { * Creates a new CssTextJustify * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextJustify(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,17 +65,14 @@ public CssTextJustify(ApplContext ac, CssExpression expression, boolean check) 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; + CssIdent id = val.getIdent(); + + if (!inherit.equals(id) && (getMatchingIdent(id) == null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssTextOrientation.java b/org/w3c/css/properties/css3/CssTextOrientation.java index 5552b9120..15f27bac5 100644 --- a/org/w3c/css/properties/css3/CssTextOrientation.java +++ b/org/w3c/css/properties/css3/CssTextOrientation.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2019/REC-css-writing-modes-3-20191210/#propdef-text-orientation + * @spec https://www.w3.org/TR/2019/CR-css-writing-modes-4-20190730/#propdef-text-orientation */ public class CssTextOrientation extends org.w3c.css.properties.css.CssTextOrientation { @@ -28,12 +28,6 @@ public class CssTextOrientation extends org.w3c.css.properties.css.CssTextOrient } } - static CssIdent all; - - static { - all = CssIdent.getIdent("all"); - } - public static CssIdent getAllowedIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { @@ -54,8 +48,7 @@ public CssTextOrientation() { * Creates a new CssTextOrientation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextOrientation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -71,15 +64,12 @@ public CssTextOrientation(ApplContext ac, CssExpression expression, boolean chec throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - if (val.equals(inherit)) { - value = inherit; - } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!inherit.equals(id) && (getAllowedIdent(id) == null)) { + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } From e9ac19a04924de65e37ce3fc6163195fb006dff9 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 21:33:15 +0200 Subject: [PATCH 19/82] internalize idents at parsing time --- org/w3c/css/parser/analyzer/CssParser.jj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/org/w3c/css/parser/analyzer/CssParser.jj b/org/w3c/css/parser/analyzer/CssParser.jj index 3774ebdb3..9c46a4f9e 100644 --- a/org/w3c/css/parser/analyzer/CssParser.jj +++ b/org/w3c/css/parser/analyzer/CssParser.jj @@ -448,10 +448,14 @@ public abstract class CssParser { if (n.kind == CssParserConstants.IDENT) { String s = convertIdent(val); - if ('-' == s.charAt(0)) { - expr.markVendorExtension(); - } - v.set(convertIdent(val), ac); + if ('-' == s.charAt(0)) { + expr.markVendorExtension(); + } + if (v.getRawType() == CssTypes.CSS_IDENT) { + v = CssIdent.getIdent(s); // might be in the setValue call + } else { + v.set(s, ac); + } } else if (n.kind == CssParserConstants.STRING) { v.set(val, ac); } else { From 6c30f3fd5c9d53088e48f3a0d1593ee581b4e0a0 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 21:33:22 +0200 Subject: [PATCH 20/82] regen --- org/w3c/css/parser/analyzer/CssParser.java | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/org/w3c/css/parser/analyzer/CssParser.java b/org/w3c/css/parser/analyzer/CssParser.java index bc4bb672b..dde057b90 100644 --- a/org/w3c/css/parser/analyzer/CssParser.java +++ b/org/w3c/css/parser/analyzer/CssParser.java @@ -429,10 +429,14 @@ private void setValue(CssValue v, CssExpression expr, if (n.kind == CssParserConstants.IDENT) { String s = convertIdent(val); - if ('-' == s.charAt(0)) { - expr.markVendorExtension(); - } - v.set(convertIdent(val), ac); + if ('-' == s.charAt(0)) { + expr.markVendorExtension(); + } + if (v.getRawType() == CssTypes.CSS_IDENT) { + v = CssIdent.getIdent(s); // might be in the setValue call + } else { + v.set(s, ac); + } } else if (n.kind == CssParserConstants.STRING) { v.set(val, ac); } else { @@ -7940,14 +7944,6 @@ private boolean jj_2_15(int xla) finally { jj_save(14, xla); } } - private boolean jj_3R_320() - { - if (jj_3R_195()) return true; - if (jj_scan_token(EQ)) return true; - if (jj_scan_token(NUMBER)) return true; - return false; - } - private boolean jj_3R_205() { if (jj_3R_222()) return true; @@ -9663,6 +9659,14 @@ private boolean jj_3R_292() return false; } + private boolean jj_3R_320() + { + if (jj_3R_195()) return true; + if (jj_scan_token(EQ)) return true; + if (jj_scan_token(NUMBER)) return true; + return false; + } + /** Generated Token Manager. */ public CssParserTokenManager token_source; SimpleCharStream jj_input_stream; From c89caf4ed0e1ddcae4ec39c590c985f2da701800 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 21:44:58 +0200 Subject: [PATCH 21/82] casting issue (cont) --- .../properties/css3/CssTextDecoration.java | 3 +++ .../css3/CssTextDecorationColor.java | 9 +++---- .../css3/CssTextDecorationLine.java | 8 +++--- .../css3/CssTextDecorationSkip.java | 27 +++++++++---------- .../css3/CssTextDecorationSkipBox.java | 6 ++--- .../css3/CssTextDecorationSkipInk.java | 8 +++--- .../css3/CssTextDecorationSkipInset.java | 8 +++--- .../css3/CssTextDecorationSkipSelf.java | 8 +++--- .../css3/CssTextDecorationSkipSpaces.java | 8 +++--- .../css3/CssTextDecorationStyle.java | 18 +++++-------- .../css3/CssTextDecorationThickness.java | 16 +++++------ 11 files changed, 56 insertions(+), 63 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextDecoration.java b/org/w3c/css/properties/css3/CssTextDecoration.java index 94f2e8a87..da47042e6 100644 --- a/org/w3c/css/properties/css3/CssTextDecoration.java +++ b/org/w3c/css/properties/css3/CssTextDecoration.java @@ -150,6 +150,9 @@ public CssTextDecoration(ApplContext ac, CssExpression expression, boolean check try { CssColor c = new CssColor(ac, expression, false); colValue = c.getColor(); + if (colValue == null) { + colValue = c.value; + } state *= 2; } catch (InvalidParamException iex) { // as it is a catchall, we do not know if the intent was a color diff --git a/org/w3c/css/properties/css3/CssTextDecorationColor.java b/org/w3c/css/properties/css3/CssTextDecorationColor.java index eb9d08c30..16685c177 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationColor.java +++ b/org/w3c/css/properties/css3/CssTextDecorationColor.java @@ -26,8 +26,7 @@ public CssTextDecorationColor() { * Creates a new CssTextDecorationColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextDecorationColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -38,13 +37,13 @@ public CssTextDecorationColor(ApplContext ac, CssExpression expression, boolean throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; expression.next(); } else { try { CssColor tcolor = new CssColor(ac, expression, check); - value = tcolor.color; + value = (tcolor.value != null) ? tcolor.value : tcolor.color; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssTextDecorationLine.java b/org/w3c/css/properties/css3/CssTextDecorationLine.java index 7bdfa7368..3306e6943 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationLine.java +++ b/org/w3c/css/properties/css3/CssTextDecorationLine.java @@ -99,14 +99,14 @@ public CssTextDecorationLine(ApplContext ac, CssExpression expression, boolean c val.toString(), getPropertyName(), ac); } - id = (CssIdent) val; + id = val.getIdent(); if (inherit.equals(id)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; } v = getSingleAllowedValue(id); @@ -116,7 +116,7 @@ public CssTextDecorationLine(ApplContext ac, CssExpression expression, boolean c val.toString(), getPropertyName(), ac); } - values.add(v); + values.add(val); break; } v = getMultipleAllowedValue(id); @@ -125,7 +125,7 @@ public CssTextDecorationLine(ApplContext ac, CssExpression expression, boolean c val.toString(), getPropertyName(), ac); } - values.add(v); + values.add(val); expression.next(); if (!expression.end() && (op != SPACE)) { diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkip.java b/org/w3c/css/properties/css3/CssTextDecorationSkip.java index 223c33b29..793e66058 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkip.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkip.java @@ -58,8 +58,7 @@ public CssTextDecorationSkip() { * Creates a new CssTextDecorationSkip * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextDecorationSkip(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -71,10 +70,10 @@ public CssTextDecorationSkip(ApplContext ac, CssExpression expression, boolean c CssValue val; char op; - CssIdent edgValue = null; - CssIdent spaValue = null; - CssIdent inkValue = null; - CssIdent objValue = null; + CssValue edgValue = null; + CssValue spaValue = null; + CssValue inkValue = null; + CssValue objValue = null; val = expression.getValue(); op = expression.getOperator(); @@ -85,16 +84,16 @@ public CssTextDecorationSkip(ApplContext ac, CssExpression expression, boolean c getPropertyName(), ac); } - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { - value = inherit; + value = val; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } else if (none.equals(ident)) { - value = none; + value = val; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), @@ -104,13 +103,13 @@ public CssTextDecorationSkip(ApplContext ac, CssExpression expression, boolean c int nbgot = 0; do { if (edgValue == null && edges.equals(ident)) { - edgValue = edges; + edgValue = val; } else if (spaValue == null && spaces.equals(ident)) { - spaValue = spaces; + spaValue = val; } else if (inkValue == null && ink.equals(ident)) { - inkValue = ink; + inkValue = val; } else if (objValue == null && objects.equals(ident)) { - objValue = objects; + objValue = val; } else { throw new InvalidParamException("value", val.toString(), @@ -134,7 +133,7 @@ public CssTextDecorationSkip(ApplContext ac, CssExpression expression, boolean c val.toString(), getPropertyName(), ac); } - ident = (CssIdent) val; + ident = val.getIdent(); } while (!expression.end()); // now construct the value ArrayList v = new ArrayList(nbgot); diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkipBox.java b/org/w3c/css/properties/css3/CssTextDecorationSkipBox.java index de26d1ac0..99a21073c 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkipBox.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkipBox.java @@ -61,12 +61,12 @@ public CssTextDecorationSkipBox(ApplContext ac, CssExpression expression, boolea switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { value = inherit; break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingIdent(val.getIdent()) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkipInk.java b/org/w3c/css/properties/css3/CssTextDecorationSkipInk.java index 888d199d4..9c0323411 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkipInk.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkipInk.java @@ -61,12 +61,12 @@ public CssTextDecorationSkipInk(ApplContext ac, CssExpression expression, boolea switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingIdent(val.getIdent()) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkipInset.java b/org/w3c/css/properties/css3/CssTextDecorationSkipInset.java index 37a0656b5..e2136e9c7 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkipInset.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkipInset.java @@ -61,12 +61,12 @@ public CssTextDecorationSkipInset(ApplContext ac, CssExpression expression, bool switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingIdent(val.getIdent()) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkipSelf.java b/org/w3c/css/properties/css3/CssTextDecorationSkipSelf.java index 9c0d0cbf1..6f2036b98 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkipSelf.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkipSelf.java @@ -61,12 +61,12 @@ public CssTextDecorationSkipSelf(ApplContext ac, CssExpression expression, boole switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingIdent(val.getIdent()) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssTextDecorationSkipSpaces.java b/org/w3c/css/properties/css3/CssTextDecorationSkipSpaces.java index dfda55908..1edfd8752 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationSkipSpaces.java +++ b/org/w3c/css/properties/css3/CssTextDecorationSkipSpaces.java @@ -100,14 +100,14 @@ public CssTextDecorationSkipSpaces(ApplContext ac, CssExpression expression, boo val.toString(), getPropertyName(), ac); } - id = (CssIdent) val; + id = val.getIdent(); if (inherit.equals(id)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; } v = getSingleAllowedValue(id); @@ -117,7 +117,7 @@ public CssTextDecorationSkipSpaces(ApplContext ac, CssExpression expression, boo val.toString(), getPropertyName(), ac); } - values.add(v); + values.add(val); break; } v = getMultipleAllowedValue(id); @@ -126,7 +126,7 @@ public CssTextDecorationSkipSpaces(ApplContext ac, CssExpression expression, boo val.toString(), getPropertyName(), ac); } - values.add(v); + values.add(val); expression.next(); if (!expression.end() && (op != SPACE)) { diff --git a/org/w3c/css/properties/css3/CssTextDecorationStyle.java b/org/w3c/css/properties/css3/CssTextDecorationStyle.java index 79c12cb95..d2bb63412 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationStyle.java +++ b/org/w3c/css/properties/css3/CssTextDecorationStyle.java @@ -48,8 +48,7 @@ public CssTextDecorationStyle() { * Creates a new CssTextDecorationStyle * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextDecorationStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,16 +65,11 @@ public CssTextDecorationStyle(ApplContext ac, CssExpression expression, boolean 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; + CssIdent ident = val.getIdent(); + if (!inherit.equals(ident) && (getMatchingIdent(ident) == null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssTextDecorationThickness.java b/org/w3c/css/properties/css3/CssTextDecorationThickness.java index d40c07731..66a574c12 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationThickness.java +++ b/org/w3c/css/properties/css3/CssTextDecorationThickness.java @@ -68,20 +68,18 @@ public CssTextDecorationThickness(ApplContext ac, CssExpression expression, bool value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - } else { - val = getMatchingIdent((CssIdent) val); - if (val != null) { - value = val; - break; - } + if (inherit.equals(val.getIdent())) { + value = val; + break; + } + if (getMatchingIdent(val.getIdent()) != null) { + value = val; + break; } default: throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); - } expression.next(); } From 37305d0fa0ee6a4413a91f79b1d528a608ded12e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 6 Sep 2021 23:22:55 +0200 Subject: [PATCH 22/82] casting issue (cont) --- org/w3c/css/properties/css3/CssTabSize.java | 4 ++-- org/w3c/css/properties/css3/CssTableLayout.java | 8 ++++---- org/w3c/css/properties/css3/CssTextAlign.java | 13 ++++++------- org/w3c/css/properties/css3/CssTextAlignAll.java | 10 +++++----- org/w3c/css/properties/css3/CssTextAlignLast.java | 9 ++++----- .../css/properties/css3/CssTextCombineUpright.java | 6 +++--- org/w3c/css/properties/css3/CssTextEmphasis.java | 7 +++---- .../css/properties/css3/CssTextEmphasisColor.java | 9 ++++----- .../properties/css3/CssTextEmphasisPosition.java | 6 +++--- 9 files changed, 34 insertions(+), 38 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTabSize.java b/org/w3c/css/properties/css3/CssTabSize.java index 39d7d26be..6624165ee 100644 --- a/org/w3c/css/properties/css3/CssTabSize.java +++ b/org/w3c/css/properties/css3/CssTabSize.java @@ -52,8 +52,8 @@ public CssTabSize(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssTableLayout.java b/org/w3c/css/properties/css3/CssTableLayout.java index b8c9030c5..03b5d20a8 100644 --- a/org/w3c/css/properties/css3/CssTableLayout.java +++ b/org/w3c/css/properties/css3/CssTableLayout.java @@ -65,16 +65,16 @@ public CssTableLayout(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { - value = inherit; + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssTextAlign.java b/org/w3c/css/properties/css3/CssTextAlign.java index bbc2a91f7..98473bc71 100644 --- a/org/w3c/css/properties/css3/CssTextAlign.java +++ b/org/w3c/css/properties/css3/CssTextAlign.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-text-align + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-align */ public class CssTextAlign extends org.w3c.css.properties.css.CssTextAlign { @@ -49,8 +49,7 @@ public CssTextAlign() { * Creates a new CssTextAlign * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,15 +65,15 @@ public CssTextAlign(ApplContext ac, CssExpression expression, boolean check) expression.getValue(), getPropertyName(), ac); } - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { + if (getAllowedIdent(val.getIdent()) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } + value = val; } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssTextAlignAll.java b/org/w3c/css/properties/css3/CssTextAlignAll.java index d6627b28c..a093be878 100644 --- a/org/w3c/css/properties/css3/CssTextAlignAll.java +++ b/org/w3c/css/properties/css3/CssTextAlignAll.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-text-align-all + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-text-align-all */ public class CssTextAlignAll extends org.w3c.css.properties.css.CssTextAlignAll { @@ -65,15 +65,15 @@ public CssTextAlignAll(ApplContext ac, CssExpression expression, boolean check) expression.getValue(), getPropertyName(), ac); } - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { + if (getAllowedIdent(val.getIdent()) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } + value = val; } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssTextAlignLast.java b/org/w3c/css/properties/css3/CssTextAlignLast.java index 77e6f277d..9dd3c233b 100644 --- a/org/w3c/css/properties/css3/CssTextAlignLast.java +++ b/org/w3c/css/properties/css3/CssTextAlignLast.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-text-align-last + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#text-align-last-property */ public class CssTextAlignLast extends org.w3c.css.properties.css.CssTextAlignLast { @@ -68,11 +68,10 @@ public CssTextAlignLast(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(val.getIdent()) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssTextCombineUpright.java b/org/w3c/css/properties/css3/CssTextCombineUpright.java index 3d91f3fbd..afa7a8931 100644 --- a/org/w3c/css/properties/css3/CssTextCombineUpright.java +++ b/org/w3c/css/properties/css3/CssTextCombineUpright.java @@ -76,10 +76,10 @@ public CssTextCombineUpright(ApplContext ac, CssExpression expression, boolean c throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - if (val.equals(inherit)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { - value = getAllowedIdent((CssIdent) val); + value = getAllowedIdent(val.getIdent()); if (value == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssTextEmphasis.java b/org/w3c/css/properties/css3/CssTextEmphasis.java index 767f05e7a..ec3ed2328 100644 --- a/org/w3c/css/properties/css3/CssTextEmphasis.java +++ b/org/w3c/css/properties/css3/CssTextEmphasis.java @@ -36,8 +36,7 @@ public CssTextEmphasis() { * Creates a new CssTextEmphasis * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextEmphasis(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -64,13 +63,13 @@ public CssTextEmphasis(ApplContext ac, CssExpression expression, boolean check) expression.next(); break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - value = inherit; + value = val; expression.next(); return; } diff --git a/org/w3c/css/properties/css3/CssTextEmphasisColor.java b/org/w3c/css/properties/css3/CssTextEmphasisColor.java index 43887faf3..84a3596e5 100644 --- a/org/w3c/css/properties/css3/CssTextEmphasisColor.java +++ b/org/w3c/css/properties/css3/CssTextEmphasisColor.java @@ -26,8 +26,7 @@ public CssTextEmphasisColor() { * Creates a new CssTextEmphasisColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTextEmphasisColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -38,13 +37,13 @@ public CssTextEmphasisColor(ApplContext ac, CssExpression expression, boolean ch throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; expression.next(); } else { try { CssColor tcolor = new CssColor(ac, expression, check); - value = tcolor.color; + value = (tcolor.color != null) ? tcolor.color : tcolor.value; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssTextEmphasisPosition.java b/org/w3c/css/properties/css3/CssTextEmphasisPosition.java index 8815de92e..19a26ee60 100644 --- a/org/w3c/css/properties/css3/CssTextEmphasisPosition.java +++ b/org/w3c/css/properties/css3/CssTextEmphasisPosition.java @@ -102,9 +102,9 @@ public CssTextEmphasisPosition(ApplContext ac, CssExpression expression, boolean getPropertyName(), ac); } - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { - value = inherit; + value = val; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), @@ -146,7 +146,7 @@ public CssTextEmphasisPosition(ApplContext ac, CssExpression expression, boolean val.toString(), getPropertyName(), ac); } - ident = (CssIdent) val; + ident = val.getIdent(); } while (!expression.end()); // now construct the value if (hValue != null && vValue != null) { From 1eacc41c8afa85aa24e4618a77f725d39464b9c5 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 00:17:39 +0200 Subject: [PATCH 23/82] updated per https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-position --- .../css/properties/css3/CssRubyPosition.java | 68 +++++++++++++------ 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/org/w3c/css/properties/css3/CssRubyPosition.java b/org/w3c/css/properties/css3/CssRubyPosition.java index 7182b9217..37828c692 100644 --- a/org/w3c/css/properties/css3/CssRubyPosition.java +++ b/org/w3c/css/properties/css3/CssRubyPosition.java @@ -15,19 +15,24 @@ import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2014/WD-css-ruby-1-20140805/#propdef-ruby-position + * @spec https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-position */ public class CssRubyPosition extends org.w3c.css.properties.css.CssRubyPosition { public static final CssIdent[] allowed_values; - // Here we use the 9 November 2017 draft values - // https://github.com/w3c/csswg-drafts/blob/85d366602c156b1735da30d99b68f3fe0908ed60/css-ruby-1/Overview.bs + public static final CssIdent inter_char = CssIdent.getIdent("inter-character"); + public static final CssIdent alternate = CssIdent.getIdent("alternate"); static { - String[] _allowed_values = {"over", "under", "inter-character"}; + String[] _allowed_values = {"over", "under"}; allowed_values = new CssIdent[_allowed_values.length]; int i = 0; for (String s : _allowed_values) { @@ -55,34 +60,57 @@ public CssRubyPosition() { * Create new CssRubyPosition * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssRubyPosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { + CssValue val; + char op; + boolean gotAlt = false; + boolean gotLine = false; + ArrayList v = new ArrayList<>(); setByUser(); - CssValue val = expression.getValue(); - - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } - if (val.getType() != CssTypes.CSS_IDENT) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); - } - if (inherit.equals(val)) { - value = inherit; - } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } + CssIdent ident = val.getIdent(); + if (inherit.equals(ident) || inter_char.equals(ident)) { + // single values + if (expression.getCount() != 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + } else if (!gotAlt && alternate.equals(ident)) { + gotAlt = true; + v.add(val); + } else if (!gotLine && (getAllowedIdent(ident) != null)) { + gotLine = true; + v.add(val); + } else { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + expression.next(); + if (!expression.end() && (op != SPACE)) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + } + if (!v.isEmpty()) { + value = (v.size() == 1) ? v.get(0): new CssValueList(v); } - expression.next(); } From 0cf06af09276939438672a1a19131853eb3c245a Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 00:17:55 +0200 Subject: [PATCH 24/82] cast+ref --- org/w3c/css/properties/css3/CssRubyAlign.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/org/w3c/css/properties/css3/CssRubyAlign.java b/org/w3c/css/properties/css3/CssRubyAlign.java index 4ffc6b164..d5d47e9c4 100644 --- a/org/w3c/css/properties/css3/CssRubyAlign.java +++ b/org/w3c/css/properties/css3/CssRubyAlign.java @@ -17,7 +17,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2014/WD-css-ruby-1-20140805/#propdef-ruby-align + * @spec https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-align */ public class CssRubyAlign extends org.w3c.css.properties.css.CssRubyAlign { @@ -52,8 +52,7 @@ public CssRubyAlign() { * Create new CssRubyAlign * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssRubyAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,15 +68,15 @@ public CssRubyAlign(ApplContext ac, CssExpression expression, expression.getValue(), getPropertyName(), ac); } - if (inherit.equals(val)) { - value = inherit; + if (inherit.equals(val.getIdent())) { + value = val; } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { + if (getAllowedIdent(val.getIdent()) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } + value = val; } expression.next(); } From 165b8435c87d0b155de45fe6173a003733278c6a Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 00:20:19 +0200 Subject: [PATCH 25/82] updated per https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-merge --- org/w3c/css/properties/css3/CssRubyMerge.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/org/w3c/css/properties/css3/CssRubyMerge.java b/org/w3c/css/properties/css3/CssRubyMerge.java index c8706779c..53f8e0de4 100644 --- a/org/w3c/css/properties/css3/CssRubyMerge.java +++ b/org/w3c/css/properties/css3/CssRubyMerge.java @@ -14,14 +14,14 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2014/WD-css-ruby-1-20140805/#propdef-ruby-merge + * @spec https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-merge */ public class CssRubyMerge extends org.w3c.css.properties.css.CssRubyMerge { public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"separate", "collapse", "auto"}; + String[] _allowed_values = {"separate", "merge", "auto"}; allowed_values = new CssIdent[_allowed_values.length]; int i = 0; for (String s : _allowed_values) { @@ -49,8 +49,7 @@ public CssRubyMerge() { * Create new CssRubyMerge * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssRubyMerge(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -62,16 +61,16 @@ public CssRubyMerge(ApplContext ac, CssExpression expression, } if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { - value = inherit; + value = val; } else { - value = getAllowedIdent(ident); - if (value == null) { + if (getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", From 9057e1fc434f75828ced35df2ae32d9337c2bde0 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:18:48 +0200 Subject: [PATCH 26/82] rewrote entirely ruby-overhang per https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-overhang --- .../css/properties/css/CssRubyOverhang.java | 114 +++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 +- .../css/properties/css3/CssRubyOverhang.java | 155 +++++------------- 3 files changed, 160 insertions(+), 120 deletions(-) create mode 100644 org/w3c/css/properties/css/CssRubyOverhang.java diff --git a/org/w3c/css/properties/css/CssRubyOverhang.java b/org/w3c/css/properties/css/CssRubyOverhang.java new file mode 100644 index 000000000..5112325e5 --- /dev/null +++ b/org/w3c/css/properties/css/CssRubyOverhang.java @@ -0,0 +1,114 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssRubyOverhang extends CssProperty { + + + /** + * Create a new CssRubyOverhang + */ + public CssRubyOverhang() { + } + + /** + * Creates a new CssRubyOverhang + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssRubyOverhang(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssRubyOverhang(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 final String getPropertyName() { + return "ruby-overhang"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssRubyOverhang != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssRubyOverhang = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssRubyOverhang && + value.equals(((CssRubyOverhang) property).value)); + } + + + /** + * 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).getRubyOverhang(); + } else { + return ((Css3Style) style).cssRubyOverhang; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 11575db99..526bed53f 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -409,8 +409,8 @@ public class Css3Style extends ATSCStyle { public CssRubyPosition cssRubyPosition; public CssRubyAlign cssRubyAlign; public CssRubyMerge cssRubyMerge; - @Deprecated - CssRubyOverhang cssRubyOverhang; + public org.w3c.css.properties.css.CssRubyOverhang cssRubyOverhang; + public CssAlignmentBaseline cssAlignmentBaseline; public CssBaselineShift cssBaselineShift; public CssDominantBaseline cssDominantBaseline; @@ -2065,12 +2065,11 @@ public CssRubyMerge getRubyMerge() { return cssRubyMerge; } - @Deprecated - public CssRubyOverhang getRubyOverhang() { + public org.w3c.css.properties.css.CssRubyOverhang getRubyOverhang() { if (cssRubyOverhang == null) { cssRubyOverhang = - (CssRubyOverhang) style.CascadingOrder( - new CssRubyOverhang(), style, selector); + (org.w3c.css.properties.css.CssRubyOverhang) style.CascadingOrder( + new org.w3c.css.properties.css.CssRubyOverhang(), style, selector); } return cssRubyOverhang; } diff --git a/org/w3c/css/properties/css3/CssRubyOverhang.java b/org/w3c/css/properties/css3/CssRubyOverhang.java index 95f6a01c2..16f663879 100644 --- a/org/w3c/css/properties/css3/CssRubyOverhang.java +++ b/org/w3c/css/properties/css3/CssRubyOverhang.java @@ -1,47 +1,51 @@ // // $Id$ // From Sijtsche de Jong (sy.de.jong@let.rug.nl) +// Rewritten entirely 2021 by Yves Lafon // -// (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; /** - *

- * Value: auto || start || end || none || inherit
- * Initial:auto
- * Applies to:the parent of elements with display: ruby-text
- * Inherited:yes
- * Percentages:no
- * Media::visual - * @deprecated + * @spec https://www.w3.org/TR/2021/WD-css-ruby-1-20210310/#propdef-ruby-overhang */ -public class CssRubyOverhang extends CssProperty { +public class CssRubyOverhang extends org.w3c.css.properties.css.CssRubyOverhang { - CssValue rubyov; - ApplContext ac; + private static CssIdent[] allowed_values; - CssIdent auto = new CssIdent("auto"); - CssIdent start = new CssIdent("start"); - CssIdent end = new CssIdent("end"); - CssIdent none = new CssIdent("none"); + static { + String id_values[] = {"auto", "none"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } /** * Create a new CssRubyOverhang */ public CssRubyOverhang() { - rubyov = auto; + value = initial; } /** @@ -52,33 +56,27 @@ public CssRubyOverhang() { */ public CssRubyOverhang(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - + CssValue val; setByUser(); - ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); - - CssValue val = expression.getValue(); + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } - if (val.equals(auto)) { - rubyov = auto; - expression.next(); - } else if (val.equals(start)) { - rubyov = start; - expression.next(); - } else if (val.equals(end)) { - rubyov = end; - expression.next(); - } else if (val.equals(none)) { - rubyov = end; - expression.next(); - } else if (val.equals(inherit)) { - rubyov = inherit; - expression.next(); - } else { - throw new InvalidParamException("value", expression.getValue(), + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val, getPropertyName(), ac); + } + // ident, so inherit, or allowed value + CssIdent ident = val.getIdent(); + if (!inherit.equals(ident) && (getMatchingIdent(ident) == null)) { + throw new InvalidParamException("value", + expression.getValue(), getPropertyName(), ac); } - + value = val; + expression.next(); } public CssRubyOverhang(ApplContext ac, CssExpression expression) @@ -86,75 +84,4 @@ public CssRubyOverhang(ApplContext ac, CssExpression expression) this(ac, expression, false); } - /** - * Add this property to the CssStyle. - * - * @param style The CssStyle - */ - public void addToStyle(ApplContext ac, CssStyle style) { - if (((Css3Style) style).cssRubyOverhang != null) - style.addRedefinitionWarning(ac, this); - ((Css3Style) style).cssRubyOverhang = 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).getRubyOverhang(); - } else { - return ((Css3Style) style).cssRubyOverhang; - } - } - - /** - * Compares two properties for equality. - * - * @param value The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssRubyOverhang && - rubyov.equals(((CssRubyOverhang) property).rubyov)); - } - - /** - * Returns the name of this property - */ - public String getPropertyName() { - return "ruby-overhang"; - } - - /** - * Returns the value of this property - */ - public Object get() { - return rubyov; - } - - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return rubyov.equals(inherit); - } - - /** - * Returns a string representation of the object - */ - public String toString() { - return rubyov.toString(); - } - - /** - * Is the value of this property a default value - * It is used by all macro for the function print - */ - public boolean isDefault() { - return rubyov == auto; - } - } From 7f6f00e4cbac68a5776e60fab15baa8f81f2cdc0 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:19:17 +0200 Subject: [PATCH 27/82] cast+ref --- org/w3c/css/properties/css3/CssRubySpan.java | 1 + org/w3c/css/properties/css3/CssTextDecorationStyle.java | 1 + 2 files changed, 2 insertions(+) diff --git a/org/w3c/css/properties/css3/CssRubySpan.java b/org/w3c/css/properties/css3/CssRubySpan.java index 4ad9b8360..a85705a80 100644 --- a/org/w3c/css/properties/css3/CssRubySpan.java +++ b/org/w3c/css/properties/css3/CssRubySpan.java @@ -27,6 +27,7 @@ * Inherited:no
* Percentages:no
* Media::interactive + * @deprecated */ public class CssRubySpan extends CssProperty { diff --git a/org/w3c/css/properties/css3/CssTextDecorationStyle.java b/org/w3c/css/properties/css3/CssTextDecorationStyle.java index d2bb63412..8359da8c6 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationStyle.java +++ b/org/w3c/css/properties/css3/CssTextDecorationStyle.java @@ -71,6 +71,7 @@ public CssTextDecorationStyle(ApplContext ac, CssExpression expression, boolean expression.getValue(), getPropertyName(), ac); } + value = val; expression.next(); } From 4b9dfb7369d5c1ac250749209e21a18cb43b1e06 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:21:57 +0200 Subject: [PATCH 28/82] don't forget the value --- org/w3c/css/properties/css3/CssTransformBox.java | 1 + 1 file changed, 1 insertion(+) diff --git a/org/w3c/css/properties/css3/CssTransformBox.java b/org/w3c/css/properties/css3/CssTransformBox.java index 36523c77d..72b15f9de 100644 --- a/org/w3c/css/properties/css3/CssTransformBox.java +++ b/org/w3c/css/properties/css3/CssTransformBox.java @@ -90,6 +90,7 @@ public CssTransformBox(ApplContext ac, CssExpression expression, val.toString(), getPropertyName(), ac); } + value = val; expression.next(); } From f42b36b504e255ce2dec0226af72debd0de23300 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:28:18 +0200 Subject: [PATCH 29/82] cast+ref --- org/w3c/css/properties/css3/CssSpeak.java | 8 +++---- org/w3c/css/properties/css3/CssSpeakAs.java | 23 ++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/org/w3c/css/properties/css3/CssSpeak.java b/org/w3c/css/properties/css3/CssSpeak.java index ea921c32b..9f995f33e 100644 --- a/org/w3c/css/properties/css3/CssSpeak.java +++ b/org/w3c/css/properties/css3/CssSpeak.java @@ -65,13 +65,13 @@ public CssSpeak(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { - value = inherit; + value = val; break; } else { - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } } diff --git a/org/w3c/css/properties/css3/CssSpeakAs.java b/org/w3c/css/properties/css3/CssSpeakAs.java index 086968b20..bc94ac0d0 100644 --- a/org/w3c/css/properties/css3/CssSpeakAs.java +++ b/org/w3c/css/properties/css3/CssSpeakAs.java @@ -59,8 +59,7 @@ public CssSpeakAs() { * Creates a new CssSpeakAs * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeakAs(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -81,39 +80,39 @@ public CssSpeakAs(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; break; } if (normal.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = normal; + value = val; break; } if (spellVal == null) { if (spell_out.equals(id)) { - spellVal = id; - value = id; + spellVal = val; + value = val; break; } } if (digitVal == null) { if (digits.equals(id)) { - digitVal = digits; - value = id; + digitVal = val; + value = val; break; } } if (punctVal == null) { - punctVal = getPunctuation(id); - if (punctVal != null) { - value = id; + if (getPunctuation(id) != null) { + punctVal = val; + value = val; break; } } From c0cee835ba7ca966a61437cfaf04b8354b50e60d Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:28:30 +0200 Subject: [PATCH 30/82] cast+ref (on deprecated classes) --- org/w3c/css/properties/css3/CssSpeakHeader.java | 5 ++--- org/w3c/css/properties/css3/CssSpeakNumeral.java | 5 ++--- org/w3c/css/properties/css3/CssSpeakPunctuation.java | 5 ++--- org/w3c/css/properties/css3/CssSpeechRate.java | 5 ++--- org/w3c/css/properties/css3/CssStress.java | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/org/w3c/css/properties/css3/CssSpeakHeader.java b/org/w3c/css/properties/css3/CssSpeakHeader.java index 4ac3883ca..54616ed4c 100644 --- a/org/w3c/css/properties/css3/CssSpeakHeader.java +++ b/org/w3c/css/properties/css3/CssSpeakHeader.java @@ -49,8 +49,7 @@ public CssSpeakHeader() { * Creates a new CssSpeakHeader * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeakHeader(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,7 +68,7 @@ public CssSpeakHeader(ApplContext ac, CssExpression expression, boolean check) ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { value = inherit; } else { diff --git a/org/w3c/css/properties/css3/CssSpeakNumeral.java b/org/w3c/css/properties/css3/CssSpeakNumeral.java index 69322b03c..afbb66811 100644 --- a/org/w3c/css/properties/css3/CssSpeakNumeral.java +++ b/org/w3c/css/properties/css3/CssSpeakNumeral.java @@ -49,8 +49,7 @@ public CssSpeakNumeral() { * Creates a new CssSpeakNumeral * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeakNumeral(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,7 +68,7 @@ public CssSpeakNumeral(ApplContext ac, CssExpression expression, boolean check) ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { value = inherit; } else { diff --git a/org/w3c/css/properties/css3/CssSpeakPunctuation.java b/org/w3c/css/properties/css3/CssSpeakPunctuation.java index e4b57f02f..bdedb0db1 100644 --- a/org/w3c/css/properties/css3/CssSpeakPunctuation.java +++ b/org/w3c/css/properties/css3/CssSpeakPunctuation.java @@ -49,8 +49,7 @@ public CssSpeakPunctuation() { * Creates a new CssSpeakPunctuation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeakPunctuation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,7 +68,7 @@ public CssSpeakPunctuation(ApplContext ac, CssExpression expression, boolean che ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { value = inherit; } else { diff --git a/org/w3c/css/properties/css3/CssSpeechRate.java b/org/w3c/css/properties/css3/CssSpeechRate.java index 4d1884be5..2b18d067b 100644 --- a/org/w3c/css/properties/css3/CssSpeechRate.java +++ b/org/w3c/css/properties/css3/CssSpeechRate.java @@ -51,8 +51,7 @@ public CssSpeechRate() { * Creates a new CssSpeechRate * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSpeechRate(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -77,7 +76,7 @@ public CssSpeechRate(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (inherit.equals(id)) { value = inherit; break; diff --git a/org/w3c/css/properties/css3/CssStress.java b/org/w3c/css/properties/css3/CssStress.java index 821526431..7e75d4614 100644 --- a/org/w3c/css/properties/css3/CssStress.java +++ b/org/w3c/css/properties/css3/CssStress.java @@ -56,7 +56,7 @@ public CssStress(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { value = inherit; break; } From 0693abf1e6fb5daa10ac24ecc0dd5745c7962953 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 10:49:02 +0200 Subject: [PATCH 31/82] cast+ref --- .../properties/css3/CssCounterIncrement.java | 24 +++++++++++-------- .../css/properties/css3/CssCounterReset.java | 19 +++++++++------ .../css/properties/css3/CssCounterSet.java | 23 +++++++++++------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/org/w3c/css/properties/css3/CssCounterIncrement.java b/org/w3c/css/properties/css3/CssCounterIncrement.java index cec84b774..e98e1dc32 100644 --- a/org/w3c/css/properties/css3/CssCounterIncrement.java +++ b/org/w3c/css/properties/css3/CssCounterIncrement.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-counter-increment + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-counter-increment */ public class CssCounterIncrement extends org.w3c.css.properties.css.CssCounterIncrement { @@ -34,8 +34,7 @@ public CssCounterIncrement() { * Creates a new CssCounterIncrement * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssCounterIncrement(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -51,16 +50,17 @@ public CssCounterIncrement(ApplContext ac, CssExpression expression, boolean che op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent id = val.getIdent(); + if (inherit.equals(id)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } break; } - if (none.equals(val)) { - value = none; + if (none.equals(id)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -68,9 +68,13 @@ public CssCounterIncrement(ApplContext ac, CssExpression expression, boolean che break; } // check for reserved keyword - if (CssIdent.isCssWide((CssIdent) val)) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); + if (CssIdent.isCssWide(id)) { + value = val; + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + break; } v.add(val); intallowed = true; diff --git a/org/w3c/css/properties/css3/CssCounterReset.java b/org/w3c/css/properties/css3/CssCounterReset.java index 3a682543e..bb8a05857 100644 --- a/org/w3c/css/properties/css3/CssCounterReset.java +++ b/org/w3c/css/properties/css3/CssCounterReset.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-counter-reset + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-counter-reset */ public class CssCounterReset extends org.w3c.css.properties.css.CssCounterReset { @@ -51,8 +51,9 @@ public CssCounterReset(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent id = val.getIdent(); + if (inherit.equals(id)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -60,7 +61,7 @@ public CssCounterReset(ApplContext ac, CssExpression expression, boolean check) break; } if (none.equals(val)) { - value = none; + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -68,9 +69,13 @@ public CssCounterReset(ApplContext ac, CssExpression expression, boolean check) break; } // check for reserved keyword - if (CssIdent.isCssWide((CssIdent) val)) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); + if (CssIdent.isCssWide(id)) { + value = val; + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + break; } v.add(val); intallowed = true; diff --git a/org/w3c/css/properties/css3/CssCounterSet.java b/org/w3c/css/properties/css3/CssCounterSet.java index c6bbccbe2..883809bb4 100644 --- a/org/w3c/css/properties/css3/CssCounterSet.java +++ b/org/w3c/css/properties/css3/CssCounterSet.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-counter-set + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-counter-set */ public class CssCounterSet extends org.w3c.css.properties.css.CssCounterSet { @@ -51,26 +51,31 @@ public CssCounterSet(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent id = val.getIdent(); + if (inherit.equals(id)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } break; } - if (none.equals(val)) { - value = none; + if (none.equals(id)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } break; } - // check for reserved keyword - if (CssIdent.isCssWide((CssIdent) val)) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); + // check for reserved keyword FIXME this should replace inherit check? + if (CssIdent.isCssWide(id)) { + value = val; + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + break; } v.add(val); intallowed = true; From 1ebfe9cfdaf2251c5f16a06e8e1ae42eb10fbf13 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 13:57:27 +0200 Subject: [PATCH 32/82] fix equality when 2nd val is null --- org/w3c/css/values/CssCalc.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/values/CssCalc.java b/org/w3c/css/values/CssCalc.java index 03dd21e5d..e2fb45c51 100644 --- a/org/w3c/css/values/CssCalc.java +++ b/org/w3c/css/values/CssCalc.java @@ -330,9 +330,22 @@ public boolean isZero() { * @param value The other value. */ public boolean equals(Object value) { - return (value instanceof CssCalc && - this.val1.equals(((CssCalc) value).val1) && - this.val2.equals(((CssCalc) value).val2)); + if (value instanceof CssCalc) { + CssCalc c = (CssCalc) value; + if (this.val1 != null && !this.val1.equals(c.val1)) { + return false; + } else if ((this.val1 == null) && (c.val1 != null)) { + return false; + } + // val1 and c.val2 are equal even if null + if (this.val2 != null && !this.val2.equals(c.val2)) { + return false; + } else if ((this.val2 == null) && (c.val2 != null)) { + return false; + } + return true; + } + return false; } /** From fa5b752ff654860a7a2723579685488dc7f64b2b Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 7 Sep 2021 21:28:02 +0200 Subject: [PATCH 33/82] redid content per https://www.w3.org/TR/2019/WD-css-content-3-20190802/#propdef-content --- org/w3c/css/properties/css3/CssContent.java | 496 ++++++++++++++++---- 1 file changed, 408 insertions(+), 88 deletions(-) diff --git a/org/w3c/css/properties/css3/CssContent.java b/org/w3c/css/properties/css3/CssContent.java index 96575508a..39b8baa8a 100644 --- a/org/w3c/css/properties/css3/CssContent.java +++ b/org/w3c/css/properties/css3/CssContent.java @@ -21,24 +21,58 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2011/REC-CSS2-20110607/generate.html#content + * @spec https://www.w3.org/TR/2019/WD-css-content-3-20190802/#propdef-content */ public class CssContent extends org.w3c.css.properties.css.CssContent { private static CssIdent normal = CssIdent.getIdent("normal"); - protected static CssIdent[] allowed_values; + private static CssIdent contents = CssIdent.getIdent("contents"); + protected static CssIdent[] allowed_quote_values, allowed_target_text_values; + protected static CssIdent[] allowed_leader_values; static { String[] _allowed_values = {"open-quote", "close-quote", "no-open-quote", "no-close-quote"}; int i = 0; - allowed_values = new CssIdent[_allowed_values.length]; + allowed_quote_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { - allowed_values[i++] = CssIdent.getIdent(s); + allowed_quote_values[i++] = CssIdent.getIdent(s); } + + String[] _target_text = {"content", "before", "after", "first-letter"}; + i = 0; + allowed_target_text_values = new CssIdent[_target_text.length]; + for (String s : _target_text) { + allowed_target_text_values[i++] = CssIdent.getIdent(s); + } + + String[] _leader = {"dotted", "solid", "space"}; + i = 0; + allowed_leader_values = new CssIdent[_leader.length]; + for (String s : _leader) { + allowed_leader_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingQuoteIdent(CssIdent ident) { + for (CssIdent id : allowed_quote_values) { + if (id.equals(ident)) { + return id; + } + } + return null; } - public static CssIdent getMatchingIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { + public static CssIdent getTargetTextIdent(CssIdent ident) { + for (CssIdent id : allowed_target_text_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getLeaderIdent(CssIdent ident) { + for (CssIdent id : allowed_leader_values) { if (id.equals(ident)) { return id; } @@ -57,8 +91,7 @@ public CssContent() { * Creates a new CssContent * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssContent(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -68,52 +101,84 @@ public CssContent(ApplContext ac, CssExpression expression, boolean check) values = new ArrayList<>(); CssValue val; char op; + boolean gotSlash = false; - while (!expression.end()) { + while (!gotSlash && !expression.end()) { val = expression.getValue(); op = expression.getOperator(); switch (val.getType()) { + case CssTypes.CSS_SWITCH: + gotSlash = true; + values.add(val); + break; + case CssTypes.CSS_IMAGE: case CssTypes.CSS_STRING: case CssTypes.CSS_URL: values.add(val); break; case CssTypes.CSS_FUNCTION: - checkCounterFunction(ac, this, val); + CssFunction f = (CssFunction) val; + switch (f.getName()) { + case "counter": + checkCounterFunction(ac, f, this); + break; + case "counters": + checkCountersFunction(ac, f, this); + break; + case "target-counter": + checkTargetCounterFunction(ac, f, this); + break; + case "target-counters": + checkTargetCountersFunction(ac, f, this); + break; + case "target-text": + checkTargetTextFunction(ac, f, this); + break; + case "leader": + checkLeaderFunction(ac, f, this); + break; + default: + throw new InvalidParamException("value", + val, getPropertyName(), ac); + } values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - values.add(inherit); + CssIdent id = val.getIdent(); + if (inherit.equals(id)) { + values.add(val); if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } break; } - if (normal.equals(val)) { - values.add(normal); + if (normal.equals(id)) { + values.add(val); if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } break; } - if (none.equals(val)) { - values.add(none); + if (none.equals(id)) { + values.add(val); if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingQuoteIdent(id) != null) { + values.add(val); + break; + } + if (contents.equals(id)) { values.add(val); break; } // if not recognized... it can be a color. default: throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); + val, getPropertyName(), ac); } if ((op != SPACE)) { @@ -122,92 +187,347 @@ public CssContent(ApplContext ac, CssExpression expression, boolean check) } expression.next(); } + if (gotSlash) { + boolean gotOne = false; + // second part of parsing + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_FUNCTION: + CssFunction f = (CssFunction) val; + switch (f.getName()) { + case "counter": + checkCounterFunction(ac, f, this); + break; + case "counters": + checkCountersFunction(ac, f, this); + break; + default: + throw new InvalidParamException("value", + val, getPropertyName(), ac); + } + values.add(val); + break; + case CssTypes.CSS_STRING: + values.add(val); + break; + } + gotOne = true; + if ((op != SPACE)) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + expression.next(); + } + if (!gotOne) { + throw new InvalidParamException("unrecognize", ac); + } + } value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } - // check the value of counter and counters function - // per https://www.w3.org/TR/2011/REC-CSS2-20110607/syndata.html#value-def-counter + // check the value of counter function protected static void checkCounterFunction(ApplContext ac, - CssProperty property, - CssValue function) + CssFunction function, CssProperty property) throws InvalidParamException { CssExpression exp; char op; CssValue v; - CssFunction f = (CssFunction) function; - - switch (f.getName()) { - case "counter": - exp = f.getParameters(); - // must be counter(name [,style?]) - if (exp.getCount() > 2) { - throw new InvalidParamException("unrecognize", ac); - } - v = exp.getValue(); - op = exp.getOperator(); - if (v.getType() != CssTypes.CSS_IDENT) { - throw new InvalidParamException("value", v, - property.getPropertyName(), ac); - } - exp.next(); - if (!exp.end()) { - // we have another item, it must be an ident matching list-style-type. - if (op != COMMA) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - v = exp.getValue(); - if (v.getType() == CssTypes.CSS_IDENT) { - if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { - throw new InvalidParamException("value", v, - property.getPropertyName(), ac); - } - } - } - break; - case "counters": - exp = f.getParameters(); - // must be counter(name string[,style?]) - if (exp.getCount() < 2 || exp.getCount() > 3) { - throw new InvalidParamException("unrecognize", ac); - } - v = exp.getValue(); - op = exp.getOperator(); - if (v.getType() != CssTypes.CSS_IDENT) { + + if (!function.getName().equals("counter")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + // must be counter(name [,style?]) + if (exp.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + if (!exp.end()) { + // we have another item, it must be an ident matching list-style-type. + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + if (v.getType() == CssTypes.CSS_IDENT) { + if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { throw new InvalidParamException("value", v, property.getPropertyName(), ac); } - exp.next(); - if (op != COMMA) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - v = exp.getValue(); - op = exp.getOperator(); - if (v.getType() != CssTypes.CSS_STRING) { + } + } + } + + // check the value of counters function + protected static void checkCountersFunction(ApplContext ac, + CssFunction function, CssProperty property) + throws InvalidParamException { + CssExpression exp; + char op; + CssValue v; + + if (!function.getName().equals("counters")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + // must be counter(name string[,style?]) + if (exp.getCount() < 2 || exp.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_STRING) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + if (!exp.end()) { + // we have another item, it must be an ident matching list-style-type. + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + if (v.getType() == CssTypes.CSS_IDENT) { + if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { throw new InvalidParamException("value", v, property.getPropertyName(), ac); } - exp.next(); - if (!exp.end()) { - // we have another item, it must be an ident matching list-style-type. - if (op != COMMA) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - v = exp.getValue(); - if (v.getType() == CssTypes.CSS_IDENT) { - if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { - throw new InvalidParamException("value", v, - property.getPropertyName(), ac); - } - } - } + } + } + + } + + // https://www.w3.org/TR/2019/WD-css-content-3-20190802/#funcdef-target-counter + protected static void checkTargetCounterFunction(ApplContext ac, + CssFunction function, CssProperty property) + throws InvalidParamException { + CssExpression exp; + char op; + CssValue v; + + if (!function.getName().equals("target-counter")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + if (exp.getCount() < 2 || exp.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + switch (v.getType()) { + case CssTypes.CSS_URL: + case CssTypes.CSS_STRING: + break; + default: + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + exp.next(); + + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (CssIdent.isCssWide(v.getIdent())) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + if (!exp.end()) { + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + CssExpression e = new CssExpression(); + e.addValue(v); + try { + CssListStyleType listStyleType = new CssListStyleType(ac, e, false); + } catch (Exception ex) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + } + } + + // https://www.w3.org/TR/2019/WD-css-content-3-20190802/#funcdef-target-counters + protected static void checkTargetCountersFunction(ApplContext ac, + CssFunction function, CssProperty property) + throws InvalidParamException { + CssExpression exp; + char op; + CssValue v; + + if (!function.getName().equals("target-counters")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + if (exp.getCount() < 3 || exp.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + switch (v.getType()) { + case CssTypes.CSS_URL: + case CssTypes.CSS_STRING: + break; + default: + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + exp.next(); + + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (CssIdent.isCssWide(v.getIdent())) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + exp.next(); + + v = exp.getValue(); + op = exp.getOperator(); + if (v.getType() != CssTypes.CSS_STRING) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + + if (!exp.end()) { + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + CssExpression e = new CssExpression(); + e.addValue(v); + try { + CssListStyleType listStyleType = new CssListStyleType(ac, e, false); + } catch (Exception ex) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + } + } + + // https://www.w3.org/TR/2019/WD-css-content-3-20190802/#funcdef-target-text + protected static void checkTargetTextFunction(ApplContext ac, + CssFunction function, CssProperty property) + throws InvalidParamException { + CssExpression exp; + char op; + CssValue v; + + if (!function.getName().equals("target-text")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + if (exp.getCount() < 1 || exp.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + switch (v.getType()) { + case CssTypes.CSS_URL: + case CssTypes.CSS_STRING: break; default: - throw new InvalidParamException("value", function, + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + exp.next(); + + if (!exp.end()) { + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + v = exp.getValue(); + if (v.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + if (getTargetTextIdent(v.getIdent()) == null) { + throw new InvalidParamException("value", v, + property.getPropertyName(), ac); + } + } + } + + // https://www.w3.org/TR/2019/WD-css-content-3-20190802/#funcdef-target-text + protected static void checkLeaderFunction(ApplContext ac, + CssFunction function, CssProperty property) + throws InvalidParamException { + CssExpression exp; + char op; + CssValue v; + + if (!function.getName().equals("leader")) { + throw new InvalidParamException("unrecognize", ac); + } + + exp = function.getParameters(); + if (exp.getCount() != 1) { + throw new InvalidParamException("unrecognize", ac); + } + v = exp.getValue(); + op = exp.getOperator(); + switch (v.getType()) { + case CssTypes.CSS_STRING: + break; + case CssTypes.CSS_IDENT: + if (getLeaderIdent(v.getIdent()) != null) { + break; + } + default: + throw new InvalidParamException("value", v, property.getPropertyName(), ac); } + exp.next(); } public CssContent(ApplContext ac, CssExpression expression) From f9d8c09a20f45c9c183d098ec29f887503f2a5d3 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 10:15:44 +0200 Subject: [PATCH 34/82] cast+ref --- .../properties/css3/CssScrollBehavior.java | 12 ++++---- .../properties/css3/CssScrollSnapAlign.java | 26 ++++++++--------- .../properties/css3/CssScrollSnapStop.java | 15 +++++----- .../properties/css3/CssScrollSnapType.java | 29 ++++++++----------- 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/org/w3c/css/properties/css3/CssScrollBehavior.java b/org/w3c/css/properties/css3/CssScrollBehavior.java index 700acdccb..010d7b44a 100644 --- a/org/w3c/css/properties/css3/CssScrollBehavior.java +++ b/org/w3c/css/properties/css3/CssScrollBehavior.java @@ -54,7 +54,7 @@ public CssScrollBehavior() { * @throws InvalidParamException Incorrect value */ public CssScrollBehavior(ApplContext ac, CssExpression expression, - boolean check) throws InvalidParamException { + boolean check) throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); @@ -67,15 +67,15 @@ public CssScrollBehavior(ApplContext ac, CssExpression expression, val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssScrollSnapAlign.java b/org/w3c/css/properties/css3/CssScrollSnapAlign.java index 13898e715..b1635d7c8 100644 --- a/org/w3c/css/properties/css3/CssScrollSnapAlign.java +++ b/org/w3c/css/properties/css3/CssScrollSnapAlign.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/#propdef-scroll-snap-align + * @spec https://www.w3.org/TR/2021/CR-css-scroll-snap-1-20210311/#scroll-snap-align */ public class CssScrollSnapAlign extends org.w3c.css.properties.css.CssScrollSnapAlign { @@ -70,13 +70,16 @@ public CssScrollSnapAlign(ApplContext ac, CssExpression expression, boolean chec switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - values.add(inherit); + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + values.add(val); break; } - CssIdent ident = getMatchingIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getMatchingIdent(ident) != null) { + values.add(val); break; } // unrecognized... fail. @@ -94,13 +97,10 @@ public CssScrollSnapAlign(ApplContext ac, CssExpression expression, boolean chec val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - values.add(inherit); - break; - } - CssIdent ident = getMatchingIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + CssIdent ident = val.getIdent(); + // can't have inherit second, so don't test for it + if (getMatchingIdent(ident) != null) { + values.add(val); break; } // unrecognized... fail. diff --git a/org/w3c/css/properties/css3/CssScrollSnapStop.java b/org/w3c/css/properties/css3/CssScrollSnapStop.java index f0b34eeef..7ebc999f4 100644 --- a/org/w3c/css/properties/css3/CssScrollSnapStop.java +++ b/org/w3c/css/properties/css3/CssScrollSnapStop.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/#propdef-scroll-snap-stop + * @spec https://www.w3.org/TR/2021/CR-css-scroll-snap-1-20210311/#propdef-scroll-snap-stop */ public class CssScrollSnapStop extends org.w3c.css.properties.css.CssScrollSnapStop { @@ -48,8 +48,7 @@ public CssScrollSnapStop() { * Creates a new CssScrollSnapStop * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssScrollSnapStop(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -62,13 +61,13 @@ public CssScrollSnapStop(ApplContext ac, CssExpression expression, boolean check switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; break; } - CssIdent ident = getMatchingIdent((CssIdent) val); - if (ident != null) { - value = ident; + if (getMatchingIdent(ident) != null) { + value = val; break; } // unrecognized... fail. diff --git a/org/w3c/css/properties/css3/CssScrollSnapType.java b/org/w3c/css/properties/css3/CssScrollSnapType.java index 08b6c9e4e..6bd5ad241 100644 --- a/org/w3c/css/properties/css3/CssScrollSnapType.java +++ b/org/w3c/css/properties/css3/CssScrollSnapType.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2019/CR-css-scroll-snap-1-20190319/#propdef-scroll-snap-type + * @spec https://www.w3.org/TR/2021/CR-css-scroll-snap-1-20210311/#propdef-scroll-snap-type */ public class CssScrollSnapType extends org.w3c.css.properties.css.CssScrollSnapType { @@ -69,8 +69,7 @@ public CssScrollSnapType() { * Creates a new CssScrollSnapType * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssScrollSnapType(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -86,28 +85,28 @@ public CssScrollSnapType(ApplContext ac, CssExpression expression, boolean check switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; } // 'none' is a strictness value, but can only appear alone - if (none.equals(val)) { + if (none.equals(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(none); + values.add(val); break; } - CssIdent ident = getMatchingAxisIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getMatchingAxisIdent(ident) != null) { + values.add(val); break; } // unrecognized... fail. @@ -125,13 +124,9 @@ public CssScrollSnapType(ApplContext ac, CssExpression expression, boolean check val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - values.add(inherit); - break; - } - CssIdent ident = getMatchingStrictnesssIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + CssIdent ident = val.getIdent(); + if (getMatchingStrictnesssIdent(ident) != null) { + values.add(val); break; } // unrecognized... fail. From 153f3698fa43d267aabb5dd96736da2b21ea963b Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 10:30:38 +0200 Subject: [PATCH 35/82] refs+cast + added 'text' value as obsolete from webcompat spec --- .../properties/css3/CssBackgroundClip.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBackgroundClip.java b/org/w3c/css/properties/css3/CssBackgroundClip.java index 8e9056870..95ef850f8 100644 --- a/org/w3c/css/properties/css3/CssBackgroundClip.java +++ b/org/w3c/css/properties/css3/CssBackgroundClip.java @@ -20,16 +20,19 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2011/CR-css3-background-20110215/#the-background-clip + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-clip + * @spec https://compat.spec.whatwg.org/#the-webkit-background-clip-property */ public class CssBackgroundClip extends org.w3c.css.properties.css.CssBackgroundClip { public final static CssIdent border_box; public static CssIdent[] allowed_values; - public final static String val[] = {"border-box", "padding-box", "content-box"}; + // from https://compat.spec.whatwg.org/#the-webkit-background-clip-property + public static final CssIdent text = CssIdent.getIdent("text"); static { + String val[] = {"border-box", "padding-box", "content-box"}; border_box = CssIdent.getIdent("border-box"); allowed_values = new CssIdent[val.length]; int i = 0; @@ -72,7 +75,6 @@ public CssBackgroundClip(ApplContext ac, CssExpression expression, ArrayList values = new ArrayList(); CssValue val; - CssIdent matchingIdent; char op; while (!expression.end()) { @@ -80,19 +82,24 @@ public CssBackgroundClip(ApplContext ac, CssExpression expression, op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; } - matchingIdent = getMatchingIdent((CssIdent) val); - if (matchingIdent != null) { - values.add(matchingIdent); + if (getMatchingIdent(ident) != null) { + values.add(val); + break; + } + if (text.equals(ident)) { + ac.getFrame().addWarning("deprecated", val.toString()); + values.add(val); break; } default: From 5a65845bf9d1826b543da0101eed48679edd5e10 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 10:50:08 +0200 Subject: [PATCH 36/82] typo in test --- org/w3c/css/properties/css3/CssUnicodeBidi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssUnicodeBidi.java b/org/w3c/css/properties/css3/CssUnicodeBidi.java index 37c95a9fa..64e9caeb4 100644 --- a/org/w3c/css/properties/css3/CssUnicodeBidi.java +++ b/org/w3c/css/properties/css3/CssUnicodeBidi.java @@ -70,7 +70,7 @@ public CssUnicodeBidi(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } CssIdent id = val.getIdent(); - if (!inherit.equals(id) || (getAllowedIdent(id) == null)) { + if (!inherit.equals(id) && (getAllowedIdent(id) == null)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); From b06bfa3a17ddd49946026a314ccdc6d5106d5868 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 10:59:43 +0200 Subject: [PATCH 37/82] getting ident without testing type first is not right --- org/w3c/css/properties/css3/CssTextDecorationColor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTextDecorationColor.java b/org/w3c/css/properties/css3/CssTextDecorationColor.java index 16685c177..20f43c945 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationColor.java +++ b/org/w3c/css/properties/css3/CssTextDecorationColor.java @@ -8,6 +8,8 @@ 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; /** @@ -37,7 +39,7 @@ public CssTextDecorationColor(ApplContext ac, CssExpression expression, boolean throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val.getIdent())) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { value = val; expression.next(); } else { From 018565f198752d1283d80e917600266904c30fd0 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 11:02:07 +0200 Subject: [PATCH 38/82] same as b06bfa3a17ddd49946026a314ccdc6d5106d5868 --- org/w3c/css/properties/css3/CssTextEmphasisColor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTextEmphasisColor.java b/org/w3c/css/properties/css3/CssTextEmphasisColor.java index 84a3596e5..5a7546135 100644 --- a/org/w3c/css/properties/css3/CssTextEmphasisColor.java +++ b/org/w3c/css/properties/css3/CssTextEmphasisColor.java @@ -8,6 +8,8 @@ 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; /** @@ -37,7 +39,7 @@ public CssTextEmphasisColor(ApplContext ac, CssExpression expression, boolean ch throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val.getIdent())) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { value = val; expression.next(); } else { From 905f675e1ccc4b693c565bd611205e98f98a8c08 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 11:18:36 +0200 Subject: [PATCH 39/82] cast (cont) --- org/w3c/css/properties/css3/CssTransformOrigin.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTransformOrigin.java b/org/w3c/css/properties/css3/CssTransformOrigin.java index b175fe32f..6094d448a 100644 --- a/org/w3c/css/properties/css3/CssTransformOrigin.java +++ b/org/w3c/css/properties/css3/CssTransformOrigin.java @@ -67,8 +67,7 @@ public CssTransformOrigin() { * Creates a new CssTransformOrigin * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssTransformOrigin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -89,7 +88,7 @@ public CssTransformOrigin(ApplContext ac, CssExpression expression, val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -145,7 +144,7 @@ private void check(ArrayList values, ApplContext ac) boolean got_vertical = false; CssValue v = values.get(0); if (v.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) v; + CssIdent id = v.getIdent(); // strictly horizontal or vertical got_horizontal = isHorizontalIdent(id); if (!got_horizontal) { @@ -154,7 +153,7 @@ private void check(ArrayList values, ApplContext ac) } v = values.get(1); if (v.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) v; + CssIdent id = v.getIdent(); // yeah, it can be a single ugly test. if (got_horizontal && isHorizontalIdent(id)) { throw new InvalidParamException("value", id, From 3be827a52c24733e36ec3decd8de80eeb69df0cb Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 11:34:18 +0200 Subject: [PATCH 40/82] use original value --- org/w3c/css/properties/css3/CssTransformOrigin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTransformOrigin.java b/org/w3c/css/properties/css3/CssTransformOrigin.java index 6094d448a..8887e609f 100644 --- a/org/w3c/css/properties/css3/CssTransformOrigin.java +++ b/org/w3c/css/properties/css3/CssTransformOrigin.java @@ -93,7 +93,7 @@ public CssTransformOrigin(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val, getPropertyName(), ac); } - value = inherit; + value = val; expression.next(); return; } From a5f7863bb83cdebbc2673ac75da14042aafe6e7e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 12:37:02 +0200 Subject: [PATCH 41/82] cast (cont) --- org/w3c/css/properties/css3/CssOrder.java | 5 ++-- org/w3c/css/properties/css3/CssOrphans.java | 13 ++++----- org/w3c/css/properties/css3/CssPause.java | 18 ++++++------ org/w3c/css/properties/css3/CssPitch.java | 10 +++---- .../css/properties/css3/CssPlayDuring.java | 10 +++---- org/w3c/css/properties/css3/CssPosition.java | 28 +++++++++---------- org/w3c/css/properties/css3/CssQuotes.java | 15 ++++++---- org/w3c/css/properties/css3/CssResize.java | 20 ++++++------- org/w3c/css/properties/css3/CssRest.java | 23 ++++++++------- 9 files changed, 68 insertions(+), 74 deletions(-) diff --git a/org/w3c/css/properties/css3/CssOrder.java b/org/w3c/css/properties/css3/CssOrder.java index 9e64b8c74..8d4b1e32f 100644 --- a/org/w3c/css/properties/css3/CssOrder.java +++ b/org/w3c/css/properties/css3/CssOrder.java @@ -52,9 +52,8 @@ public CssOrder(ApplContext ac, CssExpression expression, boolean check) value = num; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } // let it flow diff --git a/org/w3c/css/properties/css3/CssOrphans.java b/org/w3c/css/properties/css3/CssOrphans.java index 4bc2cf57c..0bc372f56 100644 --- a/org/w3c/css/properties/css3/CssOrphans.java +++ b/org/w3c/css/properties/css3/CssOrphans.java @@ -16,7 +16,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/CR-css-break-3-20181204/#propdef-break-inside + * @spec https://www.w3.org/TR/2018/CR-css-break-3-20181204/#propdef-orphans */ public class CssOrphans extends org.w3c.css.properties.css.CssOrphans { @@ -35,8 +35,7 @@ public CssOrphans() { * @param ac The context * @param expression The expression for this property * @param check true will test the number of parameters - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssOrphans(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -56,9 +55,8 @@ public CssOrphans(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent ide = (CssIdent) val; - if (inherit.equals(ide)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } default: @@ -73,8 +71,7 @@ public CssOrphans(ApplContext ac, CssExpression expression, boolean check) * * @param ac, the Context * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssOrphans(ApplContext ac, CssExpression expression) throws InvalidParamException { diff --git a/org/w3c/css/properties/css3/CssPause.java b/org/w3c/css/properties/css3/CssPause.java index 1f58d8548..e7f9dac46 100644 --- a/org/w3c/css/properties/css3/CssPause.java +++ b/org/w3c/css/properties/css3/CssPause.java @@ -81,9 +81,10 @@ public CssPause(ApplContext ac, CssExpression expression, boolean check) } cssPauseAfter = new CssPauseAfter(); cssPauseAfter.value = checkPauseValue(ac, expression, this); - if (cssPauseBefore.value == inherit || cssPauseAfter.value == inherit) { + if (((cssPauseBefore.value.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(cssPauseBefore.value.getIdent())) || + ((cssPauseAfter.value.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(cssPauseAfter.value.getIdent()))) { throw new InvalidParamException("value", - inherit, getPropertyName(), ac); + cssPauseBefore.value, getPropertyName(), ac); } ArrayList values = new ArrayList(2); values.add(cssPauseBefore.value); @@ -100,7 +101,7 @@ public CssPause(ApplContext ac, CssExpression expression) protected static CssValue checkPauseValue(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, v; + CssValue val; char op; val = expression.getValue(); @@ -113,15 +114,14 @@ protected static CssValue checkPauseValue(ApplContext ac, CssExpression expressi expression.next(); return val; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { expression.next(); - return inherit; + return val; } - v = getAllowedIdent(id); - if (v != null) { + if (getAllowedIdent(id) != null) { expression.next(); - return v; + return val; } default: throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssPitch.java b/org/w3c/css/properties/css3/CssPitch.java index eab48d880..ee71a951f 100644 --- a/org/w3c/css/properties/css3/CssPitch.java +++ b/org/w3c/css/properties/css3/CssPitch.java @@ -72,13 +72,13 @@ public CssPitch(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssPlayDuring.java b/org/w3c/css/properties/css3/CssPlayDuring.java index 4acf5e929..b995a6d0d 100644 --- a/org/w3c/css/properties/css3/CssPlayDuring.java +++ b/org/w3c/css/properties/css3/CssPlayDuring.java @@ -133,13 +133,13 @@ public CssPlayDuring(ApplContext ac, CssExpression expression, boolean check) break; case CssTypes.CSS_IDENT: if (expression.getCount() == 1) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } } diff --git a/org/w3c/css/properties/css3/CssPosition.java b/org/w3c/css/properties/css3/CssPosition.java index 91453cace..c7ddff36c 100644 --- a/org/w3c/css/properties/css3/CssPosition.java +++ b/org/w3c/css/properties/css3/CssPosition.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2016/WD-css-position-3-20160517/#position-property + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-position */ public class CssPosition extends org.w3c.css.properties.css.CssPosition { @@ -49,8 +49,7 @@ public CssPosition() { * Creates a new CssPosition * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssPosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,19 +64,18 @@ public CssPosition(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; + } else if (getAllowedIdent(id) != null) { + value = val; } else { + value = val; throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssQuotes.java b/org/w3c/css/properties/css3/CssQuotes.java index 189061356..9772b579a 100644 --- a/org/w3c/css/properties/css3/CssQuotes.java +++ b/org/w3c/css/properties/css3/CssQuotes.java @@ -8,6 +8,7 @@ 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; import org.w3c.css.values.CssValueList; @@ -17,11 +18,12 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2003/WD-css3-content-20030514/#quotes - * an obsolete spec, but it's the same as CSS21. + * @spec https://www.w3.org/TR/2019/WD-css-content-3-20190802/#propdef-quotes */ public class CssQuotes extends org.w3c.css.properties.css.CssQuotes { + static final CssIdent auto = CssIdent.getIdent("auto"); + /** * Create a new CssQuotes */ @@ -51,13 +53,14 @@ public CssQuotes(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("value", val, getPropertyName(), ac); } - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; expression.next(); break; } - if (none.equals(val)) { - value = none; + if (none.equals(ident) || auto.equals(ident)) { + value = val; expression.next(); break; } diff --git a/org/w3c/css/properties/css3/CssResize.java b/org/w3c/css/properties/css3/CssResize.java index b32346353..56fafc04d 100644 --- a/org/w3c/css/properties/css3/CssResize.java +++ b/org/w3c/css/properties/css3/CssResize.java @@ -13,8 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2020/WD-css-ui-4-20210316/#propdef-resize - * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#resize + * @spec https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#propdef-resize */ public class CssResize extends org.w3c.css.properties.css.CssResize { @@ -66,17 +65,16 @@ public CssResize(ApplContext ac, CssExpression expression, boolean check) expression.getValue(), getPropertyName(), ac); } + CssIdent ident = val.getIdent(); // 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); - } + if (CssIdent.isCssWide(ident)) { value = val; + } else if (getMatchingIdent(ident) != null) { + value = val; + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssRest.java b/org/w3c/css/properties/css3/CssRest.java index 366a8e38d..5ea72fd66 100644 --- a/org/w3c/css/properties/css3/CssRest.java +++ b/org/w3c/css/properties/css3/CssRest.java @@ -56,8 +56,7 @@ public CssRest() { * Creates a new CssRest * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssRest(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -82,9 +81,10 @@ public CssRest(ApplContext ac, CssExpression expression, boolean check) } cssRestAfter = new CssRestAfter(); cssRestAfter.value = checkRestValue(ac, expression, this); - if (cssRestBefore.value == inherit || cssRestAfter.value == inherit) { + if (((cssRestBefore.value.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(cssRestBefore.value.getIdent())) || + ((cssRestAfter.value.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(cssRestAfter.value.getIdent()))) { throw new InvalidParamException("value", - inherit, getPropertyName(), ac); + cssRestBefore.value, getPropertyName(), ac); } ArrayList values = new ArrayList(2); values.add(cssRestBefore.value); @@ -99,9 +99,9 @@ public CssRest(ApplContext ac, CssExpression expression) } protected static CssValue checkRestValue(ApplContext ac, CssExpression expression, - CssProperty caller) + CssProperty caller) throws InvalidParamException { - CssValue val, v; + CssValue val; char op; val = expression.getValue(); @@ -114,15 +114,14 @@ protected static CssValue checkRestValue(ApplContext ac, CssExpression expressio expression.next(); return val; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { expression.next(); - return inherit; + return val; } - v = getAllowedIdent(id); - if (v != null) { + if (getAllowedIdent(id) != null) { expression.next(); - return v; + return val; } default: throw new InvalidParamException("value", From 3f837bf268fd94a588860231698720f684d3f1db Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 14:12:24 +0200 Subject: [PATCH 42/82] cast+mark as deprecated (should be removed at some point) --- org/w3c/css/properties/css3/CssMarqueeDirection.java | 6 ++++-- org/w3c/css/properties/css3/CssMarqueePlayCount.java | 3 ++- org/w3c/css/properties/css3/CssMarqueeSpeed.java | 9 +++++---- org/w3c/css/properties/css3/CssMarqueeStyle.java | 5 +++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/org/w3c/css/properties/css3/CssMarqueeDirection.java b/org/w3c/css/properties/css3/CssMarqueeDirection.java index ab170f62c..379aa1922 100644 --- a/org/w3c/css/properties/css3/CssMarqueeDirection.java +++ b/org/w3c/css/properties/css3/CssMarqueeDirection.java @@ -14,6 +14,7 @@ /** * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-direction + * @deprecated */ public class CssMarqueeDirection extends org.w3c.css.properties.css.CssMarqueeDirection { @@ -66,10 +67,11 @@ public CssMarqueeDirection(ApplContext ac, CssExpression expression, boolean che getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { + CssIdent ident = val.getIdent(); + if (inherit.equals(ident)) { value = inherit; } else { - val = getMatchingIdent((CssIdent) val); + val = getMatchingIdent(ident); if (val == null) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssMarqueePlayCount.java b/org/w3c/css/properties/css3/CssMarqueePlayCount.java index 7d587de88..209a45f81 100644 --- a/org/w3c/css/properties/css3/CssMarqueePlayCount.java +++ b/org/w3c/css/properties/css3/CssMarqueePlayCount.java @@ -15,6 +15,7 @@ /** * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-play-count + * @deprecated */ public class CssMarqueePlayCount extends org.w3c.css.properties.css.CssMarqueePlayCount { @@ -55,7 +56,7 @@ public CssMarqueePlayCount(ApplContext ac, CssExpression expression, boolean che value = num; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); if (inherit.equals(ident)) { value = inherit; break; diff --git a/org/w3c/css/properties/css3/CssMarqueeSpeed.java b/org/w3c/css/properties/css3/CssMarqueeSpeed.java index 3783a1db3..1ff8645b8 100644 --- a/org/w3c/css/properties/css3/CssMarqueeSpeed.java +++ b/org/w3c/css/properties/css3/CssMarqueeSpeed.java @@ -14,13 +14,14 @@ /** * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-speed + * @deprecated */ public class CssMarqueeSpeed extends org.w3c.css.properties.css.CssMarqueeSpeed { - private static CssIdent[] allowed_values; + private static final CssIdent[] allowed_values; static { - String id_values[] = {"slow", "normal", "fast"}; + String[] id_values = {"slow", "normal", "fast"}; allowed_values = new CssIdent[id_values.length]; int i = 0; for (String s : id_values) { @@ -66,10 +67,10 @@ public CssMarqueeSpeed(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { value = inherit; } else { - val = getMatchingIdent((CssIdent) val); + val = getMatchingIdent(val.getIdent()); if (val == null) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssMarqueeStyle.java b/org/w3c/css/properties/css3/CssMarqueeStyle.java index aa535b31f..0a9e808ca 100644 --- a/org/w3c/css/properties/css3/CssMarqueeStyle.java +++ b/org/w3c/css/properties/css3/CssMarqueeStyle.java @@ -14,6 +14,7 @@ /** * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#marquee-style + * @deprecated */ public class CssMarqueeStyle extends org.w3c.css.properties.css.CssMarqueeStyle { @@ -66,10 +67,10 @@ public CssMarqueeStyle(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { + if (inherit.equals(val.getIdent())) { value = inherit; } else { - val = getMatchingIdent((CssIdent) val); + val = getMatchingIdent(val.getIdent()); if (val == null) { throw new InvalidParamException("value", expression.getValue(), From 49ef87dd84d8ee302b6039978ba62a8186f8c078 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 15:33:24 +0200 Subject: [PATCH 43/82] redone font src parsing per https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#descdef-font-face-src --- .../css/properties/css3/fontface/CssSrc.java | 197 +++++++++++++++++- 1 file changed, 190 insertions(+), 7 deletions(-) diff --git a/org/w3c/css/properties/css3/fontface/CssSrc.java b/org/w3c/css/properties/css3/fontface/CssSrc.java index 197e4f1ba..1deb742c8 100644 --- a/org/w3c/css/properties/css3/fontface/CssSrc.java +++ b/org/w3c/css/properties/css3/fontface/CssSrc.java @@ -9,6 +9,7 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssFunction; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -20,10 +21,85 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2013/CR-css-fonts-3-20131003/#descdef-src + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#descdef-font-face-src */ public class CssSrc extends org.w3c.css.properties.css.fontface.CssSrc { + public static final CssIdent[] allowed_font_format; + public static final CssIdent[] allowed_font_technologies; + public static final CssIdent[] allowed_font_feature_technologies; + public static final CssIdent[] allowed_color_font_technologies; + + public static final CssIdent supports = CssIdent.getIdent("supports"); + + static { + int i = 0; + String[] _allowed_font_format_values = {"woff", "truetype", "opentype", + "woff2", "embedded-opentype", "collection", "svg"}; + allowed_font_format = new CssIdent[_allowed_font_format_values.length]; + for (String s : _allowed_font_format_values) { + allowed_font_format[i++] = CssIdent.getIdent(s); + } + + i = 0; + String[] _allowed_font_technologies = {"variations", "palettes"}; + allowed_font_technologies = new CssIdent[_allowed_font_technologies.length]; + for (String s : _allowed_font_technologies) { + allowed_font_technologies[i++] = CssIdent.getIdent(s); + } + + i = 0; + String[] _allowed_font_feature_technologies = {"opentype", "aat", "graphite"}; + allowed_font_feature_technologies = new CssIdent[_allowed_font_feature_technologies.length]; + for (String s : _allowed_font_feature_technologies) { + allowed_font_feature_technologies[i++] = CssIdent.getIdent(s); + } + + i = 0; + String[] _allowed_color_font_technologies = {"COLRv0", "COLRv1", "SVG", + "sbix", "CBDT"}; + allowed_color_font_technologies = new CssIdent[_allowed_color_font_technologies.length]; + for (String s : _allowed_color_font_technologies) { + allowed_color_font_technologies[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingFontFormat(CssIdent ident) { + for (CssIdent id : allowed_font_format) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getMatchingColorFontTechnology(CssIdent ident) { + for (CssIdent id : allowed_color_font_technologies) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getMatchingFontTechnology(CssIdent ident) { + for (CssIdent id : allowed_font_technologies) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getMatchingFontFeatureTechnology(CssIdent ident) { + for (CssIdent id : allowed_font_feature_technologies) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + /** * Create a new CssSrc */ @@ -35,8 +111,7 @@ public CssSrc() { * Creates a new CssSrc * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssSrc(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -139,21 +214,129 @@ protected void parseFormatFunction(ApplContext ac, CssFunction f) char op; CssValue val; - while (!exp.end()) { + val = exp.getValue(); + op = exp.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_STRING: + break; + case CssTypes.CSS_IDENT: + if (getMatchingFontFormat(val.getIdent()) != null) { + break; + } + default: + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + exp.next(); + + if (!exp.end()) { + if (op != SPACE) { + throw new InvalidParamException("operator", op, + f.getName(), ac); + } val = exp.getValue(); op = exp.getOperator(); - if (val.getType() != CssTypes.CSS_STRING) { + // we need 'supports' ... + if ((val.getType() != CssTypes.CSS_IDENT) || !supports.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), f.getName(), ac); } - if (op != COMMA && exp.getRemainingCount() > 1) { + exp.next(); + if ((op != SPACE) || exp.end()) { throw new InvalidParamException("operator", op, f.getName(), ac); } - exp.next(); + while (!exp.end()) { + val = exp.getValue(); + op = exp.getOperator(); + switch (val.getType()) { + case CssTypes.CSS_FUNCTION: + CssFunction subf = (CssFunction) val; + String subfname = subf.getName().toLowerCase(); + switch (subfname) { + case "features": + parseFontFeatureTechnology(ac, subf); + break; + case "color": + parseColorFontTechnology(ac, subf); + break; + default: + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + break; + case CssTypes.CSS_IDENT: + CssIdent ident = val.getIdent(); + if (getMatchingFontTechnology(ident) != null) { + break; + } + // unrecognized ident + default: + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + exp.next(); + if (op != COMMA && !exp.end()) { + throw new InvalidParamException("operator", op, + f.getName(), ac); + } + } + } + + } + + protected void parseFontFeatureTechnology(ApplContext ac, CssFunction f) + throws InvalidParamException { + CssExpression exp = f.getParameters(); + char op; + CssValue val; + + if (exp.getCount() > 1) { + throw new InvalidParamException("value", exp.toStringFromStart(), + f.getName(), ac); + } + val = exp.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + if (getMatchingFontFeatureTechnology(val.getIdent()) == null) { + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + exp.next(); + } + + protected void parseColorFontTechnology(ApplContext ac, CssFunction f) + throws InvalidParamException { + CssExpression exp = f.getParameters(); + char op; + CssValue val; + + if (exp.getCount() > 1) { + throw new InvalidParamException("value", exp.toStringFromStart(), + f.getName(), ac); + } + val = exp.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); + } + if (getMatchingColorFontTechnology(val.getIdent()) == null) { + throw new InvalidParamException("value", + val.toString(), + f.getName(), ac); } + exp.next(); } protected void parseLocalFunction(ApplContext ac, CssFunction f) From 2c06677c3cc74fd6e10c15146a2238b8c4c78663 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 15:58:48 +0200 Subject: [PATCH 44/82] refs+cast (cont) --- .../css/properties/css3/CssAlignContent.java | 23 +++++------ .../css/properties/css3/CssAlignItems.java | 40 ++++++++----------- org/w3c/css/properties/css3/CssAlignSelf.java | 39 ++++++++---------- .../properties/css3/CssAlignmentBaseline.java | 14 +++---- 4 files changed, 50 insertions(+), 66 deletions(-) diff --git a/org/w3c/css/properties/css3/CssAlignContent.java b/org/w3c/css/properties/css3/CssAlignContent.java index 143b82ddf..480a6c304 100644 --- a/org/w3c/css/properties/css3/CssAlignContent.java +++ b/org/w3c/css/properties/css3/CssAlignContent.java @@ -20,7 +20,7 @@ /** * @spec https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/#propdef-align-content - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-align-content + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-align-content */ public class CssAlignContent extends org.w3c.css.properties.css.CssAlignContent { @@ -127,7 +127,7 @@ public CssAlignContent(ApplContext ac, CssExpression expression, boolean check) public static CssValue parseAlignContent(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -136,7 +136,7 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = val.getIdent(); - if (inherit.equals(ident)) { + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); @@ -148,8 +148,7 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio expression.next(); return val; } - value = getContentDistribution(ident); - if (value != null) { + if (getContentDistribution(ident) != null) { expression.next(); return val; } @@ -158,14 +157,12 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio expression.next(); return val; } - value = getContentPosition(ident); - if (value != null) { + if (getContentPosition(ident) != null) { expression.next(); return val; } // ok, at that point we need two values. - value = getBaselineQualifier(ident); - if (value != null) { + if (getBaselineQualifier(ident) != null) { values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", @@ -176,7 +173,7 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio throw new InvalidParamException("unrecognize", ac); } val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !baseline.equals(val)) { + if (val.getType() != CssTypes.CSS_IDENT || !baseline.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } @@ -184,8 +181,7 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio expression.next(); return new CssValueList(values); } - value = getOverflowPosition(ident); - if (value != null) { + if (getOverflowPosition(ident) != null) { values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", @@ -200,8 +196,7 @@ public static CssValue parseAlignContent(ApplContext ac, CssExpression expressio throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = getContentPosition((CssIdent) val); - if (value == null) { + if (getContentPosition(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } diff --git a/org/w3c/css/properties/css3/CssAlignItems.java b/org/w3c/css/properties/css3/CssAlignItems.java index 3a03e0856..2e539715c 100644 --- a/org/w3c/css/properties/css3/CssAlignItems.java +++ b/org/w3c/css/properties/css3/CssAlignItems.java @@ -21,7 +21,7 @@ /** * @spec https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/#propdef-align-items * replaced by - * https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-align-items + * https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-align-items */ public class CssAlignItems extends org.w3c.css.properties.css.CssAlignItems { @@ -56,8 +56,7 @@ public CssAlignItems() { * Creates a new CssAlignItems * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAlignItems(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -76,7 +75,7 @@ public CssAlignItems(ApplContext ac, CssExpression expression, boolean check) public static CssValue parseAlignItems(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -85,33 +84,30 @@ public static CssValue parseAlignItems(ApplContext ac, CssExpression expression, if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = val.getIdent(); - if (inherit.equals(ident)) { + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } expression.next(); - return inherit; + return val; } - value = getSingleAlignItemsValue(ident); - if (value != null) { + if (getSingleAlignItemsValue(ident) != null) { expression.next(); - return value; + return val; } // now try the two-values position, starting first with only one. if (CssAlignContent.baseline.equals(ident)) { expression.next(); - return CssAlignContent.baseline; + return val; } - value = CssAlignSelf.getSelfPosition(ident); - if (value != null) { + if (CssAlignSelf.getSelfPosition(ident) != null) { expression.next(); - return value; + return val; } // ok, at that point we need two values. - value = CssAlignContent.getBaselineQualifier(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getBaselineQualifier(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -121,17 +117,16 @@ public static CssValue parseAlignItems(ApplContext ac, CssExpression expression, throw new InvalidParamException("unrecognize", ac); } val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(CssAlignContent.baseline); + values.add(val); expression.next(); return new CssValueList(values); } - value = CssAlignContent.getOverflowPosition(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getOverflowPosition(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -145,8 +140,7 @@ public static CssValue parseAlignItems(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = CssAlignSelf.getSelfPosition(val.getIdent()); - if (value == null) { + if (CssAlignSelf.getSelfPosition(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } diff --git a/org/w3c/css/properties/css3/CssAlignSelf.java b/org/w3c/css/properties/css3/CssAlignSelf.java index df94a78c5..a2ea15755 100644 --- a/org/w3c/css/properties/css3/CssAlignSelf.java +++ b/org/w3c/css/properties/css3/CssAlignSelf.java @@ -21,7 +21,7 @@ /** * @spec https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/#propdef-align-self * replaced by - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#align-self-property + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-align-self */ public class CssAlignSelf extends org.w3c.css.properties.css.CssAlignSelf { @@ -92,7 +92,7 @@ public CssAlignSelf(ApplContext ac, CssExpression expression, boolean check) public static CssValue parseAlignSelf(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -100,34 +100,31 @@ public static CssValue parseAlignSelf(ApplContext ac, CssExpression expression, op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } expression.next(); - return inherit; + return val; } - value = getSingleAlignSelfValue(ident); - if (value != null) { + if (getSingleAlignSelfValue(ident) != null) { expression.next(); - return value; + return val; } // now try the two-values position, starting first with only one. if (CssAlignContent.baseline.equals(ident)) { expression.next(); return CssAlignContent.baseline; } - value = getSelfPosition(ident); - if (value != null) { + if (getSelfPosition(ident) != null) { expression.next(); - return value; + return val; } // ok, at that point we need two values. - value = CssAlignContent.getBaselineQualifier(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getBaselineQualifier(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -137,17 +134,16 @@ public static CssValue parseAlignSelf(ApplContext ac, CssExpression expression, throw new InvalidParamException("unrecognize", ac); } val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(CssAlignContent.baseline); + values.add(val); expression.next(); return new CssValueList(values); } - value = CssAlignContent.getOverflowPosition(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getOverflowPosition(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -161,12 +157,11 @@ public static CssValue parseAlignSelf(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = getSelfPosition((CssIdent) val); - if (value == null) { + if (getSelfPosition(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(value); + values.add(val); expression.next(); return new CssValueList(values); } diff --git a/org/w3c/css/properties/css3/CssAlignmentBaseline.java b/org/w3c/css/properties/css3/CssAlignmentBaseline.java index 19bc3beb9..705dbe8ba 100644 --- a/org/w3c/css/properties/css3/CssAlignmentBaseline.java +++ b/org/w3c/css/properties/css3/CssAlignmentBaseline.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#alignment-baseline-property + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-alignment-baseline */ public class CssAlignmentBaseline extends org.w3c.css.properties.css.CssAlignmentBaseline { @@ -20,7 +20,7 @@ public class CssAlignmentBaseline extends org.w3c.css.properties.css.CssAlignmen static { String[] _allowed_values = {"baseline", "text-bottom", "alphabetic", "ideographic", - "middle", "central", "mathematical", "text-top", "bottom", "center", "top"}; + "middle", "central", "mathematical", "text-top"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -63,16 +63,16 @@ public CssAlignmentBaseline(ApplContext ac, CssExpression expression, boolean ch val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", From f686ded71735c4f6ad7ab83f93c8d1cc2999d672 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 16:20:31 +0200 Subject: [PATCH 45/82] handle both css3 and svg based on the profile used, as the css3 version is more likely to be updated --- .../css/properties/CSS3SVGProperties.properties | 4 ++-- .../properties/css3/CssAlignmentBaseline.java | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/org/w3c/css/properties/CSS3SVGProperties.properties b/org/w3c/css/properties/CSS3SVGProperties.properties index e25f2b647..f9df1325f 100644 --- a/org/w3c/css/properties/CSS3SVGProperties.properties +++ b/org/w3c/css/properties/CSS3SVGProperties.properties @@ -58,5 +58,5 @@ enable-background: org.w3c.css.properties.svg.CssEnableBack baseline-shift: org.w3c.css.properties.svg.CssBaselineShift dominant-baseline: org.w3c.css.properties.svg.CssDominantBaseline -# The SVG version handle SVG and CSS3+SVG -alignment-baseline: org.w3c.css.properties.svg.CssAlignmentBaseline +# The CSS3 version handle CSS3+SVG +alignment-baseline: org.w3c.css.properties.css3.CssAlignmentBaseline diff --git a/org/w3c/css/properties/css3/CssAlignmentBaseline.java b/org/w3c/css/properties/css3/CssAlignmentBaseline.java index 705dbe8ba..e0479a7a5 100644 --- a/org/w3c/css/properties/css3/CssAlignmentBaseline.java +++ b/org/w3c/css/properties/css3/CssAlignmentBaseline.java @@ -5,6 +5,7 @@ package org.w3c.css.properties.css3; import org.w3c.css.util.ApplContext; +import org.w3c.css.util.CssProfile; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; @@ -68,9 +69,18 @@ public CssAlignmentBaseline(ApplContext ac, CssExpression expression, boolean ch value = val; } else { if (getAllowedIdent(id) == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + // test for SVG + if (ac.getCssProfile().equals(CssProfile.SVG)) { + if (org.w3c.css.properties.svg.CssAlignmentBaseline.getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + } else { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } } value = val; } From 665eff82f60bdfed851469529b759455886867a4 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 16:40:37 +0200 Subject: [PATCH 46/82] cast (cont) on deprecated property --- org/w3c/css/properties/css3/CssAzimuth.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/org/w3c/css/properties/css3/CssAzimuth.java b/org/w3c/css/properties/css3/CssAzimuth.java index edf32344e..6d8d43d4f 100644 --- a/org/w3c/css/properties/css3/CssAzimuth.java +++ b/org/w3c/css/properties/css3/CssAzimuth.java @@ -77,8 +77,7 @@ private boolean checkIdent(CssIdent ident) { * Creates a new CssAzimuth * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAzimuth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -113,7 +112,7 @@ public CssAzimuth(ApplContext ac, CssExpression expression, boolean check) break; case CssTypes.CSS_IDENT: int count = expression.getCount(); - CssIdent ident = (CssIdent) val; + CssIdent ident = val.getIdent(); char op = expression.getOperator(); // inherit, leftwards, rightwards @@ -142,7 +141,7 @@ public CssAzimuth(ApplContext ac, CssExpression expression, boolean check) if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", val, ac); } - ident = (CssIdent) val; + ident = val.getIdent(); if (op != CssOperator.SPACE) { throw new InvalidParamException("operator", val, From 30b3c3dd5aaf52f5e9a033b9be625f577d7aff4d Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 17:12:31 +0200 Subject: [PATCH 47/82] cast (cont) + small updates --- .../css/properties/css3/CssAppearance.java | 15 ++++++----- .../css3/CssBackfaceVisibility.java | 8 +++--- org/w3c/css/properties/css3/CssFilter.java | 8 +++--- org/w3c/css/properties/css3/CssLineBreak.java | 10 +++---- .../css/properties/css3/CssLineHeight.java | 26 +++++++++---------- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/org/w3c/css/properties/css3/CssAppearance.java b/org/w3c/css/properties/css3/CssAppearance.java index 7f5fcac6e..4283ec745 100644 --- a/org/w3c/css/properties/css3/CssAppearance.java +++ b/org/w3c/css/properties/css3/CssAppearance.java @@ -86,20 +86,23 @@ public CssAppearance(ApplContext ac, CssExpression expression, val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; // output will use auto if (isCompatAuto(id)) { // need a specific warning to tell that it is seen as "auto"? ac.getFrame().addWarning("value-unofficial"); - value = auto; + // let's replace it if it was a real ident + if (val.getRawType() == CssTypes.CSS_IDENT) { + value = auto; + } } } } else { diff --git a/org/w3c/css/properties/css3/CssBackfaceVisibility.java b/org/w3c/css/properties/css3/CssBackfaceVisibility.java index fd749aa1b..48752afac 100644 --- a/org/w3c/css/properties/css3/CssBackfaceVisibility.java +++ b/org/w3c/css/properties/css3/CssBackfaceVisibility.java @@ -65,12 +65,12 @@ public CssBackfaceVisibility(ApplContext ac, CssExpression expression, boolean c expression.getValue(), getPropertyName(), ac); } + CssIdent id = val.getIdent(); // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(id)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(id) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssFilter.java b/org/w3c/css/properties/css3/CssFilter.java index 066f6cf35..7ba46f5cd 100644 --- a/org/w3c/css/properties/css3/CssFilter.java +++ b/org/w3c/css/properties/css3/CssFilter.java @@ -101,14 +101,14 @@ public CssFilter(final ApplContext ac, final CssExpression expression, final boo values.add(val); break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; singleVal = true; break; } if (none.equals(ident)) { - value = none; + value = val; singleVal = true; break; } diff --git a/org/w3c/css/properties/css3/CssLineBreak.java b/org/w3c/css/properties/css3/CssLineBreak.java index bc9967a93..b6fcb01fb 100644 --- a/org/w3c/css/properties/css3/CssLineBreak.java +++ b/org/w3c/css/properties/css3/CssLineBreak.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-line-break + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-line-break */ public class CssLineBreak extends org.w3c.css.properties.css.CssLineBreak { @@ -65,12 +65,12 @@ public CssLineBreak(ApplContext ac, CssExpression expression, boolean check) expression.getValue(), getPropertyName(), ac); } + CssIdent ident = val.getIdent(); // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssLineHeight.java b/org/w3c/css/properties/css3/CssLineHeight.java index f6717252b..653de3c17 100644 --- a/org/w3c/css/properties/css3/CssLineHeight.java +++ b/org/w3c/css/properties/css3/CssLineHeight.java @@ -14,8 +14,7 @@ import org.w3c.css.values.CssValue; /** - * @version $Revision$ - * @spec http://www.w3.org/TR/2002/WD-css3-linebox-20020515/#line-height + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-line-height */ public class CssLineHeight extends org.w3c.css.properties.css.CssLineHeight { @@ -32,8 +31,7 @@ public CssLineHeight() { * Creates a new CssLineHeight * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssLineHeight(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -45,17 +43,17 @@ public CssLineHeight(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - } else if (normal.equals(val)) { - value = normal; - } else if (none.equals(val)) { - value = none; - } else { - throw new InvalidParamException("value", val.toString(), - getPropertyName(), ac); + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + break; } - break; + if (normal.equals(val)) { + value = val; + break; + } + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); case CssTypes.CSS_LENGTH: case CssTypes.CSS_NUMBER: case CssTypes.CSS_PERCENTAGE: From a9a0aafc6151311ae61d88a59fcbd4602740407c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 18:47:14 +0200 Subject: [PATCH 48/82] ref+cast and mark deprecated --- org/w3c/css/properties/css3/CssClip.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/org/w3c/css/properties/css3/CssClip.java b/org/w3c/css/properties/css3/CssClip.java index 85f89b43d..c73edc81c 100644 --- a/org/w3c/css/properties/css3/CssClip.java +++ b/org/w3c/css/properties/css3/CssClip.java @@ -18,7 +18,8 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/WD-css3-positioning-20120207/#clip + * @spec https://www.w3.org/TR/2021/CRD-css-masking-1-20210805/#propdef-clip + * @deprecated */ public class CssClip extends org.w3c.css.properties.css.CssClip { @@ -46,12 +47,13 @@ public CssClip(ApplContext ac, CssExpression expression, boolean check) setByUser(); CssValue val = expression.getValue(); + ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); switch (val.getType()) { case CssTypes.CSS_FUNCTION: CssFunction func = (CssFunction) val; String funcname = func.getName().toLowerCase(); - if (!funcname.equals("rect") && !funcname.equals("inset")) { + if (!funcname.equals("rect")) { throw new InvalidParamException("value", val, getPropertyName(), ac); } @@ -59,11 +61,12 @@ public CssClip(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; break; - } else if (auto.equals(val)) { - value = auto; + } else if (auto.equals(ident)) { + value = val; break; } // let if fail. @@ -102,7 +105,7 @@ static void checkShape(ApplContext ac, CssExpression expression, case CssTypes.CSS_LENGTH: break; case CssTypes.CSS_IDENT: - if (auto.equals(val)) { + if (auto.equals(val.getIdent())) { break; } default: From dff56ac4a4ca7e4bc3b5fbae11104cf2ec214a31 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 18:47:31 +0200 Subject: [PATCH 49/82] ref+cast (cont) --- .../css/properties/css3/CssBaselineShift.java | 17 ++++--- .../css/properties/css3/CssBreakAfter.java | 17 +++---- .../css/properties/css3/CssBreakBefore.java | 11 ++--- .../css/properties/css3/CssBreakInside.java | 8 ++-- .../css/properties/css3/CssCaptionSide.java | 12 ++--- org/w3c/css/properties/css3/CssCaret.java | 47 +++++++++---------- .../css/properties/css3/CssCaretColor.java | 11 +++-- .../css/properties/css3/CssCaretShape.java | 8 ++-- org/w3c/css/properties/css3/CssClear.java | 22 ++++----- 9 files changed, 72 insertions(+), 81 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBaselineShift.java b/org/w3c/css/properties/css3/CssBaselineShift.java index 145cc0c84..893bc33c4 100644 --- a/org/w3c/css/properties/css3/CssBaselineShift.java +++ b/org/w3c/css/properties/css3/CssBaselineShift.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#baseline-shift-property + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-baseline-shift */ public class CssBaselineShift extends org.w3c.css.properties.css.CssBaselineShift { @@ -21,7 +21,7 @@ public class CssBaselineShift extends org.w3c.css.properties.css.CssBaselineShif public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"sub", "super"}; + String[] _allowed_values = {"sub", "super", "top", "center", "bottom"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -42,8 +42,7 @@ public static final CssIdent getAllowedIdent(CssIdent ident) { * Creates a new CssBaselineShift * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBaselineShift(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,13 +64,13 @@ public CssBaselineShift(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } // unrecognized ident -> fail. diff --git a/org/w3c/css/properties/css3/CssBreakAfter.java b/org/w3c/css/properties/css3/CssBreakAfter.java index 2b7b21830..219dcd252 100644 --- a/org/w3c/css/properties/css3/CssBreakAfter.java +++ b/org/w3c/css/properties/css3/CssBreakAfter.java @@ -15,12 +15,10 @@ import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; -import static org.w3c.css.properties.css3.CssBreakBefore.auto; -import static org.w3c.css.properties.css3.CssBreakBefore.getMatchingIdent; - /** * @spec https://www.w3.org/TR/2018/CR-css-break-3-20181204/#propdef-break-after + * @see CssBreakBefore */ public class CssBreakAfter extends org.w3c.css.properties.css.CssBreakAfter { @@ -36,8 +34,7 @@ public CssBreakAfter() { * Create a new CssPageBreakAfter * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Incorrect value + * @throws org.w3c.css.util.InvalidParamException Incorrect value */ public CssBreakAfter(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -55,11 +52,11 @@ public CssBreakAfter(ApplContext ac, CssExpression expression, getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (CssBreakBefore.getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); @@ -79,7 +76,7 @@ public CssBreakAfter(ApplContext ac, CssExpression expression) * It is used by all macro for the function print */ public boolean isDefault() { - return (auto == value); + return (CssBreakBefore.auto == value); } } diff --git a/org/w3c/css/properties/css3/CssBreakBefore.java b/org/w3c/css/properties/css3/CssBreakBefore.java index 9a367d098..d90f65543 100644 --- a/org/w3c/css/properties/css3/CssBreakBefore.java +++ b/org/w3c/css/properties/css3/CssBreakBefore.java @@ -58,8 +58,7 @@ public CssBreakBefore() { * @param ac the context * @param expression The expression for this property * @param check if checking is needed - * @throws org.w3c.css.util.InvalidParamException - * Incorrect value + * @throws org.w3c.css.util.InvalidParamException Incorrect value */ public CssBreakBefore(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -76,11 +75,11 @@ public CssBreakBefore(ApplContext ac, CssExpression expression, getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssBreakInside.java b/org/w3c/css/properties/css3/CssBreakInside.java index c33b753c7..69e0bb723 100644 --- a/org/w3c/css/properties/css3/CssBreakInside.java +++ b/org/w3c/css/properties/css3/CssBreakInside.java @@ -73,11 +73,11 @@ public CssBreakInside(ApplContext ac, CssExpression expression, getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssCaptionSide.java b/org/w3c/css/properties/css3/CssCaptionSide.java index 0b95f841c..f1591df46 100644 --- a/org/w3c/css/properties/css3/CssCaptionSide.java +++ b/org/w3c/css/properties/css3/CssCaptionSide.java @@ -14,7 +14,7 @@ /** * @spec http://www.w3.org/TR/2011/REC-CSS2-20110607/tables.html#propdef-caption-side - * @spec https://www.w3.org/TR/2017/WD-css-logical-1-20170518/#caption-side + * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#caption-side */ public class CssCaptionSide extends org.w3c.css.properties.css.CssCaptionSide { @@ -66,16 +66,16 @@ public CssCaptionSide(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssCaret.java b/org/w3c/css/properties/css3/CssCaret.java index 789e51f3a..619d353ad 100644 --- a/org/w3c/css/properties/css3/CssCaret.java +++ b/org/w3c/css/properties/css3/CssCaret.java @@ -17,7 +17,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2020/WD-css-ui-4-20200124/#propdef-caret + * @spec https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#propdef-caret */ public class CssCaret extends org.w3c.css.properties.css.CssCaret { @@ -63,30 +63,29 @@ public CssCaret(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - values.add(inherit); - break; - } - v = getMatchingIdent((CssIdent) val); - if (v != null) { - // auto can be used for both color and shape - values.add(v); - break; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); } - v = CssCaretShape.getMatchingIdent((CssIdent) val); - if (v != null) { - if (gotShape) { - throw new InvalidParamException("value", - val, getPropertyName(), ac); - } - gotShape = true; - values.add(v); - break; + values.add(val); + break; + } + if (getMatchingIdent(ident) != null) { + // auto can be used for both color and shape + values.add(val); + break; + } + if (CssCaretShape.getMatchingIdent(ident) != null) { + if (gotShape) { + throw new InvalidParamException("value", + val, getPropertyName(), ac); } - // if not recognized... it can be a color. + gotShape = true; + values.add(val); + break; + } + // if not recognized... it can be a color. default: try { CssExpression nex = new CssExpression(); @@ -99,7 +98,7 @@ public CssCaret(ApplContext ac, CssExpression expression, boolean check) val, getPropertyName(), ac); } gotColor = true; - values.add(tcolor.color); + values.add((tcolor.color == null) ? tcolor.value : tcolor.color); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssCaretColor.java b/org/w3c/css/properties/css3/CssCaretColor.java index 550948f1a..1a9678b84 100644 --- a/org/w3c/css/properties/css3/CssCaretColor.java +++ b/org/w3c/css/properties/css3/CssCaretColor.java @@ -52,12 +52,13 @@ public CssCaretColor(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; break; } - value = getMatchingIdent((CssIdent) val); - if (value != null) { + if (getMatchingIdent(ident) != null) { + value = val; break; } // if not recognized... it can be a color. @@ -66,7 +67,7 @@ public CssCaretColor(ApplContext ac, CssExpression expression, boolean check) CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = tcolor.color; + value = (tcolor.color == null) ? tcolor.value : tcolor.color; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssCaretShape.java b/org/w3c/css/properties/css3/CssCaretShape.java index b089bc3fc..1b0252e45 100644 --- a/org/w3c/css/properties/css3/CssCaretShape.java +++ b/org/w3c/css/properties/css3/CssCaretShape.java @@ -65,11 +65,11 @@ public CssCaretShape(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssClear.java b/org/w3c/css/properties/css3/CssClear.java index 2b371c929..e0558b644 100644 --- a/org/w3c/css/properties/css3/CssClear.java +++ b/org/w3c/css/properties/css3/CssClear.java @@ -21,10 +21,8 @@ public class CssClear extends org.w3c.css.properties.css.CssClear { public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"both" /* This one is for CSS21 backward compat. - discussion started in CSS WG */ - , "inline-start", "inline-end", "block-start", - "block-end", "left", "right", "top", "bottom", "none"}; + String[] _allowed_values = {"both", "left", "right", "none", + "inline-start", "inline-end"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -54,8 +52,7 @@ public CssClear() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssClear(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -67,8 +64,7 @@ public CssClear(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssClear(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -84,16 +80,16 @@ public CssClear(ApplContext ac, CssExpression expression, op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", From 7b5a795d10b7b12798862cef29334ab959ee782c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 20:58:19 +0200 Subject: [PATCH 50/82] updated refs + cast issue (cont) --- org/w3c/css/properties/css/CssColumnRule.java | 7 +- org/w3c/css/properties/css3/CssClear.java | 1 - .../css/properties/css3/CssColumnCount.java | 14 +-- .../css/properties/css3/CssColumnFill.java | 10 +- org/w3c/css/properties/css3/CssColumnGap.java | 13 ++- .../css/properties/css3/CssColumnRule.java | 105 ++++-------------- .../properties/css3/CssColumnRuleColor.java | 45 ++++---- .../properties/css3/CssColumnRuleStyle.java | 2 +- .../properties/css3/CssColumnRuleWidth.java | 2 +- .../css/properties/css3/CssColumnSpan.java | 15 +-- .../css/properties/css3/CssColumnWidth.java | 20 ++-- org/w3c/css/properties/css3/CssColumns.java | 19 ++-- org/w3c/css/properties/css3/CssContain.java | 22 ++-- org/w3c/css/properties/css3/CssContent.java | 4 +- org/w3c/css/properties/css3/CssFloat.java | 23 ++-- 15 files changed, 121 insertions(+), 181 deletions(-) diff --git a/org/w3c/css/properties/css/CssColumnRule.java b/org/w3c/css/properties/css/CssColumnRule.java index ac5ce29c4..44a2b3c29 100644 --- a/org/w3c/css/properties/css/CssColumnRule.java +++ b/org/w3c/css/properties/css/CssColumnRule.java @@ -22,9 +22,9 @@ public class CssColumnRule extends CssProperty { private static final String propertyName = "column-rule"; - CssColumnRuleWidth rule_width; - CssColumnRuleStyle rule_style; - CssColumnRuleColor rule_color; + public CssColumnRuleWidth rule_width; + public CssColumnRuleStyle rule_style; + public CssColumnRuleColor rule_color; /** * Create a new CssColumnRule @@ -109,7 +109,6 @@ public Object get() { * Returns a string representation of the object */ public String toString() { - return value.toString(); } } diff --git a/org/w3c/css/properties/css3/CssClear.java b/org/w3c/css/properties/css3/CssClear.java index e0558b644..d72bc3433 100644 --- a/org/w3c/css/properties/css3/CssClear.java +++ b/org/w3c/css/properties/css3/CssClear.java @@ -13,7 +13,6 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2015/WD-css-page-floats-3-20150915/#propdef-clear * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#float-clear */ public class CssClear extends org.w3c.css.properties.css.CssClear { diff --git a/org/w3c/css/properties/css3/CssColumnCount.java b/org/w3c/css/properties/css3/CssColumnCount.java index 6a96ebfc2..74101f6a9 100644 --- a/org/w3c/css/properties/css3/CssColumnCount.java +++ b/org/w3c/css/properties/css3/CssColumnCount.java @@ -16,7 +16,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-count + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-count */ public class CssColumnCount extends org.w3c.css.properties.css.CssColumnCount { @@ -43,7 +43,6 @@ public CssColumnCount(ApplContext ac, CssExpression expression, setByUser(); CssValue val = expression.getValue(); - CssCheckableValue num; if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); @@ -51,18 +50,19 @@ public CssColumnCount(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_NUMBER: - num = val.getCheckableValue(); + CssCheckableValue num = val.getCheckableValue(); num.checkInteger(ac, this); num.checkStrictPositiveness(ac, this); value = val; break; case CssTypes.CSS_IDENT: - if (auto.equals(val)) { - value = auto; + CssIdent ident = val.getIdent(); + if (auto.equals(ident)) { + value = val; break; } - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(ident)) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssColumnFill.java b/org/w3c/css/properties/css3/CssColumnFill.java index 79a5afdd1..af371399d 100644 --- a/org/w3c/css/properties/css3/CssColumnFill.java +++ b/org/w3c/css/properties/css3/CssColumnFill.java @@ -15,7 +15,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-fill + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-fill */ public class CssColumnFill extends org.w3c.css.properties.css.CssColumnFill { @@ -72,11 +72,11 @@ public CssColumnFill(ApplContext ac, CssExpression expression, getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getAllowedValue((CssIdent) val); - if (val == null) { + if (getAllowedValue(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssColumnGap.java b/org/w3c/css/properties/css3/CssColumnGap.java index 514e8aad0..84883dc28 100644 --- a/org/w3c/css/properties/css3/CssColumnGap.java +++ b/org/w3c/css/properties/css3/CssColumnGap.java @@ -16,8 +16,8 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-gap - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-column-gap + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#cg + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-column-gap */ public class CssColumnGap extends org.w3c.css.properties.css.CssColumnGap { @@ -59,12 +59,13 @@ public CssColumnGap(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_IDENT: - if (normal.equals(val)) { - value = normal; + CssIdent ident = val.getIdent(); + if (normal.equals(ident)) { + value = val; break; } - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(ident)) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssColumnRule.java b/org/w3c/css/properties/css3/CssColumnRule.java index fd44cedcb..3d0ed08fd 100644 --- a/org/w3c/css/properties/css3/CssColumnRule.java +++ b/org/w3c/css/properties/css3/CssColumnRule.java @@ -8,7 +8,6 @@ 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; @@ -16,19 +15,18 @@ import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssValueList; + +import java.util.ArrayList; import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2011/CR-css3-multicol-20110412/#column-rule + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-rule */ public class CssColumnRule extends org.w3c.css.properties.css.CssColumnRule { - CssIdent value = null; - CssColumnRuleWidth rule_width = null; - CssColumnRuleStyle rule_style = null; - CssColumnRuleColor rule_color = null; /** * Create a new CssColumnRule @@ -40,8 +38,7 @@ public CssColumnRule() { * Create a new CssColumnRule * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Incorrect values + * @throws org.w3c.css.util.InvalidParamException Incorrect values */ public CssColumnRule(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -70,27 +67,28 @@ public CssColumnRule(ApplContext ac, CssExpression expression, if (rule_color != null) { throw new InvalidParamException("unrecognize", ac); } - rule_color = new CssColumnRuleColor(ac, expression); + rule_color = new CssColumnRuleColor(ac, expression, false); break; case CssTypes.CSS_NUMBER: case CssTypes.CSS_LENGTH: if (rule_width != null) { throw new InvalidParamException("unrecognize", ac); } - rule_width = new CssColumnRuleWidth(ac, expression); + rule_width = new CssColumnRuleWidth(ac, expression, false); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (nb_val > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; expression.next(); break; } if (rule_color == null) { try { - rule_color = new CssColumnRuleColor(ac, expression); + rule_color = new CssColumnRuleColor(ac, expression, false); break; } catch (Exception ex) { } @@ -116,6 +114,19 @@ public CssColumnRule(ApplContext ac, CssExpression expression, getPropertyName(), ac); } } + if (rule_color != null || rule_width != null || rule_style != null) { + ArrayList v = new ArrayList<>(); + if (rule_width != null) { + v.add(rule_width.value); + } + if (rule_style != null) { + v.add(rule_style.value); + } + if (rule_color != null) { + v.add(rule_color.value); + } + value = new CssValueList(v); + } } public CssColumnRule(ApplContext ac, CssExpression expression) @@ -123,40 +134,6 @@ public CssColumnRule(ApplContext ac, CssExpression expression) this(ac, expression, false); } - /** - * Add this property to the CssStyle - * - * @param style The CssStyle - */ - public void addToStyle(ApplContext ac, CssStyle style) { - if (((Css3Style) style).cssColumnRule != null) - style.addRedefinitionWarning(ac, this); - ((Css3Style) style).cssColumnRule = this; - if (rule_style != null) { - rule_style.addToStyle(ac, style); - } - if (rule_color != null) { - rule_color.addToStyle(ac, style); - } - if (rule_width != null) { - rule_width.addToStyle(ac, style); - } - } - - /** - * 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).getColumnRule(); - } else { - return ((Css3Style) style).cssColumnRule; - } - } - /** * Compares two properties for equality. * @@ -166,38 +143,4 @@ public boolean equals(CssProperty property) { return false; } - /** - * Returns the value of this property - */ - public Object get() { - return value; - } - - /** - * Returns a string representation of the object - */ - public String toString() { - StringBuilder sb = new StringBuilder(); - boolean first = true; - if (value != null) { - return value.toString(); - } - if (rule_color != null) { - sb.append(rule_color); - first = false; - } - if (rule_width != null) { - if (!first) { - sb.append(' '); - } - sb.append(rule_width); - } - if (rule_style != null) { - if (!first) { - sb.append(' '); - } - sb.append(rule_style); - } - return sb.toString(); - } } diff --git a/org/w3c/css/properties/css3/CssColumnRuleColor.java b/org/w3c/css/properties/css3/CssColumnRuleColor.java index 9253696d4..b491b86d8 100644 --- a/org/w3c/css/properties/css3/CssColumnRuleColor.java +++ b/org/w3c/css/properties/css3/CssColumnRuleColor.java @@ -10,10 +10,12 @@ 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; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-rule-color + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-rule-color */ public class CssColumnRuleColor extends org.w3c.css.properties.css.CssColumnRuleColor { @@ -29,8 +31,7 @@ public CssColumnRuleColor() { * Create a new CssColumnRuleColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Incorrect value + * @throws org.w3c.css.util.InvalidParamException Incorrect value */ public CssColumnRuleColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -41,28 +42,26 @@ public CssColumnRuleColor(ApplContext ac, CssExpression expression, if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("value", - val, getPropertyName(), ac); - } - value = inherit; - expression.next(); - } else if (currentColor.equals(val)) { - value = currentColor; - expression.next(); - } else { - try { - // we use the latest version of CssColor, aka CSS3 - // instead of using CSS21 colors + transparent per spec - CssColor tcolor = new CssColor(ac, expression, check); - value = tcolor.getColor(); - } catch (InvalidParamException e) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); + if (val.getType() == CssTypes.CSS_IDENT) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + expression.next(); + return; } } + + try { + // we use the latest version of CssColor, aka CSS3 + // instead of using CSS21 colors + transparent per spec + CssColor tcolor = new CssColor(ac, expression, check); + value = (tcolor.value == null) ? tcolor.color : tcolor.value; + } catch (InvalidParamException e) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + } public CssColumnRuleColor(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssColumnRuleStyle.java b/org/w3c/css/properties/css3/CssColumnRuleStyle.java index a795f03a5..214e0af11 100644 --- a/org/w3c/css/properties/css3/CssColumnRuleStyle.java +++ b/org/w3c/css/properties/css3/CssColumnRuleStyle.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-rule-style + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-rule-style */ public class CssColumnRuleStyle extends org.w3c.css.properties.css.CssColumnRuleStyle { diff --git a/org/w3c/css/properties/css3/CssColumnRuleWidth.java b/org/w3c/css/properties/css3/CssColumnRuleWidth.java index 9a33577c4..a396eb6af 100644 --- a/org/w3c/css/properties/css3/CssColumnRuleWidth.java +++ b/org/w3c/css/properties/css3/CssColumnRuleWidth.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-rule-width + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-rule-width */ public class CssColumnRuleWidth extends org.w3c.css.properties.css.CssColumnRuleWidth { diff --git a/org/w3c/css/properties/css3/CssColumnSpan.java b/org/w3c/css/properties/css3/CssColumnSpan.java index e1549414c..5701ee04d 100644 --- a/org/w3c/css/properties/css3/CssColumnSpan.java +++ b/org/w3c/css/properties/css3/CssColumnSpan.java @@ -19,7 +19,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-span + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-span */ public class CssColumnSpan extends org.w3c.css.properties.css.CssColumnSpan { @@ -57,16 +57,13 @@ public CssColumnSpan(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_IDENT: - if (all.equals(val)) { - value = all; + CssIdent ident = val.getIdent(); + if (all.equals(ident) || none.equals(ident)) { + value = val; break; } - if (none.equals(val)) { - value = none; - break; - } - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(ident)) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssColumnWidth.java b/org/w3c/css/properties/css3/CssColumnWidth.java index 40b5dddd1..f1e7b1e03 100644 --- a/org/w3c/css/properties/css3/CssColumnWidth.java +++ b/org/w3c/css/properties/css3/CssColumnWidth.java @@ -18,8 +18,8 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-width - * @spec https://www.w3.org/TR/2018/WD-css-sizing-3-20180304/#column-sizing + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-column-width + * @spec https://www.w3.org/TR/2021/WD-css-sizing-3-20210317/ */ public class CssColumnWidth extends org.w3c.css.properties.css.CssColumnWidth { @@ -86,20 +86,22 @@ public CssColumnWidth(ApplContext ac, CssExpression expression, value = parseFitContentFunction(ac, (CssFunction) val, this); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - CssIdent id = getAllowedIdent((CssIdent) val); - if (id != null) { - value = id; + if (getAllowedIdent(ident) != null) { + value = val; } else { - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } } break; default: - throw new InvalidParamException("value", expression.getValue(), + throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } expression.next(); diff --git a/org/w3c/css/properties/css3/CssColumns.java b/org/w3c/css/properties/css3/CssColumns.java index c5b87578f..262f176bd 100644 --- a/org/w3c/css/properties/css3/CssColumns.java +++ b/org/w3c/css/properties/css3/CssColumns.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-columns + * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#propdef-columns * @see org.w3c.css.properties.css3.CssColumnWidth * @see org.w3c.css.properties.css3.CssColumnCount */ @@ -75,7 +75,7 @@ public CssColumns(ApplContext ac, CssExpression expression, if (count != null) { throw new InvalidParamException("unrecognize", ac); } - count = new CssColumnCount(ac, expression); + count = new CssColumnCount(ac, expression, false); values.add(val); break; case CssTypes.CSS_FUNCTION: @@ -83,21 +83,22 @@ public CssColumns(ApplContext ac, CssExpression expression, if (width != null) { throw new InvalidParamException("unrecognize", ac); } - width = new CssColumnWidth(ac, expression); + width = new CssColumnWidth(ac, expression, false); values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals((CssIdent) val)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (nb_val > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; expression.next(); break; } - if (auto.equals((CssIdent) val)) { + if (auto.equals(ident)) { nb_auto++; - values.add(auto); + values.add(val); expression.next(); break; } @@ -105,7 +106,7 @@ public CssColumns(ApplContext ac, CssExpression expression, if (width != null) { throw new InvalidParamException("unrecognize", ac); } - width = new CssColumnWidth(ac, expression); + width = new CssColumnWidth(ac, expression, false); values.add(val); break; default: @@ -115,7 +116,7 @@ public CssColumns(ApplContext ac, CssExpression expression, } } if (nb_val == 1) { - if (value != inherit) { + if (!values.isEmpty()) { value = values.get(0); } } else { diff --git a/org/w3c/css/properties/css3/CssContain.java b/org/w3c/css/properties/css3/CssContain.java index b11bc4963..8a4beed2d 100644 --- a/org/w3c/css/properties/css3/CssContain.java +++ b/org/w3c/css/properties/css3/CssContain.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2019/REC-css-contain-1-20191121/#propdef-contain + * @spec https://www.w3.org/TR/2020/WD-css-contain-2-20201216/#propdef-contain */ public class CssContain extends org.w3c.css.properties.css.CssContain { @@ -33,7 +33,8 @@ public class CssContain extends org.w3c.css.properties.css.CssContain { for (String s : _allowed_single_values) { allowed_single_values[i++] = CssIdent.getIdent(s); } - String[] _allowed_multiple_values = {"size", "layout", "paint"}; + // "style" added as of css-contain-2 but at-risk + String[] _allowed_multiple_values = {"size", "layout", "paint", "style"}; i = 0; allowed_multiple_values = new CssIdent[_allowed_multiple_values.length]; for (String s : _allowed_multiple_values) { @@ -82,6 +83,7 @@ public CssContain(ApplContext ac, CssExpression expression, boolean check) setByUser(); ArrayList values = new ArrayList<>(); + ArrayList idvalues = new ArrayList<>(); while (!expression.end()) { val = expression.getValue(); @@ -92,26 +94,25 @@ public CssContain(ApplContext ac, CssExpression expression, boolean check) val.toString(), getPropertyName(), ac); } - id = (CssIdent) val; - if (id.equals(inherit)) { + id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); expression.next(); continue; } - ident = getAllowedSingleIdent(id); - if (ident != null) { + if (getAllowedSingleIdent(id) != null) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(ident); + values.add(val); expression.next(); continue; } @@ -123,12 +124,13 @@ public CssContain(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // check possible duplication - if (values.contains(ident)) { + if (idvalues.contains(ident)) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - values.add(ident); + idvalues.add(ident); + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", op, getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssContent.java b/org/w3c/css/properties/css3/CssContent.java index 39b8baa8a..7f5b6bb01 100644 --- a/org/w3c/css/properties/css3/CssContent.java +++ b/org/w3c/css/properties/css3/CssContent.java @@ -260,7 +260,7 @@ protected static void checkCounterFunction(ApplContext ac, } v = exp.getValue(); if (v.getType() == CssTypes.CSS_IDENT) { - if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { + if (null == CssListStyleType.getAllowedIdent(v.getIdent())) { throw new InvalidParamException("value", v, property.getPropertyName(), ac); } @@ -311,7 +311,7 @@ protected static void checkCountersFunction(ApplContext ac, } v = exp.getValue(); if (v.getType() == CssTypes.CSS_IDENT) { - if (null == CssListStyleType.getAllowedIdent((CssIdent) v)) { + if (null == CssListStyleType.getAllowedIdent(v.getIdent())) { throw new InvalidParamException("value", v, property.getPropertyName(), ac); } diff --git a/org/w3c/css/properties/css3/CssFloat.java b/org/w3c/css/properties/css3/CssFloat.java index 4109a9cc8..7479eb6ff 100644 --- a/org/w3c/css/properties/css3/CssFloat.java +++ b/org/w3c/css/properties/css3/CssFloat.java @@ -13,16 +13,15 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2015/WD-css-page-floats-3-20150915/#propdef-float + * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#float-clear */ public class CssFloat extends org.w3c.css.properties.css.CssFloat { public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"block-start", "block-end", "inline-start", - "inline-end", "snap-block", "snap-inline", - "left", "right", "top", "bottom", "none"}; + String[] _allowed_values = {"both", "left", "right", "none", + "inline-start", "inline-end"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -52,8 +51,7 @@ public CssFloat() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloat(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -65,8 +63,7 @@ public CssFloat(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloat(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -82,16 +79,16 @@ public CssFloat(ApplContext ac, CssExpression expression, op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", From 3b182a85beec0e4c4e9bff58ebc07cfa76b982cf Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 22:28:57 +0200 Subject: [PATCH 51/82] print-color-adjust per https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210616/#propdef-print-color-adjust --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssPrintColorAdjust.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../properties/css3/CssPrintColorAdjust.java | 88 ++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 org/w3c/css/properties/css/CssPrintColorAdjust.java create mode 100644 org/w3c/css/properties/css3/CssPrintColorAdjust.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 1bb8bc85f..752b45e0d 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -22,6 +22,7 @@ font-variant-alternates: org.w3c.css.properties.css3.CssFontVaria color: org.w3c.css.properties.css3.CssColor color-adjust: org.w3c.css.properties.css3.CssColorAdjust +print-color-adjust: org.w3c.css.properties.css3.CssPrintColorAdjust forced-color-adjust: org.w3c.css.properties.css3.CssForcedColorAdjust color-scheme: org.w3c.css.properties.css3.CssColorScheme diff --git a/org/w3c/css/properties/css/CssPrintColorAdjust.java b/org/w3c/css/properties/css/CssPrintColorAdjust.java new file mode 100644 index 000000000..e992e84b3 --- /dev/null +++ b/org/w3c/css/properties/css/CssPrintColorAdjust.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2020. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssPrintColorAdjust extends CssProperty { + + /** + * Create a new CssPrintColorAdjust + */ + public CssPrintColorAdjust() { + } + + /** + * Creates a new CssPrintColorAdjust + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssPrintColorAdjust(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssPrintColorAdjust(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 final String getPropertyName() { + return "print-color-adjust"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssPrintColorAdjust != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssPrintColorAdjust = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssPrintColorAdjust && + value.equals(((CssPrintColorAdjust) property).value)); + } + + + /** + * 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).getPrintColorAdjust(); + } else { + return ((Css3Style) style).cssPrintColorAdjust; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 526bed53f..a67097b8e 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -198,6 +198,7 @@ import org.w3c.css.properties.css.CssPlaceContent; import org.w3c.css.properties.css.CssPlaceItems; import org.w3c.css.properties.css.CssPlaceSelf; +import org.w3c.css.properties.css.CssPrintColorAdjust; import org.w3c.css.properties.css.CssResize; import org.w3c.css.properties.css.CssRest; import org.w3c.css.properties.css.CssRestAfter; @@ -561,6 +562,7 @@ public class Css3Style extends ATSCStyle { public CssColorAdjust cssColorAdjust; public CssForcedColorAdjust cssForcedColorAdjust; public CssColorScheme cssColorScheme; + public CssPrintColorAdjust cssPrintColorAdjust; public CssBlockSize cssBlockSize; public CssInlineSize cssInlineSize; @@ -1222,6 +1224,15 @@ public CssColorScheme getColorScheme() { return cssColorScheme; } + public CssPrintColorAdjust getPrintColorAdjust() { + if (cssPrintColorAdjust == null) { + cssPrintColorAdjust = + (CssPrintColorAdjust) style.CascadingOrder(new CssPrintColorAdjust(), + style, selector); + } + return cssPrintColorAdjust; + } + public CssForcedColorAdjust getForcedColorAdjust() { if (cssForcedColorAdjust == null) { cssForcedColorAdjust = diff --git a/org/w3c/css/properties/css3/CssPrintColorAdjust.java b/org/w3c/css/properties/css3/CssPrintColorAdjust.java new file mode 100644 index 000000000..9ae93ef82 --- /dev/null +++ b/org/w3c/css/properties/css3/CssPrintColorAdjust.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2020. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +/** + * @spec https://www.w3.org/TR/2020/WD-css-color-adjust-1-20200402/#propdef-color-adjust + */ +public class CssPrintColorAdjust extends org.w3c.css.properties.css.CssColorAdjust { + + private static CssIdent[] allowed_values; + + static { + String id_values[] = {"economy", "exact"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssPrintColorAdjust + */ + public CssPrintColorAdjust() { + value = initial; + } + + /** + * Creates a new CssPrintColorAdjust + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssPrintColorAdjust(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + } else { + if (getMatchingIdent(ident) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + } + expression.next(); + } + + public CssPrintColorAdjust(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From a736b1a3371025c97786af883c1eb545ea9fd378 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 22:32:21 +0200 Subject: [PATCH 52/82] updated + cast (cont) --- .../css/properties/css3/CssColorAdjust.java | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/org/w3c/css/properties/css3/CssColorAdjust.java b/org/w3c/css/properties/css3/CssColorAdjust.java index bee9df203..4fb7f9bfa 100644 --- a/org/w3c/css/properties/css3/CssColorAdjust.java +++ b/org/w3c/css/properties/css3/CssColorAdjust.java @@ -13,30 +13,11 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2020/WD-css-color-adjust-1-20200402/#propdef-color-adjust + * @spec https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210616/#propdef-color-adjust + * @see CssPrintColorAdjust */ public class CssColorAdjust extends org.w3c.css.properties.css.CssColorAdjust { - private static CssIdent[] allowed_values; - - static { - String id_values[] = {"economy", "exact"}; - allowed_values = new CssIdent[id_values.length]; - int i = 0; - for (String s : id_values) { - allowed_values[i++] = CssIdent.getIdent(s); - } - } - - public static CssIdent getMatchingIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { - if (id.equals(ident)) { - return id; - } - } - return null; - } - /** * Create a new CssColorAdjust */ @@ -65,11 +46,11 @@ public CssColorAdjust(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (CssPrintColorAdjust.getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); From 24ae446068b2de58445b932532f61db12768308c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 8 Sep 2021 22:57:13 +0200 Subject: [PATCH 53/82] updated per https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210616/#propdef-forced-color-adjust --- .../css/properties/css3/CssForcedColorAdjust.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org/w3c/css/properties/css3/CssForcedColorAdjust.java b/org/w3c/css/properties/css3/CssForcedColorAdjust.java index 498aeeb34..0450177c4 100644 --- a/org/w3c/css/properties/css3/CssForcedColorAdjust.java +++ b/org/w3c/css/properties/css3/CssForcedColorAdjust.java @@ -13,14 +13,14 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2020/WD-css-color-adjust-1-20200402/#propdef-forced-color-adjust + * @spec https://www.w3.org/TR/2021/WD-css-color-adjust-1-20210616/#propdef-forced-color-adjust */ public class CssForcedColorAdjust extends org.w3c.css.properties.css.CssForcedColorAdjust { private static CssIdent[] allowed_values; static { - String id_values[] = {"auto", "none"}; + String id_values[] = {"auto", "none", "preserve-parent-color"}; allowed_values = new CssIdent[id_values.length]; int i = 0; for (String s : id_values) { @@ -65,11 +65,11 @@ public CssForcedColorAdjust(ApplContext ac, CssExpression expression, boolean ch getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(ident) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); From 499c27a7a4c903a4bf72e1db6a270ddbe6034fae Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 00:15:50 +0200 Subject: [PATCH 54/82] cast (cont) --- org/w3c/css/properties/css3/CssNavUp.java | 39 +++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/org/w3c/css/properties/css3/CssNavUp.java b/org/w3c/css/properties/css3/CssNavUp.java index 53db6977a..a09318ccb 100644 --- a/org/w3c/css/properties/css3/CssNavUp.java +++ b/org/w3c/css/properties/css3/CssNavUp.java @@ -9,7 +9,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; -import org.w3c.css.values.CssHashIdent; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssString; import org.w3c.css.values.CssTypes; @@ -67,8 +66,7 @@ public CssNavUp() { * @param ac The context * @param expression The expression for this property * @param check true will test the number of parameters - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssNavUp(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -82,8 +80,7 @@ public CssNavUp(ApplContext ac, CssExpression expression, boolean check) * * @param ac, the Context * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssNavUp(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -108,8 +105,7 @@ protected static CssValue parseNav(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_HASH_IDENT: - CssHashIdent hash = (CssHashIdent) val; - value = hash; + value = val; // we got it, we must check if there are other values if (expression.getRemainingCount() > 1) { if (op != SPACE) { @@ -118,26 +114,27 @@ protected static CssValue parseNav(ApplContext ac, CssExpression expression, ac); } ArrayList values = new ArrayList(); - values.add(hash); + values.add(val); expression.next(); val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent match = getMatchingNonUniqueIdent((CssIdent) val); - if (match == null) { + if (getMatchingNonUniqueIdent(val.getIdent()) == null) { throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } - values.add(match); + values.add(val); break; case CssTypes.CSS_STRING: - CssString s = (CssString) val; - if (s.toString().charAt(1) == '_') { - // TODO better error (do not start with _) - throw new InvalidParamException("value", val, - caller.getPropertyName(), ac); + if (val.getRawType() == CssTypes.CSS_STRING) { + CssString s = (CssString) val; + if (s.toString().charAt(1) == '_') { + // TODO better error (do not start with _) + throw new InvalidParamException("value", val, + caller.getPropertyName(), ac); + } } - values.add(s); + values.add(val); default: throw new InvalidParamException("value", val, caller.getPropertyName(), ac); @@ -146,20 +143,20 @@ protected static CssValue parseNav(ApplContext ac, CssExpression expression, } break; case CssTypes.CSS_IDENT: - CssIdent ide = (CssIdent) val; - if (inherit.equals(ide)) { + CssIdent ide = val.getIdent(); + if (CssIdent.isCssWide(ide)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit, caller.getPropertyName(), ac); } - value = inherit; + value = val; break; } else if (auto.equals(ide)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", auto, caller.getPropertyName(), ac); } - value = auto; + value = val; break; } // let it fail From 64a6db65b82802b417041eca4af434244bb1272d Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 09:15:54 +0200 Subject: [PATCH 55/82] cast (cont) --- org/w3c/css/properties/css3/CssFlexBasis.java | 9 ++--- .../css/properties/css3/CssFlexDirection.java | 10 +++--- org/w3c/css/properties/css3/CssFlexFlow.java | 33 +++++++++---------- org/w3c/css/properties/css3/CssFlexGrow.java | 8 ++--- .../css/properties/css3/CssFlexShrink.java | 8 ++--- org/w3c/css/properties/css3/CssFlexWrap.java | 13 ++++---- 6 files changed, 38 insertions(+), 43 deletions(-) diff --git a/org/w3c/css/properties/css3/CssFlexBasis.java b/org/w3c/css/properties/css3/CssFlexBasis.java index 9a2799d71..edecd7410 100644 --- a/org/w3c/css/properties/css3/CssFlexBasis.java +++ b/org/w3c/css/properties/css3/CssFlexBasis.java @@ -53,11 +53,12 @@ public CssFlexBasis(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; break; - } else if (content.equals(val)) { - value = content; + } else if (content.equals(ident)) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssFlexDirection.java b/org/w3c/css/properties/css3/CssFlexDirection.java index 89fb9fd28..da174f89d 100644 --- a/org/w3c/css/properties/css3/CssFlexDirection.java +++ b/org/w3c/css/properties/css3/CssFlexDirection.java @@ -65,16 +65,16 @@ public CssFlexDirection(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - value = getAllowedIdent(ident); - if (value == null) { + if (getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFlexFlow.java b/org/w3c/css/properties/css3/CssFlexFlow.java index 17446e776..29b56cb69 100644 --- a/org/w3c/css/properties/css3/CssFlexFlow.java +++ b/org/w3c/css/properties/css3/CssFlexFlow.java @@ -15,14 +15,13 @@ import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; +import java.util.ArrayList; + /** * @spec https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/#propdef-flex-flow */ public class CssFlexFlow extends org.w3c.css.properties.css.CssFlexFlow { - // TODO: remove the two private value option and use the - // CssValueList for value instead. - private CssFlexDirection flexDirection; private CssFlexWrap flexWrap; @@ -39,8 +38,7 @@ public CssFlexFlow() { * Creates a new CssFlexFlow * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFlexFlow(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -60,9 +58,9 @@ public CssFlexFlow(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), @@ -71,14 +69,14 @@ public CssFlexFlow(ApplContext ac, CssExpression expression, boolean check) break; } if (directionVal == null) { - directionVal = CssFlexDirection.getAllowedIdent(ident); - if (directionVal != null) { + if (CssFlexDirection.getAllowedIdent(ident) != null) { + directionVal = val; break; } } if (wrapVal == null) { - wrapVal = CssFlexWrap.getAllowedIdent(ident); - if (wrapVal != null) { + if (CssFlexWrap.getAllowedIdent(ident) != null) { + wrapVal = val; break; } } @@ -96,11 +94,12 @@ public CssFlexFlow(ApplContext ac, CssExpression expression, boolean check) // for addToStyle, redefinitions and equality check flexDirection = new CssFlexDirection(); flexWrap = new CssFlexWrap(); - if (value == inherit) { - flexDirection.value = inherit; - flexWrap.value = inherit; + if (wrapVal == null && directionVal == null) { + // css-wide ident + flexDirection.value = value; + flexWrap.value = value; } else { - CssValueList v = new CssValueList(); + ArrayList v = new ArrayList<>(); if (directionVal != null) { v.add(directionVal); flexDirection.value = directionVal; @@ -109,7 +108,7 @@ public CssFlexFlow(ApplContext ac, CssExpression expression, boolean check) v.add(wrapVal); flexWrap.value = wrapVal; } - value = v; + value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } } diff --git a/org/w3c/css/properties/css3/CssFlexGrow.java b/org/w3c/css/properties/css3/CssFlexGrow.java index 773cab789..9cbf1a505 100644 --- a/org/w3c/css/properties/css3/CssFlexGrow.java +++ b/org/w3c/css/properties/css3/CssFlexGrow.java @@ -29,8 +29,7 @@ public CssFlexGrow() { * Creates a new CssFlexGrow * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFlexGrow(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -52,9 +51,8 @@ public CssFlexGrow(ApplContext ac, CssExpression expression, boolean check) value = num; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } // let it flow diff --git a/org/w3c/css/properties/css3/CssFlexShrink.java b/org/w3c/css/properties/css3/CssFlexShrink.java index 2665e5b6a..b60ba83ac 100644 --- a/org/w3c/css/properties/css3/CssFlexShrink.java +++ b/org/w3c/css/properties/css3/CssFlexShrink.java @@ -29,8 +29,7 @@ public CssFlexShrink() { * Creates a new CssFlexShrink * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFlexShrink(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -52,9 +51,8 @@ public CssFlexShrink(ApplContext ac, CssExpression expression, boolean check) value = num; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } // let it flow diff --git a/org/w3c/css/properties/css3/CssFlexWrap.java b/org/w3c/css/properties/css3/CssFlexWrap.java index 7d8106323..9f6eb806a 100644 --- a/org/w3c/css/properties/css3/CssFlexWrap.java +++ b/org/w3c/css/properties/css3/CssFlexWrap.java @@ -48,8 +48,7 @@ public CssFlexWrap() { * Creates a new CssFlexWrap * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFlexWrap(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,16 +64,16 @@ public CssFlexWrap(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - value = getAllowedIdent(ident); - if (value == null) { + if (getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", From 7908e4ce761d9e0c64f643399dfdb61177454cce Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 09:23:17 +0200 Subject: [PATCH 56/82] cast + refs (cont) --- org/w3c/css/properties/css3/CssFloodColor.java | 13 +++++++------ org/w3c/css/properties/css3/CssFloodOpacity.java | 13 +++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/org/w3c/css/properties/css3/CssFloodColor.java b/org/w3c/css/properties/css3/CssFloodColor.java index 6deefd1d2..dd94842b7 100644 --- a/org/w3c/css/properties/css3/CssFloodColor.java +++ b/org/w3c/css/properties/css3/CssFloodColor.java @@ -8,10 +8,12 @@ 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; /** - * @spec http://www.w3.org/TR/2014/WD-filter-effects-1-20141125/#FloodColorProperty + * @spec https://www.w3.org/TR/2018/WD-filter-effects-1-20181218/#propdef-flood-color */ public class CssFloodColor extends org.w3c.css.properties.css.CssFloodColor { @@ -26,8 +28,7 @@ public CssFloodColor() { * Creates a new CssFloodColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFloodColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -38,15 +39,15 @@ public CssFloodColor(ApplContext ac, CssExpression expression, boolean check) setByUser(); CssValue val = expression.getValue(); - if (inherit.equals(val)) { - value = inherit; + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + value = val; expression.next(); } else { try { CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = tcolor.color; + value = (tcolor.color != null) ? tcolor.color : tcolor.value; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssFloodOpacity.java b/org/w3c/css/properties/css3/CssFloodOpacity.java index 3e13f13d0..d7a04f9a2 100644 --- a/org/w3c/css/properties/css3/CssFloodOpacity.java +++ b/org/w3c/css/properties/css3/CssFloodOpacity.java @@ -1,4 +1,4 @@ -// $Id$ +// // Author: Yves Lafon // // (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2015. @@ -8,11 +8,12 @@ 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; /** - * @spec http://www.w3.org/TR/2014/WD-filter-effects-1-20141125/#FloodOpacityProperty + * @spec https://www.w3.org/TR/2018/WD-filter-effects-1-20181218/#propdef-flood-opacity */ public class CssFloodOpacity extends org.w3c.css.properties.css.CssFloodOpacity { @@ -42,8 +43,16 @@ public CssFloodOpacity(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_NUMBER: case CssTypes.CSS_PERCENTAGE: + val.getCheckableValue().warnPositiveness(ac, getPropertyName()); + // FIXME TODO clamp warnings value = val; break; + case CssTypes.CSS_IDENT: + if (CssIdent.isCssWide(val.getIdent())) { + value = val; + break; + } + // unrecognized ident, let it fail default: throw new InvalidParamException("value", val.toString(), From e63f9511a783568ddeba0da3a2c2e615933efed4 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 09:35:34 +0200 Subject: [PATCH 57/82] refs+cast (cont) --- .../css3/CssColorInterpolationFilters.java | 15 +++++++-------- org/w3c/css/properties/css3/CssFilter.java | 6 +++--- org/w3c/css/properties/css3/CssLightingColor.java | 10 ++++++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/org/w3c/css/properties/css3/CssColorInterpolationFilters.java b/org/w3c/css/properties/css3/CssColorInterpolationFilters.java index 07be8aeda..f7493f48e 100644 --- a/org/w3c/css/properties/css3/CssColorInterpolationFilters.java +++ b/org/w3c/css/properties/css3/CssColorInterpolationFilters.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2014/WD-filter-effects-1-20141125/#ColorInterpolationFiltersProperty + * @spec https://www.w3.org/TR/2018/WD-filter-effects-1-20181218/#propdef-color-interpolation-filters */ public class CssColorInterpolationFilters extends org.w3c.css.properties.css.CssColorInterpolationFilters { @@ -48,8 +48,7 @@ public CssColorInterpolationFilters() { * Creates a new CssColorInterpolationFilters * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssColorInterpolationFilters(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,16 +64,16 @@ public CssColorInterpolationFilters(ApplContext ac, CssExpression expression, bo op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - value = getAllowedValue(ident); - if (value == null) { + if (getAllowedValue(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFilter.java b/org/w3c/css/properties/css3/CssFilter.java index 7ba46f5cd..0523687f3 100644 --- a/org/w3c/css/properties/css3/CssFilter.java +++ b/org/w3c/css/properties/css3/CssFilter.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2014/WD-filter-effects-1-20141125/#propdef-filter + * @spec https://www.w3.org/TR/2018/WD-filter-effects-1-20181218/#propdef-filter * @spec http://www.w3.org/TR/SVG/filters.html#FilterProperty * @see * @see @@ -113,10 +113,10 @@ public CssFilter(final ApplContext ac, final CssExpression expression, final boo break; } if (allowLegacyIEValues(ac)) { - value = getLegacyIEIdent(ident); - if (value != null) { + if (getLegacyIEIdent(ident) != null) { singleVal = true; ac.getFrame().addWarning("vendor-extension", expression.toStringFromStart()); + value = val; break; } // not found? let it flow and fail. diff --git a/org/w3c/css/properties/css3/CssLightingColor.java b/org/w3c/css/properties/css3/CssLightingColor.java index 4f8fbe779..80ed57b74 100644 --- a/org/w3c/css/properties/css3/CssLightingColor.java +++ b/org/w3c/css/properties/css3/CssLightingColor.java @@ -8,10 +8,12 @@ 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; /** - * @spec http://www.w3.org/TR/2014/WD-filter-effects-1-20141125/#LightingColorProperty + * @spec https://www.w3.org/TR/2018/WD-filter-effects-1-20181218/#propdef-lighting-color */ public class CssLightingColor extends org.w3c.css.properties.css.CssLightingColor { @@ -38,15 +40,15 @@ public CssLightingColor(ApplContext ac, CssExpression expression, boolean check) setByUser(); CssValue val = expression.getValue(); - if (inherit.equals(val)) { - value = inherit; + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + value = val; expression.next(); } else { try { CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = tcolor.color; + value = (tcolor.color != null) ? tcolor.color : tcolor.value; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), From c7eee2fb9da14539387fcf7a3d7e05551c83ebcd Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 09:41:07 +0200 Subject: [PATCH 58/82] cast (cont) --- .../properties/css3/CssPageBreakAfter.java | 10 +++++----- .../properties/css3/CssPageBreakBefore.java | 13 ++++++------- .../properties/css3/CssPageBreakInside.java | 19 +++++++------------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/org/w3c/css/properties/css3/CssPageBreakAfter.java b/org/w3c/css/properties/css3/CssPageBreakAfter.java index 247a6d69a..5347f2abf 100644 --- a/org/w3c/css/properties/css3/CssPageBreakAfter.java +++ b/org/w3c/css/properties/css3/CssPageBreakAfter.java @@ -65,16 +65,16 @@ public CssPageBreakAfter(ApplContext ac, CssExpression expression, boolean check op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssPageBreakBefore.java b/org/w3c/css/properties/css3/CssPageBreakBefore.java index 637018df0..465f4a152 100644 --- a/org/w3c/css/properties/css3/CssPageBreakBefore.java +++ b/org/w3c/css/properties/css3/CssPageBreakBefore.java @@ -48,8 +48,7 @@ public CssPageBreakBefore() { * Creates a new CssPageBreakBefore * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssPageBreakBefore(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,16 +64,16 @@ public CssPageBreakBefore(ApplContext ac, CssExpression expression, boolean chec op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssPageBreakInside.java b/org/w3c/css/properties/css3/CssPageBreakInside.java index ff35730b8..59eaa84b9 100644 --- a/org/w3c/css/properties/css3/CssPageBreakInside.java +++ b/org/w3c/css/properties/css3/CssPageBreakInside.java @@ -48,8 +48,7 @@ public CssPageBreakInside() { * Creates a new CssPageBreakInside * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssPageBreakInside(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,17 +64,13 @@ public CssPageBreakInside(ApplContext ac, CssExpression expression, boolean chec op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; } else { throw new InvalidParamException("value", val.toString(), From e1250b6ff5de8ba98eeb2db52576db6b18104d03 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 10:19:37 +0200 Subject: [PATCH 59/82] cast (cont) + marked as deprecated --- org/w3c/css/properties/css3/CssImeMode.java | 24 ++++++++++----------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/org/w3c/css/properties/css3/CssImeMode.java b/org/w3c/css/properties/css3/CssImeMode.java index 448053427..905d69ee8 100644 --- a/org/w3c/css/properties/css3/CssImeMode.java +++ b/org/w3c/css/properties/css3/CssImeMode.java @@ -13,7 +13,8 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2012/WD-css3-ui-20120117/#ime-mode + * @spec https://www.w3.org/TR/2018/REC-css-ui-3-20180621/#input-method-editor + * @deprecated */ public class CssImeMode extends org.w3c.css.properties.css.CssImeMode { @@ -49,14 +50,15 @@ public CssImeMode() { * Creates a new CssImeMode * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssImeMode(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); + ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); + if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } @@ -66,18 +68,14 @@ public CssImeMode(ApplContext ac, CssExpression expression, boolean check) expression.getValue(), getPropertyName(), ac); } + CssIdent id = val.getIdent(); // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; - } else { - val = getAllowedIdent((CssIdent) val); - if (val == null) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); - } - value = val; + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } From 7c590b0d81456975d351653f32576b65c82aea84 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 10:49:16 +0200 Subject: [PATCH 60/82] inline-sizing per https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-inline-sizing --- .../css/properties/CSS3Properties.properties | 2 +- .../css/properties/css/CssInlineSizing.java | 114 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssInlineSizing.java | 85 +++++++++++++ 4 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 org/w3c/css/properties/css/CssInlineSizing.java create mode 100644 org/w3c/css/properties/css3/CssInlineSizing.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 752b45e0d..be453e509 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -455,7 +455,7 @@ alignment-baseline: org.w3c.css.properties.css3.CssAlignment initial-letter: org.w3c.css.properties.css3.CssInitialLetter initial-letter-align: org.w3c.css.properties.css3.CssInitialLetterAlign initial-letter-wrap: org.w3c.css.properties.css3.CssInitialLetterWrap - +inline-sizing: org.w3c.css.properties.css3.CssInlineSizing # CSS Multi-column Layout Module # http://www.w3.org/TR/css3-multicol/ diff --git a/org/w3c/css/properties/css/CssInlineSizing.java b/org/w3c/css/properties/css/CssInlineSizing.java new file mode 100644 index 000000000..a73a6c464 --- /dev/null +++ b/org/w3c/css/properties/css/CssInlineSizing.java @@ -0,0 +1,114 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssInlineSizing extends CssProperty { + + + /** + * Create a new CssInlineSizing + */ + public CssInlineSizing() { + } + + /** + * Creates a new CssInlineSizing + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssInlineSizing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssInlineSizing(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 final String getPropertyName() { + return "inline-sizing"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssInlineSizing != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssInlineSizing = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssInlineSizing && + value.equals(((CssInlineSizing) property).value)); + } + + + /** + * 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).getInlineSizing(); + } else { + return ((Css3Style) style).cssInlineSizing; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index a67097b8e..d7b94ec59 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -144,6 +144,7 @@ import org.w3c.css.properties.css.CssInitialLetterAlign; import org.w3c.css.properties.css.CssInitialLetterWrap; import org.w3c.css.properties.css.CssInlineSize; +import org.w3c.css.properties.css.CssInlineSizing; import org.w3c.css.properties.css.CssInset; import org.w3c.css.properties.css.CssInsetBlock; import org.w3c.css.properties.css.CssInsetBlockEnd; @@ -418,6 +419,7 @@ public class Css3Style extends ATSCStyle { public CssInitialLetter cssInitialLetter; public CssInitialLetterAlign cssInitialLetterAlign; public CssInitialLetterWrap cssInitialLetterWrap; + public CssInlineSizing cssInlineSizing; public CssOpacity cssOpacity; public CssBackgroundClip cssBackgroundClip; @@ -2139,6 +2141,15 @@ public CssTextAlignLast getTextAlignLast() { return cssTextAlignLast; } + public CssInlineSizing getInlineSizing() { + if (cssInlineSizing == null) { + cssInlineSizing = + (CssInlineSizing) style.CascadingOrder( + new CssInlineSizing(), style, selector); + } + return cssInlineSizing; + } + public CssDominantBaseline getDominantBaseline() { if (cssDominantBaseline == null) { cssDominantBaseline = diff --git a/org/w3c/css/properties/css3/CssInlineSizing.java b/org/w3c/css/properties/css3/CssInlineSizing.java new file mode 100644 index 000000000..fcbb487bc --- /dev/null +++ b/org/w3c/css/properties/css3/CssInlineSizing.java @@ -0,0 +1,85 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +/** + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-inline-sizing + */ +public class CssInlineSizing extends org.w3c.css.properties.css.CssInlineSizing { + + public static final CssIdent[] allowed_values; + + static { + String[] _allowed_values = {"normal", "stretch"}; + allowed_values = new CssIdent[_allowed_values.length]; + int i = 0; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssInlineSizing + */ + public CssInlineSizing() { + value = initial; + } + + /** + * Creates a new CssInlineSizing + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssInlineSizing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val = expression.getValue(); + + if (val.getType() == CssTypes.CSS_IDENT) { + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && getAllowedIdent(ident) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + } else { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + expression.next(); + + } + + public CssInlineSizing(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From a3e71f305b74507bb4e0de71ea3cc211a8354c0b Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 10:57:12 +0200 Subject: [PATCH 61/82] baseline-source per https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-baseline-source --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssBaselineSource.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../properties/css3/CssBaselineSource.java | 85 +++++++++++++ 4 files changed, 210 insertions(+) create mode 100644 org/w3c/css/properties/css/CssBaselineSource.java create mode 100644 org/w3c/css/properties/css3/CssBaselineSource.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index be453e509..a85cd5be1 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -450,6 +450,7 @@ handheld.background-clip: org.w3c.css.properties.css3.CssBackgroun # CSS Inline baseline-shift: org.w3c.css.properties.css3.CssBaselineShift +baseline-source: org.w3c.css.properties.css3.CssBaselineSource dominant-baseline: org.w3c.css.properties.css3.CssDominantBaseline alignment-baseline: org.w3c.css.properties.css3.CssAlignmentBaseline initial-letter: org.w3c.css.properties.css3.CssInitialLetter diff --git a/org/w3c/css/properties/css/CssBaselineSource.java b/org/w3c/css/properties/css/CssBaselineSource.java new file mode 100644 index 000000000..7f5988873 --- /dev/null +++ b/org/w3c/css/properties/css/CssBaselineSource.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssBaselineSource extends CssProperty { + + /** + * Create a new CssBaselineSource + */ + public CssBaselineSource() { + } + + /** + * Creates a new CssBaselineSource + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssBaselineSource(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssBaselineSource(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 final String getPropertyName() { + return "baseline-source"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssBaselineSource != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssBaselineSource = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssBaselineSource && + value.equals(((CssBaselineSource) property).value)); + } + + + /** + * 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).getBaselineSource(); + } else { + return ((Css3Style) style).cssBaselineSource; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index d7b94ec59..628b61809 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -35,6 +35,7 @@ import org.w3c.css.properties.css.CssBackgroundPositionY; import org.w3c.css.properties.css.CssBackgroundSize; import org.w3c.css.properties.css.CssBaselineShift; +import org.w3c.css.properties.css.CssBaselineSource; import org.w3c.css.properties.css.CssBlockSize; import org.w3c.css.properties.css.CssBorderBlock; import org.w3c.css.properties.css.CssBorderBlockColor; @@ -420,6 +421,7 @@ public class Css3Style extends ATSCStyle { public CssInitialLetterAlign cssInitialLetterAlign; public CssInitialLetterWrap cssInitialLetterWrap; public CssInlineSizing cssInlineSizing; + public CssBaselineSource cssBaselineSource; public CssOpacity cssOpacity; public CssBackgroundClip cssBackgroundClip; @@ -2177,6 +2179,15 @@ public CssBaselineShift getBaselineShift() { return cssBaselineShift; } + public CssBaselineSource getBaselineSource() { + if (cssBaselineSource == null) { + cssBaselineSource = + (CssBaselineSource) style.CascadingOrder( + new CssBaselineSource(), style, selector); + } + return cssBaselineSource; + } + public CssInitialLetter getInitialLetter() { if (cssInitialLetter == null) { cssInitialLetter = diff --git a/org/w3c/css/properties/css3/CssBaselineSource.java b/org/w3c/css/properties/css3/CssBaselineSource.java new file mode 100644 index 000000000..8d0e95142 --- /dev/null +++ b/org/w3c/css/properties/css3/CssBaselineSource.java @@ -0,0 +1,85 @@ +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2015. +// Please first read the full copyright statement in file COPYRIGHT.html + +package org.w3c.css.properties.css3; + +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; + +/** + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-baseline-source + */ + +public class CssBaselineSource extends org.w3c.css.properties.css.CssBaselineSource { + + public static final CssIdent[] allowed_values; + + static { + String[] _allowed_values = {"auto", "first", "last"}; + int i = 0; + allowed_values = new CssIdent[_allowed_values.length]; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static final CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Creates a new CssBaselineSource + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssBaselineSource(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + + val = expression.getValue(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; + break; + } + if (getAllowedIdent(id) != null) { + value = val; + break; + } + // unrecognized ident -> fail. + default: + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + + } + + + public CssBaselineSource(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + +} From f8dcfc773df90ebe5bcc4d8d84e556d1d701768e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 10:57:28 +0200 Subject: [PATCH 62/82] cast+refs (cont.) --- .../css/properties/css3/CssInitialLetter.java | 52 ++++++++++++++----- .../css3/CssInitialLetterAlign.java | 19 ++++--- .../properties/css3/CssInitialLetterWrap.java | 15 +++--- .../css/properties/css3/CssMarkerSide.java | 16 +++--- 4 files changed, 62 insertions(+), 40 deletions(-) diff --git a/org/w3c/css/properties/css3/CssInitialLetter.java b/org/w3c/css/properties/css3/CssInitialLetter.java index b8746d080..0604a53b0 100644 --- a/org/w3c/css/properties/css3/CssInitialLetter.java +++ b/org/w3c/css/properties/css3/CssInitialLetter.java @@ -18,12 +18,32 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#propdef-initial-letter + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-initial-letter */ public class CssInitialLetter extends org.w3c.css.properties.css.CssInitialLetter { CssIdent normal = CssIdent.getIdent("normal"); + public static final CssIdent[] allowed_values; + + static { + String[] _allowed_values = {"drop", "raise"}; + allowed_values = new CssIdent[_allowed_values.length]; + int i = 0; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + /** * Create a new CssInitialLetter */ @@ -36,8 +56,7 @@ public CssInitialLetter() { * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssInitialLetter(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -68,18 +87,18 @@ public CssInitialLetter(ApplContext ac, CssExpression expression, v.add(val); break; case CssTypes.CSS_IDENT: - // we can have only one ident - if (expression.getCount() > 1) { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || normal.equals(id)) { + // we can have only one ident + if (expression.getCount() > 1) { + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); + } + value = val; break; } - if (normal.equals(id)) { - value = normal; + if (getAllowedIdent(id) != null) { + v.add(val); break; } default: @@ -92,7 +111,12 @@ public CssInitialLetter(ApplContext ac, CssExpression expression, } expression.next(); } - if (value != inherit) { + if (!v.isEmpty()) { + // sanity check, we cannot have two idents + if (v.size() == 2 && !got_number) { + throw new InvalidParamException("value", v.get(1), + getPropertyName(), ac); + } value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } } diff --git a/org/w3c/css/properties/css3/CssInitialLetterAlign.java b/org/w3c/css/properties/css3/CssInitialLetterAlign.java index 3fe7756de..e645d685c 100644 --- a/org/w3c/css/properties/css3/CssInitialLetterAlign.java +++ b/org/w3c/css/properties/css3/CssInitialLetterAlign.java @@ -17,7 +17,7 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#propdef-initial-letter + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-initial-letter-align */ public class CssInitialLetterAlign extends org.w3c.css.properties.css.CssInitialLetterAlign { @@ -26,7 +26,7 @@ public class CssInitialLetterAlign extends org.w3c.css.properties.css.CssInitial public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"alphabetic", "ideographic", "hebrew", "hanging"}; + String[] _allowed_values = {"alphabetic", "ideographic", "leading", "hanging"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -77,26 +77,25 @@ public CssInitialLetterAlign(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - value = inherit; + value = val; break; } // border_box can only be first. if (border_box.equals(id) && v.isEmpty()) { - v.add(border_box); + v.add(val); got_border_box = true; break; } - id = getAllowedIdent(id); - if (id != null) { + if (getAllowedIdent(id) != null) { // a match! We can't have two of them so... if (v.isEmpty() || got_border_box) { - v.add(id); + v.add(val); break; } } @@ -110,7 +109,7 @@ public CssInitialLetterAlign(ApplContext ac, CssExpression expression, } expression.next(); } - if (value != inherit) { + if (!v.isEmpty()) { value = (v.size() == 1) ? v.get(0) : new CssValueList(v); } } diff --git a/org/w3c/css/properties/css3/CssInitialLetterWrap.java b/org/w3c/css/properties/css3/CssInitialLetterWrap.java index c91b05cca..b8a262320 100644 --- a/org/w3c/css/properties/css3/CssInitialLetterWrap.java +++ b/org/w3c/css/properties/css3/CssInitialLetterWrap.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#propdef-initial-letter-wrap + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-initial-letter-wrap */ public class CssInitialLetterWrap extends org.w3c.css.properties.css.CssInitialLetterWrap { @@ -49,8 +49,7 @@ public CssInitialLetterWrap() { * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssInitialLetterWrap(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -71,13 +70,13 @@ public CssInitialLetterWrap(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent(id); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssMarkerSide.java b/org/w3c/css/properties/css3/CssMarkerSide.java index acae1d793..6f86bad35 100644 --- a/org/w3c/css/properties/css3/CssMarkerSide.java +++ b/org/w3c/css/properties/css3/CssMarkerSide.java @@ -13,14 +13,14 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-marker-side + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-marker-side */ public class CssMarkerSide extends org.w3c.css.properties.css.CssMarkerSide { public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"list-item", "list-container"}; + String[] _allowed_values = {"match-self", "match-parent"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -48,8 +48,7 @@ public CssMarkerSide() { * Creates a new CssMarkerSide * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssMarkerSide(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -64,12 +63,13 @@ public CssMarkerSide(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent((CssIdent) val); - if (value != null) { + if (getAllowedIdent(id) != null) { + value = val; break; } // unrecognized ident.. fail! From c87ee827212ac3cb8a499c45e9373ffbaa0b62b3 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 11:18:33 +0200 Subject: [PATCH 63/82] cast+refs (cont.) --- .../properties/css3/CssJustifyContent.java | 37 +++++------- .../css/properties/css3/CssJustifyItems.java | 60 +++++++++---------- .../css/properties/css3/CssJustifySelf.java | 60 ++++++++++--------- 3 files changed, 75 insertions(+), 82 deletions(-) diff --git a/org/w3c/css/properties/css3/CssJustifyContent.java b/org/w3c/css/properties/css3/CssJustifyContent.java index 68ae68ce3..3774feac8 100644 --- a/org/w3c/css/properties/css3/CssJustifyContent.java +++ b/org/w3c/css/properties/css3/CssJustifyContent.java @@ -19,10 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * original - * @spec https://www.w3.org/TR/2018/CR-css-flexbox-1-20181119/#propdef-justify-content - * replaced by - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-justify-content + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-justify-content */ public class CssJustifyContent extends org.w3c.css.properties.css.CssJustifyContent { @@ -78,7 +75,7 @@ public CssJustifyContent(ApplContext ac, CssExpression expression, boolean check public static CssValue parseJustifyContent(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -86,34 +83,31 @@ public static CssValue parseJustifyContent(ApplContext ac, CssExpression express op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } expression.next(); - return inherit; + return val; } if (normal.equals(ident)) { expression.next(); - return normal; + return val; } - value = CssAlignContent.getContentDistribution(ident); - if (value != null) { + if (CssAlignContent.getContentDistribution(ident) != null) { expression.next(); - return value; + return val; } - // now try the two-values position, starting first with only one. - value = getContentPositionAndExtras(ident); - if (value != null) { + // now try the potential two-values position, starting first with only one. + if (getContentPositionAndExtras(ident) != null) { expression.next(); - return value; + return val; } // ok, at that point we need two values. - value = CssAlignContent.getOverflowPosition(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getOverflowPosition(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -127,12 +121,11 @@ public static CssValue parseJustifyContent(ApplContext ac, CssExpression express throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = getContentPositionAndExtras((CssIdent) val); - if (value == null) { + if (getContentPositionAndExtras(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(value); + values.add(val); expression.next(); return new CssValueList(values); } diff --git a/org/w3c/css/properties/css3/CssJustifyItems.java b/org/w3c/css/properties/css3/CssJustifyItems.java index 9b1f4e1fe..5d2ea324b 100644 --- a/org/w3c/css/properties/css3/CssJustifyItems.java +++ b/org/w3c/css/properties/css3/CssJustifyItems.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#justify-items-property + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-justify-items */ public class CssJustifyItems extends org.w3c.css.properties.css.CssJustifyItems { @@ -106,7 +106,7 @@ public CssJustifyItems(ApplContext ac, CssExpression expression, boolean check) public static CssValue parseJustifyItems(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -114,19 +114,18 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } expression.next(); - return inherit; + return val; } - value = getSingleJustifyItemsValue(ident); - if (value != null) { + if (getSingleJustifyItemsValue(ident) != null) { expression.next(); - return value; + return val; } // now try the two-values position, starting first with only one. if (CssAlignContent.baseline.equals(ident)) { @@ -134,37 +133,35 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio return CssAlignContent.baseline; } // we must check the extras first - value = getLegacyQualifier(ident); // legacy qualifier are part of self-position, so we may have nothing - if (value != null) { + if (getLegacyQualifier(ident) != null) { expression.next(); if (expression.end()) { - return value; + return val; } + values.add(val); val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !legacy.equals(val)) { - return value; + if (val.getType() != CssTypes.CSS_IDENT || !legacy.equals(val.getIdent())) { + // FIXME sreturn or throw??? + return val; } // ok, we got a leagacy, operator check and return if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); } - values.add(value); - values.add(legacy); + values.add(val); expression.next(); return new CssValueList(values); } - value = getSelfPositionAddExtras(ident); - if (value != null) { + if (getSelfPositionAddExtras(ident) != null) { expression.next(); - return value; + return val; } // ok, at that point we need two values. - value = CssAlignContent.getBaselineQualifier(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getBaselineQualifier(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -174,17 +171,16 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio throw new InvalidParamException("unrecognize", ac); } val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(CssAlignContent.baseline); + values.add(val); expression.next(); return new CssValueList(values); } - value = CssAlignContent.getOverflowPosition(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getOverflowPosition(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -198,12 +194,11 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = getSelfPositionAddExtras((CssIdent) val); - if (value == null) { + if (getSelfPositionAddExtras(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(value); + values.add(val); expression.next(); return new CssValueList(values); } @@ -212,14 +207,13 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio // we can have nothing or a qualifier here. expression.next(); if (expression.end()) { - return legacy; + return val; } val = expression.getValue(); if (val.getType() != CssTypes.CSS_IDENT) { return legacy; // let the caller check and fail if necessary } - value = getLegacyQualifier((CssIdent) val); - if (value == null) { + if (getLegacyQualifier(val.getIdent()) == null) { return legacy; } // so we got something, check the operator @@ -228,7 +222,7 @@ public static CssValue parseJustifyItems(ApplContext ac, CssExpression expressio Character.toString(op), ac); } values.add(legacy); - values.add(value); + values.add(val); expression.next(); return new CssValueList(values); } diff --git a/org/w3c/css/properties/css3/CssJustifySelf.java b/org/w3c/css/properties/css3/CssJustifySelf.java index 2bf25f369..c225d8115 100644 --- a/org/w3c/css/properties/css3/CssJustifySelf.java +++ b/org/w3c/css/properties/css3/CssJustifySelf.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#justify-self-property + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-justify-self */ public class CssJustifySelf extends org.w3c.css.properties.css.CssJustifySelf { @@ -54,8 +54,7 @@ public CssJustifySelf() { * Creates a new CssAlignSelf * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssJustifySelf(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -73,7 +72,7 @@ public CssJustifySelf(ApplContext ac, CssExpression expression, boolean check) public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { - CssValue val, value; + CssValue val; ArrayList values = new ArrayList<>(); char op; @@ -81,34 +80,43 @@ public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } expression.next(); - return inherit; + return val; } - value = CssAlignSelf.getSingleAlignSelfValue(ident); - if (value != null) { + if (CssAlignSelf.getSingleAlignSelfValue(ident) != null) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } expression.next(); - return value; + return val; } - // now try the two-values position, starting first with only one. + // now try the two-values position, starting first with the "only one value" case if (CssAlignContent.baseline.equals(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } expression.next(); - return CssAlignContent.baseline; + return val; } - value = getSelfPositionAddExtras(ident); - if (value != null) { + if (getSelfPositionAddExtras(ident) != null) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } expression.next(); - return value; + return val; } - // ok, at that point we need two values. - value = CssAlignContent.getBaselineQualifier(ident); - if (value != null) { - values.add(value); + // ok, at that point we really need two values. + if (CssAlignContent.getBaselineQualifier(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -118,17 +126,16 @@ public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression throw new InvalidParamException("unrecognize", ac); } val = expression.getValue(); - if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(CssAlignContent.baseline); + values.add(val); expression.next(); return new CssValueList(values); } - value = CssAlignContent.getOverflowPosition(ident); - if (value != null) { - values.add(value); + if (CssAlignContent.getOverflowPosition(ident) != null) { + values.add(val); if (op != SPACE) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -142,12 +149,11 @@ public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - value = getSelfPositionAddExtras((CssIdent) val); - if (value == null) { + if (getSelfPositionAddExtras(val.getIdent()) == null) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - values.add(value); + values.add(val); expression.next(); return new CssValueList(values); } From 25254da3f248fea4564526a5b2857c7c4553319a Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 11:35:05 +0200 Subject: [PATCH 64/82] mark as deprecated --- .../css3/CssGlyphOrientationVertical.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/org/w3c/css/properties/css3/CssGlyphOrientationVertical.java b/org/w3c/css/properties/css3/CssGlyphOrientationVertical.java index 1028877c3..31dce743f 100644 --- a/org/w3c/css/properties/css3/CssGlyphOrientationVertical.java +++ b/org/w3c/css/properties/css3/CssGlyphOrientationVertical.java @@ -18,7 +18,8 @@ import java.math.BigDecimal; /** - * @spec https://www.w3.org/TR/2018/CR-css-writing-modes-3-20180524/#propdef-glyph-orientation-vertical + * @spec https://www.w3.org/TR/2019/REC-css-writing-modes-3-20191210/#propdef-glyph-orientation-vertical + * @deprecated */ public class CssGlyphOrientationVertical extends org.w3c.css.properties.css.CssGlyphOrientationVertical { @@ -82,6 +83,7 @@ public CssGlyphOrientationVertical(ApplContext ac, CssExpression expression, boo throw new InvalidParamException("unrecognize", ac); } setByUser(); + ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); CssValue val; val = expression.getValue(); @@ -112,12 +114,9 @@ public CssGlyphOrientationVertical(ApplContext ac, CssExpression expression, boo } break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - break; - } - if (auto.equals(val)) { - value = auto; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || auto.equals(id)) { + value = val; break; } default: From f1143becc15bdabde5304103a184deae1e6db027 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 12:26:29 +0200 Subject: [PATCH 65/82] cast+refs (cont.) + a few updates --- .../css3/CssHangingPunctuation.java | 31 ++++++++------- org/w3c/css/properties/css3/CssHyphens.java | 26 +++++-------- org/w3c/css/properties/css3/CssListStyle.java | 30 +++++++-------- .../properties/css3/CssListStyleImage.java | 12 +++--- .../properties/css3/CssListStylePosition.java | 24 +++++------- .../css/properties/css3/CssListStyleType.java | 38 ++++++++----------- 6 files changed, 69 insertions(+), 92 deletions(-) diff --git a/org/w3c/css/properties/css3/CssHangingPunctuation.java b/org/w3c/css/properties/css3/CssHangingPunctuation.java index 839a6c181..759c2e98b 100644 --- a/org/w3c/css/properties/css3/CssHangingPunctuation.java +++ b/org/w3c/css/properties/css3/CssHangingPunctuation.java @@ -17,7 +17,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-hanging-punctuation + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-hanging-punctuation */ public class CssHangingPunctuation extends org.w3c.css.properties.css.CssHangingPunctuation { @@ -57,8 +57,7 @@ public CssHangingPunctuation() { * Creates a new CssHangingPunctuation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssHangingPunctuation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -70,9 +69,9 @@ public CssHangingPunctuation(ApplContext ac, CssExpression expression, boolean c CssValue val; char op; - CssIdent firstValue = null; - CssIdent lastValue = null; - CssIdent endValue = null; + CssValue firstValue = null; + CssValue lastValue = null; + CssValue endValue = null; val = expression.getValue(); op = expression.getOperator(); @@ -83,16 +82,16 @@ public CssHangingPunctuation(ApplContext ac, CssExpression expression, boolean c getPropertyName(), ac); } - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } } else if (none.equals(ident)) { - value = none; + value = val; if (check && expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), @@ -103,15 +102,15 @@ public CssHangingPunctuation(ApplContext ac, CssExpression expression, boolean c do { boolean match = false; if (firstValue == null && first.equals(ident)) { - firstValue = first; + firstValue = val; match = true; } else if (lastValue == null && last.equals(ident)) { - lastValue = last; + lastValue = val; match = true; } else { - if (endValue == null) { - endValue = getEndValue(ident); - match = (endValue != null); + if ((endValue == null) && (getEndValue(ident) != null)) { + endValue = val; + match = true; } } if (!match) { @@ -137,7 +136,7 @@ public CssHangingPunctuation(ApplContext ac, CssExpression expression, boolean c val.toString(), getPropertyName(), ac); } - ident = (CssIdent) val; + ident = val.getIdent(); } while (!expression.end()); // now construct the value ArrayList v = new ArrayList(nbgot); diff --git a/org/w3c/css/properties/css3/CssHyphens.java b/org/w3c/css/properties/css3/CssHyphens.java index 0119f4cf0..71dfca0b3 100644 --- a/org/w3c/css/properties/css3/CssHyphens.java +++ b/org/w3c/css/properties/css3/CssHyphens.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @pec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#hyphens-property + * @pec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-hyphens */ public class CssHyphens extends org.w3c.css.properties.css.CssHyphens { @@ -51,8 +51,7 @@ public CssHyphens() { * Creates a new CssHyphens * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssHyphens(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -67,23 +66,18 @@ public CssHyphens(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && getAllowedValue(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssListStyle.java b/org/w3c/css/properties/css3/CssListStyle.java index 1616641fe..8a169ea34 100644 --- a/org/w3c/css/properties/css3/CssListStyle.java +++ b/org/w3c/css/properties/css3/CssListStyle.java @@ -39,8 +39,7 @@ public CssListStyle() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStyle(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -52,8 +51,7 @@ public CssListStyle(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -99,22 +97,22 @@ public CssListStyle(ApplContext ac, CssExpression expression, typeVal = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; - imageVal = inherit; - positionVal = inherit; - typeVal = inherit; + value = val; + imageVal = val; + positionVal = val; + typeVal = val; break; } - if (none.equals(val)) { + if (none.equals(id)) { nbnone++; break; } // now we go to other values... - CssIdent id = (CssIdent) val; if (positionVal == null) { positionVal = CssListStylePosition.getAllowedIdent(id); if (positionVal != null) { @@ -179,8 +177,8 @@ public CssListStyle(ApplContext ac, CssExpression expression, } } - // set the value - if (value != inherit) { + // set the value if we parse a non-wide value + if (nbnone != 0 || imageVal != null || typeVal != null || positionVal != null) { ArrayList v = new ArrayList(); if (typeVal != null) { v.add(typeVal); @@ -197,10 +195,10 @@ public CssListStyle(ApplContext ac, CssExpression expression, } // then the shorthand values cssListStyleType = new CssListStyleType(); - cssListStyleType.value = typeVal; + cssListStyleType.value = (typeVal == null) ? initial : typeVal; cssListStylePosition = new CssListStylePosition(); - cssListStylePosition.value = positionVal; + cssListStylePosition.value = (positionVal == null) ? initial : positionVal; cssListStyleImage = new CssListStyleImage(); - cssListStyleImage.value = imageVal; + cssListStyleImage.value = (imageVal == null) ? initial : imageVal; } } diff --git a/org/w3c/css/properties/css3/CssListStyleImage.java b/org/w3c/css/properties/css3/CssListStyleImage.java index 394c7be26..dc5a6440c 100644 --- a/org/w3c/css/properties/css3/CssListStyleImage.java +++ b/org/w3c/css/properties/css3/CssListStyleImage.java @@ -8,11 +8,12 @@ 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; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-list-style-image + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-list-style-image */ public class CssListStyleImage extends org.w3c.css.properties.css.CssListStyleImage { @@ -62,12 +63,9 @@ public CssListStyleImage(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - break; - } - if (none.equals(val)) { - value = none; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || none.equals(id)) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssListStylePosition.java b/org/w3c/css/properties/css3/CssListStylePosition.java index cc70e8d48..f700a44bb 100644 --- a/org/w3c/css/properties/css3/CssListStylePosition.java +++ b/org/w3c/css/properties/css3/CssListStylePosition.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-list-style-position + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-list-style-position */ public class CssListStylePosition extends org.w3c.css.properties.css.CssListStylePosition { @@ -50,8 +50,7 @@ public CssListStylePosition() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStylePosition(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -63,8 +62,7 @@ public CssListStylePosition(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStylePosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -81,17 +79,13 @@ public CssListStylePosition(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val, getPropertyName(), ac); } - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; expression.next(); } } diff --git a/org/w3c/css/properties/css3/CssListStyleType.java b/org/w3c/css/properties/css3/CssListStyleType.java index a11ff7c72..a6eaa6581 100644 --- a/org/w3c/css/properties/css3/CssListStyleType.java +++ b/org/w3c/css/properties/css3/CssListStyleType.java @@ -19,8 +19,8 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2014/WD-css-lists-3-20140320/#propdef-list-style-type - * @spec https://www.w3.org/TR/2015/CR-css-counter-styles-3-20150611/#typedef-counter-style + * @spec https://www.w3.org/TR/2020/WD-css-lists-3-20201117/#propdef-list-style-type + * @spec https://www.w3.org/TR/2021/CR-css-counter-styles-3-20210727/#typedef-counter-style */ public class CssListStyleType extends org.w3c.css.properties.css.CssListStyleType { @@ -39,8 +39,9 @@ public class CssListStyleType extends org.w3c.css.properties.css.CssListStyleTyp "upper-latin", "cjk-earthly-branch", "cjk-heavenly-stem", "lower-greek", "hiragana", "hiragana-iroha", "katakana", "katakana-iroha", "disc", "circle", "square", "disclosure-open", - "disclosure-closed", "japanese-informal", "japanese-formal", - "korean-hangul-formal", "korean-hanja-informal", + "disclosure-closed", "cjk-earthly-branch", "cjk-heavenly-stem", + "japanese-informal", "japanese-formal", + "korean-hangul-formal", "korean-hanja-informal", "cjk-ideographic", "korean-hanja-formal", "simp-chinese-informal", "simp-chinese-formal", "trad-chinese-informal", "trad-chinese-formal", "ethiopic-numeric"}; int i = 0; @@ -86,8 +87,7 @@ public CssListStyleType() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStyleType(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -99,8 +99,7 @@ public CssListStyleType(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssListStyleType(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -121,27 +120,23 @@ public CssListStyleType(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (none.equals(id)) { - value = none; + value = val; break; } - if (inherit.equals(id)) { - value = inherit; + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { // it's still acceptable // but the name should be listed in a // @counter-style rule - if (CssIdent.isCssWide(id)) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = id; + // FIXME TODO check or add a warning + value = val; } + value = val; break; default: throw new InvalidParamException("value", @@ -175,8 +170,7 @@ protected static CssFunction parseSymbolsFunction(ApplContext ac, CssFunction fu throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } - CssIdent ident = getSymbolsFunctionAllowedIdent((CssIdent) val); - if (ident == null) { + if (getSymbolsFunctionAllowedIdent(val.getIdent()) == null) { throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } From ecaa943d6e629979042fcea3f3d378d4a56b1436 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 15:08:09 +0200 Subject: [PATCH 66/82] cast+ref (cont.) --- .../css3/CssBackgroundAttachment.java | 34 +++++----- .../css3/CssBackgroundBlendMode.java | 16 ++--- .../properties/css3/CssBackgroundColor.java | 14 ++-- .../properties/css3/CssBackgroundImage.java | 20 +++--- .../properties/css3/CssBackgroundOrigin.java | 27 +++----- .../css3/CssBackgroundPosition.java | 65 +++++++++---------- .../css3/CssBackgroundPositionX.java | 12 ++-- .../css3/CssBackgroundPositionY.java | 12 ++-- .../properties/css3/CssBackgroundRepeat.java | 21 +++--- .../properties/css3/CssBackgroundSize.java | 27 ++++---- org/w3c/css/properties/css3/CssElevation.java | 23 +++---- 11 files changed, 123 insertions(+), 148 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBackgroundAttachment.java b/org/w3c/css/properties/css3/CssBackgroundAttachment.java index c504694da..8e46cc532 100644 --- a/org/w3c/css/properties/css3/CssBackgroundAttachment.java +++ b/org/w3c/css/properties/css3/CssBackgroundAttachment.java @@ -19,17 +19,19 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-attachment + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-attachment */ public class CssBackgroundAttachment extends org.w3c.css.properties.css.CssBackgroundAttachment { - private static CssIdent[] allowed_values; + private static final CssIdent[] allowed_values; static { - allowed_values = new CssIdent[3]; - allowed_values[0] = CssIdent.getIdent("scroll"); - allowed_values[1] = CssIdent.getIdent("fixed"); - allowed_values[2] = CssIdent.getIdent("local"); + String[] id_values = {"scroll", "fixed", "local"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } } public static boolean isMatchingIdent(CssIdent ident) { @@ -63,8 +65,7 @@ public CssBackgroundAttachment() { * @param ac the context * @param expression The expression for this property * @param check if some length checking is required - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBackgroundAttachment(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -82,22 +83,22 @@ public CssBackgroundAttachment(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val, getPropertyName(), ac); } - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - values.add(inherit); + values.add(val); } else { // check that it's in the allowed values - CssValue new_val = getMatchingIdent((CssIdent) val); - if (new_val == null) { + if (getMatchingIdent(id) == null) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - values.add(new_val); + values.add(val); } expression.next(); // and check that values are separated by commas @@ -106,12 +107,7 @@ public CssBackgroundAttachment(ApplContext ac, CssExpression expression, Character.toString(op), ac); } } - - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); - } + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); } public CssBackgroundAttachment(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssBackgroundBlendMode.java b/org/w3c/css/properties/css3/CssBackgroundBlendMode.java index c9a20f80a..d65311f4b 100644 --- a/org/w3c/css/properties/css3/CssBackgroundBlendMode.java +++ b/org/w3c/css/properties/css3/CssBackgroundBlendMode.java @@ -34,15 +34,14 @@ public CssBackgroundBlendMode() { * Creates a new CssBackgroundBlendMode * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBackgroundBlendMode(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val; - CssIdent ident, id; + CssIdent ident; char op; ArrayList values = new ArrayList<>(); @@ -52,22 +51,21 @@ public CssBackgroundBlendMode(ApplContext ac, CssExpression expression, boolean op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - ident = (CssIdent) val; - if (inherit.equals(ident)) { + ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - values.add(inherit); + values.add(val); } else { - id = CssMixBlendMode.getAllowedIdent(ident); - if (id == null) { + if (CssMixBlendMode.getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - values.add(id); + values.add(val); } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssBackgroundColor.java b/org/w3c/css/properties/css3/CssBackgroundColor.java index f8ae3b624..17af804ac 100644 --- a/org/w3c/css/properties/css3/CssBackgroundColor.java +++ b/org/w3c/css/properties/css3/CssBackgroundColor.java @@ -10,10 +10,12 @@ 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; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-color */ public class CssBackgroundColor extends org.w3c.css.properties.css.CssBackgroundColor { @@ -28,8 +30,7 @@ public CssBackgroundColor() { * Create a new CssBackgroundColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBackgroundColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -41,8 +42,8 @@ public CssBackgroundColor(ApplContext ac, CssExpression expression, throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val)) { - value = inherit; + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + value = val; expression.next(); } else { try { @@ -51,7 +52,7 @@ public CssBackgroundColor(ApplContext ac, CssExpression expression, CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = (tcolor.value == null) ? tcolor.color : tcolor.value; + value = (tcolor.color != null) ? tcolor.color : tcolor.value; } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), @@ -69,6 +70,7 @@ public CssBackgroundColor(ApplContext ac, CssExpression expression) * Is the value of this property is a default value. * It is used by all macro for the function print */ + @Override public boolean isDefault() { return (value == transparent); } diff --git a/org/w3c/css/properties/css3/CssBackgroundImage.java b/org/w3c/css/properties/css3/CssBackgroundImage.java index a99d784d9..0a3131b0c 100644 --- a/org/w3c/css/properties/css3/CssBackgroundImage.java +++ b/org/w3c/css/properties/css3/CssBackgroundImage.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-image + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-image */ public class CssBackgroundImage extends org.w3c.css.properties.css.CssBackgroundImage { @@ -41,8 +41,7 @@ public CssBackgroundImage() { * @param ac the context * @param expression The expression for this property * @param check boolean - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBackgroundImage(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -62,17 +61,18 @@ public CssBackgroundImage(ApplContext ac, CssExpression expression, values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; - } else if (none.equals(val)) { - values.add(none); + } else if (isMatchingIdent(id)) { + values.add(val); break; } default: @@ -85,11 +85,7 @@ public CssBackgroundImage(ApplContext ac, CssExpression expression, Character.toString(op), ac); } } - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); - } + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); } public CssBackgroundImage(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssBackgroundOrigin.java b/org/w3c/css/properties/css3/CssBackgroundOrigin.java index 1734340b7..11bbf3231 100644 --- a/org/w3c/css/properties/css3/CssBackgroundOrigin.java +++ b/org/w3c/css/properties/css3/CssBackgroundOrigin.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-origin + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-origin */ public class CssBackgroundOrigin extends org.w3c.css.properties.css.CssBackgroundOrigin { @@ -53,8 +53,7 @@ public CssBackgroundOrigin() { * Create a new CssBackgroundClip * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Incorrect value + * @throws org.w3c.css.util.InvalidParamException Incorrect value */ public CssBackgroundOrigin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,23 +68,19 @@ public CssBackgroundOrigin(ApplContext ac, CssExpression expression, op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - values.add(inherit); + values.add(val); break; - } else if (border_box.equals(val)) { - values.add(border_box); - break; - } else if (content_box.equals(val)) { - values.add(content_box); - break; - } else if (padding_box.equals(val)) { - values.add(padding_box); + } + if (isMatchingIdent(id)) { + values.add(val); break; } default: @@ -98,11 +93,7 @@ public CssBackgroundOrigin(ApplContext ac, CssExpression expression, Character.toString(op), ac); } } - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); - } + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); } public CssBackgroundOrigin(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssBackgroundPosition.java b/org/w3c/css/properties/css3/CssBackgroundPosition.java index 796721354..0b628d200 100644 --- a/org/w3c/css/properties/css3/CssBackgroundPosition.java +++ b/org/w3c/css/properties/css3/CssBackgroundPosition.java @@ -24,7 +24,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#background-position + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-position */ public class CssBackgroundPosition extends org.w3c.css.properties.css.CssBackgroundPosition { @@ -80,8 +80,7 @@ public CssBackgroundPosition() { * Creates a new CssBackgroundPosition * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBackgroundPosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -97,14 +96,16 @@ public CssBackgroundPosition(ApplContext ac, CssExpression expression, val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("value", val, - getPropertyName(), ac); + if (val.getType() == CssTypes.CSS_IDENT) { + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + value = val; + expression.next(); + return; } - value = inherit; - expression.next(); - return; } if (b_val == null) { b_val = new CssBackgroundPositionValue(); @@ -116,7 +117,7 @@ public CssBackgroundPosition(ApplContext ac, CssExpression expression, if (!expression.end()) { // incomplete value followed by a comma... it's complete! if (op == COMMA) { - check(b_val, ac); + check(b_val, ac, getPropertyName()); values.add(b_val); b_val = null; } else if (op != SPACE) { @@ -127,14 +128,10 @@ public CssBackgroundPosition(ApplContext ac, CssExpression expression, } // if we reach the end in a value that can come in pair if (b_val != null) { - check(b_val, ac); + check(b_val, ac, getPropertyName()); values.add(b_val); } - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); - } + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); } public CssBackgroundPosition(ApplContext ac, CssExpression expression) @@ -158,7 +155,7 @@ public boolean isDefault() { (v.horizontal_offset == null)); } - public void check(CssBackgroundPositionValue v, ApplContext ac) + public void check(CssBackgroundPositionValue v, ApplContext ac, String caller) throws InvalidParamException { int nb_keyword = 0; int nb_percentage = 0; @@ -231,18 +228,18 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) case 1: switch (nb_values) { case 1: - CssIdent ident = (CssIdent) v.value.get(0); + CssIdent ident = v.value.get(0).getIdent(); // ugly as we need to set values for equality tests v.val_vertical = defaultPercent50; v.val_horizontal = defaultPercent50; ident = getMatchingIdent(ident); if (ident != null) { if (isVertical(ident)) { - v.vertical = ident; + v.vertical = v.value.get(0); v.val_vertical = identToPercent(ident); } else { // horizontal || center - v.horizontal = ident; + v.horizontal = v.value.get(0); v.val_horizontal = identToPercent(ident); } break; @@ -254,7 +251,7 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) // and second vertical CssValue val0 = v.value.get(0); if (val0.getType() == CssTypes.CSS_IDENT) { - ident = getMatchingIdent((CssIdent) val0); + ident = getMatchingIdent(val0.getIdent()); if (ident == null) { throw new InvalidParamException("unrecognize", ident, getPropertyName(), ac); @@ -263,7 +260,7 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) throw new InvalidParamException("incompatible", ident, v.value.get(1), ac); } - v.horizontal = ident; + v.horizontal = val0; v.val_horizontal = identToPercent(ident); // and the vertical value... v.vertical = v.value.get(1); @@ -277,7 +274,7 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) throw new InvalidParamException("unrecognize", value1, getPropertyName(), ac); } - ident = getMatchingIdent((CssIdent) value1); + ident = getMatchingIdent(value1.getIdent()); if (ident == null) { throw new InvalidParamException("unrecognize", ident, getPropertyName(), ac); @@ -286,7 +283,7 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) throw new InvalidParamException("incompatible", val0, value1, ac); } - v.vertical = ident; + v.vertical = value1; v.val_vertical = identToPercent(ident); // and the first value v.horizontal = val0; @@ -315,16 +312,16 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) for (CssValue aValue : v.value) { switch (aValue.getType()) { case CssTypes.CSS_IDENT: - aValue = getMatchingIdent((CssIdent) aValue); - if (aValue == null) { + CssIdent id = aValue.getIdent(); + if (getMatchingIdent(id) == null) { throw new InvalidParamException("unrecognize", aValue, getPropertyName(), ac); } got_ident = true; if (id1 == null) { - id1 = (CssIdent) aValue; + id1 = id; } else { - id2 = (CssIdent) aValue; + id2 = id; // we got both, let's check. if (((isVertical(id1) && isVertical(id2))) || (isHorizontal(id1) && isHorizontal(id2))) { @@ -334,7 +331,7 @@ public void check(CssBackgroundPositionValue v, ApplContext ac) } break; case CssTypes.CSS_NUMBER: - aValue = aValue.getLength(); + aValue.getCheckableValue().checkEqualsZero(ac, caller); case CssTypes.CSS_PERCENTAGE: case CssTypes.CSS_LENGTH: if (!got_ident) { @@ -403,7 +400,7 @@ public static boolean isVertical(CssIdent ident) { public static CssValue checkBackgroundPosition(ApplContext ac, CssExpression expression, CssProperty caller) - throws InvalidParamException { + throws InvalidParamException { return checkSyntax(ac, expression, caller.getPropertyName()); } @@ -462,7 +459,7 @@ public static CssValue checkSyntax(ApplContext ac, CssExpression expression, Str switch (nb_values) { case 1: // one value, one keyword... easy :) - if (getMatchingIdent((CssIdent) v.get(0)) == null) { + if (getMatchingIdent(v.get(0).getIdent()) == null) { throw new InvalidParamException("value", v.get(0), caller, ac); } @@ -473,7 +470,7 @@ public static CssValue checkSyntax(ApplContext ac, CssExpression expression, Str CssValue val0 = v.get(0); CssIdent ident; if (val0.getType() == CssTypes.CSS_IDENT) { - ident = getMatchingIdent((CssIdent) val0); + ident = getMatchingIdent(val0.getIdent()); if (ident == null) { throw new InvalidParamException("value", val0, caller, ac); @@ -488,7 +485,7 @@ public static CssValue checkSyntax(ApplContext ac, CssExpression expression, Str throw new InvalidParamException("value", value1, caller, ac); } - ident = getMatchingIdent((CssIdent) value1); + ident = getMatchingIdent(value1.getIdent()); if (ident == null) { throw new InvalidParamException("value", value1, caller, ac); diff --git a/org/w3c/css/properties/css3/CssBackgroundPositionX.java b/org/w3c/css/properties/css3/CssBackgroundPositionX.java index bf86c8061..510728e66 100644 --- a/org/w3c/css/properties/css3/CssBackgroundPositionX.java +++ b/org/w3c/css/properties/css3/CssBackgroundPositionX.java @@ -61,8 +61,7 @@ public CssBackgroundPositionX() { * Creates a new CssBackgroundPositionX * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBackgroundPositionX(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -79,11 +78,12 @@ public CssBackgroundPositionX(ApplContext ac, CssExpression expression, boolean op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - if (val.equals(inherit)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; expression.next(); continue; } @@ -138,8 +138,8 @@ public static CssValue checkBackgroundPositionXLayer(ApplContext ac, CssExpressi v.add(val); break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (id.equals(center) && !gotCenter && !gotIdent && !gotLP) { + CssIdent id = val.getIdent(); + if (center.equals(id) && !gotCenter && !gotIdent && !gotLP) { gotCenter = true; v.add(val); break; diff --git a/org/w3c/css/properties/css3/CssBackgroundPositionY.java b/org/w3c/css/properties/css3/CssBackgroundPositionY.java index 0e73ba752..e67b5ed3d 100644 --- a/org/w3c/css/properties/css3/CssBackgroundPositionY.java +++ b/org/w3c/css/properties/css3/CssBackgroundPositionY.java @@ -61,8 +61,7 @@ public CssBackgroundPositionY() { * Creates a new CssBackgroundPositionY * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBackgroundPositionY(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -79,11 +78,12 @@ public CssBackgroundPositionY(ApplContext ac, CssExpression expression, boolean op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - if (val.equals(inherit)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; expression.next(); continue; } @@ -138,8 +138,8 @@ public static CssValue checkBackgroundPositionYLayer(ApplContext ac, CssExpressi v.add(val); break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (id.equals(center) && !gotCenter && !gotIdent && !gotLP) { + CssIdent id = val.getIdent(); + if (center.equals(id) && !gotCenter && !gotIdent && !gotLP) { gotCenter = true; v.add(val); break; diff --git a/org/w3c/css/properties/css3/CssBackgroundRepeat.java b/org/w3c/css/properties/css3/CssBackgroundRepeat.java index dd522bca7..3f5a55115 100644 --- a/org/w3c/css/properties/css3/CssBackgroundRepeat.java +++ b/org/w3c/css/properties/css3/CssBackgroundRepeat.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-backgrounds-3-20171017/#the-background-repeat + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-repeat */ public class CssBackgroundRepeat extends org.w3c.css.properties.css.CssBackgroundRepeat { @@ -126,40 +126,37 @@ public static CssValue checkBackgroundRepeat(ApplContext ac, CssExpression expre caller.getPropertyName(), ac); } - CssIdent id_val = (CssIdent) val; - if (inherit.equals(id_val)) { + CssIdent id_val = val.getIdent(); + if (CssIdent.isCssWide(id_val)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } - return inherit; + return val; } else { - CssIdent new_val; // check values that must be alone - new_val = getSimpleValue(id_val); - if (new_val != null) { + if (getSimpleValue(id_val) != null) { // if we already have a double value... it's an error if (!is_complete) { throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } - values.add(new_val); + values.add(val); is_complete = true; } else { // the the one that may come in pairs - new_val = getDoubleValue(id_val); // not an allowed value ! - if (new_val == null) { + if (getDoubleValue(id_val) == null) { throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } if (is_complete) { vl = new CssValueList(); - vl.add(new_val); + vl.add(val); } else { - vl.add(new_val); + vl.add(val); values.add(vl); } is_complete = !is_complete; diff --git a/org/w3c/css/properties/css3/CssBackgroundSize.java b/org/w3c/css/properties/css3/CssBackgroundSize.java index cd1d05f88..956da2592 100644 --- a/org/w3c/css/properties/css3/CssBackgroundSize.java +++ b/org/w3c/css/properties/css3/CssBackgroundSize.java @@ -9,7 +9,6 @@ import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; @@ -23,7 +22,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2009/CR-css3-background-20091217/#the-background-size + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background-size */ public class CssBackgroundSize extends org.w3c.css.properties.css.CssBackgroundSize { @@ -64,8 +63,7 @@ public CssBackgroundSize() { * @param ac The context * @param expression The expression for this property * @param check if arguments count must be checked. - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBackgroundSize(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -96,11 +94,10 @@ public static CssValue checkBackgroundSize(ApplContext ac, CssExpression express op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - val.getLength(); + val.getCheckableValue().checkEqualsZero(ac, caller); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: - CssCheckableValue l = val.getCheckableValue(); - l.checkPositiveness(ac, caller); + val.getCheckableValue().checkPositiveness(ac, caller); if (is_complete) { vl = new CssValueList(); vl.add(val); @@ -111,31 +108,31 @@ public static CssValue checkBackgroundSize(ApplContext ac, CssExpression express is_complete = !is_complete; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { // if we got inherit after other values, fail // if we got more than one value... fail if ((values.size() > 0) || (expression.getCount() > 1)) { throw new InvalidParamException("value", val, caller, ac); } - values.add(inherit); + values.add(val); break; - } else if (auto.equals(val)) { + } else if (auto.equals(id)) { if (is_complete) { vl = new CssValueList(); - vl.add(auto); + vl.add(val); } else { - vl.add(auto); + vl.add(val); values.add(vl); } is_complete = !is_complete; break; } else { - CssValue v = getMatchingIdent((CssIdent) val); // if ok, and if we are not in a middle of a compound // value... - if (v != null && is_complete) { - values.add(v); + if ((getMatchingIdent(id) != null) && is_complete) { + values.add(val); break; } } diff --git a/org/w3c/css/properties/css3/CssElevation.java b/org/w3c/css/properties/css3/CssElevation.java index d6afc3795..b370f0e36 100644 --- a/org/w3c/css/properties/css3/CssElevation.java +++ b/org/w3c/css/properties/css3/CssElevation.java @@ -51,8 +51,7 @@ public CssElevation() { * Creates a new ACssElevation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssElevation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,21 +68,23 @@ public CssElevation(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_NUMBER: case CssTypes.CSS_ANGLE: - CssAngle a = val.getAngle(); - float v = a.getDegree(); - if (v > 90 && v < 270) { - throw new InvalidParamException("elevation.range", ac); + if (val.getRawType() == CssTypes.CSS_ANGLE || val.getRawType() == CssTypes.CSS_NUMBER) { + CssAngle a = val.getAngle(); + float v = a.getDegree(); + if (v > 90 && v < 270) { + throw new InvalidParamException("elevation.range", ac); + } } value = val; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; break; } - value = getAllowedIdent(ident); - if (value != null) { + if (getAllowedIdent(ident) != null) { + value = val; break; } default: From f427cbefbfb711435d020bfbd393335fc229bf0c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 15:28:08 +0200 Subject: [PATCH 67/82] cast+ref (cont.) --- .../css/properties/css3/CssBackground.java | 133 ++++++++---------- 1 file changed, 58 insertions(+), 75 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBackground.java b/org/w3c/css/properties/css3/CssBackground.java index 6bcd1a0ec..c42270f68 100644 --- a/org/w3c/css/properties/css3/CssBackground.java +++ b/org/w3c/css/properties/css3/CssBackground.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120724/#the-background + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-background * @see org.w3c.css.properties.css.CssBackgroundColor * @see org.w3c.css.properties.css.CssBackgroundImage * @see org.w3c.css.properties.css.CssBackgroundRepeat @@ -43,8 +43,7 @@ public CssBackground() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBackground(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -56,8 +55,7 @@ public CssBackground(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBackground(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -75,12 +73,12 @@ public CssBackground(ApplContext ac, CssExpression expression, val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - value = inherit; + value = val; expression.next(); return; } @@ -118,9 +116,9 @@ public CssBackground(ApplContext ac, CssExpression expression, transform_into_individual_values(); } - private Object getCssBackgroundRepeatValue(ApplContext ac, - CssExpression expression, - boolean check) + private CssValue getCssBackgroundRepeatValue(ApplContext ac, + CssExpression expression, + boolean check) throws InvalidParamException { char op = expression.getOperator(); CssExpression exp = new CssExpression(); @@ -133,8 +131,8 @@ private Object getCssBackgroundRepeatValue(ApplContext ac, if (!expression.end()) { CssValue val = expression.getValue(); if ((val.getType() == CssTypes.CSS_IDENT) && - (CssBackgroundRepeat.isMatchingIdent((CssIdent) val))) { - exp.addValue(expression.getValue()); + CssBackgroundRepeat.isMatchingIdent((val.getIdent()))) { + exp.addValue(val); exp.starts(); try { repeat = new CssBackgroundRepeat(ac, exp, check); @@ -146,12 +144,12 @@ private Object getCssBackgroundRepeatValue(ApplContext ac, } } } - return repeat.get(); + return repeat.value; } - private Object getCssBackgroundSizeValue(ApplContext ac, - CssExpression expression, - boolean check) + private CssValue getCssBackgroundSizeValue(ApplContext ac, + CssExpression expression, + boolean check) throws InvalidParamException { char op = expression.getOperator(); CssExpression exp = new CssExpression(); @@ -176,13 +174,13 @@ private Object getCssBackgroundSizeValue(ApplContext ac, } } } - return bg_size.get(); + return bg_size.value; } - private Object getCssBackgroundPositionValue(ApplContext ac, - CssExpression expression, - boolean check) + private CssValue getCssBackgroundPositionValue(ApplContext ac, + CssExpression expression, + boolean check) throws InvalidParamException { CssExpression exp = new CssExpression(); char op = expression.getOperator(); @@ -218,7 +216,7 @@ private Object getCssBackgroundPositionValue(ApplContext ac, expression.next(); last_val--; } - return bg_pos.get(); + return bg_pos.value; } @@ -235,12 +233,11 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, // bg-origin is IDENT // + color as CSS_COLOR or IDENT on final-layer - CssValue val; + CssValue val, res; char op; CssExpression exp; CssBackgroundValue v = new CssBackgroundValue(); boolean next_is_size, got_size, prev_is_position; - Object res; next_is_size = false; got_size = false; @@ -263,7 +260,7 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, CssBackgroundColor bg_color; bg_color = new CssBackgroundColor(ac, exp, check); - v.color = (CssValue) bg_color.get(); + v.color = bg_color.value; break; case CssTypes.CSS_URL: @@ -279,10 +276,10 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, CssBackgroundImage bg_image; bg_image = new CssBackgroundImage(ac, exp, check); - res = bg_image.get(); + res = bg_image.value; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.bg_image = (CssValue) res; + if (res != null) { + v.bg_image = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -327,7 +324,7 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, op = expression.getOperator(); prev_is_position = true; // we only have one value so it should always be the case - if (res instanceof CssValue) { + if (res != null) { v.bg_position = (CssValue) res; } else { throw new InvalidParamException("value", val, @@ -339,7 +336,7 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, case CssTypes.CSS_IDENT: prev_is_position = false; // inherit is already taken care of... - CssIdent ident_val = (CssIdent) val; + CssIdent ident_val = val.getIdent(); if (CssBackgroundAttachment.isMatchingIdent(ident_val)) { if (v.attachment != null || next_is_size) { throw new InvalidParamException("value", val, @@ -350,10 +347,10 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, CssBackgroundAttachment attachment; attachment = new CssBackgroundAttachment(ac, exp, check); - res = attachment.get(); + res = attachment.value; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.attachment = (CssValue) res; + if (res != null) { + v.attachment = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -371,10 +368,10 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, exp.addValue(val); bg_image = new CssBackgroundImage(ac, exp, check); - res = bg_image.get(); + res = bg_image.value; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.bg_image = (CssValue) res; + if (res != null) { + v.bg_image = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -399,10 +396,10 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, CssBackgroundClip clip; clip = new CssBackgroundClip(ac, exp, check); - res = clip.get(); + res = clip.value; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.clip = (CssValue) res; + if (res != null) { + v.clip = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -414,10 +411,10 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, CssBackgroundOrigin origin; origin = new CssBackgroundOrigin(ac, exp, check); - res = origin.get(); + res = origin.value; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.origin = (CssValue) res; + if (res != null) { + v.origin = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -433,7 +430,7 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, op = expression.getOperator(); // we only have one vale so it should always be the case - if (res instanceof CssValue) { + if (res != null) { v.repeat_style = (CssValue) res; } else { throw new InvalidParamException("value", val, @@ -451,8 +448,8 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, res = getCssBackgroundSizeValue(ac, expression, check); op = expression.getOperator(); // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.bg_size = (CssValue) res; + if (res != null) { + v.bg_size = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -476,8 +473,8 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, op = expression.getOperator(); prev_is_position = true; // we only have one vale so it should always be the case - if (res instanceof CssValue) { - v.bg_position = (CssValue) res; + if (res != null) { + v.bg_position = res; } else { throw new InvalidParamException("value", val, getPropertyName(), ac); @@ -512,7 +509,7 @@ public CssBackgroundValue check(ApplContext ac, CssExpression expression, exp.addValue(val); bg_color = new CssBackgroundColor(ac, exp, check); - v.color = (CssValue) bg_color.get(); + v.color = bg_color.value; break; // the infamous switch... // note that we should check that we got something first. @@ -543,62 +540,48 @@ private void align_bg_values(CssBackgroundValue v) { // || Object value; if (v.bg_image == null) { - value = (new CssBackgroundImage()).get(); - if (value instanceof CssValue) { - v.bg_image_value = (CssValue) value; - } + v.bg_image_value = (new CssBackgroundImage()).value; } else { v.bg_image_value = v.bg_image; } if (v.bg_position == null) { - value = (new CssBackgroundPosition()).get(); - if (value instanceof CssValue) { - v.bg_position_value = (CssValue) value; - } + v.bg_position_value = (new CssBackgroundPosition()).value; } else { v.bg_position_value = v.bg_position; } if (v.bg_size == null) { - value = (new CssBackgroundSize()).get(); - if (value instanceof CssValue) { - v.bg_size_value = (CssValue) value; - } + v.bg_size_value = (new CssBackgroundSize()).value; } else { v.bg_size_value = v.bg_size; } if (v.repeat_style == null) { - value = (new CssBackgroundRepeat()).get(); - if (value instanceof CssValue) { - v.repeat_style_value = (CssValue) value; - } + v.repeat_style_value = (new CssBackgroundRepeat()).value; } else { v.repeat_style_value = v.repeat_style; } if (v.attachment == null) { - value = (new CssBackgroundAttachment()).get(); - if (value instanceof CssValue) { - v.attachment_value = (CssValue) value; - } + v.attachment_value = (new CssBackgroundAttachment()).value; } else { v.attachment_value = v.attachment; } if (v.origin == null) { - value = (new CssBackgroundOrigin()).get(); - if (value instanceof CssValue) { - CssValue css_val = (CssValue) value; - v.origin_value = (CssValue) value; - // If 'background-origin' is present and its value matches a - // possible value for 'background-clip' then it also sets - // 'background-clip' to that value. + CssValue css_val = (new CssBackgroundOrigin()).value; + v.origin_value = (new CssBackgroundOrigin()).value; + // If 'background-origin' is present and its value matches a + // possible value for 'background-clip' then it also sets + // 'background-clip' to that value. + try { if (v.clip == null && (css_val.getType() == CssTypes.CSS_IDENT) && - CssBackgroundClip.isMatchingIdent((CssIdent) css_val)) { + CssBackgroundClip.isMatchingIdent(css_val.getIdent())) { v.clip_value = v.origin_value; } + } catch (InvalidParamException e) { + // should never happen if defaults are right } } else { v.origin_value = v.origin; From 44583672dc3c3666dd2e6e4507b407c0d0b9531e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 17:48:14 +0200 Subject: [PATCH 68/82] mark as deprecated --- org/w3c/css/properties/css3/CssOverflowStyle.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/org/w3c/css/properties/css3/CssOverflowStyle.java b/org/w3c/css/properties/css3/CssOverflowStyle.java index 4d5bd8821..985c1f108 100644 --- a/org/w3c/css/properties/css3/CssOverflowStyle.java +++ b/org/w3c/css/properties/css3/CssOverflowStyle.java @@ -14,6 +14,7 @@ /** * @spec http://www.w3.org/TR/2008/CR-css3-marquee-20081205/#overflow-style + * @deprecated */ public class CssOverflowStyle extends org.w3c.css.properties.css.CssOverflowStyle { @@ -56,6 +57,8 @@ public CssOverflowStyle(ApplContext ac, CssExpression expression, boolean check) setByUser(); CssValue val = expression.getValue(); + ac.getFrame().addWarning("deprecatedproperty", getPropertyName()); + if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } @@ -66,11 +69,11 @@ public CssOverflowStyle(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - val = getMatchingIdent((CssIdent) val); - if (val == null) { + if (getMatchingIdent(id) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); From 39aef5d048a9a0bc826f696176cbca4820a8d3db Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 17:48:28 +0200 Subject: [PATCH 69/82] cast (cont.) --- org/w3c/css/properties/css3/CssOverflow.java | 28 ++++++++----------- .../properties/css3/CssOverflowAnchor.java | 15 ++++------ .../css/properties/css3/CssOverflowWrap.java | 20 ++++++------- org/w3c/css/properties/css3/CssOverflowX.java | 2 +- org/w3c/css/properties/css3/CssOverflowY.java | 2 +- 5 files changed, 27 insertions(+), 40 deletions(-) diff --git a/org/w3c/css/properties/css3/CssOverflow.java b/org/w3c/css/properties/css3/CssOverflow.java index 78def1d5b..c910e6550 100644 --- a/org/w3c/css/properties/css3/CssOverflow.java +++ b/org/w3c/css/properties/css3/CssOverflow.java @@ -22,7 +22,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#overflow + * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#propdef-overflow */ public class CssOverflow extends org.w3c.css.properties.css.CssOverflow { @@ -32,8 +32,7 @@ public class CssOverflow extends org.w3c.css.properties.css.CssOverflow { public static final CssIdent[] allowed_values; static { - String[] _allowed_values = {"visible", "hidden", "scroll", - "auto", "no-display", "no-content"}; + String[] _allowed_values = {"visible", "hidden", "scroll", "auto"}; int i = 0; allowed_values = new CssIdent[_allowed_values.length]; for (String s : _allowed_values) { @@ -63,8 +62,7 @@ public CssOverflow() { * Creates a new CssOverflow * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssOverflow(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -87,7 +85,7 @@ public CssOverflow(ApplContext ac, CssExpression expression, boolean check) CssValue val; char op = expression.getOperator(); val = checkOverflowAxis(ac, expression, false, this); - if (val == inherit) { + if (val.getType() == CssTypes.CSS_IDENT && CssIdent.isCssWide(val.getIdent())) { throw new InvalidParamException("value", val, getPropertyName(), ac); } @@ -98,7 +96,7 @@ public CssOverflow(ApplContext ac, CssExpression expression, boolean check) Character.toString(op), ac); } val = checkOverflowAxis(ac, expression, false, this); - if (val == inherit) { + if (val.getType() == CssTypes.CSS_IDENT && CssIdent.isCssWide(val.getIdent())) { throw new InvalidParamException("value", val, getPropertyName(), ac); } @@ -148,17 +146,13 @@ static CssValue checkOverflowAxis(ApplContext ac, CssExpression expression, throw new InvalidParamException("value", val, caller.getPropertyName(), ac); } - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - caller.getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); } + value = val; expression.next(); return value; } diff --git a/org/w3c/css/properties/css3/CssOverflowAnchor.java b/org/w3c/css/properties/css3/CssOverflowAnchor.java index 866f83b53..bc9893469 100644 --- a/org/w3c/css/properties/css3/CssOverflowAnchor.java +++ b/org/w3c/css/properties/css3/CssOverflowAnchor.java @@ -65,16 +65,13 @@ public CssOverflowAnchor(ApplContext ac, CssExpression expression, expression.getValue(), getPropertyName(), ac); } - if (inherit.equals(val)) { - value = inherit; - } else { - value = getAllowedIdent((CssIdent) val); - if (value == null) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssOverflowWrap.java b/org/w3c/css/properties/css3/CssOverflowWrap.java index 0059d1f19..e6b2ed3e9 100644 --- a/org/w3c/css/properties/css3/CssOverflowWrap.java +++ b/org/w3c/css/properties/css3/CssOverflowWrap.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-overflow-wrap + * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-overflow-wrap *

* Note that word-wrap is also an alias for this. */ @@ -55,7 +55,7 @@ public CssOverflowWrap() { */ public CssOverflowWrap(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 2) { + if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } setByUser(); @@ -67,17 +67,13 @@ public CssOverflowWrap(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && getAllowedValue(ident) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; } else { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssOverflowX.java b/org/w3c/css/properties/css3/CssOverflowX.java index e2c029c9e..7bd14eca1 100644 --- a/org/w3c/css/properties/css3/CssOverflowX.java +++ b/org/w3c/css/properties/css3/CssOverflowX.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#overflow-x + * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#propdef-overflow-x * @see CssOverflow */ public class CssOverflowX extends org.w3c.css.properties.css.CssOverflowX { diff --git a/org/w3c/css/properties/css3/CssOverflowY.java b/org/w3c/css/properties/css3/CssOverflowY.java index ca5590a0f..af5a3a767 100644 --- a/org/w3c/css/properties/css3/CssOverflowY.java +++ b/org/w3c/css/properties/css3/CssOverflowY.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2007/WD-css3-box-20070809/#overflow-y + * @spec https://www.w3.org/TR/2020/WD-css-overflow-3-20200603/#propdef-overflow-y * @see org.w3c.css.properties.css3.CssOverflow */ public class CssOverflowY extends org.w3c.css.properties.css.CssOverflowY { From 79d2c06e5592cee5ff57771ccc7e9023d338ec7e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 18:04:23 +0200 Subject: [PATCH 70/82] cast (cont.) --- org/w3c/css/properties/css3/CssMaxWidth.java | 15 ++++------ org/w3c/css/properties/css3/CssMinWidth.java | 10 +++---- .../css/properties/css3/CssMixBlendMode.java | 25 +++++++--------- .../properties/css3/CssPerspectiveOrigin.java | 30 +++++++++---------- 4 files changed, 35 insertions(+), 45 deletions(-) diff --git a/org/w3c/css/properties/css3/CssMaxWidth.java b/org/w3c/css/properties/css3/CssMaxWidth.java index b8dec028a..1832d0683 100644 --- a/org/w3c/css/properties/css3/CssMaxWidth.java +++ b/org/w3c/css/properties/css3/CssMaxWidth.java @@ -92,17 +92,12 @@ public static CssValue parseMaxWidth(ApplContext ac, CssExpression expression, v = parseFunctionValue(ac, val, caller); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - v = inherit; - } else { - CssIdent id = getAllowedIdent((CssIdent) val); - if (id != null) { - v = id; - } else { - throw new InvalidParamException("unrecognize", ac); - } + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || getAllowedIdent(id) != null) { + v = val; + break; } - break; + // unrecognized, let it fail default: throw new InvalidParamException("value", expression.getValue(), caller.getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssMinWidth.java b/org/w3c/css/properties/css3/CssMinWidth.java index 428c7638e..18e2f7d64 100644 --- a/org/w3c/css/properties/css3/CssMinWidth.java +++ b/org/w3c/css/properties/css3/CssMinWidth.java @@ -92,12 +92,12 @@ public static CssValue parseMinWidth(ApplContext ac, CssExpression expression, v = parseFunctionValue(ac, val, caller); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - v = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + v = val; } else { - CssIdent id = getAllowedIdent((CssIdent) val); - if (id != null) { - v = id; + if (getAllowedIdent(id) != null) { + v = val; } else { throw new InvalidParamException("unrecognize", ac); } diff --git a/org/w3c/css/properties/css3/CssMixBlendMode.java b/org/w3c/css/properties/css3/CssMixBlendMode.java index 1b8fb20bb..395b122be 100644 --- a/org/w3c/css/properties/css3/CssMixBlendMode.java +++ b/org/w3c/css/properties/css3/CssMixBlendMode.java @@ -51,8 +51,7 @@ public CssMixBlendMode() { * Creates a new CssMixBlendMode * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssMixBlendMode(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -67,23 +66,19 @@ public CssMixBlendMode(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssPerspectiveOrigin.java b/org/w3c/css/properties/css3/CssPerspectiveOrigin.java index 2ea207aa5..7df57db33 100644 --- a/org/w3c/css/properties/css3/CssPerspectiveOrigin.java +++ b/org/w3c/css/properties/css3/CssPerspectiveOrigin.java @@ -48,11 +48,11 @@ public static CssIdent getMatchingIdent(CssIdent ident) { return null; } - public boolean isVerticalIdent(CssIdent ident) { + public static boolean isVerticalIdent(CssIdent ident) { return top.equals(ident) || bottom.equals(ident); } - public boolean isHorizontalIdent(CssIdent ident) { + public static boolean isHorizontalIdent(CssIdent ident) { return left.equals(ident) || right.equals(ident); } @@ -67,8 +67,7 @@ public CssPerspectiveOrigin() { * Creates a new CssPerspectiveOrigin * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssPerspectiveOrigin(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -89,12 +88,12 @@ public CssPerspectiveOrigin(ApplContext ac, CssExpression expression, val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - value = inherit; + value = val; expression.next(); return; } @@ -108,13 +107,14 @@ public CssPerspectiveOrigin(ApplContext ac, CssExpression expression, } } // if we reach the end in a value that can come in pair - check(values, ac); + parsePerspectiveOrigin(ac, values, getPropertyName()); value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } // check the value - - private void check(ArrayList values, ApplContext ac) + // TODO FIXME do it right using the epxression instead + protected static void parsePerspectiveOrigin(ApplContext ac, ArrayList values, + String caller) throws InvalidParamException { int nb_keyword = 0; int nb_values = values.size(); @@ -126,7 +126,7 @@ private void check(ArrayList values, ApplContext ac) for (CssValue aValue : values) { switch (aValue.getType()) { case CssTypes.CSS_NUMBER: - aValue.getCheckableValue().checkEqualsZero(ac, this); + aValue.getCheckableValue().checkEqualsZero(ac, caller); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: break; @@ -135,7 +135,7 @@ private void check(ArrayList values, ApplContext ac) break; default: throw new InvalidParamException("value", aValue, - getPropertyName(), ac); + caller, ac); } } // then we need to ckeck the values if we got two values and @@ -145,7 +145,7 @@ private void check(ArrayList values, ApplContext ac) boolean gotvertical = false; CssValue v = values.get(0); if (v.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) v; + CssIdent id = v.getIdent(); // strictly horizontal or vertical gothorizontal = isHorizontalIdent(id); if (!gothorizontal) { @@ -154,15 +154,15 @@ private void check(ArrayList values, ApplContext ac) } v = values.get(1); if (v.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) v; + CssIdent id = v.getIdent(); // yeah, it can be a single ugly test. if (gothorizontal && isHorizontalIdent(id)) { throw new InvalidParamException("value", id, - getPropertyName(), ac); + caller, ac); } if (gotvertical && isVerticalIdent(id)) { throw new InvalidParamException("value", id, - getPropertyName(), ac); + caller, ac); } } } From 17f813065500f9adad6583ce57edc1c8b5d61f93 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 21:08:07 +0200 Subject: [PATCH 71/82] refs+cast (cont.) --- org/w3c/css/properties/css3/CssCursor.java | 7 +-- .../properties/css3/CssImageOrientation.java | 51 ++++++++++++------- .../properties/css3/CssImageRendering.java | 18 +++---- org/w3c/css/properties/css3/CssObjectFit.java | 27 ++++------ org/w3c/css/properties/css3/CssOpacity.java | 5 +- 5 files changed, 60 insertions(+), 48 deletions(-) diff --git a/org/w3c/css/properties/css3/CssCursor.java b/org/w3c/css/properties/css3/CssCursor.java index 75d7a43a3..1ed187fcb 100644 --- a/org/w3c/css/properties/css3/CssCursor.java +++ b/org/w3c/css/properties/css3/CssCursor.java @@ -105,17 +105,18 @@ public CssCursor(ApplContext ac, CssExpression expression, boolean check) } break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("value", inherit.toString(), getPropertyName(), ac); } - value = inherit; + value = val; break; } if (lastIdent == null) { - lastIdent = getMatchingIdent((CssIdent) val); + lastIdent = getMatchingIdent(id); // not recognized... exit if (lastIdent == null) { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssImageOrientation.java b/org/w3c/css/properties/css3/CssImageOrientation.java index a9b589fac..df0771e24 100644 --- a/org/w3c/css/properties/css3/CssImageOrientation.java +++ b/org/w3c/css/properties/css3/CssImageOrientation.java @@ -7,7 +7,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssAngle; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssOperator; @@ -18,7 +17,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2019/CR-css-images-3-20191010/#propdef-image-orientation + * @spec https://www.w3.org/TR/2020/CRD-css-images-3-20201217/#propdef-image-orientation * @deprecated */ public class CssImageOrientation extends org.w3c.css.properties.css.CssImageOrientation { @@ -56,8 +55,7 @@ public CssImageOrientation() { * Creates a new CssImageOrientation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssImageOrientation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -87,34 +85,53 @@ public CssImageOrientation(ApplContext ac, CssExpression expression, boolean che val.toString(), getPropertyName(), ac); } - if (!flip.equals((CssIdent) val)) { + if (!flip.equals(val.getIdent())) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } ArrayList v = new ArrayList<>(2); v.add(value); - v.add(flip); + v.add(val); value = new CssValueList(v); } break; case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (flip.equals(id)) { + value = val; + // check for optional angle + if (op == CssOperator.SPACE && expression.getRemainingCount() > 1) { + CssValueList values = new CssValueList(); + values.add(val); + expression.next(); + val = expression.getValue(); + op = expression.getOperator(); + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkEqualsZero(ac, getPropertyName()); + case CssTypes.CSS_ANGLE: + values.add(val); + break; + default: + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = values; + } + break; + } + // we can only have one value if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(id)) { + value = val; break; } - value = getAllowedIdent((CssIdent) val); - if (value != null) { - // single 'flip' will be pretty-printed as 0deg flip - if (flip == value) { - ArrayList v = new ArrayList<>(2); - v.add(new CssAngle()); - v.add(flip); - value = new CssValueList(v); - } + if (getAllowedIdent(id) != null) { + value = val; break; } // null value, bail out diff --git a/org/w3c/css/properties/css3/CssImageRendering.java b/org/w3c/css/properties/css3/CssImageRendering.java index 744566687..15be4393b 100644 --- a/org/w3c/css/properties/css3/CssImageRendering.java +++ b/org/w3c/css/properties/css3/CssImageRendering.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2019/CR-css-images-3-20191010/#propdef-image-rendering + * @spec https://www.w3.org/TR/2020/CRD-css-images-3-20201217/#propdef-image-rendering */ public class CssImageRendering extends org.w3c.css.properties.css.CssImageRendering { @@ -67,8 +67,7 @@ public CssImageRendering() { * Creates a new CssImageRendering * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssImageRendering(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -84,20 +83,19 @@ public CssImageRendering(ApplContext ac, CssExpression expression, boolean check op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; } else { - value = getAllowedValue(ident); - if (value == null) { - value = getDeprecatedValue(ident); - if (value == null) { + if (getAllowedValue(ident) == null) { + if (getDeprecatedValue(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } ac.getFrame().addWarning("deprecated", value.toString()); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssObjectFit.java b/org/w3c/css/properties/css3/CssObjectFit.java index 401a32ddf..444c4320e 100644 --- a/org/w3c/css/properties/css3/CssObjectFit.java +++ b/org/w3c/css/properties/css3/CssObjectFit.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2019/CR-css-images-3-20191010/#propdef-object-fit + * @spec https://www.w3.org/TR/2020/CRD-css-images-3-20201217/#propdef-object-fit */ public class CssObjectFit extends org.w3c.css.properties.css.CssObjectFit { @@ -49,8 +49,7 @@ public CssObjectFit() { * Creates a new CssObjectFit * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssObjectFit(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,23 +64,19 @@ public CssObjectFit(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && getAllowedIdent(ident) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; + expression.next(); } diff --git a/org/w3c/css/properties/css3/CssOpacity.java b/org/w3c/css/properties/css3/CssOpacity.java index bd8b3579b..99da7b51c 100644 --- a/org/w3c/css/properties/css3/CssOpacity.java +++ b/org/w3c/css/properties/css3/CssOpacity.java @@ -11,6 +11,7 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssPercentage; import org.w3c.css.values.CssTypes; @@ -90,8 +91,8 @@ public CssOpacity(ApplContext ac, CssExpression expression, boolean check) value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } // let it flow through the exception From 84c59cb5b18e49a4b33480088656f63fff467edb Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Thu, 9 Sep 2021 23:31:53 +0200 Subject: [PATCH 72/82] refs+cast (cont.) --- org/w3c/css/properties/css3/CssAnimation.java | 43 +++++++++---------- .../properties/css3/CssAnimationDelay.java | 10 ++--- .../css3/CssAnimationDirection.java | 17 ++++---- .../properties/css3/CssAnimationDuration.java | 20 ++++----- .../properties/css3/CssAnimationFillMode.java | 17 ++++---- .../css3/CssAnimationIterationCount.java | 21 ++++----- .../css/properties/css3/CssAnimationName.java | 18 +++++--- .../css3/CssAnimationPlayState.java | 14 +++--- .../css3/CssAnimationTimingFunction.java | 23 +++++----- org/w3c/css/properties/css3/CssOutline.java | 21 ++++----- .../css/properties/css3/CssOutlineStyle.java | 13 +++--- 11 files changed, 104 insertions(+), 113 deletions(-) diff --git a/org/w3c/css/properties/css3/CssAnimation.java b/org/w3c/css/properties/css3/CssAnimation.java index a0a457667..00aa12f7d 100644 --- a/org/w3c/css/properties/css3/CssAnimation.java +++ b/org/w3c/css/properties/css3/CssAnimation.java @@ -23,7 +23,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/WD-css3-transitions-20120403/#transition + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation */ public class CssAnimation extends org.w3c.css.properties.css.CssAnimation { @@ -53,8 +53,7 @@ public CssAnimation() { * Creates a new CssAnimation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -70,12 +69,12 @@ public CssAnimation(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - value = inherit; + value = val; expression.next(); return; } @@ -229,46 +228,44 @@ private CssAnimationValue checkLayer(ApplContext ac, val.toString(), caller.getPropertyName(), ac); case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - CssIdent match; - if (inherit.equals(ident)) { + CssIdent id = val.getIdent(); + // already matched but in case it is an external call... + if (CssIdent.isCssWide(id)) { if (expression.getCount() != 1) { throw new InvalidParamException("unrecognize", ac); } - v.name = inherit; + v.name = val; break; } if (v.timingfunc == null) { - match = CssAnimationTimingFunction.getAllowedIdent(ident); - if (match != null) { - v.timingfunc = match; + if (CssAnimationTimingFunction.getAllowedIdent(id) != null) { + v.timingfunc = val; break; } } if (v.direction == null) { - match = CssAnimationDirection.getAllowedIdent(ident); - if (match != null) { - v.direction = match; + if (CssAnimationDirection.getAllowedIdent(id) != null) { + v.direction = val; break; } } if (v.fillmode == null) { - match = CssAnimationFillMode.getAllowedIdent(ident); - if (match != null) { - v.fillmode = match; + if (CssAnimationFillMode.getAllowedIdent(id) != null) { + v.fillmode = val; break; } } if (v.itercount == null) { - match = CssAnimationIterationCount.getAllowedIdent(ident); - if (match != null) { - v.itercount = match; + if (CssAnimationIterationCount.getAllowedIdent(id) != null) { + v.itercount = val; break; } } if (v.name == null) { - v.name = CssAnimationName.getAllowedIdent(ac, ident); - break; + if (CssAnimationName.getAllowedIdent(ac, id) != null) { + v.name = val; + break; + } } // already set, let it fail default: diff --git a/org/w3c/css/properties/css3/CssAnimationDelay.java b/org/w3c/css/properties/css3/CssAnimationDelay.java index ce46161af..ab8e48d32 100644 --- a/org/w3c/css/properties/css3/CssAnimationDelay.java +++ b/org/w3c/css/properties/css3/CssAnimationDelay.java @@ -8,6 +8,7 @@ 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.CssLayerList; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -17,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-delay + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-delay */ public class CssAnimationDelay extends org.w3c.css.properties.css.CssAnimationDelay { @@ -32,8 +33,7 @@ public CssAnimationDelay() { * Creates a new CssAnimationDelay * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimationDelay(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -52,9 +52,9 @@ public CssAnimationDelay(ApplContext ac, CssExpression expression, boolean check values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (CssIdent.isCssWide(val.getIdent())) { gotinherit = true; - values.add(inherit); + values.add(val); break; } default: diff --git a/org/w3c/css/properties/css3/CssAnimationDirection.java b/org/w3c/css/properties/css3/CssAnimationDirection.java index aa81747a3..d9eb227fa 100644 --- a/org/w3c/css/properties/css3/CssAnimationDirection.java +++ b/org/w3c/css/properties/css3/CssAnimationDirection.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-direction + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-direction */ public class CssAnimationDirection extends org.w3c.css.properties.css.CssAnimationDirection { @@ -53,8 +53,7 @@ public CssAnimationDirection() { * Creates a new CssAnimationDirection * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimationDirection(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -71,15 +70,15 @@ public CssAnimationDirection(ApplContext ac, CssExpression expression, boolean c op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); break; } else { - CssIdent ident = getAllowedIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getAllowedIdent(id) != null) { + values.add(val); break; } } diff --git a/org/w3c/css/properties/css3/CssAnimationDuration.java b/org/w3c/css/properties/css3/CssAnimationDuration.java index 8066342a8..bc1213689 100644 --- a/org/w3c/css/properties/css3/CssAnimationDuration.java +++ b/org/w3c/css/properties/css3/CssAnimationDuration.java @@ -7,8 +7,8 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2013/WD-css3-animations-20130219/#animation-duration + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-duration */ public class CssAnimationDuration extends org.w3c.css.properties.css.CssAnimationDuration { @@ -33,14 +33,13 @@ public CssAnimationDuration() { * Creates a new CssAnimationDuration * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimationDuration(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); - CssValue val; + CssValue val, sVal = expression.getValue(); char op; ArrayList values = new ArrayList(); boolean gotinherit = false; @@ -50,14 +49,15 @@ public CssAnimationDuration(ApplContext ac, CssExpression expression, boolean ch op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_TIME: - CssCheckableValue t = val.getCheckableValue(); - t.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, this); values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { gotinherit = true; - values.add(inherit); + sVal = val; + values.add(val); break; } default: @@ -73,7 +73,7 @@ public CssAnimationDuration(ApplContext ac, CssExpression expression, boolean ch } if (gotinherit && values.size() > 1) { throw new InvalidParamException("value", - inherit.toString(), + sVal.toString(), getPropertyName(), ac); } value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); diff --git a/org/w3c/css/properties/css3/CssAnimationFillMode.java b/org/w3c/css/properties/css3/CssAnimationFillMode.java index 384481fb2..428644718 100644 --- a/org/w3c/css/properties/css3/CssAnimationFillMode.java +++ b/org/w3c/css/properties/css3/CssAnimationFillMode.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-fill-mode + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-fill-mode */ public class CssAnimationFillMode extends org.w3c.css.properties.css.CssAnimationFillMode { @@ -53,8 +53,7 @@ public CssAnimationFillMode() { * Creates a new CssAnimationFillMode * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimationFillMode(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -71,15 +70,15 @@ public CssAnimationFillMode(ApplContext ac, CssExpression expression, boolean ch op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); break; } else { - CssIdent ident = getAllowedIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getAllowedIdent(id) != null) { + values.add(val); break; } } diff --git a/org/w3c/css/properties/css3/CssAnimationIterationCount.java b/org/w3c/css/properties/css3/CssAnimationIterationCount.java index aa38a09b7..03ea77ca3 100644 --- a/org/w3c/css/properties/css3/CssAnimationIterationCount.java +++ b/org/w3c/css/properties/css3/CssAnimationIterationCount.java @@ -7,7 +7,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; @@ -19,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-iteration-count + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-iteration-count */ public class CssAnimationIterationCount extends org.w3c.css.properties.css.CssAnimationIterationCount { @@ -40,8 +39,7 @@ public CssAnimationIterationCount() { * Creates a new CssAnimationIterationCount * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssAnimationIterationCount(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -58,20 +56,19 @@ public CssAnimationIterationCount(ApplContext ac, CssExpression expression, bool op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssCheckableValue num = val.getCheckableValue(); - num.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, this); values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); break; } else { - CssIdent ident = getAllowedIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getAllowedIdent(id) != null) { + values.add(val); break; } } diff --git a/org/w3c/css/properties/css3/CssAnimationName.java b/org/w3c/css/properties/css3/CssAnimationName.java index 8410daa9b..cc184f6a6 100644 --- a/org/w3c/css/properties/css3/CssAnimationName.java +++ b/org/w3c/css/properties/css3/CssAnimationName.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-name + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-name */ public class CssAnimationName extends org.w3c.css.properties.css.CssAnimationName { @@ -61,15 +61,19 @@ public CssAnimationName(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); + break; } else { - CssIdent ident = getAllowedIdent(ac, (CssIdent) val); - values.add(ident); + if (getAllowedIdent(ac, id) != null) { + values.add(val); + break; + } } - break; + // unrecognized ident default: throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssAnimationPlayState.java b/org/w3c/css/properties/css3/CssAnimationPlayState.java index 7302b0603..bce82bcc6 100644 --- a/org/w3c/css/properties/css3/CssAnimationPlayState.java +++ b/org/w3c/css/properties/css3/CssAnimationPlayState.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-play-state + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-play-state */ public class CssAnimationPlayState extends org.w3c.css.properties.css.CssAnimationPlayState { @@ -71,15 +71,15 @@ public CssAnimationPlayState(ApplContext ac, CssExpression expression, boolean c op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); break; } else { - CssIdent ident = getAllowedIdent((CssIdent) val); - if (ident != null) { - values.add(ident); + if (getAllowedIdent(id) != null) { + values.add(val); break; } } diff --git a/org/w3c/css/properties/css3/CssAnimationTimingFunction.java b/org/w3c/css/properties/css3/CssAnimationTimingFunction.java index 0c9e819e6..ad9d887a1 100644 --- a/org/w3c/css/properties/css3/CssAnimationTimingFunction.java +++ b/org/w3c/css/properties/css3/CssAnimationTimingFunction.java @@ -13,7 +13,6 @@ import org.w3c.css.values.CssFunction; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; -import org.w3c.css.values.CssNumber; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -22,7 +21,8 @@ import static org.w3c.css.values.CssOperator.COMMA; /** - * @spec http://www.w3.org/TR/2012/WD-css3-animations-20120403/#animation-timing-function + * @spec https://www.w3.org/TR/2018/WD-css-animations-1-20181011/#propdef-animation-timing-function + * @spec https://www.w3.org/TR/2021/CRD-css-easing-1-20210401/#easing-functions */ public class CssAnimationTimingFunction extends org.w3c.css.properties.css.CssAnimationTimingFunction { @@ -87,15 +87,15 @@ public CssAnimationTimingFunction(ApplContext ac, CssExpression expression, bool values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { singleVal = true; - sValue = inherit; - values.add(inherit); + sValue = val; + values.add(val); break; } else { - CssIdent id = getAllowedIdent((CssIdent) val); - if (id != null) { - values.add(id); + if (getAllowedIdent(id) != null) { + values.add(val); break; } // if not recognized, let it fail @@ -201,11 +201,12 @@ private static CssValue parseCubicBezierFunction(ApplContext ac, CssExpression f caller.getPropertyName(), ac); } // we have a number, continue checks - CssNumber number = val.getNumber(); // it must be between 0 and 1 for X [x1,y1,x2,y2] if ((i & 0x1) == 0) { - number.checkPositiveness(ac, caller); - number.checkLowerEqualThan(ac, 1., caller); + val.getCheckableValue().checkPositiveness(ac, caller); + if (val.getRawType() == CssTypes.CSS_NUMBER) { + val.getNumber().checkLowerEqualThan(ac, 1., caller); + } } values.add(val); // go to the next item... diff --git a/org/w3c/css/properties/css3/CssOutline.java b/org/w3c/css/properties/css3/CssOutline.java index 4f4b4ad15..9cb81192b 100644 --- a/org/w3c/css/properties/css3/CssOutline.java +++ b/org/w3c/css/properties/css3/CssOutline.java @@ -102,35 +102,32 @@ public CssOutline(ApplContext ac, CssExpression expression, boolean check) val.toString(), getPropertyName(), ac); case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; + value = val; break; } - CssIdent ident = (CssIdent) val; // let's try to find which ident we have... if (styleValue == null) { - CssIdent match = CssOutlineStyle.getMatchingIdent(ident); - if (match != null) { - styleValue = match; + if (CssOutlineStyle.getMatchingIdent(ident) != null) { + styleValue = val; break; } } if (widthValue == null) { - CssIdent match = CssBorderWidth.getMatchingIdent(ident); - if (match != null) { - widthValue = match; + if (CssBorderWidth.getMatchingIdent(ident) != null) { + widthValue = val; break; } } if (colorValue == null) { - CssIdent match = CssOutlineColor.getMatchingIdent(ident); - if (match != null) { - colorValue = match; + if (CssOutlineColor.getMatchingIdent(ident) != null) { + colorValue = val; break; } else { CssExpression ex = new CssExpression(); diff --git a/org/w3c/css/properties/css3/CssOutlineStyle.java b/org/w3c/css/properties/css3/CssOutlineStyle.java index b25dcc159..84e5d1c3b 100644 --- a/org/w3c/css/properties/css3/CssOutlineStyle.java +++ b/org/w3c/css/properties/css3/CssOutlineStyle.java @@ -39,8 +39,7 @@ public CssOutlineStyle() { * Creates a new CssOutlineStyle * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssOutlineStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -56,11 +55,9 @@ public CssOutlineStyle(ApplContext ac, CssExpression expression, boolean check) // css3 adds an 'auto' value on top of border-style values value = null; if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id_val = (CssIdent) val; - if (inherit.equals(id_val)) { - value = inherit; - } else if (auto.equals(id_val)) { - value = auto; + CssIdent id_val = val.getIdent(); + if (CssIdent.isCssWide(id_val) || auto.equals(id_val)) { + value = val; } } // if we got a match, work on the expression, otherwise @@ -71,7 +68,7 @@ public CssOutlineStyle(ApplContext ac, CssExpression expression, boolean check) // here we delegate to BorderStyle implementation value = CssBorderStyle.parseBorderSideStyle(ac, expression, check, this); // but hidden is not a valid value... - if (hidden.equals(value)) { + if (value.getType() == CssTypes.CSS_IDENT && hidden.equals(value.getIdent())) { throw new InvalidParamException("value", hidden, getPropertyName(), ac); } From dd4fb2ec426313b167a97e31b0384e991c2dda15 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 08:24:14 +0200 Subject: [PATCH 73/82] column now use row to parse, updated ref+cast --- org/w3c/css/properties/css3/CssColumnGap.java | 39 +------------------ org/w3c/css/properties/css3/CssGap.java | 12 +++--- org/w3c/css/properties/css3/CssRowGap.java | 13 +++---- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/org/w3c/css/properties/css3/CssColumnGap.java b/org/w3c/css/properties/css3/CssColumnGap.java index 84883dc28..778d686e6 100644 --- a/org/w3c/css/properties/css3/CssColumnGap.java +++ b/org/w3c/css/properties/css3/CssColumnGap.java @@ -9,25 +9,16 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; -import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2021/WD-css-multicol-1-20210212/#cg * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-column-gap + * @see CssRowGap */ public class CssColumnGap extends org.w3c.css.properties.css.CssColumnGap { - static CssIdent normal; - - static { - normal = CssIdent.getIdent("normal"); - } - /** * Create a new CssColumnGap */ @@ -46,33 +37,7 @@ public CssColumnGap(ApplContext ac, CssExpression expression, if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val.getCheckableValue().checkEqualsZero(ac, this); - value = val; - break; - case CssTypes.CSS_PERCENTAGE: - case CssTypes.CSS_LENGTH: - CssCheckableValue l = val.getCheckableValue(); - l.checkPositiveness(ac, this); - value = val; - break; - case CssTypes.CSS_IDENT: - CssIdent ident = val.getIdent(); - if (normal.equals(ident)) { - value = val; - break; - } - if (CssIdent.isCssWide(ident)) { - value = val; - break; - } - default: - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); - } - expression.next(); + value = CssRowGap.parseRowGap(ac, expression, this); } public CssColumnGap(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssGap.java b/org/w3c/css/properties/css3/CssGap.java index a21b56875..323773ec2 100644 --- a/org/w3c/css/properties/css3/CssGap.java +++ b/org/w3c/css/properties/css3/CssGap.java @@ -10,6 +10,8 @@ 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; import org.w3c.css.values.CssValueList; @@ -18,7 +20,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-gap + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-gap */ public class CssGap extends org.w3c.css.properties.css.CssGap { @@ -51,7 +53,7 @@ public CssGap(ApplContext ac, CssExpression expression, columnGap = new CssColumnGap(); rowGap = new CssRowGap(); - val = CssRowGap.checkSyntax(ac, expression, this); + val = CssRowGap.parseRowGap(ac, expression, this); rowGap.value = val; if (!expression.end()) { if (op != SPACE) { @@ -59,13 +61,13 @@ public CssGap(ApplContext ac, CssExpression expression, Character.toString(op), ac); } // inherit can only be alone - if (inherit.equals(val)) { + if ((val.getType()== CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - val = CssRowGap.checkSyntax(ac, expression, this); + val = CssRowGap.parseRowGap(ac, expression, this); // same for value #2 - if (inherit.equals(val)) { + if ((val.getType()== CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } diff --git a/org/w3c/css/properties/css3/CssRowGap.java b/org/w3c/css/properties/css3/CssRowGap.java index 86cb57608..546d26102 100644 --- a/org/w3c/css/properties/css3/CssRowGap.java +++ b/org/w3c/css/properties/css3/CssRowGap.java @@ -16,7 +16,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-row-gap + * @spec https://www.w3.org/TR/2020/WD-css-align-3-20200421/#propdef-row-gap */ public class CssRowGap extends org.w3c.css.properties.css.CssRowGap { @@ -44,10 +44,10 @@ public CssRowGap(ApplContext ac, CssExpression expression, if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = checkSyntax(ac, expression, this); + value = parseRowGap(ac, expression, this); } - public static CssValue checkSyntax(ApplContext ac, CssExpression expression, CssProperty caller) + public static CssValue parseRowGap(ApplContext ac, CssExpression expression, CssProperty caller) throws InvalidParamException { CssValue val = expression.getValue(); @@ -61,12 +61,11 @@ public static CssValue checkSyntax(ApplContext ac, CssExpression expression, Css l.checkPositiveness(ac, caller); break; case CssTypes.CSS_IDENT: - if (normal.equals(val)) { - val = normal; + CssIdent id = val.getIdent(); + if (normal.equals(id)) { break; } - if (inherit.equals(val)) { - val = inherit; + if (CssIdent.isCssWide(id)) { break; } default: From 30231267b4476c4028d6a575367a6c348994a830 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 08:34:21 +0200 Subject: [PATCH 74/82] aligned all refs --- org/w3c/css/properties/css3/CssBottom.java | 2 +- org/w3c/css/properties/css3/CssInsetBlockEnd.java | 1 + org/w3c/css/properties/css3/CssInsetBlockStart.java | 1 + org/w3c/css/properties/css3/CssInsetInlineEnd.java | 1 + org/w3c/css/properties/css3/CssInsetInlineStart.java | 1 + org/w3c/css/properties/css3/CssLeft.java | 2 +- org/w3c/css/properties/css3/CssRight.java | 2 +- org/w3c/css/properties/css3/CssTop.java | 12 ++++++------ 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBottom.java b/org/w3c/css/properties/css3/CssBottom.java index 93b21f2ce..1623ffb30 100644 --- a/org/w3c/css/properties/css3/CssBottom.java +++ b/org/w3c/css/properties/css3/CssBottom.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/WD-css3-positioning-20120207/#bottom + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-bottom * @see org.w3c.css.properties.css3.CssTop */ public class CssBottom extends org.w3c.css.properties.css.CssBottom { diff --git a/org/w3c/css/properties/css3/CssInsetBlockEnd.java b/org/w3c/css/properties/css3/CssInsetBlockEnd.java index 1a0697b7e..068864655 100644 --- a/org/w3c/css/properties/css3/CssInsetBlockEnd.java +++ b/org/w3c/css/properties/css3/CssInsetBlockEnd.java @@ -11,6 +11,7 @@ /** * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#propdef-inset-block-end + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-inset-block-end */ public class CssInsetBlockEnd extends org.w3c.css.properties.css.CssInsetBlockEnd { diff --git a/org/w3c/css/properties/css3/CssInsetBlockStart.java b/org/w3c/css/properties/css3/CssInsetBlockStart.java index 828edc101..15a2c04b9 100644 --- a/org/w3c/css/properties/css3/CssInsetBlockStart.java +++ b/org/w3c/css/properties/css3/CssInsetBlockStart.java @@ -11,6 +11,7 @@ /** * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#propdef-inset-block-start + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-inset-block-start */ public class CssInsetBlockStart extends org.w3c.css.properties.css.CssInsetBlockStart { diff --git a/org/w3c/css/properties/css3/CssInsetInlineEnd.java b/org/w3c/css/properties/css3/CssInsetInlineEnd.java index 8229e28f9..9a754eba6 100644 --- a/org/w3c/css/properties/css3/CssInsetInlineEnd.java +++ b/org/w3c/css/properties/css3/CssInsetInlineEnd.java @@ -11,6 +11,7 @@ /** * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#propdef-inset-inline-end + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-inset-inline-end */ public class CssInsetInlineEnd extends org.w3c.css.properties.css.CssInsetInlineEnd { diff --git a/org/w3c/css/properties/css3/CssInsetInlineStart.java b/org/w3c/css/properties/css3/CssInsetInlineStart.java index 02bc3cdfc..29ba91c96 100644 --- a/org/w3c/css/properties/css3/CssInsetInlineStart.java +++ b/org/w3c/css/properties/css3/CssInsetInlineStart.java @@ -11,6 +11,7 @@ /** * @spec https://www.w3.org/TR/2018/WD-css-logical-1-20180827/#propdef-inset-inline-start + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-inset-inline-start */ public class CssInsetInlineStart extends org.w3c.css.properties.css.CssInsetInlineStart { diff --git a/org/w3c/css/properties/css3/CssLeft.java b/org/w3c/css/properties/css3/CssLeft.java index 49ec580d6..8d2df2d82 100644 --- a/org/w3c/css/properties/css3/CssLeft.java +++ b/org/w3c/css/properties/css3/CssLeft.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/WD-css3-positioning-20120207/#left + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-left * @see org.w3c.css.properties.css3.CssTop */ public class CssLeft extends org.w3c.css.properties.css.CssLeft { diff --git a/org/w3c/css/properties/css3/CssRight.java b/org/w3c/css/properties/css3/CssRight.java index fe75feaaf..1a42ec583 100644 --- a/org/w3c/css/properties/css3/CssRight.java +++ b/org/w3c/css/properties/css3/CssRight.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/WD-css3-positioning-20120207/#right + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-right * @see org.w3c.css.properties.css3.CssTop */ public class CssRight extends org.w3c.css.properties.css.CssRight { diff --git a/org/w3c/css/properties/css3/CssTop.java b/org/w3c/css/properties/css3/CssTop.java index 01821a700..9faf44e22 100644 --- a/org/w3c/css/properties/css3/CssTop.java +++ b/org/w3c/css/properties/css3/CssTop.java @@ -14,7 +14,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2012/WD-css3-positioning-20120207/#top + * @spec https://www.w3.org/TR/2020/WD-css-position-3-20200519/#propdef-top */ public class CssTop extends org.w3c.css.properties.css.CssTop { @@ -31,8 +31,7 @@ public CssTop() { * Creates a new CssTop * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssTop(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -73,11 +72,12 @@ protected static CssValue parseTop(ApplContext ac, expression.next(); return val; case CssTypes.CSS_IDENT: - if (inherit.equals(val.getIdent())) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { expression.next(); - return inherit; + return val; } - if (auto.equals(val.getIdent())) { + if (auto.equals(id)) { expression.next(); return val; } From f646100fcf7fe460237304e0ef5f083db3299c45 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 10:38:02 +0200 Subject: [PATCH 75/82] refs+cast (cont.) --- org/w3c/css/properties/css3/CssGrid.java | 40 +++++++++---------- org/w3c/css/properties/css3/CssGridArea.java | 2 +- .../properties/css3/CssGridAutoColumns.java | 7 ++-- .../css/properties/css3/CssGridAutoFlow.java | 18 ++++----- .../css/properties/css3/CssGridAutoRows.java | 22 +++++----- .../css/properties/css3/CssGridColumn.java | 2 +- .../css/properties/css3/CssGridColumnEnd.java | 2 +- .../properties/css3/CssGridColumnStart.java | 2 +- org/w3c/css/properties/css3/CssGridRow.java | 2 +- .../css/properties/css3/CssGridRowEnd.java | 2 +- .../css/properties/css3/CssGridRowStart.java | 22 +++++----- .../css/properties/css3/CssGridTemplate.java | 29 +++++--------- .../properties/css3/CssGridTemplateAreas.java | 17 +++----- .../css3/CssGridTemplateColumns.java | 2 +- .../properties/css3/CssGridTemplateRows.java | 9 ++--- 15 files changed, 80 insertions(+), 98 deletions(-) diff --git a/org/w3c/css/properties/css3/CssGrid.java b/org/w3c/css/properties/css3/CssGrid.java index 885530310..dde8a6342 100644 --- a/org/w3c/css/properties/css3/CssGrid.java +++ b/org/w3c/css/properties/css3/CssGrid.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid */ public class CssGrid extends org.w3c.css.properties.css.CssGrid { @@ -93,7 +93,7 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) auto_flow_first = true; } // else defaults to false } else if (val.getType() == CssTypes.CSS_IDENT) { - got_auto_flow = auto_flow.equals((CssIdent) val); + got_auto_flow = auto_flow.equals(val.getIdent()); } expression.next(); } @@ -114,9 +114,9 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) val.toString(), getPropertyName(), ac); } - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (auto_flow.equals(id)) { - values.add(auto_flow); + values.add(val); autoFlowValues.add(CssGridAutoFlow.row); // optional 'dense' if (op != SPACE) { @@ -126,9 +126,9 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) expression.next(); val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && CssGridAutoFlow.dense.equals(val)) { - values.add(CssGridAutoFlow.dense); - autoFlowValues.add(CssGridAutoFlow.dense); + if (val.getType() == CssTypes.CSS_IDENT && CssGridAutoFlow.dense.equals(val.getIdent())) { + values.add(val); + autoFlowValues.add(val); if (op != SPACE) { throw new InvalidParamException("operator", op, getPropertyName(), ac); @@ -137,8 +137,8 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) } } else { if (CssGridAutoFlow.dense.equals(id)) { - values.add(CssGridAutoFlow.dense); - autoFlowValues.add(CssGridAutoFlow.dense); + values.add(val); + autoFlowValues.add(val); // mandatory 'auto-flow' if (op != SPACE) { throw new InvalidParamException("operator", op, @@ -147,8 +147,8 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) expression.next(); val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && auto_flow.equals(val)) { - values.add(auto_flow); + if (val.getType() == CssTypes.CSS_IDENT && auto_flow.equals(val.getIdent())) { + values.add(val); autoFlowValues.add(CssGridAutoFlow.row); } else { throw new InvalidParamException("value", @@ -211,9 +211,9 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) val.toString(), getPropertyName(), ac); } - CssIdent id = (CssIdent) val; + CssIdent id = val.getIdent(); if (auto_flow.equals(id)) { - values.add(auto_flow); + values.add(val); autoFlowValues.add(CssGridAutoFlow.row); // optional 'dense' if (op != SPACE) { @@ -223,8 +223,8 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) expression.next(); val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && CssGridAutoFlow.dense.equals(val)) { - values.add(CssGridAutoFlow.dense); + if (val.getType() == CssTypes.CSS_IDENT && CssGridAutoFlow.dense.equals(val.getIdent())) { + values.add(val); autoFlowValues.add(CssGridAutoFlow.dense); if (op != SPACE) { throw new InvalidParamException("operator", op, @@ -234,7 +234,7 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) } } else { if (CssGridAutoFlow.dense.equals(id)) { - values.add(CssGridAutoFlow.dense); + values.add(val); autoFlowValues.add(CssGridAutoFlow.dense); // mandatory 'auto-flow' if (op != SPACE) { @@ -244,8 +244,8 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) expression.next(); val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && auto_flow.equals(val)) { - values.add(auto_flow); + if (val.getType() == CssTypes.CSS_IDENT && auto_flow.equals(val.getIdent())) { + values.add(val); autoFlowValues.add(CssGridAutoFlow.row); } else { throw new InvalidParamException("value", @@ -281,8 +281,8 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) } else { // inherit ? val = expression.getValue(); - if (expression.getCount() == 1 && val.getType() == CssTypes.CSS_IDENT == inherit.equals((CssIdent) val)) { - value = inherit; + if (expression.getCount() == 1 && (val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + value = val; expression.next(); return; } diff --git a/org/w3c/css/properties/css3/CssGridArea.java b/org/w3c/css/properties/css3/CssGridArea.java index 18897b2ad..a681623fe 100644 --- a/org/w3c/css/properties/css3/CssGridArea.java +++ b/org/w3c/css/properties/css3/CssGridArea.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-area + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-area */ public class CssGridArea extends org.w3c.css.properties.css.CssGridArea { diff --git a/org/w3c/css/properties/css3/CssGridAutoColumns.java b/org/w3c/css/properties/css3/CssGridAutoColumns.java index 6a270dd9f..832347c68 100644 --- a/org/w3c/css/properties/css3/CssGridAutoColumns.java +++ b/org/w3c/css/properties/css3/CssGridAutoColumns.java @@ -8,6 +8,7 @@ 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; import org.w3c.css.values.CssValueList; @@ -18,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-auto-columns + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-auto-columns */ public class CssGridAutoColumns extends org.w3c.css.properties.css.CssGridAutoColumns { @@ -49,11 +50,11 @@ public CssGridAutoColumns(ApplContext ac, CssExpression expression, boolean chec val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && inherit.equals(val)) { + if (val.getType() == CssTypes.CSS_IDENT && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - values.add(inherit); + values.add(val); } else { values.add(parseTrackSize(ac, val, this)); } diff --git a/org/w3c/css/properties/css3/CssGridAutoFlow.java b/org/w3c/css/properties/css3/CssGridAutoFlow.java index f8a799beb..ae63df8d7 100644 --- a/org/w3c/css/properties/css3/CssGridAutoFlow.java +++ b/org/w3c/css/properties/css3/CssGridAutoFlow.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-auto-flow + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-auto-flow */ public class CssGridAutoFlow extends org.w3c.css.properties.css.CssGridAutoFlow { @@ -64,7 +64,7 @@ public CssGridAutoFlow(ApplContext ac, CssExpression expression, boolean check) } setByUser(); - CssValue val, ident; + CssValue val; char op; @@ -77,33 +77,33 @@ public CssGridAutoFlow(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - values.add(inherit); + values.add(val); break; } - ident = getAllowedIdent((CssIdent) val); - if (ident != null) { + if (getAllowedIdent(id) != null) { if (got_axis) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } else { got_axis = true; - values.add(ident); + values.add(val); break; } } - if (dense.equals(val)) { + if (dense.equals(id)) { // did we get another 'dense' ? if (values.size() > 0 && !got_axis) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - values.add(dense); + values.add(val); break; } default: diff --git a/org/w3c/css/properties/css3/CssGridAutoRows.java b/org/w3c/css/properties/css3/CssGridAutoRows.java index 9c0bdb726..5eeb29b53 100644 --- a/org/w3c/css/properties/css3/CssGridAutoRows.java +++ b/org/w3c/css/properties/css3/CssGridAutoRows.java @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-auto-rows + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-auto-rows */ public class CssGridAutoRows extends org.w3c.css.properties.css.CssGridAutoRows { @@ -60,8 +60,7 @@ public CssGridAutoRows() { * Creates a new CssGridAutoRows * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssGridAutoRows(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -76,11 +75,11 @@ public CssGridAutoRows(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT && inherit.equals(val)) { + if (val.getType() == CssTypes.CSS_IDENT && CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - values.add(inherit); + values.add(val); } else { values.add(parseTrackSize(ac, val, this)); } @@ -159,7 +158,6 @@ protected static CssValue parseFixedSize(ApplContext ac, CssValue value, protected static CssValue parseTrackBreadth(ApplContext ac, CssValue value, CssProperty caller) throws InvalidParamException { - CssIdent ident; switch (value.getType()) { case CssTypes.CSS_NUMBER: @@ -171,10 +169,10 @@ protected static CssValue parseTrackBreadth(ApplContext ac, CssValue value, value.getCheckableValue().checkPositiveness(ac, caller); return value; case CssTypes.CSS_IDENT: - ident = getAllowedIdent((CssIdent) value); - if (ident != null) { - return ident; + if (getAllowedIdent(value.getIdent()) != null) { + return value; } + // else fail default: throw new InvalidParamException("value", value.toString(), @@ -196,10 +194,10 @@ protected static CssValue parseInflexibleBreadth(ApplContext ac, CssValue value, value.getCheckableValue().checkPositiveness(ac, caller); return value; case CssTypes.CSS_IDENT: - ident = getAllowedIdent((CssIdent) value); - if (ident != null) { - return ident; + if (getAllowedIdent(value.getIdent()) != null) { + return value; } + // else fail default: throw new InvalidParamException("value", value.toString(), diff --git a/org/w3c/css/properties/css3/CssGridColumn.java b/org/w3c/css/properties/css3/CssGridColumn.java index e914422d0..180655e78 100644 --- a/org/w3c/css/properties/css3/CssGridColumn.java +++ b/org/w3c/css/properties/css3/CssGridColumn.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-column + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-column */ public class CssGridColumn extends org.w3c.css.properties.css.CssGridColumn { diff --git a/org/w3c/css/properties/css3/CssGridColumnEnd.java b/org/w3c/css/properties/css3/CssGridColumnEnd.java index 710db9ba6..eda0270d0 100644 --- a/org/w3c/css/properties/css3/CssGridColumnEnd.java +++ b/org/w3c/css/properties/css3/CssGridColumnEnd.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-column-end + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-column-end */ public class CssGridColumnEnd extends org.w3c.css.properties.css.CssGridColumnEnd { diff --git a/org/w3c/css/properties/css3/CssGridColumnStart.java b/org/w3c/css/properties/css3/CssGridColumnStart.java index fa777a73c..38fe9d626 100644 --- a/org/w3c/css/properties/css3/CssGridColumnStart.java +++ b/org/w3c/css/properties/css3/CssGridColumnStart.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-column-start + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-column-start */ public class CssGridColumnStart extends org.w3c.css.properties.css.CssGridColumnStart { diff --git a/org/w3c/css/properties/css3/CssGridRow.java b/org/w3c/css/properties/css3/CssGridRow.java index a8ceaf5b5..e02959d96 100644 --- a/org/w3c/css/properties/css3/CssGridRow.java +++ b/org/w3c/css/properties/css3/CssGridRow.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-row + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-row */ public class CssGridRow extends org.w3c.css.properties.css.CssGridRow { diff --git a/org/w3c/css/properties/css3/CssGridRowEnd.java b/org/w3c/css/properties/css3/CssGridRowEnd.java index 7ca31d1ed..ab40eef10 100644 --- a/org/w3c/css/properties/css3/CssGridRowEnd.java +++ b/org/w3c/css/properties/css3/CssGridRowEnd.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-row-end + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-row-end */ public class CssGridRowEnd extends org.w3c.css.properties.css.CssGridRowEnd { diff --git a/org/w3c/css/properties/css3/CssGridRowStart.java b/org/w3c/css/properties/css3/CssGridRowStart.java index 0f63198d1..a28bc0aff 100644 --- a/org/w3c/css/properties/css3/CssGridRowStart.java +++ b/org/w3c/css/properties/css3/CssGridRowStart.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-row-start + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-row-start */ public class CssGridRowStart extends org.w3c.css.properties.css.CssGridRowStart { @@ -37,8 +37,7 @@ public CssGridRowStart() { * Creates a new CssGridRowEnd * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssGridRowStart(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -67,7 +66,7 @@ public static CssValue checkGridLine(ApplContext ac, CssExpression expression, b switch (val.getType()) { case CssTypes.CSS_NUMBER: - if (gotNumber || val.getCheckableValue().isZero()) { + if (gotNumber || ((val.getRawType() == CssTypes.CSS_NUMBER) && val.getCheckableValue().isZero())) { // TODO add a specific exception, value can't be zero. throw new InvalidParamException("value", val.toString(), @@ -77,10 +76,10 @@ public static CssValue checkGridLine(ApplContext ac, CssExpression expression, b gotNumber = true; v.add(val); break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - v.add(inherit); + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + v.add(val); if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), @@ -88,8 +87,8 @@ public static CssValue checkGridLine(ApplContext ac, CssExpression expression, b } break; } - if (auto.equals(val)) { - v.add(auto); + if (auto.equals(id)) { + v.add(val); if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), @@ -97,14 +96,14 @@ public static CssValue checkGridLine(ApplContext ac, CssExpression expression, b } break; } - if (span.equals(val)) { + if (span.equals(id)) { // span cannot be in the middle... if (v.size() > 0 && expression.getRemainingCount() > 1) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); } - v.add(span); + v.add(val); break; } if (gotCustomIdent) { @@ -115,7 +114,6 @@ public static CssValue checkGridLine(ApplContext ac, CssExpression expression, b v.add(val); gotCustomIdent = true; break; - default: throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssGridTemplate.java b/org/w3c/css/properties/css3/CssGridTemplate.java index aa1f7847a..a3b2f40e2 100644 --- a/org/w3c/css/properties/css3/CssGridTemplate.java +++ b/org/w3c/css/properties/css3/CssGridTemplate.java @@ -26,7 +26,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-template + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-template */ public class CssGridTemplate extends org.w3c.css.properties.css.CssGridTemplate { @@ -60,8 +60,7 @@ public CssGridTemplate() { * Creates a new CssGridTemplate * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssGridTemplate(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -100,17 +99,12 @@ protected static CssValue parseGridTemplate(ApplContext ac, CssExpression expres val.toString(), caller.getPropertyName(), ac); } - CssIdent id = (CssIdent) val; - if (none.equals(id)) { - values.add(none); - areaValues.add(none); - columnValues.add(none); - rowValues.add(none); - } else if (inherit.equals(id)) { - values.add(inherit); - areaValues.add(inherit); - columnValues.add(inherit); - rowValues.add(inherit); + CssIdent id = val.getIdent(); + if (none.equals(id) || CssIdent.isCssWide(id)) { + values.add(val); + areaValues.add(val); + columnValues.add(val); + rowValues.add(val); } else { throw new InvalidParamException("value", val.toString(), @@ -276,9 +270,9 @@ protected static CssValue parseTemplateRows(ApplContext ac, CssExpression exp, C throws InvalidParamException { if (exp.getCount() == 1) { CssValue val = exp.getValue(); - if (val.getType() == CssTypes.CSS_IDENT && none.equals((CssIdent) val)) { + if (val.getType() == CssTypes.CSS_IDENT && none.equals(val.getIdent())) { exp.next(); - return none; + return val; } } exp.mark(); @@ -519,8 +513,7 @@ protected static CssFunction parseRepeatFunction(ApplContext ac, CssFunction fun switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = getAllowedRepeatIdent((CssIdent) val); - if (id == null || type != RepeatType.AUTO_REPEAT) { + if ((getAllowedRepeatIdent(val.getIdent()) == null) || (type != RepeatType.AUTO_REPEAT)) { throw new InvalidParamException("value", val.toString(), caller.getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssGridTemplateAreas.java b/org/w3c/css/properties/css3/CssGridTemplateAreas.java index 64dafd4d3..e4be01ebc 100644 --- a/org/w3c/css/properties/css3/CssGridTemplateAreas.java +++ b/org/w3c/css/properties/css3/CssGridTemplateAreas.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-template-areas + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-template-areas */ public class CssGridTemplateAreas extends org.w3c.css.properties.css.CssGridTemplateAreas { @@ -33,8 +33,7 @@ public CssGridTemplateAreas() { * Creates a new CssGridTemplateAreas * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssGridTemplateAreas(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -53,18 +52,12 @@ public CssGridTemplateAreas(ApplContext ac, CssExpression expression, boolean ch values.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || none.equals(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - values.add(inherit); - break; - } - if (none.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - values.add(none); + values.add(val); break; } default: diff --git a/org/w3c/css/properties/css3/CssGridTemplateColumns.java b/org/w3c/css/properties/css3/CssGridTemplateColumns.java index ed3cbb698..e43acf09d 100644 --- a/org/w3c/css/properties/css3/CssGridTemplateColumns.java +++ b/org/w3c/css/properties/css3/CssGridTemplateColumns.java @@ -19,7 +19,7 @@ import static org.w3c.css.properties.css3.CssGridTemplate.parseTrackList; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-template-columns + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-template-rows */ public class CssGridTemplateColumns extends org.w3c.css.properties.css.CssGridTemplateColumns { diff --git a/org/w3c/css/properties/css3/CssGridTemplateRows.java b/org/w3c/css/properties/css3/CssGridTemplateRows.java index f8328de28..8e3e50d4e 100644 --- a/org/w3c/css/properties/css3/CssGridTemplateRows.java +++ b/org/w3c/css/properties/css3/CssGridTemplateRows.java @@ -16,7 +16,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-template-rows + * @spec https://www.w3.org/TR/2020/CRD-css-grid-1-20201218/#propdef-grid-template-rows */ public class CssGridTemplateRows extends org.w3c.css.properties.css.CssGridTemplateRows { @@ -31,8 +31,7 @@ public CssGridTemplateRows() { * Creates a new CssGridTemplateRows * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssGridTemplateRows(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -47,11 +46,11 @@ public CssGridTemplateRows(ApplContext ac, CssExpression expression, boolean che switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - values.add(inherit); + values.add(val); expression.next(); break; } From 9ffdf7eb3cb3b35575421174a831c0c7462377a6 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 11:23:09 +0200 Subject: [PATCH 76/82] removed overloaded value --- org/w3c/css/properties/css3/CssColor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssColor.java b/org/w3c/css/properties/css3/CssColor.java index 57246c6b4..88e9a3a4f 100644 --- a/org/w3c/css/properties/css3/CssColor.java +++ b/org/w3c/css/properties/css3/CssColor.java @@ -19,7 +19,6 @@ public class CssColor extends org.w3c.css.properties.css.CssColor { CssValue color = null; - CssValue value = null; /** * Create a new CssColor From bbed863c0198ea03621f31ca3866bd0b501bcc69 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 11:26:08 +0200 Subject: [PATCH 77/82] cast+refs (cont.) --- .../properties/css3/CssBorderCollapse.java | 19 ++++----- .../css3/CssBoxDecorationBreak.java | 42 +++++++++---------- org/w3c/css/properties/css3/CssBoxShadow.java | 26 +++++------- org/w3c/css/properties/css3/CssBoxSizing.java | 19 ++++----- .../css/properties/css3/CssBoxSuppress.java | 19 ++++----- .../properties/css3/CssDominantBaseline.java | 21 ++++------ .../css/properties/css3/CssEmptyCells.java | 13 +++--- org/w3c/css/properties/css3/CssFlex.java | 25 ++++++----- .../css/properties/css3/CssFloatDefer.java | 19 +++------ .../css/properties/css3/CssFloatOffset.java | 5 +-- .../properties/css3/CssFloatReference.java | 16 ++++--- org/w3c/css/properties/css3/CssIsolation.java | 5 +-- 12 files changed, 95 insertions(+), 134 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBorderCollapse.java b/org/w3c/css/properties/css3/CssBorderCollapse.java index cbdb1fc1f..775792332 100644 --- a/org/w3c/css/properties/css3/CssBorderCollapse.java +++ b/org/w3c/css/properties/css3/CssBorderCollapse.java @@ -48,8 +48,7 @@ public CssBorderCollapse() { * Creates a new CssBorderCollapse * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBorderCollapse(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -65,17 +64,13 @@ public CssBorderCollapse(ApplContext ac, CssExpression expression, boolean check op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; } else { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssBoxDecorationBreak.java b/org/w3c/css/properties/css3/CssBoxDecorationBreak.java index f7dada312..a33f395e9 100644 --- a/org/w3c/css/properties/css3/CssBoxDecorationBreak.java +++ b/org/w3c/css/properties/css3/CssBoxDecorationBreak.java @@ -21,27 +21,38 @@ public class CssBoxDecorationBreak extends org.w3c.css.properties.css.CssBoxDecorationBreak { - public static CssIdent slice; - public static CssIdent clone; + public static final CssIdent[] allowed_values; static { - slice = CssIdent.getIdent("slice"); - clone = CssIdent.getIdent("clone"); + String[] _allowed_values = {"slice", "clone"}; + int i = 0; + allowed_values = new CssIdent[_allowed_values.length]; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + } + + public static final CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; } /** * Create new CssBoxDecorationBreak */ public CssBoxDecorationBreak() { - value = slice; + value = initial; } /** * Create new CssBoxDecorationBreak * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Values are incorrect + * @throws org.w3c.css.util.InvalidParamException Values are incorrect */ public CssBoxDecorationBreak(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -58,17 +69,13 @@ public CssBoxDecorationBreak(ApplContext ac, CssExpression expression, getPropertyName(), ac); } // ident, so inherit, or allowed value - if (inherit.equals(val)) { - value = inherit; - } else if (slice.equals(val)) { - value = slice; - } else if (clone.equals(val)) { - value = clone; - } else { + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } + value = val; expression.next(); } @@ -78,11 +85,4 @@ public CssBoxDecorationBreak(ApplContext ac, CssExpression expression) this(ac, expression, false); } - /** - * Is the value of this property a default value - * It is used by all macro for the function print - */ - public boolean isDefault() { - return slice == value; - } } diff --git a/org/w3c/css/properties/css3/CssBoxShadow.java b/org/w3c/css/properties/css3/CssBoxShadow.java index 22e911dba..00c12d7cf 100644 --- a/org/w3c/css/properties/css3/CssBoxShadow.java +++ b/org/w3c/css/properties/css3/CssBoxShadow.java @@ -10,7 +10,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; @@ -24,7 +23,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2014/WD-css3-background-20140204/#box-shadow + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-box-shadow */ public class CssBoxShadow extends org.w3c.css.properties.css.CssBoxShadow { @@ -61,13 +60,9 @@ public CssBoxShadow(ApplContext ac, CssExpression expression, if (expression.getCount() == 1) { // it can be only 'none' or 'inherit' if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - expression.next(); - return; - } else if (none.equals(ident)) { - value = none; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || none.equals(val)) { + value = val; expression.next(); return; } @@ -148,8 +143,7 @@ public CssBoxShadowValue check(ApplContext ac, CssExpression expression, value.vertical_offset = val; break; case 3: - CssCheckableValue length = val.getCheckableValue(); - length.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); value.blur_radius = val; break; case 4: @@ -165,14 +159,14 @@ public CssBoxShadowValue check(ApplContext ac, CssExpression expression, if (got_length != 0) { length_ok = false; } - CssIdent ident = (CssIdent) val; + CssIdent id = val.getIdent(); // checked before, not allowed here - if (inherit.equals(ident)) { + if (CssIdent.isCssWide(id)) { throw new InvalidParamException("value", val, getPropertyName(), ac); } - if (inset.equals(ident) && value.shadow_mod == null) { - value.shadow_mod = inset; + if (inset.equals(id) && value.shadow_mod == null) { + value.shadow_mod = val; // inset has been relaxed break; } @@ -193,7 +187,7 @@ public CssBoxShadowValue check(ApplContext ac, CssExpression expression, CssExpression exp = new CssExpression(); exp.addValue(val); CssColor color = new CssColor(ac, exp, check); - value.color = (CssValue) color.get(); + value.color = (color.color == null) ? color.value : color.color; break; default: throw new InvalidParamException("value", val, diff --git a/org/w3c/css/properties/css3/CssBoxSizing.java b/org/w3c/css/properties/css3/CssBoxSizing.java index 86b7ea98a..b2fe6c9d0 100644 --- a/org/w3c/css/properties/css3/CssBoxSizing.java +++ b/org/w3c/css/properties/css3/CssBoxSizing.java @@ -48,8 +48,7 @@ public CssBoxSizing() { * Creates a new CssBoxSizing * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBoxSizing(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,17 +65,13 @@ public CssBoxSizing(ApplContext ac, CssExpression expression, boolean check) 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; + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getMatchingIdent(id) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssBoxSuppress.java b/org/w3c/css/properties/css3/CssBoxSuppress.java index 0b6e8b4ac..858b1868e 100644 --- a/org/w3c/css/properties/css3/CssBoxSuppress.java +++ b/org/w3c/css/properties/css3/CssBoxSuppress.java @@ -48,8 +48,7 @@ public CssBoxSuppress() { * Creates a new CssBoxSuppress * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBoxSuppress(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,17 +65,13 @@ public CssBoxSuppress(ApplContext ac, CssExpression expression, boolean check) 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; + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && (getMatchingIdent(id) == null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssDominantBaseline.java b/org/w3c/css/properties/css3/CssDominantBaseline.java index e4c3773a0..28788a798 100644 --- a/org/w3c/css/properties/css3/CssDominantBaseline.java +++ b/org/w3c/css/properties/css3/CssDominantBaseline.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2016/WD-css-inline-3-20160524/#dominant-baseline-property + * @spec https://www.w3.org/TR/2020/WD-css-inline-3-20200827/#propdef-dominant-baseline */ public class CssDominantBaseline extends org.w3c.css.properties.css.CssDominantBaseline { @@ -48,8 +48,7 @@ public CssDominantBaseline() { * Creates a new CssDominantBaseline * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssDominantBaseline(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -63,17 +62,13 @@ public CssDominantBaseline(ApplContext ac, CssExpression expression, boolean che val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && (getAllowedIdent(id) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } + value = val; } else { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssEmptyCells.java b/org/w3c/css/properties/css3/CssEmptyCells.java index 27fc7499d..ae0a301c0 100644 --- a/org/w3c/css/properties/css3/CssEmptyCells.java +++ b/org/w3c/css/properties/css3/CssEmptyCells.java @@ -49,8 +49,7 @@ public CssEmptyCells() { * Creates a new CssEmptyCells * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssEmptyCells(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,16 +65,16 @@ public CssEmptyCells(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFlex.java b/org/w3c/css/properties/css3/CssFlex.java index 24fe15ee7..b6f54d16a 100644 --- a/org/w3c/css/properties/css3/CssFlex.java +++ b/org/w3c/css/properties/css3/CssFlex.java @@ -8,7 +8,6 @@ import org.w3c.css.parser.CssStyle; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssNumber; @@ -60,6 +59,7 @@ public CssFlex(ApplContext ac, CssExpression expression, boolean check) CssValue val; char op; boolean gotNumber = false; + boolean gotCssWide = false; while (!expression.end()) { val = expression.getValue(); @@ -67,9 +67,10 @@ public CssFlex(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + gotCssWide = true; + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), @@ -78,7 +79,7 @@ public CssFlex(ApplContext ac, CssExpression expression, boolean check) break; } if (none.equals(ident)) { - value = none; + value = val; if (expression.getCount() > 1) { throw new InvalidParamException("value", val.toString(), @@ -102,16 +103,14 @@ public CssFlex(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); case CssTypes.CSS_NUMBER: if (growVal == null) { - CssCheckableValue num = val.getCheckableValue(); - num.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, this); growVal = val; gotNumber = true; break; } // we can get shrink only after grow if (gotNumber && shrinkVal == null) { - CssCheckableValue num = val.getCheckableValue(); - num.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, this); shrinkVal = val; break; } @@ -146,10 +145,10 @@ public CssFlex(ApplContext ac, CssExpression expression, boolean check) flexBasis = new CssFlexBasis(); flexGrow = new CssFlexGrow(); flexShrink = new CssFlexShrink(); - if (value == inherit) { - flexBasis.value = inherit; - flexGrow.value = inherit; - flexShrink.value = inherit; + if (gotCssWide) { + flexBasis.value = value; + flexGrow.value = value; + flexShrink.value = value; } else if (value == none) { flexBasis.value = CssWidth.auto; CssNumber z = new CssNumber(); diff --git a/org/w3c/css/properties/css3/CssFloatDefer.java b/org/w3c/css/properties/css3/CssFloatDefer.java index 56ea9581b..7012fd7c7 100644 --- a/org/w3c/css/properties/css3/CssFloatDefer.java +++ b/org/w3c/css/properties/css3/CssFloatDefer.java @@ -50,8 +50,7 @@ public CssFloatDefer() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloatDefer(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -63,8 +62,7 @@ public CssFloatDefer(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloatDefer(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -79,19 +77,14 @@ public CssFloatDefer(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_NUMBER: - val.getCheckableValue().checkInteger(ac, this); + val.getCheckableValue().checkInteger(ac, getPropertyName()); value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || getAllowedIdent(id) != null) { + value = val; break; - } else { - value = getAllowedIdent(id); - if (value != null) { - break; - } } default: throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFloatOffset.java b/org/w3c/css/properties/css3/CssFloatOffset.java index c2c4a62e7..ec00bb0d0 100644 --- a/org/w3c/css/properties/css3/CssFloatOffset.java +++ b/org/w3c/css/properties/css3/CssFloatOffset.java @@ -66,9 +66,8 @@ public CssFloatOffset(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent())) { + value = val; break; } default: diff --git a/org/w3c/css/properties/css3/CssFloatReference.java b/org/w3c/css/properties/css3/CssFloatReference.java index 6ccfc5e43..136566da8 100644 --- a/org/w3c/css/properties/css3/CssFloatReference.java +++ b/org/w3c/css/properties/css3/CssFloatReference.java @@ -50,8 +50,7 @@ public CssFloatReference() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloatReference(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -63,8 +62,7 @@ public CssFloatReference(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssFloatReference(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -78,16 +76,16 @@ public CssFloatReference(ApplContext ac, CssExpression expression, val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; } else { - value = getAllowedIdent(id); - if (value == null) { + if (getAllowedIdent(id) == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssIsolation.java b/org/w3c/css/properties/css3/CssIsolation.java index e79bf13a6..cbc49404b 100644 --- a/org/w3c/css/properties/css3/CssIsolation.java +++ b/org/w3c/css/properties/css3/CssIsolation.java @@ -48,8 +48,7 @@ public CssIsolation() { * Creates a new CssIsolation * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssIsolation(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,7 +65,7 @@ public CssIsolation(ApplContext ac, CssExpression expression, boolean check) if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = val.getIdent(); - if (inherit.equals(ident)) { + if (CssIdent.isCssWide(ident)) { value = val; } else { if (getAllowedIdent(ident) == null) { From 7931fe1d4893a9694c3c3088d08c06ba03d37146 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 14:01:58 +0200 Subject: [PATCH 78/82] color accessor --- org/w3c/css/properties/css3/CssBackgroundColor.java | 2 +- org/w3c/css/properties/css3/CssBoxShadow.java | 2 +- org/w3c/css/properties/css3/CssCaret.java | 2 +- org/w3c/css/properties/css3/CssCaretColor.java | 2 +- org/w3c/css/properties/css3/CssColor.java | 11 +++++++++++ org/w3c/css/properties/css3/CssColumnRuleColor.java | 2 +- org/w3c/css/properties/css3/CssFloodColor.java | 2 +- org/w3c/css/properties/css3/CssLightingColor.java | 5 ++--- .../css/properties/css3/CssTextDecorationColor.java | 2 +- org/w3c/css/properties/css3/CssTextEmphasisColor.java | 2 +- 10 files changed, 21 insertions(+), 11 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBackgroundColor.java b/org/w3c/css/properties/css3/CssBackgroundColor.java index 17af804ac..2c0bf6c0b 100644 --- a/org/w3c/css/properties/css3/CssBackgroundColor.java +++ b/org/w3c/css/properties/css3/CssBackgroundColor.java @@ -52,7 +52,7 @@ public CssBackgroundColor(ApplContext ac, CssExpression expression, CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = (tcolor.color != null) ? tcolor.color : tcolor.value; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssBoxShadow.java b/org/w3c/css/properties/css3/CssBoxShadow.java index 00c12d7cf..f05a98659 100644 --- a/org/w3c/css/properties/css3/CssBoxShadow.java +++ b/org/w3c/css/properties/css3/CssBoxShadow.java @@ -187,7 +187,7 @@ public CssBoxShadowValue check(ApplContext ac, CssExpression expression, CssExpression exp = new CssExpression(); exp.addValue(val); CssColor color = new CssColor(ac, exp, check); - value.color = (color.color == null) ? color.value : color.color; + value.color = color.getValue(); break; default: throw new InvalidParamException("value", val, diff --git a/org/w3c/css/properties/css3/CssCaret.java b/org/w3c/css/properties/css3/CssCaret.java index 619d353ad..ea04b3fc8 100644 --- a/org/w3c/css/properties/css3/CssCaret.java +++ b/org/w3c/css/properties/css3/CssCaret.java @@ -98,7 +98,7 @@ public CssCaret(ApplContext ac, CssExpression expression, boolean check) val, getPropertyName(), ac); } gotColor = true; - values.add((tcolor.color == null) ? tcolor.value : tcolor.color); + values.add(tcolor.getValue()); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssCaretColor.java b/org/w3c/css/properties/css3/CssCaretColor.java index 1a9678b84..9ea7c833d 100644 --- a/org/w3c/css/properties/css3/CssCaretColor.java +++ b/org/w3c/css/properties/css3/CssCaretColor.java @@ -67,7 +67,7 @@ public CssCaretColor(ApplContext ac, CssExpression expression, boolean check) CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = (tcolor.color == null) ? tcolor.value : tcolor.color; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssColor.java b/org/w3c/css/properties/css3/CssColor.java index 88e9a3a4f..849976ce0 100644 --- a/org/w3c/css/properties/css3/CssColor.java +++ b/org/w3c/css/properties/css3/CssColor.java @@ -117,6 +117,17 @@ public Object get() { return color; } + /** + * + * @return the computed CssValue + */ + public CssValue getValue() { + if (color != null) { + return color; + } + return value; + } + /** * Returns the color */ diff --git a/org/w3c/css/properties/css3/CssColumnRuleColor.java b/org/w3c/css/properties/css3/CssColumnRuleColor.java index b491b86d8..bc13bcacd 100644 --- a/org/w3c/css/properties/css3/CssColumnRuleColor.java +++ b/org/w3c/css/properties/css3/CssColumnRuleColor.java @@ -55,7 +55,7 @@ public CssColumnRuleColor(ApplContext ac, CssExpression expression, // we use the latest version of CssColor, aka CSS3 // instead of using CSS21 colors + transparent per spec CssColor tcolor = new CssColor(ac, expression, check); - value = (tcolor.value == null) ? tcolor.color : tcolor.value; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssFloodColor.java b/org/w3c/css/properties/css3/CssFloodColor.java index dd94842b7..a0c212c30 100644 --- a/org/w3c/css/properties/css3/CssFloodColor.java +++ b/org/w3c/css/properties/css3/CssFloodColor.java @@ -47,7 +47,7 @@ public CssFloodColor(ApplContext ac, CssExpression expression, boolean check) CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = (tcolor.color != null) ? tcolor.color : tcolor.value; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssLightingColor.java b/org/w3c/css/properties/css3/CssLightingColor.java index 80ed57b74..870248e39 100644 --- a/org/w3c/css/properties/css3/CssLightingColor.java +++ b/org/w3c/css/properties/css3/CssLightingColor.java @@ -28,8 +28,7 @@ public CssLightingColor() { * Creates a new CssLightingColor * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssLightingColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -48,7 +47,7 @@ public CssLightingColor(ApplContext ac, CssExpression expression, boolean check) CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - value = (tcolor.color != null) ? tcolor.color : tcolor.value; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssTextDecorationColor.java b/org/w3c/css/properties/css3/CssTextDecorationColor.java index 20f43c945..89064c2dc 100644 --- a/org/w3c/css/properties/css3/CssTextDecorationColor.java +++ b/org/w3c/css/properties/css3/CssTextDecorationColor.java @@ -45,7 +45,7 @@ public CssTextDecorationColor(ApplContext ac, CssExpression expression, boolean } else { try { CssColor tcolor = new CssColor(ac, expression, check); - value = (tcolor.value != null) ? tcolor.value : tcolor.color; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), diff --git a/org/w3c/css/properties/css3/CssTextEmphasisColor.java b/org/w3c/css/properties/css3/CssTextEmphasisColor.java index 5a7546135..941d5ad3c 100644 --- a/org/w3c/css/properties/css3/CssTextEmphasisColor.java +++ b/org/w3c/css/properties/css3/CssTextEmphasisColor.java @@ -45,7 +45,7 @@ public CssTextEmphasisColor(ApplContext ac, CssExpression expression, boolean ch } else { try { CssColor tcolor = new CssColor(ac, expression, check); - value = (tcolor.color != null) ? tcolor.color : tcolor.value; + value = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", expression.getValue(), From d6feb0aa0218e501dfbe6c7f206bac92d62dda39 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Fri, 10 Sep 2021 18:56:56 +0200 Subject: [PATCH 79/82] cast+refs (cont.) --- org/w3c/css/properties/css3/CssBorder.java | 29 ++++---- .../css/properties/css3/CssBorderBottom.java | 2 +- .../properties/css3/CssBorderBottomColor.java | 2 +- .../css3/CssBorderBottomLeftRadius.java | 2 +- .../css3/CssBorderBottomRightRadius.java | 2 +- .../properties/css3/CssBorderBottomStyle.java | 2 +- .../properties/css3/CssBorderBottomWidth.java | 2 +- .../css/properties/css3/CssBorderColor.java | 35 ++++++---- .../css/properties/css3/CssBorderImage.java | 23 +++---- .../properties/css3/CssBorderImageOutset.java | 11 ++-- .../properties/css3/CssBorderImageRepeat.java | 31 +++++---- .../properties/css3/CssBorderImageSlice.java | 9 +-- .../properties/css3/CssBorderImageSource.java | 13 ++-- .../properties/css3/CssBorderImageWidth.java | 19 +++--- .../css/properties/css3/CssBorderLeft.java | 2 +- .../properties/css3/CssBorderLeftColor.java | 2 +- .../properties/css3/CssBorderLeftStyle.java | 2 +- .../properties/css3/CssBorderLeftWidth.java | 2 +- .../css/properties/css3/CssBorderRadius.java | 40 ++++++----- .../css/properties/css3/CssBorderRight.java | 2 +- .../properties/css3/CssBorderRightColor.java | 2 +- .../properties/css3/CssBorderRightStyle.java | 2 +- .../properties/css3/CssBorderRightWidth.java | 2 +- .../css/properties/css3/CssBorderSpacing.java | 5 +- .../css/properties/css3/CssBorderStyle.java | 48 +++++++------- org/w3c/css/properties/css3/CssBorderTop.java | 20 +++--- .../properties/css3/CssBorderTopColor.java | 2 +- .../css3/CssBorderTopLeftRadius.java | 2 +- .../css3/CssBorderTopRightRadius.java | 2 +- .../properties/css3/CssBorderTopStyle.java | 2 +- .../properties/css3/CssBorderTopWidth.java | 2 +- .../css/properties/css3/CssBorderWidth.java | 66 +++++++++---------- org/w3c/css/properties/css3/CssOutline.java | 2 +- .../css/properties/css3/CssOutlineStyle.java | 2 +- 34 files changed, 195 insertions(+), 196 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBorder.java b/org/w3c/css/properties/css3/CssBorder.java index 570f63e23..1186f2810 100644 --- a/org/w3c/css/properties/css3/CssBorder.java +++ b/org/w3c/css/properties/css3/CssBorder.java @@ -8,7 +8,6 @@ import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; @@ -18,7 +17,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border */ public class CssBorder extends org.w3c.css.properties.css.CssBorder { @@ -118,13 +117,11 @@ protected static SideValues parseBorderSide(ApplContext ac, CssExpression expres switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssCheckableValue number = val.getCheckableValue(); - number.checkEqualsZero(ac, caller); + val.getCheckableValue().checkEqualsZero(ac, caller); _width = val; break; case CssTypes.CSS_LENGTH: - CssCheckableValue length = val.getCheckableValue(); - length.checkPositiveness(ac, caller); + val.getCheckableValue().checkPositiveness(ac, caller); _width = val; break; case CssTypes.CSS_HASH_IDENT: @@ -141,28 +138,28 @@ protected static SideValues parseBorderSide(ApplContext ac, CssExpression expres _color = transparent; break; } - if (inherit.equals(id)) { + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - _width = inherit; - _style = inherit; - _color = inherit; + _width = val; + _style = val; + _color = val; break; } - CssIdent match = CssBorderWidth.getMatchingIdent(id); + CssIdent match = CssBorderWidth.getAllowedIdent(id); if (match != null) { - _width = match; + _width = val; } else { - match = CssBorderStyle.getMatchingIdent(id); + match = CssBorderStyle.getAllowedIdent(id); if (match != null) { - _style = match; + _style = val; } else { // if not a width or a style, fail if it's not a proper color nex = new CssExpression(); nex.addValue(val); CssColor cssColor = new CssColor(ac, nex, false); - _color = cssColor.color; + _color = cssColor.getValue(); } } break; @@ -170,7 +167,7 @@ protected static SideValues parseBorderSide(ApplContext ac, CssExpression expres nex = new CssExpression(); nex.addValue(val); CssColor cssColor = new CssColor(ac, nex, false); - _color = cssColor.color; + _color = cssColor.getValue(); break; default: throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssBorderBottom.java b/org/w3c/css/properties/css3/CssBorderBottom.java index 2ebc9de93..11b558014 100644 --- a/org/w3c/css/properties/css3/CssBorderBottom.java +++ b/org/w3c/css/properties/css3/CssBorderBottom.java @@ -11,7 +11,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-right * @see CssBorder */ public class CssBorderBottom extends org.w3c.css.properties.css.CssBorderBottom { diff --git a/org/w3c/css/properties/css3/CssBorderBottomColor.java b/org/w3c/css/properties/css3/CssBorderBottomColor.java index 27c29c214..861f814e1 100644 --- a/org/w3c/css/properties/css3/CssBorderBottomColor.java +++ b/org/w3c/css/properties/css3/CssBorderBottomColor.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-bottom-color * @see CssBorderColor */ public class CssBorderBottomColor extends org.w3c.css.properties.css.CssBorderBottomColor { diff --git a/org/w3c/css/properties/css3/CssBorderBottomLeftRadius.java b/org/w3c/css/properties/css3/CssBorderBottomLeftRadius.java index e0019aa6e..fa30dd2de 100644 --- a/org/w3c/css/properties/css3/CssBorderBottomLeftRadius.java +++ b/org/w3c/css/properties/css3/CssBorderBottomLeftRadius.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValueList; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom-left-radius + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-bottom-left-radius * @see CssBorderRadius */ public class CssBorderBottomLeftRadius extends org.w3c.css.properties.css.CssBorderBottomLeftRadius { diff --git a/org/w3c/css/properties/css3/CssBorderBottomRightRadius.java b/org/w3c/css/properties/css3/CssBorderBottomRightRadius.java index 88f10c26d..0f339fcc7 100644 --- a/org/w3c/css/properties/css3/CssBorderBottomRightRadius.java +++ b/org/w3c/css/properties/css3/CssBorderBottomRightRadius.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValueList; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom-right-radius + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-bottom-right-radius * @see CssBorderRadius */ public class CssBorderBottomRightRadius extends org.w3c.css.properties.css.CssBorderBottomRightRadius { diff --git a/org/w3c/css/properties/css3/CssBorderBottomStyle.java b/org/w3c/css/properties/css3/CssBorderBottomStyle.java index 26174c34c..bec51fc6e 100644 --- a/org/w3c/css/properties/css3/CssBorderBottomStyle.java +++ b/org/w3c/css/properties/css3/CssBorderBottomStyle.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom-style + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-bottom-style * @see CssBorderStyle */ public class CssBorderBottomStyle extends org.w3c.css.properties.css.CssBorderBottomStyle { diff --git a/org/w3c/css/properties/css3/CssBorderBottomWidth.java b/org/w3c/css/properties/css3/CssBorderBottomWidth.java index 6130dcc75..24e65e3ce 100644 --- a/org/w3c/css/properties/css3/CssBorderBottomWidth.java +++ b/org/w3c/css/properties/css3/CssBorderBottomWidth.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-bottom-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-width * @see CssBorderWidth */ public class CssBorderBottomWidth extends org.w3c.css.properties.css.CssBorderBottomWidth { diff --git a/org/w3c/css/properties/css3/CssBorderColor.java b/org/w3c/css/properties/css3/CssBorderColor.java index e250fcd71..95517a170 100644 --- a/org/w3c/css/properties/css3/CssBorderColor.java +++ b/org/w3c/css/properties/css3/CssBorderColor.java @@ -9,6 +9,8 @@ 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; import org.w3c.css.values.CssValueList; @@ -17,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-color */ public class CssBorderColor extends org.w3c.css.properties.css.CssBorderColor { @@ -37,8 +39,7 @@ public CssBorderColor() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderColor(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -50,8 +51,7 @@ public CssBorderColor(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderColor(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -61,14 +61,17 @@ public CssBorderColor(ApplContext ac, CssExpression expression, setByUser(); CssValue val; char op; + boolean isCssWide = false; ArrayList res = new ArrayList(); while (res.size() < 4 && !expression.end()) { val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { - res.add(inherit); + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + res.add(val); + isCssWide = true; + value = val; } else { try { CssExpression ex = new CssExpression(); @@ -77,7 +80,7 @@ public CssBorderColor(ApplContext ac, CssExpression expression, CssColor tcolor = new CssColor(ac, ex, check); // instead of using getColor, we get the value directly // as we can have idents - res.add(tcolor.color); + res.add(tcolor.getValue()); } catch (InvalidParamException e) { throw new InvalidParamException("value", val.toString(), @@ -92,8 +95,10 @@ public CssBorderColor(ApplContext ac, CssExpression expression, } } // check that inherit is alone - if (res.size() > 1 && res.contains(inherit)) { - throw new InvalidParamException("unrecognize", ac); + if (res.size() > 1 && isCssWide) { + throw new InvalidParamException("value", + value.toString(), + getPropertyName(), ac); } value = (res.size() == 1) ? res.get(0) : new CssValueList(res); @@ -133,7 +138,9 @@ public CssBorderColor(ApplContext ac, CssExpression expression, * Check the border-*-color and returns a value. * It makes sense to do it only once for all the sides, so by having the code here. */ - protected static CssValue parseBorderSideColor(ApplContext ac, CssExpression expression, boolean check, CssProperty caller) throws InvalidParamException { + protected static CssValue parseBorderSideColor(ApplContext ac, CssExpression expression, + boolean check, CssProperty caller) + throws InvalidParamException { if (check && expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); @@ -142,15 +149,15 @@ protected static CssValue parseBorderSideColor(ApplContext ac, CssExpression exp CssValue retval = null; CssValue val = expression.getValue(); - if (inherit.equals(val)) { - retval = inherit; + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + retval = val; } else { try { // we use the latest version of CssColor, aka CSS3 CssColor tcolor = new CssColor(ac, expression, check); // instead of using getColor, we get the value directly // as we can have idents - retval = tcolor.color; + retval = tcolor.getValue(); } catch (InvalidParamException e) { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssBorderImage.java b/org/w3c/css/properties/css3/CssBorderImage.java index 6636b73d5..5363d94b9 100644 --- a/org/w3c/css/properties/css3/CssBorderImage.java +++ b/org/w3c/css/properties/css3/CssBorderImage.java @@ -81,11 +81,12 @@ public CssBorderImage(ApplContext ac, CssExpression expression, expression.next(); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - value = inherit; + value = val; // TODO force individual values as inherit expression.next(); break; @@ -94,7 +95,7 @@ public CssBorderImage(ApplContext ac, CssExpression expression, case 0: // state 0, we can only have slice or repeat or image // slice - tval = CssBorderImageSlice.getMatchingIdent((CssIdent) val); + tval = CssBorderImageSlice.getMatchingIdent(id); if (tval != null) { if (slice != null) { throw new InvalidParamException("value", val.toString(), @@ -119,7 +120,7 @@ public CssBorderImage(ApplContext ac, CssExpression expression, break; } // TODO check for border-image! (none) - if (CssBorderImageSource.isMatchingIdent((CssIdent) val)) { + if (CssBorderImageSource.isMatchingIdent(id)) { if (source != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); @@ -132,7 +133,7 @@ public CssBorderImage(ApplContext ac, CssExpression expression, case 1: // it can be only width or repeat. // width - tval = CssBorderImageWidth.getMatchingIdent((CssIdent) val); + tval = CssBorderImageWidth.getMatchingIdent(id); if (tval != null) { if (width != null) { throw new InvalidParamException("value", val.toString(), @@ -164,7 +165,7 @@ public CssBorderImage(ApplContext ac, CssExpression expression, break; } // TODO check for border-image! (none) - if (CssBorderImageSource.isMatchingIdent((CssIdent) val)) { + if (CssBorderImageSource.isMatchingIdent(id)) { if (source != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); @@ -318,7 +319,7 @@ private CssExpression getRepeatExpression(ApplContext ac, CssExpression expressi val = expression.getValue(); op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - tval = CssBorderImageRepeat.getMatchingIdent((CssIdent) val); + tval = CssBorderImageRepeat.getMatchingIdent(val.getIdent()); if (tval == null) { return null; } @@ -334,9 +335,9 @@ private CssExpression getRepeatExpression(ApplContext ac, CssExpression expressi val = expression.getValue(); op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - tval = CssBorderImageRepeat.getMatchingIdent((CssIdent) val); + tval = CssBorderImageRepeat.getMatchingIdent(val.getIdent()); if (tval != null) { - exp.addValue(tval); + exp.addValue(val); expression.next(); if (op != SPACE) { return exp; @@ -363,7 +364,7 @@ private CssExpression getSliceExpression(ApplContext ac, CssExpression expressio exp.addValue(val); break; case CssTypes.CSS_IDENT: - tval = CssBorderImageSlice.getMatchingIdent((CssIdent) val); + tval = CssBorderImageSlice.getMatchingIdent(val.getIdent()); if (tval == null) { return exp; } @@ -397,7 +398,7 @@ private CssExpression getWidthExpression(ApplContext ac, CssExpression expressio exp.addValue(val); break; case CssTypes.CSS_IDENT: - tval = CssBorderImageWidth.getMatchingIdent((CssIdent) val); + tval = CssBorderImageWidth.getMatchingIdent(val.getIdent()); if (tval == null) { return exp; } diff --git a/org/w3c/css/properties/css3/CssBorderImageOutset.java b/org/w3c/css/properties/css3/CssBorderImageOutset.java index 6ad380676..ecd30610c 100644 --- a/org/w3c/css/properties/css3/CssBorderImageOutset.java +++ b/org/w3c/css/properties/css3/CssBorderImageOutset.java @@ -7,8 +7,8 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -16,7 +16,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image-outset + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-image-outset */ public class CssBorderImageOutset extends org.w3c.css.properties.css.CssBorderImageOutset { @@ -51,16 +51,15 @@ public CssBorderImageOutset(ApplContext ac, CssExpression expression, boolean ch switch (val.getType()) { case CssTypes.CSS_NUMBER: case CssTypes.CSS_LENGTH: - CssCheckableValue num = val.getCheckableValue(); - num.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); valueList.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - valueList.add(inherit); + valueList.add(val); break; } // unrecognized ident, let it fail diff --git a/org/w3c/css/properties/css3/CssBorderImageRepeat.java b/org/w3c/css/properties/css3/CssBorderImageRepeat.java index e019cc750..82066d15f 100644 --- a/org/w3c/css/properties/css3/CssBorderImageRepeat.java +++ b/org/w3c/css/properties/css3/CssBorderImageRepeat.java @@ -16,22 +16,22 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image-repeat + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-image-repeat */ public class CssBorderImageRepeat extends org.w3c.css.properties.css.CssBorderImageRepeat { - public static final CssIdent allowed_values[]; + private static CssIdent[] allowed_values; - // stretch | repeat | round | space static { - allowed_values = new CssIdent[4]; - allowed_values[0] = CssIdent.getIdent("stretch"); - allowed_values[1] = CssIdent.getIdent("repeat"); - allowed_values[2] = CssIdent.getIdent("round"); - allowed_values[3] = CssIdent.getIdent("space"); + String id_values[] = {"stretch", "repeat", "round", "space"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } } - public final static CssIdent getMatchingIdent(CssIdent ident) { + public static CssIdent getMatchingIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; @@ -51,8 +51,7 @@ public CssBorderImageRepeat() { * Creates a new CssBorderImageWidth * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBorderImageRepeat(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -70,16 +69,16 @@ public CssBorderImageRepeat(ApplContext ac, CssExpression expression, boolean ch switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - valueList.add(inherit); + valueList.add(val); break; } - CssIdent id = getMatchingIdent((CssIdent) val); - if (id != null) { - valueList.add(id); + if (getMatchingIdent(id) != null) { + valueList.add(val); break; } // unrecognized ident, let it fail diff --git a/org/w3c/css/properties/css3/CssBorderImageSlice.java b/org/w3c/css/properties/css3/CssBorderImageSlice.java index 6e0305157..31cffc2b2 100644 --- a/org/w3c/css/properties/css3/CssBorderImageSlice.java +++ b/org/w3c/css/properties/css3/CssBorderImageSlice.java @@ -18,7 +18,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image-slice + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-image-slice */ public class CssBorderImageSlice extends org.w3c.css.properties.css.CssBorderImageSlice { @@ -77,14 +77,15 @@ public CssBorderImageSlice(ApplContext ac, CssExpression expression, boolean che valueList.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - valueList.add(inherit); + valueList.add(val); break; } - if (fill.equals(val)) { + if (fill.equals(id)) { // fill is first or last and can't appear twice if (gotFill || (valueList.size() != 0 && expression.getRemainingCount() > 1)) { throw new InvalidParamException("value", val.toString(), diff --git a/org/w3c/css/properties/css3/CssBorderImageSource.java b/org/w3c/css/properties/css3/CssBorderImageSource.java index 5275a4a97..56874eaf2 100644 --- a/org/w3c/css/properties/css3/CssBorderImageSource.java +++ b/org/w3c/css/properties/css3/CssBorderImageSource.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image-source + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-image-source */ public class CssBorderImageSource extends org.w3c.css.properties.css.CssBorderImageSource { @@ -33,8 +33,7 @@ public CssBorderImageSource() { * Creates a new CssBorderImageSource * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBorderImageSource(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -50,11 +49,9 @@ public CssBorderImageSource(ApplContext ac, CssExpression expression, boolean ch value = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - break; - } else if (none.equals(val)) { - value = none; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || isMatchingIdent(id)) { + value = val; break; } // unrecognized ident... let it fail diff --git a/org/w3c/css/properties/css3/CssBorderImageWidth.java b/org/w3c/css/properties/css3/CssBorderImageWidth.java index 51f601b5e..6eb5b0624 100644 --- a/org/w3c/css/properties/css3/CssBorderImageWidth.java +++ b/org/w3c/css/properties/css3/CssBorderImageWidth.java @@ -7,7 +7,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; @@ -17,7 +16,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-image-width */ public class CssBorderImageWidth extends org.w3c.css.properties.css.CssBorderImageWidth { @@ -42,8 +41,7 @@ public CssBorderImageWidth() { * Creates a new CssBorderImageWidth * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssBorderImageWidth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -63,21 +61,20 @@ public CssBorderImageWidth(ApplContext ac, CssExpression expression, boolean che case CssTypes.CSS_NUMBER: case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: - CssCheckableValue num = val.getCheckableValue(); - num.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); valueList.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() > 1) { throw new InvalidParamException("unrecognize", ac); } - valueList.add(inherit); + valueList.add(val); break; } - if (auto.equals(val)) { - // fill is first or last and can't appear twice - valueList.add(auto); + if (getMatchingIdent(id) != null) { + valueList.add(val); break; } // unrecognized ident, let it fail diff --git a/org/w3c/css/properties/css3/CssBorderLeft.java b/org/w3c/css/properties/css3/CssBorderLeft.java index e28da7896..d2c1e99c9 100644 --- a/org/w3c/css/properties/css3/CssBorderLeft.java +++ b/org/w3c/css/properties/css3/CssBorderLeft.java @@ -11,7 +11,7 @@ import org.w3c.css.values.CssValueList; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-left + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-left * @see CssBorder */ public class CssBorderLeft extends org.w3c.css.properties.css.CssBorderLeft { diff --git a/org/w3c/css/properties/css3/CssBorderLeftColor.java b/org/w3c/css/properties/css3/CssBorderLeftColor.java index 946577f58..d3060bb1b 100644 --- a/org/w3c/css/properties/css3/CssBorderLeftColor.java +++ b/org/w3c/css/properties/css3/CssBorderLeftColor.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-left-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-left-color * @see CssBorderColor */ public class CssBorderLeftColor extends org.w3c.css.properties.css.CssBorderLeftColor { diff --git a/org/w3c/css/properties/css3/CssBorderLeftStyle.java b/org/w3c/css/properties/css3/CssBorderLeftStyle.java index 91bc92b16..54f992b12 100644 --- a/org/w3c/css/properties/css3/CssBorderLeftStyle.java +++ b/org/w3c/css/properties/css3/CssBorderLeftStyle.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-left-style + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-left-style * @see CssBorderStyle */ public class CssBorderLeftStyle extends org.w3c.css.properties.css.CssBorderLeftStyle { diff --git a/org/w3c/css/properties/css3/CssBorderLeftWidth.java b/org/w3c/css/properties/css3/CssBorderLeftWidth.java index 967c195f3..f493b3eb3 100644 --- a/org/w3c/css/properties/css3/CssBorderLeftWidth.java +++ b/org/w3c/css/properties/css3/CssBorderLeftWidth.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-left-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-width * @see CssBorderWidth */ public class CssBorderLeftWidth extends org.w3c.css.properties.css.CssBorderLeftWidth { diff --git a/org/w3c/css/properties/css3/CssBorderRadius.java b/org/w3c/css/properties/css3/CssBorderRadius.java index 626745f9e..d74695dd2 100644 --- a/org/w3c/css/properties/css3/CssBorderRadius.java +++ b/org/w3c/css/properties/css3/CssBorderRadius.java @@ -8,8 +8,8 @@ import org.w3c.css.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssSwitch; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -20,7 +20,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-radius + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-radius */ public class CssBorderRadius extends org.w3c.css.properties.css.CssBorderRadius { @@ -61,13 +61,12 @@ public CssBorderRadius(ApplContext ac, CssExpression expression, op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_NUMBER: - val.getCheckableValue().checkEqualsZero(ac, this); + val.getCheckableValue().checkEqualsZero(ac, getPropertyName()); cur_radius.add(val); break; case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: - CssCheckableValue length = val.getCheckableValue(); - length.checkPositiveness(ac, this); + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); cur_radius.add(val); break; case CssTypes.CSS_SWITCH: @@ -79,15 +78,17 @@ public CssBorderRadius(ApplContext ac, CssExpression expression, cur_radius = v_radius; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + if (CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", val, + getPropertyName(), ac); } - cur_radius.add(inherit); + cur_radius.add(val); break; } default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", val, + getPropertyName(), ac); } expression.next(); if (op != SPACE) { @@ -183,7 +184,7 @@ public static CssValue parseBorderCornerRadius(ApplContext ac, CssExpression exp if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } - CssValue val; + CssValue val, cssWideVal = null; CssValueList res = new CssValueList(); char op; @@ -198,20 +199,16 @@ public static CssValue parseBorderCornerRadius(ApplContext ac, CssExpression exp break; case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: - CssCheckableValue length = val.getCheckableValue(); - length.checkPositiveness(ac, caller); + val.getCheckableValue().checkPositiveness(ac, caller); res.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - if (res.size() > 0) { - throw new InvalidParamException("unrecognize", ac); - } - res.add(inherit); + if (CssIdent.isCssWide(val.getIdent())) { + cssWideVal = val; break; } default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", val, caller, ac); } if (op != SPACE) { throw new InvalidParamException("operator", @@ -220,6 +217,13 @@ public static CssValue parseBorderCornerRadius(ApplContext ac, CssExpression exp } expression.next(); } + // sanity check + if ((cssWideVal != null) && (res.size() != 0)) { + throw new InvalidParamException("value", cssWideVal, caller, ac); + } + if (cssWideVal != null) { + return cssWideVal; + } return (res.size() == 1) ? res.get(0) : res; } } diff --git a/org/w3c/css/properties/css3/CssBorderRight.java b/org/w3c/css/properties/css3/CssBorderRight.java index 65c18d22f..bce15428e 100644 --- a/org/w3c/css/properties/css3/CssBorderRight.java +++ b/org/w3c/css/properties/css3/CssBorderRight.java @@ -11,7 +11,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-right + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-right * @see CssBorder */ public class CssBorderRight extends org.w3c.css.properties.css.CssBorderRight { diff --git a/org/w3c/css/properties/css3/CssBorderRightColor.java b/org/w3c/css/properties/css3/CssBorderRightColor.java index 094e7280e..4c6cb666b 100644 --- a/org/w3c/css/properties/css3/CssBorderRightColor.java +++ b/org/w3c/css/properties/css3/CssBorderRightColor.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-right-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-right-color * @see CssBorderColor */ public class CssBorderRightColor extends org.w3c.css.properties.css.CssBorderRightColor { diff --git a/org/w3c/css/properties/css3/CssBorderRightStyle.java b/org/w3c/css/properties/css3/CssBorderRightStyle.java index 328d2e86b..b338f6026 100644 --- a/org/w3c/css/properties/css3/CssBorderRightStyle.java +++ b/org/w3c/css/properties/css3/CssBorderRightStyle.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-right-style + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-right-style * @see CssBorderStyle */ public class CssBorderRightStyle extends org.w3c.css.properties.css.CssBorderRightStyle { diff --git a/org/w3c/css/properties/css3/CssBorderRightWidth.java b/org/w3c/css/properties/css3/CssBorderRightWidth.java index 7dea06127..7b477d538 100644 --- a/org/w3c/css/properties/css3/CssBorderRightWidth.java +++ b/org/w3c/css/properties/css3/CssBorderRightWidth.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-right-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-width * @see CssBorderWidth */ public class CssBorderRightWidth extends org.w3c.css.properties.css.CssBorderRightWidth { diff --git a/org/w3c/css/properties/css3/CssBorderSpacing.java b/org/w3c/css/properties/css3/CssBorderSpacing.java index e1bfa865e..94d518e8b 100644 --- a/org/w3c/css/properties/css3/CssBorderSpacing.java +++ b/org/w3c/css/properties/css3/CssBorderSpacing.java @@ -9,6 +9,7 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -64,8 +65,8 @@ public CssBorderSpacing(ApplContext ac, CssExpression expression, boolean check) v.add(l); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val) && expression.getCount() == 1) { - value = inherit; + if (CssIdent.isCssWide(val.getIdent()) && expression.getCount() == 1) { + value = val; break; } // unrecognized ident => fail diff --git a/org/w3c/css/properties/css3/CssBorderStyle.java b/org/w3c/css/properties/css3/CssBorderStyle.java index 27a983788..a7ffe5027 100644 --- a/org/w3c/css/properties/css3/CssBorderStyle.java +++ b/org/w3c/css/properties/css3/CssBorderStyle.java @@ -19,7 +19,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-style + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border--style */ public class CssBorderStyle extends org.w3c.css.properties.css.CssBorderStyle { @@ -36,7 +36,7 @@ public class CssBorderStyle extends org.w3c.css.properties.css.CssBorderStyle { } } - public static CssIdent getMatchingIdent(CssIdent ident) { + public static CssIdent getAllowedIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; @@ -61,8 +61,7 @@ public CssBorderStyle() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderStyle(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -74,8 +73,7 @@ public CssBorderStyle(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -85,6 +83,7 @@ public CssBorderStyle(ApplContext ac, CssExpression expression, setByUser(); CssValue val; char op; + boolean gotCssWide = false; ArrayList res = new ArrayList(); while (res.size() < 4 && !expression.end()) { @@ -93,19 +92,20 @@ public CssBorderStyle(ApplContext ac, CssExpression expression, switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - res.add(inherit); + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + gotCssWide = true; + value = val; + res.add(val); break; } - CssIdent match = getMatchingIdent((CssIdent) val); - if (match == null) { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + if (getAllowedIdent(id) != null) { + res.add(val); + break; } - res.add(match); - break; default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", expression.getValue(), + getPropertyName(), ac); } expression.next(); if (op != SPACE) { @@ -115,7 +115,7 @@ public CssBorderStyle(ApplContext ac, CssExpression expression, } } // check that inherit is alone - if (res.size() > 1 && res.contains(inherit)) { + if (res.size() > 1 && gotCssWide) { throw new InvalidParamException("unrecognize", ac); } value = (res.size() == 1) ? res.get(0) : new CssValueList(res); @@ -164,18 +164,14 @@ protected static CssValue parseBorderSideStyle(ApplContext ac, CssExpression exp CssValue val = expression.getValue(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - retval = inherit; - } else { - retval = getMatchingIdent((CssIdent) val); - } - if (retval == null) { - throw new InvalidParamException("value", expression.getValue(), - caller.getPropertyName(), ac); + if (CssIdent.isCssWide(val.getIdent()) || (getAllowedIdent(val.getIdent()) != null)) { + retval = val; + break; } - break; + // else, fail default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", val, + caller.getPropertyName(), ac); } expression.next(); return retval; diff --git a/org/w3c/css/properties/css3/CssBorderTop.java b/org/w3c/css/properties/css3/CssBorderTop.java index 0a5e90ca0..691ad256e 100644 --- a/org/w3c/css/properties/css3/CssBorderTop.java +++ b/org/w3c/css/properties/css3/CssBorderTop.java @@ -9,9 +9,11 @@ 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; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-image + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top * @see CssBorder */ public class CssBorderTop extends org.w3c.css.properties.css.CssBorderTop { @@ -31,8 +33,7 @@ public CssBorderTop() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderTop(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -44,8 +45,7 @@ public CssBorderTop(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderTop(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -72,11 +72,11 @@ public CssBorderTop(ApplContext ac, CssExpression expression, */ public String toString() { if (_width != null) { - if (inherit == _width.value) { - return inherit.toString(); - } - if (initial == _width.value) { - return initial.toString(); + try { + if ((_width.value.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(_width.value.getIdent())) { + return _width.value.toString(); + } + } catch (Exception ignored) { } } StringBuilder sb = new StringBuilder(); diff --git a/org/w3c/css/properties/css3/CssBorderTopColor.java b/org/w3c/css/properties/css3/CssBorderTopColor.java index a9b7d60c3..38e265bca 100644 --- a/org/w3c/css/properties/css3/CssBorderTopColor.java +++ b/org/w3c/css/properties/css3/CssBorderTopColor.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-top-color + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-color * @see CssBorderColor */ public class CssBorderTopColor extends org.w3c.css.properties.css.CssBorderTopColor { diff --git a/org/w3c/css/properties/css3/CssBorderTopLeftRadius.java b/org/w3c/css/properties/css3/CssBorderTopLeftRadius.java index 92e544391..ee92a9bd6 100644 --- a/org/w3c/css/properties/css3/CssBorderTopLeftRadius.java +++ b/org/w3c/css/properties/css3/CssBorderTopLeftRadius.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssValueList; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-top-left-radius + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-left-radius * @see CssBorderRadius */ public class CssBorderTopLeftRadius extends org.w3c.css.properties.css.CssBorderTopLeftRadius { diff --git a/org/w3c/css/properties/css3/CssBorderTopRightRadius.java b/org/w3c/css/properties/css3/CssBorderTopRightRadius.java index 8bdd1567b..c0d371220 100644 --- a/org/w3c/css/properties/css3/CssBorderTopRightRadius.java +++ b/org/w3c/css/properties/css3/CssBorderTopRightRadius.java @@ -12,7 +12,7 @@ import org.w3c.css.values.CssValueList; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-top-right-radius + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-right-radius * @see CssBorderRadius */ public class CssBorderTopRightRadius extends org.w3c.css.properties.css.CssBorderTopRightRadius { diff --git a/org/w3c/css/properties/css3/CssBorderTopStyle.java b/org/w3c/css/properties/css3/CssBorderTopStyle.java index de49b6d56..d05d1657c 100644 --- a/org/w3c/css/properties/css3/CssBorderTopStyle.java +++ b/org/w3c/css/properties/css3/CssBorderTopStyle.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-top-style + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-style * @see CssBorderStyle */ public class CssBorderTopStyle extends org.w3c.css.properties.css.CssBorderTopStyle { diff --git a/org/w3c/css/properties/css3/CssBorderTopWidth.java b/org/w3c/css/properties/css3/CssBorderTopWidth.java index 5bbd1077d..264cba73c 100644 --- a/org/w3c/css/properties/css3/CssBorderTopWidth.java +++ b/org/w3c/css/properties/css3/CssBorderTopWidth.java @@ -10,7 +10,7 @@ import org.w3c.css.values.CssExpression; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-top-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-top-width * @see CssBorderWidth */ public class CssBorderTopWidth extends org.w3c.css.properties.css.CssBorderTopWidth { diff --git a/org/w3c/css/properties/css3/CssBorderWidth.java b/org/w3c/css/properties/css3/CssBorderWidth.java index 66bb82a33..b24e1247b 100644 --- a/org/w3c/css/properties/css3/CssBorderWidth.java +++ b/org/w3c/css/properties/css3/CssBorderWidth.java @@ -20,23 +20,23 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2012/CR-css3-background-20120417/#border-width + * @spec https://www.w3.org/TR/2021/CRD-css-backgrounds-3-20210726/#propdef-border-width */ public class CssBorderWidth extends org.w3c.css.properties.css.CssBorderWidth { - public static CssIdent allowed_values[]; + + public static final CssIdent[] allowed_values; static { - allowed_values = new CssIdent[3]; - allowed_values[0] = CssIdent.getIdent("thin"); - allowed_values[1] = CssIdent.getIdent("medium"); - allowed_values[2] = CssIdent.getIdent("thick"); + String[] _allowed_values = {"thin", "medium", "thick"}; + int i = 0; + allowed_values = new CssIdent[_allowed_values.length]; + for (String s : _allowed_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } } - /* - * Get the cached ident if it matches null otherwise - */ - static CssIdent getMatchingIdent(CssIdent ident) { + public static final CssIdent getAllowedIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; @@ -61,8 +61,7 @@ public CssBorderWidth() { * Does not check the number of values * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * The expression is incorrect + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderWidth(ApplContext ac, CssExpression expression) throws InvalidParamException { @@ -74,8 +73,7 @@ public CssBorderWidth(ApplContext ac, CssExpression expression) * * @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 + * @throws org.w3c.css.util.InvalidParamException The expression is incorrect */ public CssBorderWidth(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -85,6 +83,7 @@ public CssBorderWidth(ApplContext ac, CssExpression expression, setByUser(); CssValue val; char op; + boolean gotCssWide = false; ArrayList res = new ArrayList(); while (res.size() < 4 && !expression.end()) { @@ -102,19 +101,22 @@ public CssBorderWidth(ApplContext ac, CssExpression expression, res.add(val); break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - res.add(inherit); + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + gotCssWide = true; + res.add(id); + value = val; break; } - CssIdent match = getMatchingIdent((CssIdent) val); - if (match == null) { - throw new InvalidParamException("value", expression.getValue(), + if (getAllowedIdent(id) == null) { + throw new InvalidParamException("value", val, getPropertyName(), ac); } - res.add(match); + res.add(val); break; default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", val, + getPropertyName(), ac); } expression.next(); if (op != SPACE) { @@ -124,8 +126,9 @@ public CssBorderWidth(ApplContext ac, CssExpression expression, } } // check that inherit is alone - if (res.size() > 1 && res.contains(inherit)) { - throw new InvalidParamException("unrecognize", ac); + if (res.size() > 1 && gotCssWide) { + throw new InvalidParamException("value", value, + getPropertyName(), ac); } value = (res.size() == 1) ? res.get(0) : new CssValueList(res); @@ -185,18 +188,15 @@ protected static CssValue parseBorderSideWidth(ApplContext ac, CssExpression exp retval = val; break; case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - retval = inherit; - } else { - retval = getMatchingIdent((CssIdent) val); - } - if (retval == null) { - throw new InvalidParamException("value", expression.getValue(), - caller.getPropertyName(), ac); + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || getAllowedIdent(id) != null) { + retval = val; + break; } - break; + // else fail default: - throw new InvalidParamException("unrecognize", ac); + throw new InvalidParamException("value", expression.getValue(), + caller.getPropertyName(), ac); } expression.next(); return retval; diff --git a/org/w3c/css/properties/css3/CssOutline.java b/org/w3c/css/properties/css3/CssOutline.java index 9cb81192b..cbe00b61c 100644 --- a/org/w3c/css/properties/css3/CssOutline.java +++ b/org/w3c/css/properties/css3/CssOutline.java @@ -120,7 +120,7 @@ public CssOutline(ApplContext ac, CssExpression expression, boolean check) } } if (widthValue == null) { - if (CssBorderWidth.getMatchingIdent(ident) != null) { + if (CssBorderWidth.getAllowedIdent(ident) != null) { widthValue = val; break; } diff --git a/org/w3c/css/properties/css3/CssOutlineStyle.java b/org/w3c/css/properties/css3/CssOutlineStyle.java index 84e5d1c3b..916e50e2b 100644 --- a/org/w3c/css/properties/css3/CssOutlineStyle.java +++ b/org/w3c/css/properties/css3/CssOutlineStyle.java @@ -25,7 +25,7 @@ public static final CssIdent getMatchingIdent(CssIdent ident) { if (auto.equals(ident)) { return auto; } - return CssBorderStyle.getMatchingIdent(ident); + return CssBorderStyle.getAllowedIdent(ident); } /** From 82472842fa069dd31cfebe04423d17be94f6b1bd Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 12 Sep 2021 10:34:17 +0200 Subject: [PATCH 80/82] Updated all font properties to https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/ That includes new properties, aligning existing properties and external definitions. Fixing some long time 'font' parsing issues. --- .../css/properties/CSS3Properties.properties | 5 + .../properties/css/CssFontOpticalSizing.java | 113 +++++++++++ .../css/properties/css/CssFontPalette.java | 113 +++++++++++ .../css/CssFontSynthesisSmallCaps.java | 114 +++++++++++ .../properties/css/CssFontSynthesisStyle.java | 114 +++++++++++ .../css/CssFontSynthesisWeight.java | 114 +++++++++++ .../properties/css/CssFontVariantEmoji.java | 113 +++++++++++ .../css/CssFontVariantPosition.java | 6 +- .../css/CssFontVariationSettings.java | 113 +++++++++++ org/w3c/css/properties/css3/Css3Style.java | 89 ++++++++- org/w3c/css/properties/css3/CssFont.java | 173 ++++++++++++---- .../css/properties/css3/CssFontFamily.java | 51 ++--- .../css3/CssFontFeatureSettings.java | 189 +++++++++--------- .../css/properties/css3/CssFontKerning.java | 51 ++--- .../css3/CssFontLanguageOverride.java | 72 ++++--- .../properties/css3/CssFontOpticalSizing.java | 89 +++++++++ .../css/properties/css3/CssFontPalette.java | 90 +++++++++ org/w3c/css/properties/css3/CssFontSize.java | 31 +-- .../properties/css3/CssFontSizeAdjust.java | 26 +-- .../css/properties/css3/CssFontStretch.java | 37 ++-- org/w3c/css/properties/css3/CssFontStyle.java | 67 ++++++- .../css/properties/css3/CssFontSynthesis.java | 124 ++++++------ .../css3/CssFontSynthesisSmallCaps.java | 88 ++++++++ .../css3/CssFontSynthesisStyle.java | 88 ++++++++ .../css3/CssFontSynthesisWeight.java | 88 ++++++++ .../css/properties/css3/CssFontVariant.java | 58 +++--- .../css3/CssFontVariantAlternates.java | 42 ++-- .../properties/css3/CssFontVariantCaps.java | 32 ++- .../css3/CssFontVariantEastAsian.java | 45 ++--- .../properties/css3/CssFontVariantEmoji.java | 89 +++++++++ .../css3/CssFontVariantLigatures.java | 57 +++--- .../css3/CssFontVariantNumeric.java | 50 +++-- .../css3/CssFontVariantPosition.java | 26 +-- .../css3/CssFontVariationSettings.java | 138 +++++++++++++ .../css/properties/css3/CssFontWeight.java | 46 ++--- .../external/OpenTypeLanguageSystemTag.java | 119 ++++++----- 36 files changed, 2248 insertions(+), 612 deletions(-) create mode 100644 org/w3c/css/properties/css/CssFontOpticalSizing.java create mode 100644 org/w3c/css/properties/css/CssFontPalette.java create mode 100644 org/w3c/css/properties/css/CssFontSynthesisSmallCaps.java create mode 100644 org/w3c/css/properties/css/CssFontSynthesisStyle.java create mode 100644 org/w3c/css/properties/css/CssFontSynthesisWeight.java create mode 100644 org/w3c/css/properties/css/CssFontVariantEmoji.java create mode 100644 org/w3c/css/properties/css/CssFontVariationSettings.java create mode 100644 org/w3c/css/properties/css3/CssFontOpticalSizing.java create mode 100644 org/w3c/css/properties/css3/CssFontPalette.java create mode 100644 org/w3c/css/properties/css3/CssFontSynthesisSmallCaps.java create mode 100644 org/w3c/css/properties/css3/CssFontSynthesisStyle.java create mode 100644 org/w3c/css/properties/css3/CssFontSynthesisWeight.java create mode 100644 org/w3c/css/properties/css3/CssFontVariantEmoji.java create mode 100644 org/w3c/css/properties/css3/CssFontVariationSettings.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index a85cd5be1..931c7b830 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -12,12 +12,17 @@ font-feature-settings: org.w3c.css.properties.css3.CssFontFeatu font-kerning: org.w3c.css.properties.css3.CssFontKerning font-language-override: org.w3c.css.properties.css3.CssFontLanguageOverride font-synthesis: org.w3c.css.properties.css3.CssFontSynthesis +font-synthesis-small-caps: org.w3c.css.properties.css3.CssFontSynthesisSmallCaps +font-synthesis-style: org.w3c.css.properties.css3.CssFontSynthesisStyle +font-synthesis-weight: org.w3c.css.properties.css3.CssFontSynthesisWeight font-variant-caps: org.w3c.css.properties.css3.CssFontVariantCaps font-variant-position: org.w3c.css.properties.css3.CssFontVariantPosition font-variant-east-asian: org.w3c.css.properties.css3.CssFontVariantEastAsian +font-variant-emoji: org.w3c.css.properties.css3.CssFontVariantEmoji font-variant-ligatures: org.w3c.css.properties.css3.CssFontVariantLigatures font-variant-numeric: org.w3c.css.properties.css3.CssFontVariantNumeric font-variant-alternates: org.w3c.css.properties.css3.CssFontVariantAlternates +font-variation-settings: org.w3c.css.properties.css3.CssFontVariationSettings color: org.w3c.css.properties.css3.CssColor diff --git a/org/w3c/css/properties/css/CssFontOpticalSizing.java b/org/w3c/css/properties/css/CssFontOpticalSizing.java new file mode 100644 index 000000000..f4c21ead4 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontOpticalSizing.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontOpticalSizing extends CssProperty { + + + /** + * Create a new CssFontOpticalSizing + */ + public CssFontOpticalSizing() { + } + + /** + * Creates a new CssFontOpticalSizing + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontOpticalSizing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontOpticalSizing(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 final String getPropertyName() { + return "font-optical-sizing"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontOpticalSizing != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontOpticalSizing = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontOpticalSizing && + value.equals(((CssFontOpticalSizing) property).value)); + } + + + /** + * 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).getFontOpticalSizing(); + } else { + return ((Css3Style) style).cssFontOpticalSizing; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontPalette.java b/org/w3c/css/properties/css/CssFontPalette.java new file mode 100644 index 000000000..fbde2199e --- /dev/null +++ b/org/w3c/css/properties/css/CssFontPalette.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontPalette extends CssProperty { + + + /** + * Create a new CssFontPalette + */ + public CssFontPalette() { + } + + /** + * Creates a new CssFontPalette + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontPalette(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontPalette(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 final String getPropertyName() { + return "font-palette"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontPalette != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontPalette = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontPalette && + value.equals((property).value)); + } + + + /** + * 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).getFontPalette(); + } else { + return ((Css3Style) style).cssFontPalette; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontSynthesisSmallCaps.java b/org/w3c/css/properties/css/CssFontSynthesisSmallCaps.java new file mode 100644 index 000000000..35a7cc9a0 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontSynthesisSmallCaps.java @@ -0,0 +1,114 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontSynthesisSmallCaps extends CssProperty { + + + /** + * Create a new CssFontSynthesisSmallCaps + */ + public CssFontSynthesisSmallCaps() { + } + + /** + * Creates a new CssFontSynthesisSmallCaps + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssFontSynthesisSmallCaps(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontSynthesisSmallCaps(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 final String getPropertyName() { + return "font-synthesis-small-caps"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontSynthesisSmallCaps != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontSynthesisSmallCaps = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontSynthesisSmallCaps && + value.equals(property.value)); + } + + + /** + * 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).getFontSynthesisSmallCaps(); + } else { + return ((Css3Style) style).cssFontSynthesisSmallCaps; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontSynthesisStyle.java b/org/w3c/css/properties/css/CssFontSynthesisStyle.java new file mode 100644 index 000000000..9790b4583 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontSynthesisStyle.java @@ -0,0 +1,114 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontSynthesisStyle extends CssProperty { + + + /** + * Create a new CssFontSynthesisStyle + */ + public CssFontSynthesisStyle() { + } + + /** + * Creates a new CssFontSynthesisStyle + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssFontSynthesisStyle(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontSynthesisStyle(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 final String getPropertyName() { + return "font-synthesis-style"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontSynthesisStyle != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontSynthesisStyle = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontSynthesisStyle && + value.equals(property.value)); + } + + + /** + * 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).getFontSynthesisStyle(); + } else { + return ((Css3Style) style).cssFontSynthesisStyle; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontSynthesisWeight.java b/org/w3c/css/properties/css/CssFontSynthesisWeight.java new file mode 100644 index 000000000..420bfa1d5 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontSynthesisWeight.java @@ -0,0 +1,114 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontSynthesisWeight extends CssProperty { + + + /** + * Create a new CssFontSynthesisWeight + */ + public CssFontSynthesisWeight() { + } + + /** + * Creates a new CssFontSynthesisWeight + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssFontSynthesisWeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontSynthesisWeight(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 final String getPropertyName() { + return "font-synthesis-weight"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontSynthesisWeight != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontSynthesisWeight = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontSynthesisWeight && + value.equals(property.value)); + } + + + /** + * 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).getFontSynthesisWeight(); + } else { + return ((Css3Style) style).cssFontSynthesisWeight; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontVariantEmoji.java b/org/w3c/css/properties/css/CssFontVariantEmoji.java new file mode 100644 index 000000000..201f027b9 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontVariantEmoji.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontVariantEmoji extends CssProperty { + + + /** + * Create a new CssFontVariantEmoji + */ + public CssFontVariantEmoji() { + } + + /** + * Creates a new CssFontVariantEmoji + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontVariantEmoji(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontVariantEmoji(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 final String getPropertyName() { + return "font-variant-emoji"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontVariantEmoji != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontVariantEmoji = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontVariantEmoji && + value.equals(((CssFontVariantEmoji) property).value)); + } + + + /** + * 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).getFontVariantEmoji(); + } else { + return ((Css3Style) style).cssFontVariantEmoji; + } + } +} + diff --git a/org/w3c/css/properties/css/CssFontVariantPosition.java b/org/w3c/css/properties/css/CssFontVariantPosition.java index 2ae6e35b6..94a448f60 100644 --- a/org/w3c/css/properties/css/CssFontVariantPosition.java +++ b/org/w3c/css/properties/css/CssFontVariantPosition.java @@ -94,7 +94,7 @@ public void addToStyle(ApplContext ac, CssStyle style) { */ public boolean equals(CssProperty property) { return (property instanceof CssFontVariantPosition && - value.equals(((CssFontVariantPosition) property).value)); + value.equals(property.value)); } @@ -106,9 +106,9 @@ public boolean equals(CssProperty property) { */ public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { if (resolve) { - return ((Css3Style) style).getFontKerning(); + return ((Css3Style) style).getFontVariantPosition(); } else { - return ((Css3Style) style).cssFontKerning; + return ((Css3Style) style).cssFontVariantPosition; } } } diff --git a/org/w3c/css/properties/css/CssFontVariationSettings.java b/org/w3c/css/properties/css/CssFontVariationSettings.java new file mode 100644 index 000000000..129cd2d28 --- /dev/null +++ b/org/w3c/css/properties/css/CssFontVariationSettings.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; + +/** + * @since CSS3 + */ +public class CssFontVariationSettings extends CssProperty { + + + /** + * Create a new CssFontVariationSettings + */ + public CssFontVariationSettings() { + } + + /** + * Creates a new CssFontVariationSettings + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssFontVariationSettings(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 final String getPropertyName() { + return "font-variation-settings"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return value.equals(inherit); + } + + /** + * 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) { + Css3Style s = (Css3Style) style; + if (s.cssFontVariationSettings != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssFontVariationSettings = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssFontVariationSettings && + value.equals((property).value)); + } + + + /** + * 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).getFontVariationSettings(); + } else { + return ((Css3Style) style).cssFontVariationSettings; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 628b61809..ef6f44b62 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -108,13 +108,20 @@ import org.w3c.css.properties.css.CssFontFeatureSettings; import org.w3c.css.properties.css.CssFontKerning; import org.w3c.css.properties.css.CssFontLanguageOverride; +import org.w3c.css.properties.css.CssFontOpticalSizing; +import org.w3c.css.properties.css.CssFontPalette; import org.w3c.css.properties.css.CssFontSynthesis; +import org.w3c.css.properties.css.CssFontSynthesisSmallCaps; +import org.w3c.css.properties.css.CssFontSynthesisStyle; +import org.w3c.css.properties.css.CssFontSynthesisWeight; import org.w3c.css.properties.css.CssFontVariantAlternates; import org.w3c.css.properties.css.CssFontVariantCaps; import org.w3c.css.properties.css.CssFontVariantEastAsian; +import org.w3c.css.properties.css.CssFontVariantEmoji; import org.w3c.css.properties.css.CssFontVariantLigatures; import org.w3c.css.properties.css.CssFontVariantNumeric; import org.w3c.css.properties.css.CssFontVariantPosition; +import org.w3c.css.properties.css.CssFontVariationSettings; import org.w3c.css.properties.css.CssForcedColorAdjust; import org.w3c.css.properties.css.CssGap; import org.w3c.css.properties.css.CssGrid; @@ -452,6 +459,13 @@ public class Css3Style extends ATSCStyle { public CssFontVariantNumeric cssFontVariantNumeric; public CssFontFeatureSettings cssFontFeatureSettings; public CssFontVariantAlternates cssFontVariantAlternates; + public CssFontSynthesisSmallCaps cssFontSynthesisSmallCaps; + public CssFontSynthesisStyle cssFontSynthesisStyle; + public CssFontSynthesisWeight cssFontSynthesisWeight; + public CssFontVariantEmoji cssFontVariantEmoji; + public CssFontOpticalSizing cssFontOpticalSizing; + public CssFontPalette cssFontPalette; + public CssFontVariationSettings cssFontVariationSettings; public CssOverflowWrap cssOverflowWrap; public CssWordBreak cssWordBreak; @@ -1236,7 +1250,7 @@ public CssPrintColorAdjust getPrintColorAdjust() { } return cssPrintColorAdjust; } - + public CssForcedColorAdjust getForcedColorAdjust() { if (cssForcedColorAdjust == null) { cssForcedColorAdjust = @@ -2151,7 +2165,7 @@ public CssInlineSizing getInlineSizing() { } return cssInlineSizing; } - + public CssDominantBaseline getDominantBaseline() { if (cssDominantBaseline == null) { cssDominantBaseline = @@ -2631,14 +2645,41 @@ public CssFontVariantCaps getFontVariantCaps() { } public CssFontVariantPosition getFontVariantPosition() { - if (cssFontVariantCaps == null) { - cssFontVariantCaps = - (CssFontVariantCaps) style.CascadingOrder( - new CssFontVariantCaps(), style, selector); + if (cssFontVariantPosition == null) { + cssFontVariantPosition = + (CssFontVariantPosition) style.CascadingOrder( + new CssFontVariantPosition(), style, selector); } return cssFontVariantPosition; } + public CssFontSynthesisSmallCaps getFontSynthesisSmallCaps() { + if (cssFontSynthesisSmallCaps == null) { + cssFontSynthesisSmallCaps = + (CssFontSynthesisSmallCaps) style.CascadingOrder( + new CssFontSynthesisSmallCaps(), style, selector); + } + return cssFontSynthesisSmallCaps; + } + + public CssFontSynthesisStyle getFontSynthesisStyle() { + if (cssFontSynthesisStyle == null) { + cssFontSynthesisStyle = + (CssFontSynthesisStyle) style.CascadingOrder( + new CssFontSynthesisStyle(), style, selector); + } + return cssFontSynthesisStyle; + } + + public CssFontSynthesisWeight getFontSynthesisWeight() { + if (cssFontSynthesisWeight == null) { + cssFontSynthesisWeight = + (CssFontSynthesisWeight) style.CascadingOrder( + new CssFontSynthesisWeight(), style, selector); + } + return cssFontSynthesisWeight; + } + public CssFontSynthesis getFontSynthesis() { if (cssFontSynthesis == null) { cssFontSynthesis = @@ -2666,6 +2707,15 @@ public CssFontVariantLigatures getFontVariantLigatures() { return cssFontVariantLigatures; } + public CssFontVariantEmoji getFontVariantEmoji() { + if (cssFontVariantEmoji == null) { + cssFontVariantEmoji = + (CssFontVariantEmoji) style.CascadingOrder( + new CssFontVariantEmoji(), style, selector); + } + return cssFontVariantEmoji; + } + public CssFontVariantNumeric getFontVariantNumeric() { if (cssFontVariantNumeric == null) { cssFontVariantNumeric = @@ -2675,6 +2725,24 @@ public CssFontVariantNumeric getFontVariantNumeric() { return cssFontVariantNumeric; } + public CssFontOpticalSizing getFontOpticalSizing() { + if (cssFontOpticalSizing == null) { + cssFontOpticalSizing = + (CssFontOpticalSizing) style.CascadingOrder( + new CssFontOpticalSizing(), style, selector); + } + return cssFontOpticalSizing; + } + + public CssFontPalette getFontPalette() { + if (cssFontPalette == null) { + cssFontPalette = + (CssFontPalette) style.CascadingOrder( + new CssFontPalette(), style, selector); + } + return cssFontPalette; + } + public CssFontFeatureSettings getFontFeatureSettings() { if (cssFontFeatureSettings == null) { cssFontFeatureSettings = @@ -2684,6 +2752,15 @@ public CssFontFeatureSettings getFontFeatureSettings() { return cssFontFeatureSettings; } + public CssFontVariationSettings getFontVariationSettings() { + if (cssFontVariationSettings == null) { + cssFontVariationSettings = + (CssFontVariationSettings) style.CascadingOrder( + new CssFontVariationSettings(), style, selector); + } + return cssFontVariationSettings; + } + public CssFontVariantAlternates getFontVariantAlternates() { if (cssFontVariantAlternates == null) { cssFontVariantAlternates = diff --git a/org/w3c/css/properties/css3/CssFont.java b/org/w3c/css/properties/css3/CssFont.java index 609c6e3d9..588030a87 100644 --- a/org/w3c/css/properties/css3/CssFont.java +++ b/org/w3c/css/properties/css3/CssFont.java @@ -5,9 +5,9 @@ // 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.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; @@ -18,10 +18,12 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font */ public class CssFont extends org.w3c.css.properties.css.CssFont { + public CssFontStretch fontStretch = null; + public static final CssIdent normal; public static final CssIdent[] systemFonts; static final String[] _systemFonts = {"caption", "icon", "menu", @@ -56,8 +58,7 @@ public CssFont() { * Creates a new CssFontSize * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFont(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,6 +67,7 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) CssValue val; char op; + CssExpression nex; boolean gotNormal = false; int state = 0; @@ -75,71 +77,92 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) op = expression.getOperator(); switch (val.getType()) { case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; + value = val; break; } - CssIdent ident; - ident = getSystemFont((CssIdent) val); - if (ident != null) { + if (getSystemFont(id) != null) { if (expression.getCount() != 1) { throw new InvalidParamException( "system-font-keyword-not-sole-value", val.toString(), val.toString(), ac); } - value = ident; + value = val; break; } // first font-style - ident = (CssIdent) val; if (state == 0) { // now check for possible font values // first the strange case of 'normal' - // which sets up to three values... + // which sets up to four values... // we keep it around for the final check - if (normal.equals((CssIdent) val)) { + if (normal.equals(id)) { gotNormal = true; break; } - int pos = CssFontStyle.allowed_values.indexOf(ident); - if (pos >= 0) { + if (CssFontStyle.getMatchingIdent(id) != null) { if (fontStyle != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - fontStyle = new CssFontStyle(); - fontStyle.value = CssFontStyle.allowed_values.get(pos); + CssValue nextVal = expression.getNextValue(); + if (nextVal != null && (nextVal.getType() == CssTypes.CSS_ANGLE)) { + nex = new CssExpression(); + nex.addValue(val); + expression.next(); + nex.addValue(nextVal); + try { + fontStyle = new CssFontStyle(ac, nex, false); + } catch (Exception ex) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + } else { + fontStyle = new CssFontStyle(); + fontStyle.value = val; + } break; } // font-variant - CssIdent v = org.w3c.css.properties.css21.CssFontVariant.getAllowedFontVariant(ident); - if (v != null) { + if (org.w3c.css.properties.css21.CssFontVariant.getAllowedFontVariant(id) != null) { if (fontVariant != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } fontVariant = new CssFontVariant(); - fontVariant.value = v; + fontVariant.value = val; break; } // font-weight - v = CssFontWeight.getAllowedValue(ident); - if (v != null) { + if (CssFontWeight.getAllowedValue(id) != null) { if (fontWeight != null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } fontWeight = new CssFontWeight(); - fontWeight.value = v; + fontWeight.value = val; + break; + } + // font-stretch + if (CssFontStretch.getAllowedValue(id) != null) { + if (fontStretch != null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + fontStretch = new CssFontStretch(); + fontStretch.value = val; break; } } @@ -147,8 +170,7 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) // check if we moved past and we now got // a font-size if (state == 0) { - CssIdent v = CssFontSize.getAllowedValue(ident); - if (v != null) { + if (CssFontSize.getAllowedValue(id) != null) { // we got a FontSize, so no more style/variant/weight state = 1; if (fontSize != null) { @@ -157,7 +179,7 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } fontSize = new CssFontSize(); - fontSize.value = v; + fontSize.value = val; break; } } @@ -189,21 +211,21 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) getPropertyName(), ac); } // let's parse a line-height - lineHeight = new CssLineHeight(ac, expression, false); + nex = new CssExpression(); + nex.addValue(expression.getValue()); + lineHeight = new CssLineHeight(ac, nex, false); state = 1; - // expression.next is called, so continue instead - // of next - continue; + break; case CssTypes.CSS_NUMBER: - CssCheckableValue c = (CssCheckableValue) val; - if (!c.isZero()) { + // TODO FIXME case of var with unknown numerical value... + if (!val.getCheckableValue().isZero()) { // must be a font-weight if (state == 0 && fontWeight == null) { - fontWeight = new CssFontWeight(ac, expression, false); - // expression.next is called, so continue instead - // of next - continue; + nex = new CssExpression(); + nex.addValue(val); + fontWeight = new CssFontWeight(ac, nex, false); + break; } throw new InvalidParamException("value", val.toString(), @@ -213,11 +235,11 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) case CssTypes.CSS_PERCENTAGE: case CssTypes.CSS_LENGTH: if (state == 0 && fontSize == null) { - fontSize = new CssFontSize(ac, expression, false); + nex = new CssExpression(); + nex.addValue(val); + fontSize = new CssFontSize(ac, nex, false); state = 1; - // expression.next is called, so continue instead - // of next - continue; + break; } throw new InvalidParamException("value", val.toString(), @@ -228,8 +250,6 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) if (state == 1) { fontFamily = new CssFontFamily(ac, expression, check); state = 2; - // expression.next is called, so continue instead - // of next continue; } default: @@ -256,7 +276,10 @@ public CssFont(ApplContext ac, CssExpression expression, boolean check) if (fontWeight == null) { fontWeight = new CssFontWeight(); fontWeight.value = normal; - + } + if (fontStretch == null) { + fontStretch = new CssFontStretch(); + fontStretch.value = normal; } } } @@ -266,5 +289,69 @@ public CssFont(ApplContext ac, CssExpression expression) this(ac, expression, false); } + @Override + public String toString() { + if (value != null) { + return value.toString(); + } + boolean first = true; + StringBuilder sb = new StringBuilder(); + if (fontStyle != null) { + sb.append(fontStyle); + first = false; + } + if (fontVariant != null) { + if (first) { + first = false; + } else { + sb.append(' '); + } + sb.append(fontVariant); + } + if (fontWeight != null) { + if (first) { + first = false; + } else { + sb.append(' '); + } + sb.append(fontWeight); + } + if (fontStretch != null) { + if (first) { + first = false; + } else { + sb.append(' '); + } + sb.append(fontStretch); + } + + // no need to test, if we are here we should have one! + if (fontSize != null) { + if (first) { + first = false; + } else { + sb.append(' '); + } + sb.append(fontSize); + } + if (lineHeight != null) { + sb.append('/'); + sb.append(lineHeight); + } + // should always be there... + if (fontFamily != null) { + sb.append(' '); + sb.append(fontFamily); + } + return sb.toString(); + } + + @Override + public void addToStyle(ApplContext ac, CssStyle style) { + super.addToStyle(ac, style); + if (fontStretch != null) { + fontStretch.addToStyle(ac, style); + } + } } diff --git a/org/w3c/css/properties/css3/CssFontFamily.java b/org/w3c/css/properties/css3/CssFontFamily.java index d6ff95008..04dc66ac3 100644 --- a/org/w3c/css/properties/css3/CssFontFamily.java +++ b/org/w3c/css/properties/css3/CssFontFamily.java @@ -10,6 +10,7 @@ import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; +import org.w3c.css.values.CssString; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; @@ -19,33 +20,22 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-family-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-family */ public class CssFontFamily extends org.w3c.css.properties.css.CssFontFamily { public static final ArrayList genericNames; - public static final ArrayList reservedNames; public static final String[] _genericNames = { - "serif", - "sans-serif", - "cursive", - "fantasy", - "monospace"}; - - public static final String[] _reservedNames = {"inherit", - "initial", "default" - }; + "serif", "sans-serif", "cursive", "fantasy", "monospace", + "system-ui", "emoji", "math", "fangsong", "ui-serif", + "ui-sans-serif", "ui-monospace", "ui-rounded"}; static { genericNames = new ArrayList(_genericNames.length); for (String s : _genericNames) { genericNames.add(CssIdent.getIdent(s)); } - reservedNames = new ArrayList(_reservedNames.length); - for (String s : _reservedNames) { - reservedNames.add(CssIdent.getIdent(s)); - } } static CssIdent getGenericFontName(CssIdent ident) { @@ -56,21 +46,13 @@ static CssIdent getGenericFontName(CssIdent ident) { return null; } - static CssIdent getReservedFontName(CssIdent ident) { - int pos = reservedNames.indexOf(ident); - if (pos >= 0) { - return reservedNames.get(pos); - } - return null; - } - private void checkExpression(ApplContext ac, ArrayList curval, ArrayList values, boolean check) { CssIdent val; if (values.size() > 1) { // create a value out of that. We could even create // a CssString for the output (TODO ?) - StringBuilder sb = new StringBuilder(); + StringBuilder sb = new StringBuilder("\""); boolean addSpace = false; for (CssIdent id : values) { if (addSpace) { @@ -80,19 +62,20 @@ private void checkExpression(ApplContext ac, ArrayList curval, } sb.append(id); } + sb.append('"'); ac.getFrame().addWarning("with-space", 1); - val = new CssIdent(sb.toString()); + curval.add(new CssString(sb.toString())); } else { val = values.get(0); // could be done in the consistency check, but... if (null != getGenericFontName(val)) { hasGenericFontFamily = true; } - if (inherit.equals(val)) { - val = inherit; + if (CssIdent.isCssWide(val)) { + // should we warn?; } + curval.add(val); } - curval.add(val); } // final consistency check @@ -101,8 +84,9 @@ private void checkValues(ApplContext ac, ArrayList values) // we need to check that we don't have 'inherit' in multiple values if (values.size() > 1) { for (CssValue val : values) { - if (inherit.equals(val)) { - throw new InvalidParamException("unrecognize", ac); + if ((val.getType() == CssTypes.CSS_IDENT) && CssIdent.isCssWide(val.getIdent())) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); } } } @@ -112,8 +96,7 @@ private void checkValues(ApplContext ac, ArrayList values) * Creates a new CssFontFamily * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontFamily(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -138,14 +121,14 @@ public CssFontFamily(ApplContext ac, CssExpression expression, boolean check) break; case CssTypes.CSS_IDENT: ArrayList idval = new ArrayList(); - idval.add((CssIdent) val); + idval.add(val.getIdent()); // we add idents if separated by spaces... while (op == SPACE && expression.getRemainingCount() > 1) { expression.next(); op = expression.getOperator(); val = expression.getValue(); if (val.getType() == CssTypes.CSS_IDENT) { - idval.add((CssIdent) val); + idval.add(val.getIdent()); } else { throw new InvalidParamException("value", val, getPropertyName(), ac); diff --git a/org/w3c/css/properties/css3/CssFontFeatureSettings.java b/org/w3c/css/properties/css3/CssFontFeatureSettings.java index 53884fcaa..292affc7b 100644 --- a/org/w3c/css/properties/css3/CssFontFeatureSettings.java +++ b/org/w3c/css/properties/css3/CssFontFeatureSettings.java @@ -7,10 +7,10 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssLayerList; +import org.w3c.css.values.CssString; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; @@ -21,7 +21,7 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2018/REC-css-fonts-3-20180920/#propdef-font-feature-settings + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-feature-settings */ public class CssFontFeatureSettings extends org.w3c.css.properties.css.CssFontFeatureSettings { @@ -33,6 +33,16 @@ public class CssFontFeatureSettings extends org.w3c.css.properties.css.CssFontFe normal = CssIdent.getIdent("normal"); } + public static final CssIdent getAllowedValue(CssIdent ident) { + if (on.equals(ident)) { + return on; + } + if (off.equals(ident)) { + return off; + } + return null; + } + /** * Create a new CssFontFeatureSettings */ @@ -44,65 +54,104 @@ public CssFontFeatureSettings() { * Creates a new CssFontFeatureSettings * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontFeatureSettings(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); + CssValue val; - ArrayList values; - CssExpression singleExpr = null; - CssValue b_val = null; char op; - values = new ArrayList(); - // we just accumulate values and check at validation + val = expression.getValue(); + op = expression.getOperator(); + ArrayList values = new ArrayList<>(); + ArrayList layervalues = new ArrayList<>(); + while (!expression.end()) { val = expression.getValue(); op = expression.getOperator(); - if (inherit.equals(val)) { - if (expression.getCount() > 1) { - throw new InvalidParamException("value", val, + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || normal.equals(id)) { + if (expression.getCount() != 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + break; + } + if (layervalues.size() == 1 && (getAllowedValue(id) != null)) { + layervalues.add(val); + break; + } + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + + case CssTypes.CSS_NUMBER: + if (layervalues.size() != 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + layervalues.add(val); + break; + case CssTypes.CSS_STRING: + if (val.getRawType() == CssTypes.CSS_STRING) { + CssString s = (CssString) val; + int l = s.toString().length(); + // limit of 4characters + two surrounding quotes + if (s.toString().length() != 6) { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + // FIXME TODO check + } + layervalues.add(val); + break; + default: + throw new InvalidParamException("value", + val.toString(), getPropertyName(), ac); - } - value = inherit; - expression.next(); - return; - } - if (singleExpr == null) { - singleExpr = new CssExpression(); } - // we will check later - singleExpr.addValue(val); - singleExpr.setOperator(op); expression.next(); - - if (!expression.end()) { - // incomplete value followed by a comma... it's complete! - if (op == COMMA) { - singleExpr.setOperator(SPACE); - b_val = check(ac, singleExpr); - values.add(b_val); - singleExpr = null; - } else if ((op != SPACE)) { - throw new InvalidParamException("operator", - Character.toString(op), ac); + if (!layervalues.isEmpty()) { + if ((layervalues.size() == 2) || ((layervalues.size() == 1) && (op == COMMA))) { + if (layervalues.size() == 1) { + values.add(val); + layervalues.clear(); + } else { + values.add(new CssValueList(layervalues)); + layervalues = new ArrayList<>(); + } + if (!expression.end()) { + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + } + } else { + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } } } } - // if we reach the end in a value that can come in pair - if (singleExpr != null) { - b_val = check(ac, singleExpr); - values.add(b_val); + // sanity check + if (layervalues.size() == 1) { + values.add(layervalues.get(0)); } - if (values.size() == 1) { - value = values.get(0); - } else { - value = new CssLayerList(values); + if (!values.isEmpty()) { + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); } + } public CssFontFeatureSettings(ApplContext ac, CssExpression expression) @@ -110,64 +159,6 @@ public CssFontFeatureSettings(ApplContext ac, CssExpression expression) this(ac, expression, false); } - public CssValue check(ApplContext ac, CssExpression exp) - throws InvalidParamException { - CssValue val; - if (exp.getCount() > 2) { - throw new InvalidParamException("unrecognize", ac); - } - val = exp.getValue(); - switch (val.getType()) { - - case CssTypes.CSS_STRING: - String s = val.toString(); - // limit of 4 characters + two surrounding quotes - if (s.length() != 6) { - throw new InvalidParamException("value", - s, getPropertyName(), ac); - } - break; - case CssTypes.CSS_IDENT: - if (normal.equals(val) && exp.getCount() == 1) { - return normal; - } - //else we throw - default: - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - if (exp.getCount() == 1) { - return val; - } - ArrayList v = new ArrayList(2); - v.add(val); - // now check the second value - exp.next(); - val = exp.getValue(); - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - CssCheckableValue n = val.getCheckableValue(); - n.checkPositiveness(ac, this); - v.add(val); - break; - case CssTypes.CSS_IDENT: - if (on.equals(val)) { - v.add(on); - break; - } - if (off.equals(val)) { - v.add(off); - break; - } - // let it fail - default: - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - return (v.size() == 1) ? v.get(0) : new CssValueList(v); - } } diff --git a/org/w3c/css/properties/css3/CssFontKerning.java b/org/w3c/css/properties/css3/CssFontKerning.java index 3c0e7bc42..631f0fa2b 100644 --- a/org/w3c/css/properties/css3/CssFontKerning.java +++ b/org/w3c/css/properties/css3/CssFontKerning.java @@ -12,17 +12,31 @@ import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; +import java.util.Arrays; + /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#propdef-font-kerning + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-kerning */ public class CssFontKerning extends org.w3c.css.properties.css.CssFontKerning { - public static final CssIdent normal; - public static final CssIdent auto; + public static final CssIdent[] allowedValues; static { - auto = CssIdent.getIdent("auto"); - normal = CssIdent.getIdent("normal"); + String[] _allowedValues = {"auto", "normal", "none"}; + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } + } + return null; } /** @@ -36,8 +50,7 @@ public CssFontKerning() { * Creates a new CssFontKerning * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontKerning(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -52,26 +65,18 @@ public CssFontKerning(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else if (normal.equals(ident)) { - value = normal; - } else if (auto.equals(ident)) { - value = auto; - } else if (none.equals(ident)) { - value = none; - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssFontLanguageOverride.java b/org/w3c/css/properties/css3/CssFontLanguageOverride.java index d55f9a658..3f846631b 100644 --- a/org/w3c/css/properties/css3/CssFontLanguageOverride.java +++ b/org/w3c/css/properties/css3/CssFontLanguageOverride.java @@ -38,8 +38,7 @@ public CssFontLanguageOverride() { * Creates a new CssFontLanguageOverride * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontLanguageOverride(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -56,39 +55,56 @@ public CssFontLanguageOverride(ApplContext ac, CssExpression expression, boolean switch (val.getType()) { case CssTypes.CSS_STRING: - CssString s = (CssString) val; - // limit of 3 characters + two surrounding quotes - if (s.toString().length() != 5) { - throw new InvalidParamException("value", - expression.getValue().toString(), - getPropertyName(), ac); + if (val.getRawType() == CssTypes.CSS_STRING) { + CssString s = (CssString) val; + int l = s.toString().length(); + // limit of 4characters + two surrounding quotes + if ((l < 4) || (l > 6)) { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + // we extract the 2, 3 or 4 letters from the quotes... + String tag = s.toString().substring(1, l - 1).toUpperCase(); + // align to 4 + switch (tag.length()) { + case 1: + tag = tag.concat(" "); + break; + case 2: + tag = tag.concat(" "); + break; + case 3: + tag = tag.concat(" "); + break; + default: + } + // valid values are specified here. + int idx = Arrays.binarySearch(OpenTypeLanguageSystemTag.tags, tag); + if (idx < 0) { + // TODO specific error code + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + // check if deprecated + idx = Arrays.binarySearch(OpenTypeLanguageSystemTag.deprecated_tags, tag); + if (idx >= 0) { + ac.getFrame().addWarning("deprecated", tag); + } } - // we extract the 3 letters from the quotes... - String tag = s.toString().substring(1, 4).toUpperCase(); - // valid values are specified here. - int idx = Arrays.binarySearch(OpenTypeLanguageSystemTag.tags, tag); - if (idx < 0) { - // TODO specific error code - throw new InvalidParamException("value", - expression.getValue().toString(), - getPropertyName(), ac); - } - value = s; + value = val; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - break; - } - if (normal.equals(ident)) { - value = normal; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || normal.equals(ident)) { + value = val; break; } + // unrecognized, let it fail default: throw new InvalidParamException("value", - expression.getValue().toString(), - getPropertyName(), ac); + val.toString(), getPropertyName(), ac); } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssFontOpticalSizing.java b/org/w3c/css/properties/css3/CssFontOpticalSizing.java new file mode 100644 index 000000000..2089e0d51 --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontOpticalSizing.java @@ -0,0 +1,89 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-optical-sizing + */ +public class CssFontOpticalSizing extends org.w3c.css.properties.css.CssFontOpticalSizing { + + public static final CssIdent[] allowedValues; + public static final String _allowedValues[] = {"auto", "none"}; + + static { + allowedValues = new CssIdent[_allowedValues.length]; + int i = 0; + for (String s : _allowedValues) { + allowedValues[i++] = CssIdent.getIdent(s); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + int idx = Arrays.binarySearch(allowedValues, ident); + if (idx >= 0) { + return allowedValues[idx]; + } + return null; + } + + /** + * Create a new CssFontOpticalSizing + */ + public CssFontOpticalSizing() { + value = initial; + } + + /** + * Creates a new CssFontOpticalSizing + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontOpticalSizing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssFontOpticalSizing(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssFontPalette.java b/org/w3c/css/properties/css3/CssFontPalette.java new file mode 100644 index 000000000..d4a550714 --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontPalette.java @@ -0,0 +1,90 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-palette + */ +public class CssFontPalette extends org.w3c.css.properties.css.CssFontPalette { + + public static final CssIdent[] allowedValues; + public static final String _allowedValues[] = {"none", "normal", "light", "dark"}; + + static { + allowedValues = new CssIdent[_allowedValues.length]; + int i = 0; + for (String s : _allowedValues) { + allowedValues[i++] = CssIdent.getIdent(s); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + int idx = Arrays.binarySearch(allowedValues, ident); + if (idx >= 0) { + return allowedValues[idx]; + } + return null; + } + + /** + * Create a new CssFontPalette + */ + public CssFontPalette() { + value = initial; + } + + /** + * Creates a new CssFontPalette + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontPalette(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || (getAllowedValue(ident) != null)) { + value = val; + expression.next(); + } else { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + } + + public CssFontPalette(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssFontSize.java b/org/w3c/css/properties/css3/CssFontSize.java index d84b2402b..d12bc91f1 100644 --- a/org/w3c/css/properties/css3/CssFontSize.java +++ b/org/w3c/css/properties/css3/CssFontSize.java @@ -7,7 +7,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; @@ -16,7 +15,7 @@ import java.util.Arrays; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-size-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-size */ public class CssFontSize extends org.w3c.css.properties.css.CssFontSize { @@ -24,7 +23,7 @@ public class CssFontSize extends org.w3c.css.properties.css.CssFontSize { static { - String[] absolute_values = {"xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large"}; + String[] absolute_values = {"xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "xxx-large"}; String[] relative_values = {"smaller", "larger"}; allowed_values = new CssIdent[absolute_values.length + relative_values.length]; @@ -57,8 +56,7 @@ public CssFontSize() { * Creates a new CssFontSize * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontSize(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -75,29 +73,20 @@ public CssFontSize(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_NUMBER: - val.getCheckableValue().checkEqualsZero(ac, this); + val.getCheckableValue().checkEqualsZero(ac, getPropertyName()); case CssTypes.CSS_LENGTH: case CssTypes.CSS_PERCENTAGE: - CssCheckableValue l = val.getCheckableValue(); - l.checkPositiveness(ac, this); - value = l; + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); + value = val; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || getAllowedValue(id) != null) { + value = val; break; } - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - expression.getValue().toString(), - getPropertyName(), ac); - } - break; default: - throw new InvalidParamException("value", - expression.getValue().toString(), + throw new InvalidParamException("value", val, getPropertyName(), ac); } expression.next(); diff --git a/org/w3c/css/properties/css3/CssFontSizeAdjust.java b/org/w3c/css/properties/css3/CssFontSizeAdjust.java index fe0d91ba9..25489b2d5 100644 --- a/org/w3c/css/properties/css3/CssFontSizeAdjust.java +++ b/org/w3c/css/properties/css3/CssFontSizeAdjust.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2013/CR-css-fonts-3-20131003/#propdef-font-size-adjust + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-size-adjust */ public class CssFontSizeAdjust extends org.w3c.css.properties.css.CssFontSizeAdjust { @@ -35,8 +35,7 @@ public CssFontSizeAdjust() { * Creates a new CssFontSizeAdjust * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontSizeAdjust(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -54,25 +53,20 @@ public CssFontSizeAdjust(ApplContext ac, CssExpression expression, boolean check switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent id = (CssIdent) val; - if (inherit.equals(id)) { - value = inherit; - } else { - value = getAllowedIdent(id); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || (getAllowedIdent(id) != null)) { + value = val; + break; } - break; + throw new InvalidParamException("value", + val, getPropertyName(), ac); case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkPositiveness(ac, getPropertyName()); value = val; break; default: throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + val, getPropertyName(), ac); } expression.next(); diff --git a/org/w3c/css/properties/css3/CssFontStretch.java b/org/w3c/css/properties/css3/CssFontStretch.java index 7f6d5b4e4..565cee2ae 100644 --- a/org/w3c/css/properties/css3/CssFontStretch.java +++ b/org/w3c/css/properties/css3/CssFontStretch.java @@ -15,7 +15,7 @@ import java.util.Arrays; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-stretch-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-stretch */ public class CssFontStretch extends org.w3c.css.properties.css.CssFontStretch { @@ -51,8 +51,7 @@ public CssFontStretch() { * Creates a new CssFontStretch * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontStretch(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -67,22 +66,24 @@ public CssFontStretch(ApplContext ac, CssExpression expression, boolean check) val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + switch (val.getType()) { + case CssTypes.CSS_PERCENTAGE: + value = val; + break; + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + value = val; + break; } - } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + if (getAllowedValue(id) != null) { + value = val; + break; + } + default: + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); } expression.next(); } diff --git a/org/w3c/css/properties/css3/CssFontStyle.java b/org/w3c/css/properties/css3/CssFontStyle.java index e85b42030..47f8f50ed 100644 --- a/org/w3c/css/properties/css3/CssFontStyle.java +++ b/org/w3c/css/properties/css3/CssFontStyle.java @@ -11,16 +11,20 @@ import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssValueList; import java.util.ArrayList; +import static org.w3c.css.values.CssOperator.SPACE; + /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-style-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-style */ public class CssFontStyle extends org.w3c.css.properties.css.CssFontStyle { static final String[] _allowed_values = {"italic", "normal", "oblique"}; static final ArrayList allowed_values; + static final CssIdent oblique = CssIdent.getIdent("oblique"); static { allowed_values = new ArrayList(_allowed_values.length); @@ -29,6 +33,15 @@ public class CssFontStyle extends org.w3c.css.properties.css.CssFontStyle { } } + public static CssIdent getMatchingIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + /** * Create a new CssFontStyle */ @@ -40,34 +53,68 @@ public CssFontStyle() { * Creates a new CssFontStyle * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontStyle(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; + CssIdent id; char op; val = expression.getValue(); op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; } else { - int pos = allowed_values.indexOf(ident); - if (pos < 0) { + id = getMatchingIdent(ident); + if (id == null) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = allowed_values.get(pos); + if (!oblique.equals(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + } else { + expression.next(); + // check for a possible angle + if (!expression.end()) { + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + CssValue v = expression.getValue(); + // FIXME TODO check for NUMBER 0 ? + if (v.getType() != CssTypes.CSS_ANGLE) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssValueList values = new CssValueList(); + values.add(val); + values.add(v); + value = values; + } else { + value = val; + } + } } } else { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFontSynthesis.java b/org/w3c/css/properties/css3/CssFontSynthesis.java index 158910ec6..1729f0265 100644 --- a/org/w3c/css/properties/css3/CssFontSynthesis.java +++ b/org/w3c/css/properties/css3/CssFontSynthesis.java @@ -9,24 +9,38 @@ import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; -import org.w3c.css.values.CssOperator; import org.w3c.css.values.CssTypes; import org.w3c.css.values.CssValue; import org.w3c.css.values.CssValueList; import java.util.ArrayList; +import java.util.Arrays; + +import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#propdef-font-synthesis + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-synthesis */ public class CssFontSynthesis extends org.w3c.css.properties.css.CssFontSynthesis { - public static final CssIdent style; - public static final CssIdent weight; + public static final CssIdent[] allowedValues; static { - style = CssIdent.getIdent("style"); - weight = CssIdent.getIdent("weight"); + String[] _allowedValues = {"weight", "style", "small-caps"}; + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } + } + return null; } /** @@ -40,81 +54,65 @@ public CssFontSynthesis() { * Creates a new CssFontSynthesis * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontSynthesis(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 2) { + if (check && expression.getCount() > allowedValues.length) { throw new InvalidParamException("unrecognize", ac); } setByUser(); CssValue val; + CssIdent okIdent; char op; + ArrayList values = new ArrayList<>(); + ArrayList ids = new ArrayList<>(); - val = expression.getValue(); - op = expression.getOperator(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else if (none.equals(ident)) { - value = none; - } else if (weight.equals(ident)) { - if (expression.getCount() > 1) { - if (op != CssOperator.SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - expression.next(); - val = expression.getValue(); - if (!style.equals(val)) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - ArrayList v = new ArrayList(2); - v.add(style); - v.add(weight); - value = new CssValueList(v); - } else { - value = weight; - } - } else if (style.equals(ident)) { - if (expression.getCount() > 1) { - if (op != CssOperator.SPACE) { - throw new InvalidParamException("operator", - Character.toString(op), ac); - } - expression.next(); - val = expression.getValue(); - if (!weight.equals(val)) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - ArrayList v = new ArrayList(2); - v.add(style); - v.add(weight); - value = new CssValueList(v); - } else { - value = style; - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || none.equals(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + } else { + okIdent = getAllowedValue(id); + if (okIdent == null) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + if (ids.contains(okIdent)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + values.add(val); + ids.add(okIdent); + + } + expression.next(); + if (!expression.end() && (op != SPACE)) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + } + if (!values.isEmpty()) { + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } - expression.next(); } public CssFontSynthesis(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssFontSynthesisSmallCaps.java b/org/w3c/css/properties/css3/CssFontSynthesisSmallCaps.java new file mode 100644 index 000000000..19ef71d5a --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontSynthesisSmallCaps.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-synthesis-small-caps + */ +public class CssFontSynthesisSmallCaps extends org.w3c.css.properties.css.CssFontSynthesisSmallCaps { + + public static final CssIdent[] allowedValues; + + static { + String[] _allowedValues = {"auto", "none"}; + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssFontSynthesisSmallCaps + */ + public CssFontSynthesisSmallCaps() { + value = initial; + } + + /** + * Creates a new CssFontSynthesisSmallCaps + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontSynthesisSmallCaps(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssFontSynthesisSmallCaps(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + diff --git a/org/w3c/css/properties/css3/CssFontSynthesisStyle.java b/org/w3c/css/properties/css3/CssFontSynthesisStyle.java new file mode 100644 index 000000000..0428cb2e2 --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontSynthesisStyle.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-synthesis-style + */ +public class CssFontSynthesisStyle extends org.w3c.css.properties.css.CssFontSynthesisStyle { + + public static final CssIdent[] allowedValues; + + static { + String[] _allowedValues = {"auto", "none"}; + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssFontSynthesisStyle + */ + public CssFontSynthesisStyle() { + value = initial; + } + + /** + * Creates a new CssFontSynthesisStyle + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontSynthesisStyle(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssFontSynthesisStyle(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + diff --git a/org/w3c/css/properties/css3/CssFontSynthesisWeight.java b/org/w3c/css/properties/css3/CssFontSynthesisWeight.java new file mode 100644 index 000000000..a4b46b4e3 --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontSynthesisWeight.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-synthesis-weight + */ +public class CssFontSynthesisWeight extends org.w3c.css.properties.css.CssFontSynthesisWeight { + + public static final CssIdent[] allowedValues; + + static { + String[] _allowedValues = {"auto", "none"}; + allowedValues = new CssIdent[_allowedValues.length]; + for (int i = 0; i < allowedValues.length; i++) { + allowedValues[i] = CssIdent.getIdent(_allowedValues[i]); + } + Arrays.sort(allowedValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + for (CssIdent id : allowedValues) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssFontSynthesisWeight + */ + public CssFontSynthesisWeight() { + value = initial; + } + + /** + * Creates a new CssFontSynthesisWeight + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontSynthesisWeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssFontSynthesisWeight(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + diff --git a/org/w3c/css/properties/css3/CssFontVariant.java b/org/w3c/css/properties/css3/CssFontVariant.java index 8607bf4d5..e9b424038 100644 --- a/org/w3c/css/properties/css3/CssFontVariant.java +++ b/org/w3c/css/properties/css3/CssFontVariant.java @@ -18,7 +18,7 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-variant-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant */ public class CssFontVariant extends org.w3c.css.properties.css.CssFontVariant { @@ -46,8 +46,7 @@ public class CssFontVariant extends org.w3c.css.properties.css.CssFontVariant { * Creates a new CssFontVariant * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariant(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -78,71 +77,72 @@ public CssFontVariant(ApplContext ac, CssExpression expression, boolean check) altExp.addValue(val); break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || normal.equals(id)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; - break; - } else if (normal.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = normal; + value = val; // normal also resets the values of individual // properties, so... altValue = new CssFontVariantAlternates(); - altValue.value = normal; + altValue.value = val; + capValue = new CssFontVariantCaps(); + capValue.value = val; + asiValue = new CssFontVariantEastAsian(); + asiValue.value = val; + ligValue = new CssFontVariantLigatures(); + ligValue.value = val; + numValue = new CssFontVariantNumeric(); + numValue.value = val; + break; + } else if (none.equals(id)) { + value = val; + altValue = new CssFontVariantAlternates(); capValue = new CssFontVariantCaps(); - capValue.value = normal; asiValue = new CssFontVariantEastAsian(); - asiValue.value = normal; ligValue = new CssFontVariantLigatures(); - ligValue.value = normal; + ligValue.value = val; numValue = new CssFontVariantNumeric(); - numValue.value = normal; break; } else { // we test the possible values // of the 5 possible properties - if (CssFontVariantCaps.getCapsValue(ident) != null) { + if (CssFontVariantCaps.getAllowedValue(id) != null) { if (capExp == null) { capExp = new CssExpression(); } - capExp.addValue(ident); + capExp.addValue(id); break; } - if (CssFontVariantNumeric.getAllowedValue(ident) != null) { + if (CssFontVariantNumeric.getAllowedValue(id) != null) { if (numExp == null) { numExp = new CssExpression(); } - numExp.addValue(ident); + numExp.addValue(id); break; } - if (CssFontVariantLigatures.getAllowedValue(ident) != null) { + if (CssFontVariantLigatures.getAllowedValue(id) != null) { if (ligExp == null) { ligExp = new CssExpression(); } - ligExp.addValue(ident); + ligExp.addValue(id); break; } - if (CssFontVariantEastAsian.getAllowedValue(ident) != null) { + if (CssFontVariantEastAsian.getAllowedValue(id) != null) { if (asiExp == null) { asiExp = new CssExpression(); } - asiExp.addValue(ident); + asiExp.addValue(id); break; } - if (CssFontVariantAlternates.getAllowedIdent(ident) != null) { + if (CssFontVariantAlternates.getAllowedIdent(id) != null) { if (altExp == null) { altExp = new CssExpression(); } - altExp.addValue(ident); + altExp.addValue(id); break; } } diff --git a/org/w3c/css/properties/css3/CssFontVariantAlternates.java b/org/w3c/css/properties/css3/CssFontVariantAlternates.java index a3ae574da..2055bc0f2 100644 --- a/org/w3c/css/properties/css3/CssFontVariantAlternates.java +++ b/org/w3c/css/properties/css3/CssFontVariantAlternates.java @@ -18,7 +18,7 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2012/WD-css3-fonts-20120823/#propdef-font-variant-alternates + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-alternates */ public class CssFontVariantAlternates extends org.w3c.css.properties.css.CssFontVariantAlternates { @@ -65,7 +65,7 @@ private void checkFuncExpression(ApplContext ac, CssExpression expression, getPropertyName(), ac); } expression.next(); - if (expression.getRemainingCount() > 0) { + if (!expression.end()) { if (op != CssOperator.COMMA) { throw new InvalidParamException("operator", Character.toString(op), ac); @@ -78,8 +78,7 @@ private void checkFuncExpression(ApplContext ac, CssExpression expression, * Creates a new CssFontVariantAlternates * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantAlternates(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -91,13 +90,13 @@ public CssFontVariantAlternates(ApplContext ac, CssExpression expression, boolea CssValue val; char op; - CssFunction stylistic = null; - CssIdent histValue = null; - CssFunction styleSet = null; - CssFunction charVariant = null; - CssFunction swash = null; - CssFunction ornaments = null; - CssFunction annotation = null; + CssValue stylistic = null; + CssValue histValue = null; + CssValue styleSet = null; + CssValue charVariant = null; + CssValue swash = null; + CssValue ornaments = null; + CssValue annotation = null; boolean match; while (!expression.end()) { @@ -106,29 +105,22 @@ public CssFontVariantAlternates(ApplContext ac, CssExpression expression, boolea switch (val.getType()) { case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || normal.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; - } else if (normal.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = normal; + value = val; } else { // no inherit, nor normal, test the up-to-(now one) values match = false; if (histValue == null) { - if (historicalForms.equals(ident)) { - histValue = historicalForms; - value = histValue; - match = true; + match = historicalForms.equals(ident); + if (match) { + histValue = val; + value = val; } } if (!match) { diff --git a/org/w3c/css/properties/css3/CssFontVariantCaps.java b/org/w3c/css/properties/css3/CssFontVariantCaps.java index b07bd63d7..6e9b3cb86 100644 --- a/org/w3c/css/properties/css3/CssFontVariantCaps.java +++ b/org/w3c/css/properties/css3/CssFontVariantCaps.java @@ -15,7 +15,7 @@ import java.util.Arrays; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-variant-caps-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-caps */ public class CssFontVariantCaps extends org.w3c.css.properties.css.CssFontVariantCaps { @@ -34,7 +34,7 @@ public class CssFontVariantCaps extends org.w3c.css.properties.css.CssFontVarian Arrays.sort(capsValues); } - public static final CssIdent getCapsValue(CssIdent ident) { + public static final CssIdent getAllowedValue(CssIdent ident) { int idx = Arrays.binarySearch(capsValues, ident); if (idx >= 0) { return capsValues[idx]; @@ -53,8 +53,7 @@ public CssFontVariantCaps() { * Creates a new CssFontVariantCaps * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantCaps(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -69,25 +68,20 @@ public CssFontVariantCaps(ApplContext ac, CssExpression expression, boolean chec val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else if (normal.equals(ident)) { - value = normal; - } else { - value = getCapsValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && + !normal.equals(ident) && + (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssFontVariantEastAsian.java b/org/w3c/css/properties/css3/CssFontVariantEastAsian.java index 12381ece3..fdac38d7b 100644 --- a/org/w3c/css/properties/css3/CssFontVariantEastAsian.java +++ b/org/w3c/css/properties/css3/CssFontVariantEastAsian.java @@ -18,7 +18,7 @@ import java.util.Arrays; /** - * @spec http://www.w3.org/TR/2012/WD-css3-fonts-20120823/#propdef-font-variant-east-asian + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-east-asian */ public class CssFontVariantEastAsian extends org.w3c.css.properties.css.CssFontVariantEastAsian { @@ -86,8 +86,7 @@ public CssFontVariantEastAsian() { * Creates a new CssFontVariantEastAsian * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantEastAsian(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -100,9 +99,9 @@ public CssFontVariantEastAsian(ApplContext ac, CssExpression expression, boolean CssValue val; char op; - CssIdent varValue = null; - CssIdent widValue = null; - CssIdent rubValue = null; + CssValue varValue = null; + CssValue widValue = null; + CssValue rubValue = null; boolean match; while (!expression.end()) { @@ -110,40 +109,38 @@ public CssFontVariantEastAsian(ApplContext ac, CssExpression expression, boolean op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || normal.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; - } else if (normal.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = normal; + value = val; } else { // no inherit, nor normal, test the up-to-three values match = false; if (varValue == null) { - varValue = getEastAsianVariantValue(ident); - value = varValue; - match = (varValue != null); + match = (getEastAsianVariantValue(ident) != null); + if (match) { + varValue = val; + value = val; + } } if (!match && (widValue == null)) { - widValue = getEastAsianWidthValue(ident); - value = widValue; - match = (widValue != null); + match = (getEastAsianWidthValue(ident) != null); + if (match) { + widValue = val; + value = val; + + } } if (!match && (rubValue == null)) { match = ruby.equals(ident); if (match) { - rubValue = ruby; - value = ruby; + rubValue = val; + value = val; } } if (!match) { diff --git a/org/w3c/css/properties/css3/CssFontVariantEmoji.java b/org/w3c/css/properties/css3/CssFontVariantEmoji.java new file mode 100644 index 000000000..e1dcc4de7 --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontVariantEmoji.java @@ -0,0 +1,89 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; + +import java.util.Arrays; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-emoji + */ +public class CssFontVariantEmoji extends org.w3c.css.properties.css.CssFontVariantEmoji { + + public static final CssIdent[] emojiValues; + public static final String _emojiValues[] = {"auto", "text", "emoji", "unicode"}; + + static { + emojiValues = new CssIdent[_emojiValues.length]; + int i = 0; + for (String s : _emojiValues) { + emojiValues[i++] = CssIdent.getIdent(s); + } + Arrays.sort(emojiValues); + } + + public static final CssIdent getAllowedValue(CssIdent ident) { + int idx = Arrays.binarySearch(emojiValues, ident); + if (idx >= 0) { + return emojiValues[idx]; + } + return null; + } + + /** + * Create a new CssFontVariantEmoji + */ + public CssFontVariantEmoji() { + value = initial; + } + + /** + * Creates a new CssFontVariantEmoji + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontVariantEmoji(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssFontVariantEmoji(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssFontVariantLigatures.java b/org/w3c/css/properties/css3/CssFontVariantLigatures.java index 1fcdd4a92..32a3e1d56 100644 --- a/org/w3c/css/properties/css3/CssFontVariantLigatures.java +++ b/org/w3c/css/properties/css3/CssFontVariantLigatures.java @@ -17,7 +17,7 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2012/WD-css3-fonts-20120823/#propdef-font-variant-ligatures + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-ligatures */ public class CssFontVariantLigatures extends org.w3c.css.properties.css.CssFontVariantLigatures { @@ -128,8 +128,7 @@ public CssFontVariantLigatures() { * Creates a new CssFontVariantLigatures * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantLigatures(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -142,10 +141,10 @@ public CssFontVariantLigatures(ApplContext ac, CssExpression expression, boolean CssValue val; char op; - CssIdent histValue = null; - CssIdent commonValue = null; - CssIdent discValue = null; - CssIdent altValue = null; + CssValue histValue = null; + CssValue commonValue = null; + CssValue discValue = null; + CssValue altValue = null; boolean match; while (!expression.end()) { @@ -153,46 +152,40 @@ public CssFontVariantLigatures(ApplContext ac, CssExpression expression, boolean op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || normal.equals(ident) || none.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; - } else if (normal.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = normal; - } else if (none.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = none; + value = val; } else { // no inherit, nor normal, test the up-to-three values match = false; if (commonValue == null) { - commonValue = getCommonLigValues(ident); - match = (commonValue != null); + match = (getCommonLigValues(ident) != null); + if (match) { + commonValue = val; + } } if (!match && histValue == null) { - histValue = getHistoricalLigValues(ident); - match = (histValue != null); + match = (getHistoricalLigValues(ident) != null); + if (match) { + histValue = val; + } } if (!match && discValue == null) { - discValue = getDiscretionaryLigValues(ident); - match = (discValue != null); + match = (getDiscretionaryLigValues(ident) != null); + if (match) { + discValue = val; + } } if (!match && altValue == null) { - altValue = getContextualAltValues(ident); - match = (altValue != null); + match = (getContextualAltValues(ident) != null); + if (match) { + altValue = val; + } } if (!match) { throw new InvalidParamException("value", diff --git a/org/w3c/css/properties/css3/CssFontVariantNumeric.java b/org/w3c/css/properties/css3/CssFontVariantNumeric.java index c19bbe5f8..0f75ea748 100644 --- a/org/w3c/css/properties/css3/CssFontVariantNumeric.java +++ b/org/w3c/css/properties/css3/CssFontVariantNumeric.java @@ -17,7 +17,7 @@ import java.util.ArrayList; /** - * @spec http://www.w3.org/TR/2012/WD-css3-fonts-20120823/#propdef-font-variant-numeric + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#font-variant-numeric-prop */ public class CssFontVariantNumeric extends org.w3c.css.properties.css.CssFontVariantNumeric { @@ -107,8 +107,7 @@ public CssFontVariantNumeric() { * Creates a new CssFontVariantNumeric * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantNumeric(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -121,11 +120,11 @@ public CssFontVariantNumeric(ApplContext ac, CssExpression expression, boolean c CssValue val; char op; - CssIdent fraValue = null; - CssIdent figValue = null; - CssIdent spaValue = null; - CssIdent zerValue = null; - CssIdent ordValue = null; + CssValue fraValue = null; + CssValue figValue = null; + CssValue spaValue = null; + CssValue zerValue = null; + CssValue ordValue = null; boolean match; while (!expression.end()) { @@ -133,46 +132,45 @@ public CssFontVariantNumeric(ApplContext ac, CssExpression expression, boolean c op = expression.getOperator(); if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident) || normal.equals(ident)) { if (expression.getCount() != 1) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - value = inherit; - } else if (normal.equals(ident)) { - if (expression.getCount() != 1) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - value = normal; + value = val; } else { // no inherit, nor normal, test the up-to-three values match = false; if (figValue == null) { - figValue = getNumericFigValues(ident); - match = (figValue != null); + match = (getNumericFigValues(ident) != null); + if (match) { + figValue = val; + } } if (!match && fraValue == null) { - fraValue = getNumericFraValues(ident); - match = (fraValue != null); + match = (getNumericFraValues(ident) != null); + if (match) { + fraValue = val; + } } if (!match && spaValue == null) { - spaValue = getNumericSpaValues(ident); - match = (spaValue != null); + match = (getNumericSpaValues(ident) != null); + if (match) { + spaValue = val; + } } if (!match && zerValue == null) { match = slashedZero.equals(ident); if (match) { - zerValue = slashedZero; + zerValue = val; } } if (!match && ordValue == null) { match = ordinal.equals(ident); if (match) { - ordValue = ordinal; + ordValue = val; } } if (!match) { diff --git a/org/w3c/css/properties/css3/CssFontVariantPosition.java b/org/w3c/css/properties/css3/CssFontVariantPosition.java index 4d449c346..1d6aa5a3d 100644 --- a/org/w3c/css/properties/css3/CssFontVariantPosition.java +++ b/org/w3c/css/properties/css3/CssFontVariantPosition.java @@ -15,7 +15,7 @@ import java.util.Arrays; /** - * @spec http://www.w3.org/TR/2012/WD-css3-fonts-20120823/#propdef-font-variant-position + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variant-position */ public class CssFontVariantPosition extends org.w3c.css.properties.css.CssFontVariantPosition { @@ -50,8 +50,7 @@ public CssFontVariantPosition() { * Creates a new CssFontVariantPosition * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontVariantPosition(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,23 +65,18 @@ public CssFontVariantPosition(ApplContext ac, CssExpression expression, boolean val = expression.getValue(); op = expression.getOperator(); - if (val.getType() == CssTypes.CSS_IDENT) { - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - } - } else { + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + CssIdent ident = val.getIdent(); + if (!CssIdent.isCssWide(ident) && (getAllowedValue(ident) == null)) { throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } + value = val; expression.next(); } diff --git a/org/w3c/css/properties/css3/CssFontVariationSettings.java b/org/w3c/css/properties/css3/CssFontVariationSettings.java new file mode 100644 index 000000000..41660b75a --- /dev/null +++ b/org/w3c/css/properties/css3/CssFontVariationSettings.java @@ -0,0 +1,138 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2021. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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.CssLayerList; +import org.w3c.css.values.CssString; +import org.w3c.css.values.CssTypes; +import org.w3c.css.values.CssValue; +import org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.COMMA; +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-variation-settings + */ +public class CssFontVariationSettings extends org.w3c.css.properties.css.CssFontVariationSettings { + + static final CssIdent normal = CssIdent.getIdent("normal"); + /** + * Create a new CssFontVariationSettings + */ + public CssFontVariationSettings() { + value = initial; + } + + /** + * Creates a new CssFontVariationSettings + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssFontVariationSettings(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + + setByUser(); + + CssValue val; + char op; + + val = expression.getValue(); + op = expression.getOperator(); + ArrayList values = new ArrayList<>(); + ArrayList layervalues = new ArrayList<>(); + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || normal.equals(id)) { + if (expression.getCount() != 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + value = val; + break; + } + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + case CssTypes.CSS_NUMBER: + if (layervalues.size() != 1) { + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + layervalues.add(val); + break; + case CssTypes.CSS_STRING: + if (val.getRawType() == CssTypes.CSS_STRING) { + CssString s = (CssString) val; + int l = s.toString().length(); + // limit of 4characters + two surrounding quotes + if (s.toString().length() != 6) { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + // FIXME TODO check + } + layervalues.add(val); + break; + default: + throw new InvalidParamException("value", + val.toString(), + getPropertyName(), ac); + } + expression.next(); + if (!layervalues.isEmpty()) { + if (layervalues.size() == 2) { + values.add(new CssValueList(layervalues)); + layervalues = new ArrayList<>(); + if (!expression.end()) { + if (op != COMMA) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + } + } else { + if (op != SPACE) { + throw new InvalidParamException("operator", + Character.toString(op), ac); + } + } + } + } + // sanity check + if (layervalues.size() == 1) { + throw new InvalidParamException("value", + layervalues.get(0).toString(), + getPropertyName(), ac); + } + if (!values.isEmpty()) { + value = (values.size() == 1) ? values.get(0) : new CssLayerList(values); + } + + } + + public CssFontVariationSettings(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssFontWeight.java b/org/w3c/css/properties/css3/CssFontWeight.java index 0f172e6b3..9ae1bb8ae 100644 --- a/org/w3c/css/properties/css3/CssFontWeight.java +++ b/org/w3c/css/properties/css3/CssFontWeight.java @@ -14,7 +14,7 @@ import org.w3c.css.values.CssValue; /** - * @spec http://www.w3.org/TR/2011/WD-css3-fonts-20111004/#font-weight-prop + * @spec https://www.w3.org/TR/2021/WD-css-fonts-4-20210729/#propdef-font-weight */ public class CssFontWeight extends org.w3c.css.properties.css.CssFontWeight { @@ -48,8 +48,7 @@ public CssFontWeight() { * Creates a new CssFontWeight * * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * @throws org.w3c.css.util.InvalidParamException Expressions are incorrect */ public CssFontWeight(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { @@ -66,42 +65,25 @@ public CssFontWeight(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_NUMBER: - CssNumber num = val.getNumber(); - switch (num.getInt()) { - case 100: - case 200: - case 300: - case 400: - case 500: - case 600: - case 700: - case 800: - case 900: - value = num; - break; - default: - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + if (val.getRawType() == CssTypes.CSS_NUMBER) { + CssNumber num = val.getNumber(); + num.checkGreaterEqualThan(ac, 1, this); + num.checkLowerEqualThan(ac, 1000, this); + } else { + // can at least check it is positive + val.getCheckableValue().checkStrictPositiveness(ac, getPropertyName()); } + value = val; break; case CssTypes.CSS_IDENT: - CssIdent ident = (CssIdent) val; - if (inherit.equals(ident)) { - value = inherit; + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id) || (getAllowedValue(id) != null)) { + value = val; break; } - value = getAllowedValue(ident); - if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - break; default: throw new InvalidParamException("value", - expression.getValue().toString(), - getPropertyName(), ac); + val.toString(), getPropertyName(), ac); } expression.next(); } diff --git a/org/w3c/css/values/external/OpenTypeLanguageSystemTag.java b/org/w3c/css/values/external/OpenTypeLanguageSystemTag.java index 8ebcd1d64..d1fffd277 100644 --- a/org/w3c/css/values/external/OpenTypeLanguageSystemTag.java +++ b/org/w3c/css/values/external/OpenTypeLanguageSystemTag.java @@ -8,54 +8,83 @@ /** * From https://www.microsoft.com/typography/otspec/languagetags.htm - * "This page was last updated 3 October 2011." - * $date$ + * Retrieved 11 September 2021 */ public class OpenTypeLanguageSystemTag { + public static final String[] deprecated_tags = {"DHV "}; + public static final String[] tags = { - "ABA", "ABK", "ADY", "AFK", "AFR", "AGW", "ALS", "ALT", "AMH", - "ARA", "ARI", "ARK", "ASM", "ATH", "AVR", "AWA", "AYM", "AZE", - "BAD", "BAG", "BAL", "BAU", "BBR", "BCH", "BCR", "BEL", "BEM", - "BEN", "BGR", "BHI", "BHO", "BIK", "BIL", "BKF", "BLI", "BLN", - "BLT", "BMB", "BML", "BOS", "BRE", "BRH", "BRI", "BRM", "BSH", - "BTI", "CAT", "CEB", "CHE", "CHG", "CHH", "CHI", "CHK", "CHP", - "CHR", "CHU", "CMR", "COP", "COS", "CRE", "CRR", "CRT", "CSL", - "CSY", "DAN", "DAR", "DCR", "DEU", "DGR", "DIV", "DJR", "DNG", - "DNK", "DRI", "DUN", "DZN", "EBI", "ECR", "EDO", "EFI", "ELL", - "ENG", "ERZ", "ESP", "ETI", "EUQ", "EVK", "EVN", "EWE", "FAN", - "FAR", "FIN", "FJI", "FLE", "FNE", "FON", "FOS", "FRA", "FRI", - "FRL", "FTA", "FUL", "GAD", "GAE", "GAG", "GAL", "GAR", "GAW", - "GEZ", "GIL", "GMZ", "GON", "GRN", "GRO", "GUA", "GUJ", "HAI", - "HAL", "HAR", "HAU", "HAW", "HBN", "HIL", "HIN", "HMA", "HND", - "HRI", "HRV", "HUN", "HYE", "IBO", "IJO", "ILO", "IND", "ING", - "INU", "IRI", "IRT", "ISL", "ISM", "ITA", "IWR", "JAN", "JAV", - "JII", "JUD", "JUL", "KAB", "KAC", "KAL", "KAN", "KAR", "KAT", - "KAZ", "KEB", "KGE", "KHA", "KHK", "KHM", "KHS", "KHV", "KHW", - "KIK", "KIR", "KIS", "KKN", "KLM", "KMB", "KMN", "KMO", "KMS", - "KNR", "KOD", "KOH", "KOK", "KON", "KOP", "KOR", "KOZ", "KPL", - "KRI", "KRK", "KRL", "KRM", "KRN", "KRT", "KSH", "KSI", "KSM", - "KUI", "KUL", "KUM", "KUR", "KUU", "KUY", "KYK", "LAD", "LAH", - "LAK", "LAM", "LAO", "LAT", "LAZ", "LCR", "LDK", "LEZ", "LIN", - "LMA", "LMB", "LMW", "LSB", "LSM", "LTH", "LTZ", "LUB", "LUG", - "LUH", "LUO", "LVI", "MAJ", "MAK", "MAL", "MAN", "MAP", "MAR", - "MAW", "MBN", "MCH", "MCR", "MDE", "MEN", "MIZ", "MKD", "MLE", - "MLG", "MLN", "MLR", "MLY", "MND", "MNG", "MNI", "MNK", "MNX", - "MOH", "MOK", "MOL", "MON", "MOR", "MRI", "MTH", "MTS", "MUN", - "NAG", "NAN", "NAS", "NCR", "NDB", "NDG", "NEP", "NEW", "NGR", - "NHC", "NIS", "NIU", "NKL", "NKO", "NLD", "NOG", "NOR", "NSM", - "NTA", "NTO", "NYN", "OCI", "OCR", "OJB", "ORI", "ORO", "OSS", - "PAA", "PAL", "PAN", "PAP", "PAS", "PGR", "PIL", "PLG", "PLK", - "PRO", "PTG", "QIN", "RAJ", "RBU", "RCR", "RIA", "RMS", "ROM", - "ROY", "RSY", "RUA", "RUS", "SAD", "SAN", "SAT", "SAY", "SEK", - "SEL", "SGO", "SHN", "SIB", "SID", "SIG", "SKS", "SKY", "SLA", - "SLV", "SML", "SMO", "SNA", "SND", "SNH", "SNK", "SOG", "SOT", - "SQI", "SRB", "SRK", "SRR", "SSL", "SSM", "SUR", "SVA", "SVE", - "SWA", "SWK", "SWZ", "SXT", "SYR", "TAB", "TAJ", "TAM", "TAT", - "TCR", "TEL", "TGN", "TGR", "TGY", "THA", "THT", "TIB", "TKM", - "TMN", "TNA", "TNE", "TNG", "TOD", "TRK", "TSG", "TUA", "TUL", - "TUV", "TWI", "UDM", "UKR", "URD", "USB", "UYG", "UZB", "VEN", - "VIT", "WAG", "WCR", "WEL", "WLF", "XBD", "XHS", "YAK", "YBA", - "YCR", "YIC", "YIM", "ZHH", "ZHP", "ZHS", "ZHT", "ZND", "ZUL" + "ABA ", "ABK ", "ACH ", "ACR ", "ADY ", "AFK ", "AFR ", "AGW ", "AIO ", + "AKA ", "AKB ", "ALS ", "ALT ", "AMH ", "ANG ", "APPH", "ARA ", "ARG ", + "ARI ", "ARK ", "ASM ", "AST ", "ATH ", "AVN ", "AVR ", "AWA ", "AYM ", + "AZB ", "AZE ", "BAD ", "BAD0", "BAG ", "BAL ", "BAN ", "BAR ", "BAU ", + "BBC ", "BBR ", "BCH ", "BCR ", "BDY ", "BEL ", "BEM ", "BEN ", "BGC ", + "BGQ ", "BGR ", "BHI ", "BHO ", "BIK ", "BIL ", "BIS ", "BJJ ", "BKF ", + "BLI ", "BLK ", "BLN ", "BLT ", "BMB ", "BML ", "BOS ", "BPY ", "BRE ", + "BRH ", "BRI ", "BRM ", "BRX ", "BSH ", "BSK ", "BTD ", "BTI ", "BTK ", + "BTM ", "BTS ", "BTX ", "BTZ ", "BUG ", "BYV ", "CAK ", "CAT ", "CBK ", + "CCHN", "CEB ", "CGG ", "CHA ", "CHE ", "CHG ", "CHH ", "CHI ", "CHK ", + "CHK0", "CHO ", "CHP ", "CHR ", "CHU ", "CHY ", "CJA ", "CJM ", "CMR ", + "COP ", "COR ", "COS ", "CPP ", "CRE ", "CRR ", "CRT ", "CSB ", "CSL ", + "CSY ", "CTG ", "CTT ", "CUK ", "DAG ", "DAN ", "DAR ", "DAX ", "DCR ", + "DEU ", "DGO ", "DGR ", "DHG ", "DHV ", "DIQ ", "DIV ", "DJR ", "DJR0", + "DNG ", "DNJ ", "DNK ", "DRI ", "DUJ ", "DUN ", "DZN ", "EBI ", "ECR ", + "EDO ", "EFI ", "ELL ", "EMK ", "ENG ", "ERZ ", "ESP ", "ESU ", "ETI ", + "EUQ ", "EVK ", "EVN ", "EWE ", "FAN ", "FAN0", "FAR ", "FAT ", "FIN ", + "FJI ", "FLE ", "FMP ", "FNE ", "FON ", "FOS ", "FRA ", "FRC ", "FRI ", + "FRL ", "FRP ", "FTA ", "FUL ", "FUV ", "GAD ", "GAE ", "GAG ", "GAL ", + "GAR ", "GAW ", "GEZ ", "GIH ", "GIL ", "GIL0", "GKP ", "GLK ", "GMZ ", + "GNN ", "GOG ", "GON ", "GRN ", "GRO ", "GUA ", "GUC ", "GUF ", "GUJ ", + "GUZ ", "HAI ", "HAI0", "HAL ", "HAR ", "HAU ", "HAW ", "HAY ", "HAZ ", + "HBN ", "HEI ", "HER ", "HIL ", "HIN ", "HMA ", "HMD ", "HMN ", "HMO ", + "HMZ ", "HND ", "HO ", "HRI ", "HRV ", "HUN ", "HYE ", "HYE0", "IBA ", + "IBB ", "IBO ", "IDO ", "IJO ", "ILE ", "ILO ", "INA ", "IND ", "ING ", + "INU ", "IPK ", "IPPH", "IRI ", "IRT ", "IRU ", "ISL ", "ISM ", "ITA ", + "IWR ", "JAM ", "JAN ", "JAV ", "JBO ", "JCT ", "JII ", "JUD ", "JUL ", + "KAB ", "KAB0", "KAC ", "KAL ", "KAN ", "KAR ", "KAT ", "KAW ", "KAZ ", + "KDE ", "KEA ", "KEB ", "KEK ", "KGE ", "KHA ", "KHK ", "KHM ", "KHS ", + "KHT ", "KHV ", "KHW ", "KIK ", "KIR ", "KIS ", "KIU ", "KJD ", "KJP ", + "KJZ ", "KKN ", "KLM ", "KMB ", "KMN ", "KMO ", "KMS ", "KMZ ", "KNR ", + "KOD ", "KOH ", "KOK ", "KOM ", "KON ", "KON0", "KOP ", "KOR ", "KOS ", + "KOZ ", "KPL ", "KRI ", "KRK ", "KRL ", "KRM ", "KRN ", "KRT ", "KSH ", + "KSH0", "KSI ", "KSM ", "KSW ", "KUA ", "KUI ", "KUL ", "KUM ", "KUR ", + "KUU ", "KUY ", "KWK ", "KYK ", "KYU ", "LAD ", "LAH ", "LAK ", "LAM ", + "LAO ", "LAT ", "LAZ ", "LCR ", "LDK ", "LEF ", "LEZ ", "LIJ ", "LIM ", + "LIN ", "LIS ", "LJP ", "LKI ", "LMA ", "LMB ", "LMO ", "LMW ", "LOM ", + "LPO ", "LRC ", "LSB ", "LSM ", "LTH ", "LTZ ", "LUA ", "LUB ", "LUG ", + "LUH ", "LUO ", "LVI ", "MAD ", "MAG ", "MAH ", "MAJ ", "MAK ", "MAL ", + "MAM ", "MAN ", "MAP ", "MAR ", "MAW ", "MBN ", "MBO ", "MCH ", "MCR ", + "MDE ", "MDR ", "MEN ", "MER ", "MFA ", "MFE ", "MIN ", "MIZ ", "MKD ", + "MKR ", "MKW ", "MLE ", "MLG ", "MLN ", "MLR ", "MLY ", "MND ", "MNG ", + "MNI ", "MNK ", "MNX ", "MOH ", "MOK ", "MOL ", "MON ", "MOR ", "MOS ", + "MRI ", "MTH ", "MTS ", "MUN ", "MUS ", "MWL ", "MWW ", "MYN ", "MZN ", + "NAG ", "NAH ", "NAN ", "NAP ", "NAS ", "NAU ", "NAV ", "NCR ", "NDB ", + "NDC ", "NDG ", "NDS ", "NEP ", "NEW ", "NGA ", "NGR ", "NHC ", "NIS ", + "NIU ", "NKL ", "NKO ", "NLD ", "NOE ", "NOG ", "NOR ", "NOV ", "NSM ", + "NSO ", "NTA ", "NTO ", "NYM ", "NYN ", "NZA ", "OCI ", "OCR ", "OJB ", + "ORI ", "ORO ", "OSS ", "PAA ", "PAG ", "PAL ", "PAM ", "PAN ", "PAP ", + "PAP0", "PAS ", "PAU ", "PCC ", "PCD ", "PDC ", "PGR ", "PHK ", "PIH ", + "PIL ", "PLG ", "PLK ", "PMS ", "PNB ", "POH ", "PON ", "PRO ", "PTG ", + "PWO ", "QIN ", "QUC ", "QUH ", "QUZ ", "QVI ", "QWH ", "RAJ ", "RAR ", + "RBU ", "RCR ", "REJ ", "RIA ", "RHG ", "RIF ", "RIT ", "RKW ", "RMS ", + "RMY ", "ROM ", "ROY ", "RSY ", "RTM ", "RUA ", "RUN ", "RUP ", "RUS ", + "SAD ", "SAN ", "SAS ", "SAT ", "SAY ", "SCN ", "SCO ", "SCS ", "SEK ", + "SEL ", "SFM ", "SGA ", "SGO ", "SGS ", "SHI ", "SHN ", "SIB ", "SID ", + "SIG ", "SKS ", "SKY ", "SLA ", "SLV ", "SML ", "SMO ", "SNA ", "SNA0", + "SND ", "SNH ", "SNK ", "SOG ", "SOP ", "SOT ", "SQI ", "SRB ", "SRD ", + "SRK ", "SRR ", "SSL ", "SSM ", "STQ ", "SUK ", "SUN ", "SUR ", "SVA ", + "SVE ", "SWA ", "SWK ", "SWZ ", "SXT ", "SXU ", "SYL ", "SYR ", "SYRE", + "SYRJ", "SYRN", "SZL ", "TAB ", "TAJ ", "TAM ", "TAT ", "TCR ", "TDD ", + "TEL ", "TET ", "TGL ", "TGN ", "TGR ", "TGY ", "THA ", "THT ", "TIB ", + "TIV ", "TKM ", "TLI ", "TMH ", "TMN ", "TNA ", "TNE ", "TNG ", "TOD ", + "TOD0", "TPI ", "TRK ", "TSG ", "TSJ ", "TUA ", "TUL ", "TUM ", "TUV ", + "TVL ", "TWI ", "TYZ ", "TZM ", "TZO ", "UDM ", "UKR ", "UMB ", "URD ", + "USB ", "UYG ", "UZB ", "VEC ", "VEN ", "VIT ", "VOL ", "VRO ", "WA ", + "WAG ", "WAR ", "WCI ", "WCR ", "WEL ", "WLF ", "WLN ", "WTM ", "XBD ", + "XHS ", "XJB ", "XKF ", "XOG ", "XPE ", "XUB ", "XUJ ", "YAK ", "YAO ", + "YAP ", "YBA ", "YCR ", "YGP ", "YIC ", "YIM ", "YNA ", "YWQ ", "ZEA ", + "ZGH ", "ZHA ", "ZHH ", "ZHP ", "ZHS ", "ZHT ", "ZHTM", "ZND ", "ZUL ", + "ZZA ", }; } From 10f25a12ec79edcfc2167426d09b5e72af35d7e5 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 12 Sep 2021 10:38:39 +0200 Subject: [PATCH 81/82] remove redundant check --- org/w3c/css/properties/css3/CssOpacity.java | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/org/w3c/css/properties/css3/CssOpacity.java b/org/w3c/css/properties/css3/CssOpacity.java index 99da7b51c..d1c6a3a5f 100644 --- a/org/w3c/css/properties/css3/CssOpacity.java +++ b/org/w3c/css/properties/css3/CssOpacity.java @@ -9,7 +9,6 @@ import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; -import org.w3c.css.values.CssCheckableValue; import org.w3c.css.values.CssExpression; import org.w3c.css.values.CssIdent; import org.w3c.css.values.CssNumber; @@ -46,23 +45,20 @@ public CssOpacity(ApplContext ac, CssExpression expression, boolean check) switch (val.getType()) { case CssTypes.CSS_NUMBER: if (val.getRawType() == CssTypes.CSS_NUMBER) { - CssCheckableValue v = val.getCheckableValue(); - if (!v.isPositive()) { + if (!val.getCheckableValue().isPositive()) { ac.getFrame().addWarning("out-of-range", val.toString()); CssNumber nb = new CssNumber(); nb.setIntValue(0); value = nb; break; } - if (val.getRawType() == CssTypes.CSS_NUMBER) { - BigDecimal pp = ((CssNumber) val).getBigDecimalValue(); - if (pp.compareTo(BigDecimal.ONE) > 0) { - ac.getFrame().addWarning("out-of-range", val.toString()); - CssNumber nb = new CssNumber(); - nb.setIntValue(1); - value = nb; - break; - } + BigDecimal pp = val.getNumber().getBigDecimalValue(); + if (pp.compareTo(BigDecimal.ONE) > 0) { + ac.getFrame().addWarning("out-of-range", val.toString()); + CssNumber nb = new CssNumber(); + nb.setIntValue(1); + value = nb; + break; } } else { // we can only check if >= 0 for now @@ -72,8 +68,7 @@ public CssOpacity(ApplContext ac, CssExpression expression, boolean check) break; case CssTypes.CSS_PERCENTAGE: // This starts with CSS Color 4 - CssCheckableValue v = val.getCheckableValue(); - if (!v.isPositive()) { + if (!val.getCheckableValue().isPositive()) { ac.getFrame().addWarning("out-of-range", val.toString()); CssNumber nb = new CssNumber(); nb.setIntValue(0); From f44bf1d0a9ef984e2d0989daeeabc20f23063ebe Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 12 Sep 2021 11:15:13 +0200 Subject: [PATCH 82/82] fix remaining CssIdent casts --- org/w3c/css/properties/css3/CssBackgroundPosition.java | 6 +++--- org/w3c/css/properties/css3/CssVoiceFamily.java | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/org/w3c/css/properties/css3/CssBackgroundPosition.java b/org/w3c/css/properties/css3/CssBackgroundPosition.java index 0b628d200..a8220fc16 100644 --- a/org/w3c/css/properties/css3/CssBackgroundPosition.java +++ b/org/w3c/css/properties/css3/CssBackgroundPosition.java @@ -515,15 +515,15 @@ public static CssValue checkSyntax(ApplContext ac, CssExpression expression, Str for (CssValue aValue : v) { switch (aValue.getType()) { case CssTypes.CSS_IDENT: - if (getMatchingIdent((CssIdent) aValue) == null) { + if (getMatchingIdent(aValue.getIdent()) == null) { throw new InvalidParamException("value", aValue, caller, ac); } got_ident = true; if (id1 == null) { - id1 = (CssIdent) aValue; + id1 = aValue.getIdent(); } else { - id2 = (CssIdent) aValue; + id2 = aValue.getIdent(); // we got both, let's check. if (((isVertical(id1) && isVertical(id2))) || (isHorizontal(id1) && isHorizontal(id2))) { diff --git a/org/w3c/css/properties/css3/CssVoiceFamily.java b/org/w3c/css/properties/css3/CssVoiceFamily.java index 6e61f7fb2..6325bd48e 100644 --- a/org/w3c/css/properties/css3/CssVoiceFamily.java +++ b/org/w3c/css/properties/css3/CssVoiceFamily.java @@ -208,7 +208,8 @@ private void checkExpression(ApplContext ac, ArrayList curval, getPropertyName(), ac); } // ok so now check that we have a generic value in nameVal - if (getGenericVoiceName((CssIdent) nameVal) == null) { + if ((nameVal.getType() == CssTypes.CSS_IDENT) + && (getGenericVoiceName(nameVal.getIdent()) == null)) { throw new InvalidParamException("value", nameVal, getPropertyName(), ac); }