From be172718f70c397fd32c7c7b6b63c8620b1a9cc6 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 18 Mar 2024 18:26:14 +0100 Subject: [PATCH 01/37] word-space-transform per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-space-transform --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssWordSpaceTransform.java | 113 +++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssTextTransform.java | 2 +- .../css3/CssWordSpaceTransform.java | 130 ++++++++++++++++++ 5 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 org/w3c/css/properties/css/CssWordSpaceTransform.java create mode 100644 org/w3c/css/properties/css3/CssWordSpaceTransform.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 233dbec19..5fcdee7a2 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -226,6 +226,7 @@ hanging-punctuation: org.w3c.css.properties.css3.CssHangingPu text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright text-orientation: org.w3c.css.properties.css3.CssTextOrientation glyph-orientation-vertical: org.w3c.css.properties.css3.CssGlyphOrientationVertical +word-space-transform: org.w3c.css.properties.css3.CssWordSpaceTransform # marquee diff --git a/org/w3c/css/properties/css/CssWordSpaceTransform.java b/org/w3c/css/properties/css/CssWordSpaceTransform.java new file mode 100644 index 000000000..33290234b --- /dev/null +++ b/org/w3c/css/properties/css/CssWordSpaceTransform.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssWordSpaceTransform extends CssProperty { + + /** + * Create a new CssWordSpaceTransform + */ + public CssWordSpaceTransform() { + } + + /** + * Creates a new CssWordSpaceTransform + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWordSpaceTransform(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWordSpaceTransform(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 "content-visibility"; + } + + /** + * 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.cssWordSpaceTransform != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWordSpaceTransform = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWordSpaceTransform && + value.equals(((CssWordSpaceTransform) 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).getWordSpaceTransform(); + } else { + return ((Css3Style) style).cssWordSpaceTransform; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 32587f40a..47ebf0ac0 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -297,6 +297,7 @@ import org.w3c.css.properties.css.CssVoiceVolume; import org.w3c.css.properties.css.CssWillChange; import org.w3c.css.properties.css.CssWordBreak; +import org.w3c.css.properties.css.CssWordSpaceTransform; import org.w3c.css.properties.css.CssWritingMode; import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols; import org.w3c.css.properties.css.counterstyle.CssFallback; @@ -684,7 +685,17 @@ public class Css3Style extends ATSCStyle { public CssOverscrollBehaviorBlock cssOverscrollBehaviorBlock; public CssOverscrollBehaviorInline cssOverscrollBehaviorInline; public CssContentVisibility cssContentVisibility; + + public CssWordSpaceTransform cssWordSpaceTransform; + public CssWordSpaceTransform getWordSpaceTransform() { + if (cssWordSpaceTransform == null) { + cssWordSpaceTransform = + (CssWordSpaceTransform) style.CascadingOrder(new CssWordSpaceTransform(), + style, selector); + } + return cssWordSpaceTransform; + } public CssContentVisibility getContentVisibility() { if (cssContentVisibility == null) { cssContentVisibility = diff --git a/org/w3c/css/properties/css3/CssTextTransform.java b/org/w3c/css/properties/css3/CssTextTransform.java index 6f943f80c..50cbe6c3f 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/2021/CRD-css-text-3-20210422/#propdef-text-transform + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-transform */ public class CssTextTransform extends org.w3c.css.properties.css.CssTextTransform { diff --git a/org/w3c/css/properties/css3/CssWordSpaceTransform.java b/org/w3c/css/properties/css3/CssWordSpaceTransform.java new file mode 100644 index 000000000..a58fcc3b7 --- /dev/null +++ b/org/w3c/css/properties/css3/CssWordSpaceTransform.java @@ -0,0 +1,130 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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 org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-space-transform + */ +public class CssWordSpaceTransform extends org.w3c.css.properties.css.CssWordSpaceTransform { + + private static CssIdent[] allowed_action_values; + private static CssIdent autoPhrase; + + + static { + autoPhrase = CssIdent.getIdent("auto-phrase"); + + String id_values[] = {"space", "ideographic-space"}; + allowed_action_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_action_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingMainIdent(CssIdent ident) { + for (CssIdent id : allowed_action_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssWordSpaceTransform + */ + public CssWordSpaceTransform() { + value = initial; + } + + /** + * Creates a new CssWordSPaceTransform + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWordSpaceTransform(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); + char op; + ArrayList values = new ArrayList<>(); + boolean got_main = false; + boolean got_auto = false; + + if (check && expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (none.equals(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (autoPhrase.equals(val.getIdent()) && !got_auto) { + got_auto = true; + values.add(val); + } else if (!got_main) { + if (getMatchingMainIdent(val.getIdent()) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + got_main = true; + values.add(val); + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); + } + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } + + public CssWordSpaceTransform(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From 493dd9f4597e3065e9e292a1a6399a938fe77e85 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 10:37:09 +0100 Subject: [PATCH 02/37] text-wrap-mode per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-wrap-mode --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssTextWrapMode.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssTextWrapMode.java | 88 ++++++++++++++ 4 files changed, 213 insertions(+) create mode 100644 org/w3c/css/properties/css/CssTextWrapMode.java create mode 100644 org/w3c/css/properties/css3/CssTextWrapMode.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 5fcdee7a2..9bde60084 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -220,6 +220,7 @@ text-emphasis-style: org.w3c.css.properties.css3.CssTextEmpha text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition +text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode tab-size: org.w3c.css.properties.css3.CssTabSize hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation diff --git a/org/w3c/css/properties/css/CssTextWrapMode.java b/org/w3c/css/properties/css/CssTextWrapMode.java new file mode 100644 index 000000000..2525dcfb6 --- /dev/null +++ b/org/w3c/css/properties/css/CssTextWrapMode.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssTextWrapMode extends CssProperty { + + /** + * Create a new CssTextWrapMode + */ + public CssTextWrapMode() { + } + + /** + * Creates a new CssTextWrapMode + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssTextWrapMode(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextWrapMode(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 "content-visibility"; + } + + /** + * 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.cssTextWrapMode != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextWrapMode = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextWrapMode && + value.equals(((CssTextWrapMode) 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).getTextWrapMode(); + } else { + return ((Css3Style) style).cssTextWrapMode; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 47ebf0ac0..09ee7eb47 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -277,6 +277,7 @@ import org.w3c.css.properties.css.CssTextSizeAdjust; import org.w3c.css.properties.css.CssTextUnderlineOffset; import org.w3c.css.properties.css.CssTextUnderlinePosition; +import org.w3c.css.properties.css.CssTextWrapMode; import org.w3c.css.properties.css.CssTouchAction; import org.w3c.css.properties.css.CssTransform; import org.w3c.css.properties.css.CssTransformBox; @@ -687,7 +688,17 @@ public class Css3Style extends ATSCStyle { public CssContentVisibility cssContentVisibility; public CssWordSpaceTransform cssWordSpaceTransform; + public CssTextWrapMode cssTextWrapMode; + + public CssTextWrapMode getTextWrapMode() { + if (cssTextWrapMode == null) { + cssTextWrapMode = + (CssTextWrapMode) style.CascadingOrder(new CssTextWrapMode(), + style, selector); + } + return cssTextWrapMode; + } public CssWordSpaceTransform getWordSpaceTransform() { if (cssWordSpaceTransform == null) { cssWordSpaceTransform = diff --git a/org/w3c/css/properties/css3/CssTextWrapMode.java b/org/w3c/css/properties/css3/CssTextWrapMode.java new file mode 100644 index 000000000..857cfa09f --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextWrapMode.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-text-wrap-mode + */ +public class CssTextWrapMode extends org.w3c.css.properties.css.CssTextWrapMode { + + private static CssIdent[] allowed_idents; + + + static { + + String id_values[] = {"wrap", "nowrap"}; + allowed_idents = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_idents[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_idents) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssTextWrapMode + */ + public CssTextWrapMode() { + value = initial; + } + + /** + * Creates a new CssTextWrapMode + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextWrapMode(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, + 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(); + } + + public CssTextWrapMode(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From 34ae5fa5ef0b4b3a01f87c146ae2adb3ab38e36c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 10:45:34 +0100 Subject: [PATCH 03/37] wrap-inside per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-wrap-inside --- .../css/properties/CSS3Properties.properties | 1 + org/w3c/css/properties/css/CssWrapInside.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 13 +- .../css/properties/css3/CssWrapInside.java | 88 ++++++++++++++ 4 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 org/w3c/css/properties/css/CssWrapInside.java create mode 100644 org/w3c/css/properties/css3/CssWrapInside.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 9bde60084..700843684 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -223,6 +223,7 @@ text-underline-position: org.w3c.css.properties.css3.CssTextUnder text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode tab-size: org.w3c.css.properties.css3.CssTabSize hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation +wrap-inside: org.w3c.css.properties.css3.CssWrapInside text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright text-orientation: org.w3c.css.properties.css3.CssTextOrientation diff --git a/org/w3c/css/properties/css/CssWrapInside.java b/org/w3c/css/properties/css/CssWrapInside.java new file mode 100644 index 000000000..739a4af38 --- /dev/null +++ b/org/w3c/css/properties/css/CssWrapInside.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssWrapInside extends CssProperty { + + /** + * Create a new CssWrapInside + */ + public CssWrapInside() { + } + + /** + * Creates a new CssWrapInside + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWrapInside(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWrapInside(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 "content-visibility"; + } + + /** + * 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.cssWrapInside != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWrapInside = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWrapInside && + value.equals(((CssWrapInside) 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).getWrapInside(); + } else { + return ((Css3Style) style).cssWrapInside; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 09ee7eb47..b31e9a396 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -299,6 +299,7 @@ import org.w3c.css.properties.css.CssWillChange; import org.w3c.css.properties.css.CssWordBreak; import org.w3c.css.properties.css.CssWordSpaceTransform; +import org.w3c.css.properties.css.CssWrapInside; import org.w3c.css.properties.css.CssWritingMode; import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols; import org.w3c.css.properties.css.counterstyle.CssFallback; @@ -686,10 +687,19 @@ public class Css3Style extends ATSCStyle { public CssOverscrollBehaviorBlock cssOverscrollBehaviorBlock; public CssOverscrollBehaviorInline cssOverscrollBehaviorInline; public CssContentVisibility cssContentVisibility; - + public CssWordSpaceTransform cssWordSpaceTransform; public CssTextWrapMode cssTextWrapMode; + public CssWrapInside cssWrapInside; + public CssWrapInside getWrapInside() { + if (cssWrapInside == null) { + cssWrapInside = + (CssWrapInside) style.CascadingOrder(new CssWrapInside(), + style, selector); + } + return cssWrapInside; + } public CssTextWrapMode getTextWrapMode() { if (cssTextWrapMode == null) { @@ -699,6 +709,7 @@ public CssTextWrapMode getTextWrapMode() { } return cssTextWrapMode; } + public CssWordSpaceTransform getWordSpaceTransform() { if (cssWordSpaceTransform == null) { cssWordSpaceTransform = diff --git a/org/w3c/css/properties/css3/CssWrapInside.java b/org/w3c/css/properties/css3/CssWrapInside.java new file mode 100644 index 000000000..62cea9186 --- /dev/null +++ b/org/w3c/css/properties/css3/CssWrapInside.java @@ -0,0 +1,88 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-wrap-inside + */ +public class CssWrapInside extends org.w3c.css.properties.css.CssWrapInside { + + private static CssIdent[] allowed_idents; + + + static { + + String[] id_values = {"auto", "avoid"}; + allowed_idents = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_idents[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_idents) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssWrapInside + */ + public CssWrapInside() { + value = initial; + } + + /** + * Creates a new CssWrapInside + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWrapInside(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, + 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(); + } + + public CssWrapInside(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From 8cd1f6b2c9f25ee4949e4b4c2bae96d3ad4b957e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 11:36:25 +0100 Subject: [PATCH 04/37] wrap-after per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-wrap-after --- .../css/properties/CSS3Properties.properties | 1 + org/w3c/css/properties/css/CssWrapAfter.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ org/w3c/css/properties/css3/CssWrapAfter.java | 87 ++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 org/w3c/css/properties/css/CssWrapAfter.java create mode 100644 org/w3c/css/properties/css3/CssWrapAfter.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 700843684..0aef63c4d 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -223,6 +223,7 @@ text-underline-position: org.w3c.css.properties.css3.CssTextUnder text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode tab-size: org.w3c.css.properties.css3.CssTabSize hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation +wrap-after: org.w3c.css.properties.css3.CssWrapAfter wrap-inside: org.w3c.css.properties.css3.CssWrapInside text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright diff --git a/org/w3c/css/properties/css/CssWrapAfter.java b/org/w3c/css/properties/css/CssWrapAfter.java new file mode 100644 index 000000000..a7398af37 --- /dev/null +++ b/org/w3c/css/properties/css/CssWrapAfter.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssWrapAfter extends CssProperty { + + /** + * Create a new CssWrapAfter + */ + public CssWrapAfter() { + } + + /** + * Creates a new CssWrapAfter + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWrapAfter(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWrapAfter(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 "content-visibility"; + } + + /** + * 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.cssWrapAfter != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWrapAfter = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWrapAfter && + value.equals(((CssWrapAfter) 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).getWrapAfter(); + } else { + return ((Css3Style) style).cssWrapAfter; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index b31e9a396..22139e67d 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -299,6 +299,7 @@ import org.w3c.css.properties.css.CssWillChange; import org.w3c.css.properties.css.CssWordBreak; import org.w3c.css.properties.css.CssWordSpaceTransform; +import org.w3c.css.properties.css.CssWrapAfter; import org.w3c.css.properties.css.CssWrapInside; import org.w3c.css.properties.css.CssWritingMode; import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols; @@ -691,7 +692,17 @@ public class Css3Style extends ATSCStyle { public CssWordSpaceTransform cssWordSpaceTransform; public CssTextWrapMode cssTextWrapMode; public CssWrapInside cssWrapInside; + public CssWrapAfter cssWrapAfter; + public CssWrapAfter getWrapAfter() { + if (cssWrapAfter == null) { + cssWrapAfter = + (CssWrapAfter) style.CascadingOrder(new CssWrapAfter(), + style, selector); + } + return cssWrapAfter; + } + public CssWrapInside getWrapInside() { if (cssWrapInside == null) { cssWrapInside = diff --git a/org/w3c/css/properties/css3/CssWrapAfter.java b/org/w3c/css/properties/css3/CssWrapAfter.java new file mode 100644 index 000000000..eb9502d5a --- /dev/null +++ b/org/w3c/css/properties/css3/CssWrapAfter.java @@ -0,0 +1,87 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-wrap-after + */ +public class CssWrapAfter extends org.w3c.css.properties.css.CssWrapAfter { + + private static final CssIdent[] allowed_idents; + + + static { + String[] id_values = {"auto", "avoid", "avoid-line", "avoid-flex", "line", "flex"}; + allowed_idents = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_idents[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_idents) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssWrapAfter + */ + public CssWrapAfter() { + value = initial; + } + + /** + * Creates a new CssWrapAfter + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWrapAfter(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, + 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(); + } + + public CssWrapAfter(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From 50510fbab552271f2bb800892485eb383b52c664 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 11:40:30 +0100 Subject: [PATCH 05/37] wrap-before per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-wrap-before --- .../css/properties/CSS3Properties.properties | 1 + org/w3c/css/properties/css/CssWrapBefore.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssWrapBefore.java | 70 +++++++++++ 4 files changed, 195 insertions(+) create mode 100644 org/w3c/css/properties/css/CssWrapBefore.java create mode 100644 org/w3c/css/properties/css3/CssWrapBefore.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 0aef63c4d..fd3297431 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -224,6 +224,7 @@ text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode tab-size: org.w3c.css.properties.css3.CssTabSize hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation wrap-after: org.w3c.css.properties.css3.CssWrapAfter +wrap-before: org.w3c.css.properties.css3.CssWrapBefore wrap-inside: org.w3c.css.properties.css3.CssWrapInside text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright diff --git a/org/w3c/css/properties/css/CssWrapBefore.java b/org/w3c/css/properties/css/CssWrapBefore.java new file mode 100644 index 000000000..c0af4ea55 --- /dev/null +++ b/org/w3c/css/properties/css/CssWrapBefore.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssWrapBefore extends CssProperty { + + /** + * Create a new CssWrapBefore + */ + public CssWrapBefore() { + } + + /** + * Creates a new CssWrapBefore + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWrapBefore(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWrapBefore(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 "content-visibility"; + } + + /** + * 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.cssWrapBefore != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWrapBefore = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWrapBefore && + value.equals(((CssWrapBefore) 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).getWrapBefore(); + } else { + return ((Css3Style) style).cssWrapBefore; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 22139e67d..7e8cafa36 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -300,6 +300,7 @@ import org.w3c.css.properties.css.CssWordBreak; import org.w3c.css.properties.css.CssWordSpaceTransform; import org.w3c.css.properties.css.CssWrapAfter; +import org.w3c.css.properties.css.CssWrapBefore; import org.w3c.css.properties.css.CssWrapInside; import org.w3c.css.properties.css.CssWritingMode; import org.w3c.css.properties.css.counterstyle.CssAdditiveSymbols; @@ -693,7 +694,17 @@ public class Css3Style extends ATSCStyle { public CssTextWrapMode cssTextWrapMode; public CssWrapInside cssWrapInside; public CssWrapAfter cssWrapAfter; + public CssWrapBefore cssWrapBefore; + public CssWrapBefore getWrapBefore() { + if (cssWrapBefore == null) { + cssWrapBefore = + (CssWrapBefore) style.CascadingOrder(new CssWrapBefore(), + style, selector); + } + return cssWrapBefore; + } + public CssWrapAfter getWrapAfter() { if (cssWrapAfter == null) { cssWrapAfter = diff --git a/org/w3c/css/properties/css3/CssWrapBefore.java b/org/w3c/css/properties/css3/CssWrapBefore.java new file mode 100644 index 000000000..a6eafb2ac --- /dev/null +++ b/org/w3c/css/properties/css3/CssWrapBefore.java @@ -0,0 +1,70 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-wrap-before + */ +public class CssWrapBefore extends org.w3c.css.properties.css.CssWrapBefore { + /* See @CssWrapAfter */ + public static CssIdent getAllowedIdent(CssIdent ident) { + return CssWrapAfter.getAllowedIdent(ident); + } + + /** + * Create a new CssWrapBefore + */ + public CssWrapBefore() { + value = initial; + } + + /** + * Creates a new CssWrapBefore + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWrapBefore(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, + 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(); + } + + public CssWrapBefore(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From b88d8cbce3a32a8d7581802631438538041f3ded Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 12:05:45 +0100 Subject: [PATCH 06/37] text-wrap-style per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-wrap-style --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssTextWrapStyle.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssTextWrapStyle.java | 87 ++++++++++++++ 4 files changed, 212 insertions(+) create mode 100644 org/w3c/css/properties/css/CssTextWrapStyle.java create mode 100644 org/w3c/css/properties/css3/CssTextWrapStyle.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index fd3297431..8a58d1abb 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -221,6 +221,7 @@ text-size-adjust: org.w3c.css.properties.css3.CssTextSizeA text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode +text-wrap-style: org.w3c.css.properties.css3.CssTextWrapStyle tab-size: org.w3c.css.properties.css3.CssTabSize hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation wrap-after: org.w3c.css.properties.css3.CssWrapAfter diff --git a/org/w3c/css/properties/css/CssTextWrapStyle.java b/org/w3c/css/properties/css/CssTextWrapStyle.java new file mode 100644 index 000000000..00347482d --- /dev/null +++ b/org/w3c/css/properties/css/CssTextWrapStyle.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssTextWrapStyle extends CssProperty { + + /** + * Create a new CssTextWrapStyle + */ + public CssTextWrapStyle() { + } + + /** + * Creates a new CssTextWrapStyle + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssTextWrapStyle(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextWrapStyle(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 "text-wrap-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.cssTextWrapStyle != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextWrapStyle = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextWrapStyle && + value.equals(((CssTextWrapStyle) 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).getTextWrapStyle(); + } else { + return ((Css3Style) style).cssTextWrapStyle; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 7e8cafa36..077259c4d 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -278,6 +278,7 @@ import org.w3c.css.properties.css.CssTextUnderlineOffset; import org.w3c.css.properties.css.CssTextUnderlinePosition; import org.w3c.css.properties.css.CssTextWrapMode; +import org.w3c.css.properties.css.CssTextWrapStyle; import org.w3c.css.properties.css.CssTouchAction; import org.w3c.css.properties.css.CssTransform; import org.w3c.css.properties.css.CssTransformBox; @@ -692,6 +693,7 @@ public class Css3Style extends ATSCStyle { public CssWordSpaceTransform cssWordSpaceTransform; public CssTextWrapMode cssTextWrapMode; + public CssTextWrapStyle cssTextWrapStyle; public CssWrapInside cssWrapInside; public CssWrapAfter cssWrapAfter; public CssWrapBefore cssWrapBefore; @@ -723,6 +725,15 @@ public CssWrapInside getWrapInside() { return cssWrapInside; } + public CssTextWrapStyle getTextWrapStyle() { + if (cssTextWrapStyle == null) { + cssTextWrapStyle = + (CssTextWrapStyle) style.CascadingOrder(new CssTextWrapStyle(), + style, selector); + } + return cssTextWrapStyle; + } + public CssTextWrapMode getTextWrapMode() { if (cssTextWrapMode == null) { cssTextWrapMode = diff --git a/org/w3c/css/properties/css3/CssTextWrapStyle.java b/org/w3c/css/properties/css3/CssTextWrapStyle.java new file mode 100644 index 000000000..981f20b33 --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextWrapStyle.java @@ -0,0 +1,87 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-text-wrap-style + */ +public class CssTextWrapStyle extends org.w3c.css.properties.css.CssTextWrapStyle { + + private static CssIdent[] allowed_idents; + + static { + + String id_values[] = {"auto", "balance", "stable", "pretty"}; + allowed_idents = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_idents[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_idents) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssTextWrapStyle + */ + public CssTextWrapStyle() { + value = initial; + } + + /** + * Creates a new CssTextWrapStyle + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextWrapStyle(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, + 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(); + } + + public CssTextWrapStyle(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From 09d66703128a741fe95927f5276434ae2bfcd975 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 12:06:19 +0100 Subject: [PATCH 07/37] fix copy/paste issue --- org/w3c/css/properties/css/CssTextWrapMode.java | 2 +- org/w3c/css/properties/css/CssWordSpaceTransform.java | 2 +- org/w3c/css/properties/css/CssWrapAfter.java | 2 +- org/w3c/css/properties/css/CssWrapBefore.java | 2 +- org/w3c/css/properties/css/CssWrapInside.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/org/w3c/css/properties/css/CssTextWrapMode.java b/org/w3c/css/properties/css/CssTextWrapMode.java index 2525dcfb6..afe06c780 100644 --- a/org/w3c/css/properties/css/CssTextWrapMode.java +++ b/org/w3c/css/properties/css/CssTextWrapMode.java @@ -53,7 +53,7 @@ public Object get() { * Returns the name of this property */ public final String getPropertyName() { - return "content-visibility"; + return "text-wrap-mode"; } /** diff --git a/org/w3c/css/properties/css/CssWordSpaceTransform.java b/org/w3c/css/properties/css/CssWordSpaceTransform.java index 33290234b..d3005f2a3 100644 --- a/org/w3c/css/properties/css/CssWordSpaceTransform.java +++ b/org/w3c/css/properties/css/CssWordSpaceTransform.java @@ -53,7 +53,7 @@ public Object get() { * Returns the name of this property */ public final String getPropertyName() { - return "content-visibility"; + return "word-space-transform"; } /** diff --git a/org/w3c/css/properties/css/CssWrapAfter.java b/org/w3c/css/properties/css/CssWrapAfter.java index a7398af37..7026769bf 100644 --- a/org/w3c/css/properties/css/CssWrapAfter.java +++ b/org/w3c/css/properties/css/CssWrapAfter.java @@ -53,7 +53,7 @@ public Object get() { * Returns the name of this property */ public final String getPropertyName() { - return "content-visibility"; + return "wrap-after"; } /** diff --git a/org/w3c/css/properties/css/CssWrapBefore.java b/org/w3c/css/properties/css/CssWrapBefore.java index c0af4ea55..29fef92a4 100644 --- a/org/w3c/css/properties/css/CssWrapBefore.java +++ b/org/w3c/css/properties/css/CssWrapBefore.java @@ -53,7 +53,7 @@ public Object get() { * Returns the name of this property */ public final String getPropertyName() { - return "content-visibility"; + return "wrap-before"; } /** diff --git a/org/w3c/css/properties/css/CssWrapInside.java b/org/w3c/css/properties/css/CssWrapInside.java index 739a4af38..b6c1a0efd 100644 --- a/org/w3c/css/properties/css/CssWrapInside.java +++ b/org/w3c/css/properties/css/CssWrapInside.java @@ -53,7 +53,7 @@ public Object get() { * Returns the name of this property */ public final String getPropertyName() { - return "content-visibility"; + return "wrap-inside"; } /** From 55875a117eefb71f0d19171199d5089fd948c336 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 13:30:59 +0100 Subject: [PATCH 08/37] updated reference --- org/w3c/css/properties/css3/CssTabSize.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTabSize.java b/org/w3c/css/properties/css3/CssTabSize.java index c6becc24b..799978f26 100644 --- a/org/w3c/css/properties/css3/CssTabSize.java +++ b/org/w3c/css/properties/css3/CssTabSize.java @@ -14,7 +14,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2017/WD-css-text-3-20170822/#tab-size-property + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-tab-size */ public class CssTabSize extends org.w3c.css.properties.css.CssTabSize { From 4363bdcde8742bf351b3de5f01f8578b744b0279 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Tue, 19 Mar 2024 14:43:32 +0100 Subject: [PATCH 09/37] text-wrap per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-wrap This fixes #415 --- .../css/properties/CSS3Properties.properties | 1 + org/w3c/css/properties/css/CssTextWrap.java | 113 ++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 32 +++-- org/w3c/css/properties/css3/CssTextWrap.java | 124 ++++++++++++++++++ 4 files changed, 260 insertions(+), 10 deletions(-) create mode 100644 org/w3c/css/properties/css/CssTextWrap.java create mode 100644 org/w3c/css/properties/css3/CssTextWrap.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 8a58d1abb..be04e9129 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -220,6 +220,7 @@ text-emphasis-style: org.w3c.css.properties.css3.CssTextEmpha text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition +text-wrap: org.w3c.css.properties.css3.CssTextWrap text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode text-wrap-style: org.w3c.css.properties.css3.CssTextWrapStyle tab-size: org.w3c.css.properties.css3.CssTabSize diff --git a/org/w3c/css/properties/css/CssTextWrap.java b/org/w3c/css/properties/css/CssTextWrap.java new file mode 100644 index 000000000..f1b2992d7 --- /dev/null +++ b/org/w3c/css/properties/css/CssTextWrap.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssTextWrap extends CssProperty { + + /** + * Create a new CssTextWrap + */ + public CssTextWrap() { + } + + /** + * Creates a new CssTextWrap + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssTextWrap(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextWrap(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 "text-wrap"; + } + + /** + * 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.cssTextWrap != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextWrap = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextWrap && + value.equals(((CssTextWrap) 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).getTextWrap(); + } else { + return ((Css3Style) style).cssTextWrap; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 077259c4d..5f1e00813 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -277,6 +277,7 @@ import org.w3c.css.properties.css.CssTextSizeAdjust; import org.w3c.css.properties.css.CssTextUnderlineOffset; import org.w3c.css.properties.css.CssTextUnderlinePosition; +import org.w3c.css.properties.css.CssTextWrap; import org.w3c.css.properties.css.CssTextWrapMode; import org.w3c.css.properties.css.CssTextWrapStyle; import org.w3c.css.properties.css.CssTouchAction; @@ -612,7 +613,7 @@ public class Css3Style extends ATSCStyle { public org.w3c.css.properties.css.fontface.CssFontFamily fontFaceCssFontFamily; public org.w3c.css.properties.css.fontface.CssFontFeatureSettings fontFaceCssFontFeatureSettings; public org.w3c.css.properties.css.fontface.CssFontVariationSettings fontFaceCssFontVariationSettings; - + public CssColorAdjust cssColorAdjust; public CssForcedColorAdjust cssForcedColorAdjust; public CssColorScheme cssColorScheme; @@ -697,6 +698,7 @@ public class Css3Style extends ATSCStyle { public CssWrapInside cssWrapInside; public CssWrapAfter cssWrapAfter; public CssWrapBefore cssWrapBefore; + public CssTextWrap cssTextWrap; public CssWrapBefore getWrapBefore() { if (cssWrapBefore == null) { @@ -706,7 +708,7 @@ public CssWrapBefore getWrapBefore() { } return cssWrapBefore; } - + public CssWrapAfter getWrapAfter() { if (cssWrapAfter == null) { cssWrapAfter = @@ -715,7 +717,7 @@ public CssWrapAfter getWrapAfter() { } return cssWrapAfter; } - + public CssWrapInside getWrapInside() { if (cssWrapInside == null) { cssWrapInside = @@ -725,6 +727,15 @@ public CssWrapInside getWrapInside() { return cssWrapInside; } + public CssTextWrap getTextWrap() { + if (cssTextWrap == null) { + cssTextWrap = + (CssTextWrap) style.CascadingOrder(new CssTextWrap(), + style, selector); + } + return cssTextWrap; + } + public CssTextWrapStyle getTextWrapStyle() { if (cssTextWrapStyle == null) { cssTextWrapStyle = @@ -733,7 +744,7 @@ public CssTextWrapStyle getTextWrapStyle() { } return cssTextWrapStyle; } - + public CssTextWrapMode getTextWrapMode() { if (cssTextWrapMode == null) { cssTextWrapMode = @@ -751,6 +762,7 @@ public CssWordSpaceTransform getWordSpaceTransform() { } return cssWordSpaceTransform; } + public CssContentVisibility getContentVisibility() { if (cssContentVisibility == null) { cssContentVisibility = @@ -759,7 +771,7 @@ public CssContentVisibility getContentVisibility() { } return cssContentVisibility; } - + public CssOverscrollBehavior getOverscrollBehavior() { if (cssOverscrollBehavior == null) { cssOverscrollBehavior = @@ -795,7 +807,7 @@ public CssOverscrollBehaviorBlock getOverscrollBehaviorBlock() { } return cssOverscrollBehaviorBlock; } - + public CssOverscrollBehaviorInline getOverscrollBehaviorInline() { if (cssOverscrollBehaviorInline == null) { cssOverscrollBehaviorInline = @@ -1461,7 +1473,7 @@ public org.w3c.css.properties.css.fontface.CssFontVariationSettings getFontFaceC } return fontFaceCssFontVariationSettings; } - + public CssUnicodeRange getFontFaceCssUnicodeRange() { if (fontFaceCssUnicodeRange == null) { fontFaceCssUnicodeRange = @@ -1479,7 +1491,7 @@ public org.w3c.css.properties.css.fontface.CssFontLanguageOverride getFontFaceCs } return fontFaceCssFontLanguageOverride; } - + public CssAscentOverride getFontFaceCssAscentOverride() { if (fontFaceCssAscentOverride == null) { fontFaceCssAscentOverride = @@ -1515,7 +1527,7 @@ public CssFontNamedInstance getFontFaceCssFontNamedInstance() { } return fontFaceCssFontNamedInstance; } - + public CssFontDisplay getFontFaceCssFontDisplay() { if (fontFaceCssFontDisplay == null) { fontFaceCssFontDisplay = @@ -1542,7 +1554,7 @@ public CssFontStyle getFontFaceCssFontStyle() { } return fontFaceCssFontStyle; } - + public CssFontWeight getFontFaceCssFontWeight() { if (fontFaceCssFontWeight == null) { fontFaceCssFontWeight = diff --git a/org/w3c/css/properties/css3/CssTextWrap.java b/org/w3c/css/properties/css3/CssTextWrap.java new file mode 100644 index 000000000..4ce65f69a --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextWrap.java @@ -0,0 +1,124 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 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.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; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-wrap + */ +public class CssTextWrap extends org.w3c.css.properties.css.CssTextWrap { + + private CssTextWrapMode _longhand_mode; + private CssTextWrapStyle _longhand_style; + + /** + * Create a new CssTextWrap + */ + public CssTextWrap() { + value = initial; + _longhand_mode = new CssTextWrapMode(); + _longhand_style = new CssTextWrapStyle(); + } + + /** + * Creates a new CssTextWrap + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextWrap(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + CssValue val; + char op; + ArrayList values = new ArrayList<>(); + _longhand_mode = new CssTextWrapMode(); + _longhand_style = new CssTextWrapStyle(); + boolean _got_mode = false; + boolean _got_style = false; + + if (check && expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + for (int i = 0; i < 2 && !expression.end(); i++) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + _longhand_mode.value = val; + _longhand_style.value = val; + break; + } else { + CssIdent id = CssTextWrapMode.getAllowedIdent(val.getIdent()); + if (_got_mode && (id != null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } else if (id != null) { + values.add(val); + _got_mode = true; + _longhand_mode.value = val; + } else { + id = CssTextWrapStyle.getAllowedIdent(val.getIdent()); + if (_got_style || (id == null)) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + _got_style = true; + _longhand_style.value = val; + } + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); + } + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } + + public CssTextWrap(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + /** + * Add this property to the CssStyle. + * + * @param style The CssStyle + */ + public void addToStyle(ApplContext ac, CssStyle style) { + super.addToStyle(ac, style); + _longhand_mode.addToStyle(ac, style); + _longhand_style.addToStyle(ac, style); + } +} + From ef6daa7556610e78702614cab62db9cc6a94e643 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 20 Mar 2024 10:16:27 +0100 Subject: [PATCH 10/37] white-space-trim per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-white-space-trim --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssWhiteSpaceTrim.java | 112 +++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../properties/css3/CssWhiteSpaceTrim.java | 135 ++++++++++++++++++ 4 files changed, 259 insertions(+) create mode 100644 org/w3c/css/properties/css/CssWhiteSpaceTrim.java create mode 100644 org/w3c/css/properties/css3/CssWhiteSpaceTrim.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index be04e9129..d624e539a 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -228,6 +228,7 @@ hanging-punctuation: org.w3c.css.properties.css3.CssHangingPu wrap-after: org.w3c.css.properties.css3.CssWrapAfter wrap-before: org.w3c.css.properties.css3.CssWrapBefore wrap-inside: org.w3c.css.properties.css3.CssWrapInside +white-space-trim: org.w3c.css.properties.css3.CssWhiteSpaceTrim text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright text-orientation: org.w3c.css.properties.css3.CssTextOrientation diff --git a/org/w3c/css/properties/css/CssWhiteSpaceTrim.java b/org/w3c/css/properties/css/CssWhiteSpaceTrim.java new file mode 100644 index 000000000..63db9917c --- /dev/null +++ b/org/w3c/css/properties/css/CssWhiteSpaceTrim.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssWhiteSpaceTrim extends CssProperty { + + /** + * Create a new CssWhiteSpaceTrim + */ + public CssWhiteSpaceTrim() { + } + + /** + * Creates a new CssWhiteSpaceTrim + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWhiteSpaceTrim(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 "white-space-trim"; + } + + /** + * 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.cssWhiteSpaceTrim != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWhiteSpaceTrim = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWhiteSpaceTrim && + value.equals(((CssWhiteSpaceTrim) 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).getWhiteSpaceTrim(); + } else { + return ((Css3Style) style).cssWhiteSpaceTrim; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 5f1e00813..17f840d72 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -298,6 +298,7 @@ import org.w3c.css.properties.css.CssVoiceRate; import org.w3c.css.properties.css.CssVoiceStress; import org.w3c.css.properties.css.CssVoiceVolume; +import org.w3c.css.properties.css.CssWhiteSpaceTrim; import org.w3c.css.properties.css.CssWillChange; import org.w3c.css.properties.css.CssWordBreak; import org.w3c.css.properties.css.CssWordSpaceTransform; @@ -699,7 +700,17 @@ public class Css3Style extends ATSCStyle { public CssWrapAfter cssWrapAfter; public CssWrapBefore cssWrapBefore; public CssTextWrap cssTextWrap; + public CssWhiteSpaceTrim cssWhiteSpaceTrim; + public CssWhiteSpaceTrim getWhiteSpaceTrim() { + if (cssWhiteSpaceTrim == null) { + cssWhiteSpaceTrim = + (CssWhiteSpaceTrim) style.CascadingOrder(new CssWhiteSpaceTrim(), + style, selector); + } + return cssWhiteSpaceTrim; + } + public CssWrapBefore getWrapBefore() { if (cssWrapBefore == null) { cssWrapBefore = diff --git a/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java new file mode 100644 index 000000000..251f2e9cd --- /dev/null +++ b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java @@ -0,0 +1,135 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-transform + */ +public class CssWhiteSpaceTrim extends org.w3c.css.properties.css.CssTextTransform { + + private static CssIdent[] allowed_action_values; + private static CssIdent fullWidth, fullSizeKana; + + + static { + fullWidth = CssIdent.getIdent("full-width"); + fullSizeKana = CssIdent.getIdent("full-size-kana"); + + String id_values[] = {"capitalize", "uppercase", "lowercase"}; + allowed_action_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_action_values[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getMatchingActionIdent(CssIdent ident) { + for (CssIdent id : allowed_action_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssTextTransform + */ + public CssWhiteSpaceTrim() { + value = initial; + } + + /** + * Creates a new CssTextTransform + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); + char op; + ArrayList values = new ArrayList<>(); + boolean got_action = false; + boolean got_full_width = false; + boolean got_full_size_kana = false; + + if (check && expression.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (none.equals(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (fullWidth.equals(val.getIdent()) && !got_full_width) { + got_full_width = true; + values.add(val); + } else if (fullSizeKana.equals(val.getIdent()) && !got_full_size_kana) { + got_full_size_kana = true; + values.add(val); + } else if (!got_action) { + if (getMatchingActionIdent(val.getIdent()) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + got_action = true; + values.add(val); + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); + } + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } + + public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From bc0b013a240ec88bca5fa9fb82eeb0ebe2cddc27 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 20 Mar 2024 10:16:52 +0100 Subject: [PATCH 11/37] (c) --- org/w3c/css/properties/css3/CssTabSize.java | 4 +- org/w3c/css/properties/css3/CssTextWrap.java | 2 +- .../css/properties/css3/CssTextWrapMode.java | 2 +- .../css/properties/css3/CssTextWrapStyle.java | 2 +- .../properties/css3/CssWhiteSpaceTrim.java | 46 +++++++------------ .../css3/CssWordSpaceTransform.java | 2 +- org/w3c/css/properties/css3/CssWrapAfter.java | 2 +- .../css/properties/css3/CssWrapBefore.java | 2 +- .../css/properties/css3/CssWrapInside.java | 2 +- 9 files changed, 26 insertions(+), 38 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTabSize.java b/org/w3c/css/properties/css3/CssTabSize.java index 799978f26..133d57676 100644 --- a/org/w3c/css/properties/css3/CssTabSize.java +++ b/org/w3c/css/properties/css3/CssTabSize.java @@ -1,7 +1,7 @@ -// $Id$ +// // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM and Keio University, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssTextWrap.java b/org/w3c/css/properties/css3/CssTextWrap.java index 4ce65f69a..72f6a47c6 100644 --- a/org/w3c/css/properties/css3/CssTextWrap.java +++ b/org/w3c/css/properties/css3/CssTextWrap.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssTextWrapMode.java b/org/w3c/css/properties/css3/CssTextWrapMode.java index 857cfa09f..2ee9d7f3c 100644 --- a/org/w3c/css/properties/css3/CssTextWrapMode.java +++ b/org/w3c/css/properties/css3/CssTextWrapMode.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssTextWrapStyle.java b/org/w3c/css/properties/css3/CssTextWrapStyle.java index 981f20b33..f5b64aa30 100644 --- a/org/w3c/css/properties/css3/CssTextWrapStyle.java +++ b/org/w3c/css/properties/css3/CssTextWrapStyle.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java index 251f2e9cd..d8dca9082 100644 --- a/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java +++ b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java @@ -18,28 +18,23 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-transform + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-white-space-trim */ -public class CssWhiteSpaceTrim extends org.w3c.css.properties.css.CssTextTransform { - - private static CssIdent[] allowed_action_values; - private static CssIdent fullWidth, fullSizeKana; +public class CssWhiteSpaceTrim extends org.w3c.css.properties.css.CssWhiteSpaceTrim { + private final static CssIdent[] allowed_values; static { - fullWidth = CssIdent.getIdent("full-width"); - fullSizeKana = CssIdent.getIdent("full-size-kana"); - - String id_values[] = {"capitalize", "uppercase", "lowercase"}; - allowed_action_values = new CssIdent[id_values.length]; + String[] id_values = {"discard-before", "discard-after", "discard-inner"}; + allowed_values = new CssIdent[id_values.length]; int i = 0; for (String s : id_values) { - allowed_action_values[i++] = CssIdent.getIdent(s); + allowed_values[i++] = CssIdent.getIdent(s); } } - public static CssIdent getMatchingActionIdent(CssIdent ident) { - for (CssIdent id : allowed_action_values) { + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; } @@ -48,28 +43,25 @@ public static CssIdent getMatchingActionIdent(CssIdent ident) { } /** - * Create a new CssTextTransform + * Create a new CssWhiteSpaceTrim */ public CssWhiteSpaceTrim() { value = initial; } /** - * Creates a new CssTextTransform + * Creates a new CssWhiteSpaceTrim * * @param expression The expression for this property - * @throws InvalidParamException - * Expressions are incorrect + * @throws InvalidParamException Expressions are incorrect */ public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); CssValue val = expression.getValue(); + CssIdent id; char op; ArrayList values = new ArrayList<>(); - boolean got_action = false; - boolean got_full_width = false; - boolean got_full_size_kana = false; if (check && expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); @@ -99,19 +91,14 @@ public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check getPropertyName(), ac); } values.add(val); - } else if (fullWidth.equals(val.getIdent()) && !got_full_width) { - got_full_width = true; - values.add(val); - } else if (fullSizeKana.equals(val.getIdent()) && !got_full_size_kana) { - got_full_size_kana = true; - values.add(val); - } else if (!got_action) { - if (getMatchingActionIdent(val.getIdent()) == null) { + } else if ((id = getAllowedIdent(val.getIdent())) != null) { + // check for duplicates. + // TODO Should it be a warning instead? + if (values.contains(id)) { throw new InvalidParamException("value", expression.getValue(), getPropertyName(), ac); } - got_action = true; values.add(val); } else { throw new InvalidParamException("value", @@ -125,6 +112,7 @@ public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check expression.next(); } value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssWordSpaceTransform.java b/org/w3c/css/properties/css3/CssWordSpaceTransform.java index a58fcc3b7..d0b9d92ea 100644 --- a/org/w3c/css/properties/css3/CssWordSpaceTransform.java +++ b/org/w3c/css/properties/css3/CssWordSpaceTransform.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssWrapAfter.java b/org/w3c/css/properties/css3/CssWrapAfter.java index eb9502d5a..6ac05b8c9 100644 --- a/org/w3c/css/properties/css3/CssWrapAfter.java +++ b/org/w3c/css/properties/css3/CssWrapAfter.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssWrapBefore.java b/org/w3c/css/properties/css3/CssWrapBefore.java index a6eafb2ac..ed29f01ab 100644 --- a/org/w3c/css/properties/css3/CssWrapBefore.java +++ b/org/w3c/css/properties/css3/CssWrapBefore.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; diff --git a/org/w3c/css/properties/css3/CssWrapInside.java b/org/w3c/css/properties/css3/CssWrapInside.java index 62cea9186..f4cc49feb 100644 --- a/org/w3c/css/properties/css3/CssWrapInside.java +++ b/org/w3c/css/properties/css3/CssWrapInside.java @@ -1,7 +1,7 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// (c) COPYRIGHT World Wide Web Consortium, 2024. // Please first read the full copyright statement in file COPYRIGHT.html package org.w3c.css.properties.css3; From 71a2e00f6059b3c57cc973da0a5b6747defdd31d Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Wed, 20 Mar 2024 11:07:37 +0100 Subject: [PATCH 12/37] white-space-collapse per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-white-space-collapse --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssWhiteSpaceCollapse.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css3/CssWhiteSpaceCollapse.java | 87 ++++++++++++++ 4 files changed, 211 insertions(+) create mode 100644 org/w3c/css/properties/css/CssWhiteSpaceCollapse.java create mode 100644 org/w3c/css/properties/css3/CssWhiteSpaceCollapse.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index d624e539a..33007fa87 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -228,6 +228,7 @@ hanging-punctuation: org.w3c.css.properties.css3.CssHangingPu wrap-after: org.w3c.css.properties.css3.CssWrapAfter wrap-before: org.w3c.css.properties.css3.CssWrapBefore wrap-inside: org.w3c.css.properties.css3.CssWrapInside +white-space-collapse: org.w3c.css.properties.css3.CssWhiteSpaceCollapse white-space-trim: org.w3c.css.properties.css3.CssWhiteSpaceTrim text-combine-upright: org.w3c.css.properties.css3.CssTextCombineUpright diff --git a/org/w3c/css/properties/css/CssWhiteSpaceCollapse.java b/org/w3c/css/properties/css/CssWhiteSpaceCollapse.java new file mode 100644 index 000000000..da2db1bd9 --- /dev/null +++ b/org/w3c/css/properties/css/CssWhiteSpaceCollapse.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 CssWhiteSpaceCollapse extends CssProperty { + + /** + * Create a new CssWhiteSpaceCollapse + */ + public CssWhiteSpaceCollapse() { + } + + /** + * Creates a new CssWhiteSpaceCollapse + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWhiteSpaceCollapse(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssWhiteSpaceCollapse(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 "white-space-collapse"; + } + + /** + * 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.cssWhiteSpaceCollapse != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssWhiteSpaceCollapse = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssWhiteSpaceCollapse && + value.equals(((CssWhiteSpaceCollapse) 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).getWhiteSpaceCollapse(); + } else { + return ((Css3Style) style).cssWhiteSpaceCollapse; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 17f840d72..c1bd415f4 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -298,6 +298,7 @@ import org.w3c.css.properties.css.CssVoiceRate; import org.w3c.css.properties.css.CssVoiceStress; import org.w3c.css.properties.css.CssVoiceVolume; +import org.w3c.css.properties.css.CssWhiteSpaceCollapse; import org.w3c.css.properties.css.CssWhiteSpaceTrim; import org.w3c.css.properties.css.CssWillChange; import org.w3c.css.properties.css.CssWordBreak; @@ -700,6 +701,7 @@ public class Css3Style extends ATSCStyle { public CssWrapAfter cssWrapAfter; public CssWrapBefore cssWrapBefore; public CssTextWrap cssTextWrap; + public CssWhiteSpaceCollapse cssWhiteSpaceCollapse; public CssWhiteSpaceTrim cssWhiteSpaceTrim; public CssWhiteSpaceTrim getWhiteSpaceTrim() { @@ -710,6 +712,15 @@ public CssWhiteSpaceTrim getWhiteSpaceTrim() { } return cssWhiteSpaceTrim; } + + public CssWhiteSpaceCollapse getWhiteSpaceCollapse() { + if (cssWhiteSpaceCollapse == null) { + cssWhiteSpaceCollapse = + (CssWhiteSpaceCollapse) style.CascadingOrder(new CssWhiteSpaceCollapse(), + style, selector); + } + return cssWhiteSpaceCollapse; + } public CssWrapBefore getWrapBefore() { if (cssWrapBefore == null) { diff --git a/org/w3c/css/properties/css3/CssWhiteSpaceCollapse.java b/org/w3c/css/properties/css3/CssWhiteSpaceCollapse.java new file mode 100644 index 000000000..d8e3720d6 --- /dev/null +++ b/org/w3c/css/properties/css3/CssWhiteSpaceCollapse.java @@ -0,0 +1,87 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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/2024/WD-css-text-4-20240219/#propdef-white-space-collapse + */ +public class CssWhiteSpaceCollapse extends org.w3c.css.properties.css.CssWhiteSpaceCollapse { + + private static final CssIdent[] allowed_idents; + + + static { + String[] id_values = {"collapse", "discard", "preserve", "preserve-breaks", "preserve-spaces", "break-spaces"}; + allowed_idents = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_idents[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_idents) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssWhiteSpaceCollapse + */ + public CssWhiteSpaceCollapse() { + value = initial; + } + + /** + * Creates a new CssWhiteSpaceCollapse + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssWhiteSpaceCollapse(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, + 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(); + } + + public CssWhiteSpaceCollapse(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } +} + From eef81b2d66859c308cfb45981e25e6fbe8fbeb92 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 10:36:38 +0900 Subject: [PATCH 13/37] white-space updated per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-white-space --- .../css/properties/css3/CssWhiteSpace.java | 98 +++++++++++++++---- .../properties/css3/CssWhiteSpaceTrim.java | 41 +++++--- 2 files changed, 107 insertions(+), 32 deletions(-) diff --git a/org/w3c/css/properties/css3/CssWhiteSpace.java b/org/w3c/css/properties/css3/CssWhiteSpace.java index 88a475d9d..9fd69aba1 100644 --- a/org/w3c/css/properties/css3/CssWhiteSpace.java +++ b/org/w3c/css/properties/css3/CssWhiteSpace.java @@ -10,9 +10,14 @@ 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/2021/CRD-css-text-3-20210422/#propdef-white-space + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-white-space */ public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace { @@ -21,7 +26,7 @@ public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace { static { String[] WHITESPACE = { - "normal", "pre", "nowrap", "pre-wrap", "break-spaces", "pre-line" + "normal", "pre", "pre-wrap", "pre-line" }; allowed_values = new CssIdent[WHITESPACE.length]; int i = 0; @@ -30,7 +35,7 @@ public class CssWhiteSpace extends org.w3c.css.properties.css.CssWhiteSpace { } } - public static final CssIdent getMatchingIdent(CssIdent ident) { + public static final CssIdent getSingleValueIdent(CssIdent ident) { for (CssIdent id : allowed_values) { if (id.equals(ident)) { return id; @@ -54,28 +59,87 @@ public CssWhiteSpace() { */ public CssWhiteSpace(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - - if (check && expression.getCount() > 1) { + ArrayList values = new ArrayList(); + CssValue val; + CssExpression trimexp = null; + CssIdent id; + char op; + boolean got_collapse = false; + boolean got_wrap_mode = false; + // we need 5 for <'white-space-collapse'> || <'text-wrap-mode'> || <'white-space-trim'> + // as <'white-space-trim'> can contain as much as 3 values + if (check && expression.getCount() > 5) { throw new InvalidParamException("unrecognize", ac); } - CssValue val = expression.getValue(); setByUser(); - if (val.getType() != CssTypes.CSS_IDENT) { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + // ident, so inherit, or allowed value + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } + if ((id = getSingleValueIdent(val.getIdent())) != null) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if ((id = CssWhiteSpaceCollapse.getAllowedIdent(val.getIdent())) != null) { + if (got_collapse) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + got_collapse = true; + values.add(val); + } else if ((id = CssTextWrapMode.getAllowedIdent(val.getIdent())) != null) { + if (got_wrap_mode) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + got_wrap_mode = true; + values.add(val); + } else if ((id = CssTextWrapMode.getAllowedIdent(val.getIdent())) != null) { + // TODO FIXME check if the values have to be contiguous or not + if (trimexp == null) { + trimexp = new CssExpression(); + } + trimexp.setOperator(op); + trimexp.addValue(val); + } else { + // nothing we know... + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); } - if (CssIdent.isCssWide(val.getIdent())) { - value = val; - } else if (getMatchingIdent(val.getIdent()) != null) { - value = val; - } else { - throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + // we got everything, check now that the wrap-mode related values are valid + if (trimexp != null) { + values.add(CssWhiteSpaceTrim.checkWhiteSpaceTrim(ac, trimexp, this)); } - expression.next(); + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } public CssWhiteSpace(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java index d8dca9082..f74cb6b68 100644 --- a/org/w3c/css/properties/css3/CssWhiteSpaceTrim.java +++ b/org/w3c/css/properties/css3/CssWhiteSpaceTrim.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.properties.css.CssProperty; import org.w3c.css.util.ApplContext; import org.w3c.css.util.InvalidParamException; import org.w3c.css.values.CssExpression; @@ -58,12 +59,27 @@ public CssWhiteSpaceTrim() { public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { setByUser(); - CssValue val = expression.getValue(); + + if (check && expression.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + + value = checkWhiteSpaceTrim(ac, expression, this); + } + + public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + public static CssValue checkWhiteSpaceTrim(ApplContext ac, CssExpression expression, CssProperty caller) + throws InvalidParamException { + ArrayList values = new ArrayList(); + CssValue val; CssIdent id; char op; - ArrayList values = new ArrayList<>(); - if (check && expression.getCount() > 3) { + if (expression.getCount() > 3) { throw new InvalidParamException("unrecognize", ac); } @@ -74,21 +90,21 @@ public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check if (val.getType() != CssTypes.CSS_IDENT) { throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + caller.getPropertyName(), ac); } // ident, so inherit, or allowed value if (CssIdent.isCssWide(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + caller.getPropertyName(), ac); } values.add(val); } else if (none.equals(val.getIdent())) { if (expression.getCount() > 1) { throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + caller.getPropertyName(), ac); } values.add(val); } else if ((id = getAllowedIdent(val.getIdent())) != null) { @@ -97,27 +113,22 @@ public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression, boolean check if (values.contains(id)) { throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + caller.getPropertyName(), ac); } values.add(val); } else { throw new InvalidParamException("value", expression.getValue(), - getPropertyName(), ac); + caller.getPropertyName(), ac); } if (op != SPACE) { throw new InvalidParamException("operator", op, - getPropertyName(), ac); + caller.getPropertyName(), ac); } expression.next(); } - value = (values.size() == 1) ? values.get(0) : new CssValueList(values); - + return (values.size() == 1) ? values.get(0) : new CssValueList(values); } - public CssWhiteSpaceTrim(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } } From 43ea344efa1b762c6d852b60f5aae7621a803a78 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 10:44:04 +0900 Subject: [PATCH 14/37] word-break per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-break --- org/w3c/css/properties/css3/CssWordBreak.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/properties/css3/CssWordBreak.java b/org/w3c/css/properties/css3/CssWordBreak.java index 2581fc8a5..067739109 100644 --- a/org/w3c/css/properties/css3/CssWordBreak.java +++ b/org/w3c/css/properties/css3/CssWordBreak.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#propdef-word-break + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-break */ public class CssWordBreak extends org.w3c.css.properties.css.CssWordBreak { @@ -21,8 +21,8 @@ public class CssWordBreak extends org.w3c.css.properties.css.CssWordBreak { public static final CssIdent break_word; static { - String[] _allowed_values = {"normal", "keep-all", "break-all", - "break-word"}; + String[] _allowed_values = {"normal", "break-all", "keep-all", "manual", + "auto-phrase", "break-word"}; allowed_values = new CssIdent[_allowed_values.length]; int i = 0; for (String s : _allowed_values) { From 293266106c66418916317862322999b6adbef11c Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 10:45:14 +0900 Subject: [PATCH 15/37] updated spec ref. --- org/w3c/css/properties/css3/CssLineBreak.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/org/w3c/css/properties/css3/CssLineBreak.java b/org/w3c/css/properties/css3/CssLineBreak.java index b6fcb01fb..dc354bcd9 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/2021/CRD-css-text-3-20210422/#propdef-line-break + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-line-break */ public class CssLineBreak extends org.w3c.css.properties.css.CssLineBreak { @@ -48,8 +48,7 @@ public CssLineBreak() { * Creates a new CssLineBreak * * @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 CssLineBreak(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { From 1b751a443ee866e65768f52ec6d49094ebc0d6c5 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 10:52:17 +0900 Subject: [PATCH 16/37] updated spec ref. --- org/w3c/css/properties/css3/CssHyphens.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssHyphens.java b/org/w3c/css/properties/css3/CssHyphens.java index 71dfca0b3..aade15b6e 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/2021/CRD-css-text-3-20210422/#propdef-hyphens + * @pec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphens */ public class CssHyphens extends org.w3c.css.properties.css.CssHyphens { From 6ade4a6ae5896c9654a295e56401eaf1b22a32da Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 11:13:05 +0900 Subject: [PATCH 17/37] hyphenate-character per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-character --- .../css/properties/CSS3Properties.properties | 3 +- .../properties/css/CssHyphenateCharacter.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 13 +- .../css3/CssHyphenateCharacter.java | 95 +++++++++++++++ 4 files changed, 221 insertions(+), 2 deletions(-) create mode 100644 org/w3c/css/properties/css/CssHyphenateCharacter.java create mode 100644 org/w3c/css/properties/css3/CssHyphenateCharacter.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 33007fa87..e6a363639 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -194,6 +194,8 @@ overflow-wrap: org.w3c.css.properties.css3.CssOverflowW #alias per spec word-wrap: org.w3c.css.properties.css3.CssOverflowWrap word-break: org.w3c.css.properties.css3.CssWordBreak +hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation +hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter hyphens: org.w3c.css.properties.css3.CssHyphens line-break: org.w3c.css.properties.css3.CssLineBreak text-align: org.w3c.css.properties.css3.CssTextAlign @@ -224,7 +226,6 @@ text-wrap: org.w3c.css.properties.css3.CssTextWrap text-wrap-mode: org.w3c.css.properties.css3.CssTextWrapMode text-wrap-style: org.w3c.css.properties.css3.CssTextWrapStyle tab-size: org.w3c.css.properties.css3.CssTabSize -hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation wrap-after: org.w3c.css.properties.css3.CssWrapAfter wrap-before: org.w3c.css.properties.css3.CssWrapBefore wrap-inside: org.w3c.css.properties.css3.CssWrapInside diff --git a/org/w3c/css/properties/css/CssHyphenateCharacter.java b/org/w3c/css/properties/css/CssHyphenateCharacter.java new file mode 100644 index 000000000..d6f1f61a1 --- /dev/null +++ b/org/w3c/css/properties/css/CssHyphenateCharacter.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssHyphenateCharacter extends CssProperty { + + /** + * Create a new CssHyphenateCharacter + */ + public CssHyphenateCharacter() { + } + + /** + * Creates a new CssHyphenateCharacter + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateCharacter(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssHyphenateCharacter(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 "hyphenate-character"; + } + + /** + * 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.cssHyphenateCharacter != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssHyphenateCharacter = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssHyphenateCharacter && + value.equals(((CssHyphenateCharacter) 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).getHyphenateCharacter(); + } else { + return ((Css3Style) style).cssHyphenateCharacter; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index c1bd415f4..4a1f9a57f 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -52,6 +52,7 @@ import org.w3c.css.properties.css.CssBorderBlockWidth; import org.w3c.css.properties.css.CssBorderEndEndRadius; import org.w3c.css.properties.css.CssBorderEndStartRadius; +import org.w3c.css.properties.css.CssHyphenateCharacter; import org.w3c.css.properties.css.CssImageRendering; import org.w3c.css.properties.css.CssBorderImageSource; import org.w3c.css.properties.css.CssBorderInline; @@ -703,7 +704,17 @@ public class Css3Style extends ATSCStyle { public CssTextWrap cssTextWrap; public CssWhiteSpaceCollapse cssWhiteSpaceCollapse; public CssWhiteSpaceTrim cssWhiteSpaceTrim; + public CssHyphenateCharacter cssHyphenateCharacter; + public CssHyphenateCharacter getHyphenateCharacter() { + if (cssHyphenateCharacter == null) { + cssHyphenateCharacter = + (CssHyphenateCharacter) style.CascadingOrder(new CssHyphenateCharacter(), + style, selector); + } + return cssHyphenateCharacter; + } + public CssWhiteSpaceTrim getWhiteSpaceTrim() { if (cssWhiteSpaceTrim == null) { cssWhiteSpaceTrim = @@ -721,7 +732,7 @@ public CssWhiteSpaceCollapse getWhiteSpaceCollapse() { } return cssWhiteSpaceCollapse; } - + public CssWrapBefore getWrapBefore() { if (cssWrapBefore == null) { cssWrapBefore = diff --git a/org/w3c/css/properties/css3/CssHyphenateCharacter.java b/org/w3c/css/properties/css3/CssHyphenateCharacter.java new file mode 100644 index 000000000..06223476d --- /dev/null +++ b/org/w3c/css/properties/css3/CssHyphenateCharacter.java @@ -0,0 +1,95 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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/2024/WD-css-text-4-20240219/#propdef-hyphenate-character + */ +public class CssHyphenateCharacter extends org.w3c.css.properties.css.CssHyphenateCharacter { + + private final static CssIdent[] allowed_values; + + static { + String[] id_values = {"auto"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_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 CssHyphenateCharacter + */ + public CssHyphenateCharacter() { + value = initial; + } + + /** + * Creates a new CssHyphenateCharacter + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateCharacter(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + CssValue val = expression.getValue(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + break; + } + if (getAllowedIdent(ident) != null) { + value = val; + break; + } + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_STRING: + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + + } + expression.next(); + } + + public CssHyphenateCharacter(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From 53f265a1a3407b323e42857c88dad174c36de307 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 11:29:39 +0900 Subject: [PATCH 18/37] hyphenate-limit-zone per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-zone --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssHyphenateLimitZone.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css3/CssHyphenateLimitZone.java | 77 ++++++++++++ 4 files changed, 201 insertions(+) create mode 100644 org/w3c/css/properties/css/CssHyphenateLimitZone.java create mode 100644 org/w3c/css/properties/css3/CssHyphenateLimitZone.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index e6a363639..cf748c35a 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -196,6 +196,7 @@ word-wrap: org.w3c.css.properties.css3.CssOverflowW word-break: org.w3c.css.properties.css3.CssWordBreak hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter +hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone hyphens: org.w3c.css.properties.css3.CssHyphens line-break: org.w3c.css.properties.css3.CssLineBreak text-align: org.w3c.css.properties.css3.CssTextAlign diff --git a/org/w3c/css/properties/css/CssHyphenateLimitZone.java b/org/w3c/css/properties/css/CssHyphenateLimitZone.java new file mode 100644 index 000000000..96a7afa06 --- /dev/null +++ b/org/w3c/css/properties/css/CssHyphenateLimitZone.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssHyphenateLimitZone extends CssProperty { + + /** + * Create a new CssHyphenateLimitZone + */ + public CssHyphenateLimitZone() { + } + + /** + * Creates a new CssHyphenateLimitZone + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitZone(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssHyphenateLimitZone(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 "hyphenate-limit-zone"; + } + + /** + * 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.cssHyphenateLimitZone != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssHyphenateLimitZone = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssHyphenateLimitZone && + value.equals(((CssHyphenateLimitZone) 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).getHyphenateLimitZone(); + } else { + return ((Css3Style) style).cssHyphenateLimitZone; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 4a1f9a57f..72e9d13c1 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -53,6 +53,7 @@ import org.w3c.css.properties.css.CssBorderEndEndRadius; import org.w3c.css.properties.css.CssBorderEndStartRadius; import org.w3c.css.properties.css.CssHyphenateCharacter; +import org.w3c.css.properties.css.CssHyphenateLimitZone; import org.w3c.css.properties.css.CssImageRendering; import org.w3c.css.properties.css.CssBorderImageSource; import org.w3c.css.properties.css.CssBorderInline; @@ -705,7 +706,17 @@ public class Css3Style extends ATSCStyle { public CssWhiteSpaceCollapse cssWhiteSpaceCollapse; public CssWhiteSpaceTrim cssWhiteSpaceTrim; public CssHyphenateCharacter cssHyphenateCharacter; + public CssHyphenateLimitZone cssHyphenateLimitZone; + public CssHyphenateLimitZone getHyphenateLimitZone() { + if (cssHyphenateLimitZone == null) { + cssHyphenateLimitZone = + (CssHyphenateLimitZone) style.CascadingOrder(new CssHyphenateLimitZone(), + style, selector); + } + return cssHyphenateLimitZone; + } + public CssHyphenateCharacter getHyphenateCharacter() { if (cssHyphenateCharacter == null) { cssHyphenateCharacter = diff --git a/org/w3c/css/properties/css3/CssHyphenateLimitZone.java b/org/w3c/css/properties/css3/CssHyphenateLimitZone.java new file mode 100644 index 000000000..ae17363e2 --- /dev/null +++ b/org/w3c/css/properties/css3/CssHyphenateLimitZone.java @@ -0,0 +1,77 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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.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/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-zone + */ +public class CssHyphenateLimitZone extends org.w3c.css.properties.css.CssHyphenateLimitZone { + + /** + * Create a new CssHyphenateLimitZone + */ + public CssHyphenateLimitZone() { + value = initial; + } + + /** + * Creates a new CssHyphenateLimitZone + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitZone(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + CssValue val = expression.getValue(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + break; + } + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_NUMBER: + CssCheckableValue p = val.getCheckableValue(); + p.checkEqualsZero(ac, this); + // flow for other possible checks + case CssTypes.CSS_LENGTH: + case CssTypes.CSS_PERCENTAGE: + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + + } + expression.next(); + } + + public CssHyphenateLimitZone(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From e302a50b1a5ceb3cf4e7669bab554e7767a674f1 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 11:44:48 +0900 Subject: [PATCH 19/37] hyphenate-limit-chars per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-chars --- .../css/properties/CSS3Properties.properties | 1 + .../css/CssHyphenateLimitChars.java | 112 +++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css3/CssHyphenateLimitChars.java | 117 ++++++++++++++++++ 4 files changed, 241 insertions(+) create mode 100644 org/w3c/css/properties/css/CssHyphenateLimitChars.java create mode 100644 org/w3c/css/properties/css3/CssHyphenateLimitChars.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index cf748c35a..39da7d5ed 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -196,6 +196,7 @@ word-wrap: org.w3c.css.properties.css3.CssOverflowW word-break: org.w3c.css.properties.css3.CssWordBreak hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter +hyphenate-limit-chars: org.w3c.css.properties.css3.CssHyphenateLimitChars hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone hyphens: org.w3c.css.properties.css3.CssHyphens line-break: org.w3c.css.properties.css3.CssLineBreak diff --git a/org/w3c/css/properties/css/CssHyphenateLimitChars.java b/org/w3c/css/properties/css/CssHyphenateLimitChars.java new file mode 100644 index 000000000..125cee3eb --- /dev/null +++ b/org/w3c/css/properties/css/CssHyphenateLimitChars.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssHyphenateLimitChars extends CssProperty { + + /** + * Create a new CssHyphenateLimitChars + */ + public CssHyphenateLimitChars() { + } + + /** + * Creates a new CssHyphenateLimitChars + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitChars(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssHyphenateLimitChars(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 "hyphenate-limit-chars"; + } + + /** + * 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.cssHyphenateLimitChars != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssHyphenateLimitChars = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssHyphenateLimitChars && + value.equals(((CssHyphenateLimitChars) 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).getHyphenateLimitChars(); + } else { + return ((Css3Style) style).cssHyphenateLimitChars; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 72e9d13c1..6bef7e655 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -53,6 +53,7 @@ import org.w3c.css.properties.css.CssBorderEndEndRadius; import org.w3c.css.properties.css.CssBorderEndStartRadius; import org.w3c.css.properties.css.CssHyphenateCharacter; +import org.w3c.css.properties.css.CssHyphenateLimitChars; import org.w3c.css.properties.css.CssHyphenateLimitZone; import org.w3c.css.properties.css.CssImageRendering; import org.w3c.css.properties.css.CssBorderImageSource; @@ -707,7 +708,17 @@ public class Css3Style extends ATSCStyle { public CssWhiteSpaceTrim cssWhiteSpaceTrim; public CssHyphenateCharacter cssHyphenateCharacter; public CssHyphenateLimitZone cssHyphenateLimitZone; + public CssHyphenateLimitChars cssHyphenateLimitChars; + public CssHyphenateLimitChars getHyphenateLimitChars() { + if (cssHyphenateLimitChars == null) { + cssHyphenateLimitChars = + (CssHyphenateLimitChars) style.CascadingOrder(new CssHyphenateLimitChars(), + style, selector); + } + return cssHyphenateLimitChars; + } + public CssHyphenateLimitZone getHyphenateLimitZone() { if (cssHyphenateLimitZone == null) { cssHyphenateLimitZone = diff --git a/org/w3c/css/properties/css3/CssHyphenateLimitChars.java b/org/w3c/css/properties/css3/CssHyphenateLimitChars.java new file mode 100644 index 000000000..dd5552f99 --- /dev/null +++ b/org/w3c/css/properties/css3/CssHyphenateLimitChars.java @@ -0,0 +1,117 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-chars + */ +public class CssHyphenateLimitChars extends org.w3c.css.properties.css.CssHyphenateLimitChars { + + private final static CssIdent[] allowed_values; + + static { + String[] id_values = {"auto"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_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 CssHyphenateLimitChars + */ + public CssHyphenateLimitChars() { + value = initial; + } + + /** + * Creates a new CssHyphenateLimitChars + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitChars(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + ArrayList values = new ArrayList(); + CssValue val; + CssIdent id; + char op; + + setByUser(); + + if (check && expression.getCount() > 3) { + throw new InvalidParamException("unrecognize", ac); + } + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + if (CssIdent.isCssWide(val.getIdent())) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + break; + } + if (getAllowedIdent(val.getIdent()) != null) { + values.add(val); + break; + } + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkInteger(ac, this); + values.add(val); + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); + } + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } + + public CssHyphenateLimitChars(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From f0b70566428cba7256496e371d13b759a1ed31ce Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 11:53:20 +0900 Subject: [PATCH 20/37] hyphenate-limit-lines per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-lines --- .../css/properties/CSS3Properties.properties | 1 + .../css/CssHyphenateLimitLines.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css3/CssHyphenateLimitLines.java | 97 +++++++++++++++ 4 files changed, 221 insertions(+) create mode 100644 org/w3c/css/properties/css/CssHyphenateLimitLines.java create mode 100644 org/w3c/css/properties/css3/CssHyphenateLimitLines.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 39da7d5ed..9c9456a9b 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -197,6 +197,7 @@ word-break: org.w3c.css.properties.css3.CssWordBreak hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter hyphenate-limit-chars: org.w3c.css.properties.css3.CssHyphenateLimitChars +hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone hyphens: org.w3c.css.properties.css3.CssHyphens line-break: org.w3c.css.properties.css3.CssLineBreak diff --git a/org/w3c/css/properties/css/CssHyphenateLimitLines.java b/org/w3c/css/properties/css/CssHyphenateLimitLines.java new file mode 100644 index 000000000..42fc22bb2 --- /dev/null +++ b/org/w3c/css/properties/css/CssHyphenateLimitLines.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssHyphenateLimitLines extends CssProperty { + + /** + * Create a new CssHyphenateLimitLines + */ + public CssHyphenateLimitLines() { + } + + /** + * Creates a new CssHyphenateLimitLines + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitLines(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssHyphenateLimitLines(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 "hyphenate-limit-lines"; + } + + /** + * 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.cssHyphenateLimitLines != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssHyphenateLimitLines = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssHyphenateLimitLines && + value.equals(((CssHyphenateLimitLines) 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).getHyphenateLimitLines(); + } else { + return ((Css3Style) style).cssHyphenateLimitLines; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 6bef7e655..8a535e6d9 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -54,6 +54,7 @@ import org.w3c.css.properties.css.CssBorderEndStartRadius; import org.w3c.css.properties.css.CssHyphenateCharacter; import org.w3c.css.properties.css.CssHyphenateLimitChars; +import org.w3c.css.properties.css.CssHyphenateLimitLines; import org.w3c.css.properties.css.CssHyphenateLimitZone; import org.w3c.css.properties.css.CssImageRendering; import org.w3c.css.properties.css.CssBorderImageSource; @@ -709,7 +710,17 @@ public class Css3Style extends ATSCStyle { public CssHyphenateCharacter cssHyphenateCharacter; public CssHyphenateLimitZone cssHyphenateLimitZone; public CssHyphenateLimitChars cssHyphenateLimitChars; + public CssHyphenateLimitLines cssHyphenateLimitLines; + public CssHyphenateLimitLines getHyphenateLimitLines() { + if (cssHyphenateLimitLines == null) { + cssHyphenateLimitLines = + (CssHyphenateLimitLines) style.CascadingOrder(new CssHyphenateLimitLines(), + style, selector); + } + return cssHyphenateLimitLines; + } + public CssHyphenateLimitChars getHyphenateLimitChars() { if (cssHyphenateLimitChars == null) { cssHyphenateLimitChars = diff --git a/org/w3c/css/properties/css3/CssHyphenateLimitLines.java b/org/w3c/css/properties/css3/CssHyphenateLimitLines.java new file mode 100644 index 000000000..1b6cc6d35 --- /dev/null +++ b/org/w3c/css/properties/css3/CssHyphenateLimitLines.java @@ -0,0 +1,97 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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.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/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-lines + */ +public class CssHyphenateLimitLines extends org.w3c.css.properties.css.CssHyphenateLimitLines { + private final static CssIdent[] allowed_values; + + static { + String[] id_values = {"no-limit"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_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 CssHyphenateLimitLines + */ + public CssHyphenateLimitLines() { + value = initial; + } + + /** + * Creates a new CssHyphenateLimitLines + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitLines(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + CssValue val = expression.getValue(); + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + break; + } + if (getAllowedIdent(val.getIdent()) != null) { + value = val; + break; + } + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_NUMBER: + CssCheckableValue p = val.getCheckableValue(); + p.checkInteger(ac, this); + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + + } + expression.next(); + } + + public CssHyphenateLimitLines(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From f7bf46048029566a08d7bf868d77828155277a07 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:00:18 +0900 Subject: [PATCH 21/37] hyphenate-limit-last per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-last --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssHyphenateLimitLast.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 19 ++- .../css3/CssHyphenateLimitLast.java | 87 ++++++++++++++ 4 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 org/w3c/css/properties/css/CssHyphenateLimitLast.java create mode 100644 org/w3c/css/properties/css3/CssHyphenateLimitLast.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 9c9456a9b..46d81b869 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -197,6 +197,7 @@ word-break: org.w3c.css.properties.css3.CssWordBreak hanging-punctuation: org.w3c.css.properties.css3.CssHangingPunctuation hyphenate-character: org.w3c.css.properties.css3.CssHyphenateCharacter hyphenate-limit-chars: org.w3c.css.properties.css3.CssHyphenateLimitChars +hyphenate-limit-last: org.w3c.css.properties.css3.CssHyphenateLimitLast hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone hyphens: org.w3c.css.properties.css3.CssHyphens diff --git a/org/w3c/css/properties/css/CssHyphenateLimitLast.java b/org/w3c/css/properties/css/CssHyphenateLimitLast.java new file mode 100644 index 000000000..ff9a138cd --- /dev/null +++ b/org/w3c/css/properties/css/CssHyphenateLimitLast.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssHyphenateLimitLast extends CssProperty { + + /** + * Create a new CssHyphenateLimitLast + */ + public CssHyphenateLimitLast() { + } + + /** + * Creates a new CssHyphenateLimitLast + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitLast(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssHyphenateLimitLast(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 "hyphenate-limit-last"; + } + + /** + * 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.cssHyphenateLimitLast != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssHyphenateLimitLast = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssHyphenateLimitLast && + value.equals(((CssHyphenateLimitLast) 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).getHyphenateLimitLast(); + } else { + return ((Css3Style) style).cssHyphenateLimitLast; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 8a535e6d9..7e370388a 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -54,6 +54,7 @@ import org.w3c.css.properties.css.CssBorderEndStartRadius; import org.w3c.css.properties.css.CssHyphenateCharacter; import org.w3c.css.properties.css.CssHyphenateLimitChars; +import org.w3c.css.properties.css.CssHyphenateLimitLast; import org.w3c.css.properties.css.CssHyphenateLimitLines; import org.w3c.css.properties.css.CssHyphenateLimitZone; import org.w3c.css.properties.css.CssImageRendering; @@ -711,6 +712,16 @@ public class Css3Style extends ATSCStyle { public CssHyphenateLimitZone cssHyphenateLimitZone; public CssHyphenateLimitChars cssHyphenateLimitChars; public CssHyphenateLimitLines cssHyphenateLimitLines; + public CssHyphenateLimitLast cssHyphenateLimitLast; + + public CssHyphenateLimitLast getHyphenateLimitLast() { + if (cssHyphenateLimitLast == null) { + cssHyphenateLimitLast = + (CssHyphenateLimitLast) style.CascadingOrder(new CssHyphenateLimitLast(), + style, selector); + } + return cssHyphenateLimitLast; + } public CssHyphenateLimitLines getHyphenateLimitLines() { if (cssHyphenateLimitLines == null) { @@ -720,7 +731,7 @@ public CssHyphenateLimitLines getHyphenateLimitLines() { } return cssHyphenateLimitLines; } - + public CssHyphenateLimitChars getHyphenateLimitChars() { if (cssHyphenateLimitChars == null) { cssHyphenateLimitChars = @@ -729,7 +740,7 @@ public CssHyphenateLimitChars getHyphenateLimitChars() { } return cssHyphenateLimitChars; } - + public CssHyphenateLimitZone getHyphenateLimitZone() { if (cssHyphenateLimitZone == null) { cssHyphenateLimitZone = @@ -738,7 +749,7 @@ public CssHyphenateLimitZone getHyphenateLimitZone() { } return cssHyphenateLimitZone; } - + public CssHyphenateCharacter getHyphenateCharacter() { if (cssHyphenateCharacter == null) { cssHyphenateCharacter = @@ -747,7 +758,7 @@ public CssHyphenateCharacter getHyphenateCharacter() { } return cssHyphenateCharacter; } - + public CssWhiteSpaceTrim getWhiteSpaceTrim() { if (cssWhiteSpaceTrim == null) { cssWhiteSpaceTrim = diff --git a/org/w3c/css/properties/css3/CssHyphenateLimitLast.java b/org/w3c/css/properties/css3/CssHyphenateLimitLast.java new file mode 100644 index 000000000..4da47dd1b --- /dev/null +++ b/org/w3c/css/properties/css3/CssHyphenateLimitLast.java @@ -0,0 +1,87 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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/2024/WD-css-text-4-20240219/#propdef-hyphenate-limit-zone + */ +public class CssHyphenateLimitLast extends org.w3c.css.properties.css.CssHyphenateLimitZone { + private final static CssIdent[] allowed_values; + + static { + String[] id_values = {"none", "always", "column", "page", "spread"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_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 CssHyphenateLimitZone + */ + public CssHyphenateLimitLast() { + value = initial; + } + + /** + * Creates a new CssHyphenateLimitZone + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssHyphenateLimitLast(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + CssValue val = expression.getValue(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + + CssIdent ident = val.getIdent(); + if (CssIdent.isCssWide(ident)) { + value = val; + } else if (getAllowedIdent(ident) != null) { + value = val; + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + expression.next(); + } + + public CssHyphenateLimitLast(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From 3b01237281eb8c62f2d54bb016a9c862de1c26fd Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:03:19 +0900 Subject: [PATCH 22/37] fixed specref --- org/w3c/css/properties/css3/CssOverflowWrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssOverflowWrap.java b/org/w3c/css/properties/css3/CssOverflowWrap.java index e6b2ed3e9..046cc46b3 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/2021/CRD-css-text-3-20210422/#propdef-overflow-wrap + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-overflow-wrap *

* Note that word-wrap is also an alias for this. */ From 1433c43962ff71884f5b7a22f47ca46cecf7ba8b Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:13:35 +0900 Subject: [PATCH 23/37] text-align updated per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-align --- org/w3c/css/properties/css3/CssTextAlign.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextAlign.java b/org/w3c/css/properties/css3/CssTextAlign.java index cad80818b..7934e051f 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/2021/CRD-css-text-3-20210422/#propdef-text-align + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-align */ public class CssTextAlign extends org.w3c.css.properties.css.CssTextAlign { @@ -60,19 +60,33 @@ public CssTextAlign(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("unrecognize", ac); } - if (val.getType() != CssTypes.CSS_IDENT) { - 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); + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + break; + case CssTypes.CSS_STRING: + if (val.getRawType() == CssTypes.CSS_STRING) { + // string length must be 1, so 3 including delimiters + if (val.toString().length() > 3) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + } + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } - value = val; expression.next(); } From 8ed3b8a088e3ca823633244fa7638db052156b2f Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:33:40 +0900 Subject: [PATCH 24/37] text-align-all updated per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-align-all --- .../css/properties/css3/CssTextAlignAll.java | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextAlignAll.java b/org/w3c/css/properties/css3/CssTextAlignAll.java index 1661d5135..fad0f1341 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/2021/CRD-css-text-3-20210422/#propdef-text-align-all + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-align-all */ public class CssTextAlignAll extends org.w3c.css.properties.css.CssTextAlignAll { @@ -59,19 +59,33 @@ public CssTextAlignAll(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("unrecognize", ac); } - if (val.getType() != CssTypes.CSS_IDENT) { - 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); + switch (val.getType()) { + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (!CssIdent.isCssWide(id) && getAllowedIdent(id) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + break; + case CssTypes.CSS_STRING: + if (val.getRawType() == CssTypes.CSS_STRING) { + // string length must be 1, so 3 including delimiters + if (val.toString().length() > 3) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + } + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); } - value = val; expression.next(); } From 485ed83f751e232d131b0d4a5ead92540b954988 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:34:27 +0900 Subject: [PATCH 25/37] fixed specref --- org/w3c/css/properties/css3/CssTextAlignLast.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTextAlignLast.java b/org/w3c/css/properties/css3/CssTextAlignLast.java index f5b6b4a5f..c37e9ccd6 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/2021/CRD-css-text-3-20210422/#text-align-last-property + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-align-last */ public class CssTextAlignLast extends org.w3c.css.properties.css.CssTextAlignLast { From 9430975280d54d79b4acfa201bf9508fe8f28f19 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 12:51:37 +0900 Subject: [PATCH 26/37] updated text-justify per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#text-justify-property The 'distribute' legacy value has been added, and adds a deprecation warning. --- .../css/properties/css3/CssTextJustify.java | 80 +++++++++++++++---- 1 file changed, 63 insertions(+), 17 deletions(-) diff --git a/org/w3c/css/properties/css3/CssTextJustify.java b/org/w3c/css/properties/css3/CssTextJustify.java index 21f39627d..6f00223fa 100644 --- a/org/w3c/css/properties/css3/CssTextJustify.java +++ b/org/w3c/css/properties/css3/CssTextJustify.java @@ -11,16 +11,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/2021/CRD-css-text-3-20210422/#propdef-text-justify + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#text-justify-property */ public class CssTextJustify extends org.w3c.css.properties.css.CssTextJustify { private static CssIdent[] allowed_values; + private static CssIdent no_compress, distribute; static { - String id_values[] = {"auto", "none", "inter-word", "inter-character"}; + no_compress = CssIdent.getIdent("no-compress"); + distribute = CssIdent.getIdent("distribute"); + String id_values[] = {"auto", "none", "inter-word", "inter-character", "ruby", "distribute"}; allowed_values = new CssIdent[id_values.length]; int i = 0; for (String s : id_values) { @@ -52,28 +60,66 @@ public CssTextJustify() { */ public CssTextJustify(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { + ArrayList values = new ArrayList(); + CssValue val; + CssExpression trimexp = null; + CssIdent id; + boolean got_no_compress = false; + char op; + 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); - } - // ident, so inherit, or allowed value - CssIdent id = val.getIdent(); + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); - if (!CssIdent.isCssWide(id) && (getMatchingIdent(id) == null)) { - throw new InvalidParamException("value", - expression.getValue(), - getPropertyName(), ac); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (id.equals(no_compress)) { + if (got_no_compress) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + got_no_compress = true; + values.add(val); + } else if (getMatchingIdent(id) != null) { + if (!got_no_compress && !values.isEmpty()) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + if (distribute.equals(id)) { + ac.getFrame().addWarning("deprecated", distribute.toString()); + } + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); } - value = val; - expression.next(); + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); } public CssTextJustify(ApplContext ac, CssExpression expression) From cd24dfcf8067dd5d7fdd9333fd09444c93add94a Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Sun, 7 Apr 2024 15:31:11 +0900 Subject: [PATCH 27/37] text-group-align per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-group-align --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssTextGroupAlign.java | 113 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../properties/css3/CssTextGroupAlign.java | 84 +++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 org/w3c/css/properties/css/CssTextGroupAlign.java create mode 100644 org/w3c/css/properties/css3/CssTextGroupAlign.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 46d81b869..993a6c1ad 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -223,6 +223,7 @@ text-emphasis: org.w3c.css.properties.css3.CssTextEmpha text-emphasis-color: org.w3c.css.properties.css3.CssTextEmphasisColor text-emphasis-position: org.w3c.css.properties.css3.CssTextEmphasisPosition text-emphasis-style: org.w3c.css.properties.css3.CssTextEmphasisStyle +text-group-align: org.w3c.css.properties.css3.CssTextGroupAlign text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition diff --git a/org/w3c/css/properties/css/CssTextGroupAlign.java b/org/w3c/css/properties/css/CssTextGroupAlign.java new file mode 100644 index 000000000..6e53d1d71 --- /dev/null +++ b/org/w3c/css/properties/css/CssTextGroupAlign.java @@ -0,0 +1,113 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2022. +// 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 CssTextGroupAlign extends CssProperty { + + /** + * Create a new CssTextGroupAlign + */ + public CssTextGroupAlign() { + } + + /** + * Creates a new CssTextgroupAlign + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssTextGroupAlign(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextGroupAlign(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 "text-group-align"; + } + + /** + * 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.cssTextGroupAlign != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextGroupAlign = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextGroupAlign && + value.equals(((CssTextGroupAlign) 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).getTextGroupAlign(); + } else { + return ((Css3Style) style).cssTextGroupAlign; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 7e370388a..2963df97b 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -276,6 +276,7 @@ import org.w3c.css.properties.css.CssTextEmphasisColor; import org.w3c.css.properties.css.CssTextEmphasisPosition; import org.w3c.css.properties.css.CssTextEmphasisStyle; +import org.w3c.css.properties.css.CssTextGroupAlign; import org.w3c.css.properties.css.CssTextJustify; import org.w3c.css.properties.css.CssTextOrientation; import org.w3c.css.properties.css.CssTextOverflow; @@ -713,6 +714,16 @@ public class Css3Style extends ATSCStyle { public CssHyphenateLimitChars cssHyphenateLimitChars; public CssHyphenateLimitLines cssHyphenateLimitLines; public CssHyphenateLimitLast cssHyphenateLimitLast; + public CssTextGroupAlign cssTextGroupAlign; + + public CssTextGroupAlign getTextGroupAlign() { + if (cssTextGroupAlign == null) { + cssTextGroupAlign = + (CssTextGroupAlign) style.CascadingOrder(new CssTextGroupAlign(), + style, selector); + } + return cssTextGroupAlign; + } public CssHyphenateLimitLast getHyphenateLimitLast() { if (cssHyphenateLimitLast == null) { diff --git a/org/w3c/css/properties/css3/CssTextGroupAlign.java b/org/w3c/css/properties/css3/CssTextGroupAlign.java new file mode 100644 index 000000000..104c3bd1a --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextGroupAlign.java @@ -0,0 +1,84 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM and Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-text-group-align + */ +public class CssTextGroupAlign extends org.w3c.css.properties.css.CssTextGroupAlign { + + private static CssIdent[] allowed_values; + + // + static { + String id_values[] = {"none", "start", "end", "left", "right", "center"}; + 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 CssTextGroupAlign + */ + public CssTextGroupAlign() { + value = initial; + } + + /** + * Creates a new CssTextGroupAlign + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextGroupAlign(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 + if (!CssIdent.isCssWide(val.getIdent()) && getMatchingIdent(val.getIdent()) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssTextGroupAlign(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From 72e245940563245713bf91d9c939f992f6c47c7e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 09:09:55 +0900 Subject: [PATCH 28/37] fixed specref --- org/w3c/css/properties/css3/CssWordSpacing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssWordSpacing.java b/org/w3c/css/properties/css3/CssWordSpacing.java index f685492d7..a11942f66 100644 --- a/org/w3c/css/properties/css3/CssWordSpacing.java +++ b/org/w3c/css/properties/css3/CssWordSpacing.java @@ -16,7 +16,7 @@ import java.util.ArrayList; /** - * @spec https://www.w3.org/TR/2021/CRD-css-text-3-20210422/#word-spacing-property + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-word-spacing */ public class CssWordSpacing extends org.w3c.css.properties.css.CssWordSpacing { From 99ade3734cf28cdbdeeb675831cf99b85e726244 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 09:12:58 +0900 Subject: [PATCH 29/37] fixed specref --- org/w3c/css/properties/css3/CssLetterSpacing.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssLetterSpacing.java b/org/w3c/css/properties/css3/CssLetterSpacing.java index a1a24266d..06cfadfc7 100644 --- a/org/w3c/css/properties/css3/CssLetterSpacing.java +++ b/org/w3c/css/properties/css3/CssLetterSpacing.java @@ -13,7 +13,7 @@ import org.w3c.css.values.CssValue; /** - * @spec https://www.w3.org/TR/2018/WD-css-text-3-20181212/#propdef-letter-spacing + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-letter-spacing */ public class CssLetterSpacing extends org.w3c.css.properties.css.CssLetterSpacing { From 5ce8f4b1276668c3c45aca1949f4658dc3c6f354 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 09:16:21 +0900 Subject: [PATCH 30/37] missed it in cd24dfcf8067dd5d7fdd9333fd09444c93add94a --- org/w3c/css/properties/css/CssTextGroupAlign.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/org/w3c/css/properties/css/CssTextGroupAlign.java b/org/w3c/css/properties/css/CssTextGroupAlign.java index 6e53d1d71..51042675f 100644 --- a/org/w3c/css/properties/css/CssTextGroupAlign.java +++ b/org/w3c/css/properties/css/CssTextGroupAlign.java @@ -26,8 +26,7 @@ public CssTextGroupAlign() { * Creates a new CssTextgroupAlign * * @param expression The expression for this property - * @throws InvalidParamException - * Expressions are incorrect + * @throws InvalidParamException Expressions are incorrect */ public CssTextGroupAlign(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { From 032af0c5bb050a732a658c314b53ca75087419fb Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 09:29:58 +0900 Subject: [PATCH 31/37] line-padding per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-line-padding --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssLinePadding.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssLinePadding.java | 70 +++++++++++ 4 files changed, 194 insertions(+) create mode 100644 org/w3c/css/properties/css/CssLinePadding.java create mode 100644 org/w3c/css/properties/css3/CssLinePadding.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 993a6c1ad..6c21a75a2 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -202,6 +202,7 @@ hyphenate-limit-lines: org.w3c.css.properties.css3.CssHyphenateLimitLines hyphenate-limit-zone: org.w3c.css.properties.css3.CssHyphenateLimitZone hyphens: org.w3c.css.properties.css3.CssHyphens line-break: org.w3c.css.properties.css3.CssLineBreak +line-padding: org.w3c.css.properties.css3.CssLinePadding text-align: org.w3c.css.properties.css3.CssTextAlign text-align-all: org.w3c.css.properties.css3.CssTextAlignAll text-align-last: org.w3c.css.properties.css3.CssTextAlignLast diff --git a/org/w3c/css/properties/css/CssLinePadding.java b/org/w3c/css/properties/css/CssLinePadding.java new file mode 100644 index 000000000..cac7b65c1 --- /dev/null +++ b/org/w3c/css/properties/css/CssLinePadding.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 CssLinePadding extends CssProperty { + + /** + * Create a new CssLinePadding + */ + public CssLinePadding() { + } + + /** + * Creates a new CssLinePadding + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssLinePadding(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssLinePadding(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 "line-padding"; + } + + /** + * 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.cssLinePadding != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssLinePadding = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssLinePadding && + value.equals(((CssLinePadding) 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).getLinePadding(); + } else { + return ((Css3Style) style).cssLinePadding; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 2963df97b..52e37379d 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -174,6 +174,7 @@ import org.w3c.css.properties.css.CssJustifySelf; import org.w3c.css.properties.css.CssLightingColor; import org.w3c.css.properties.css.CssLineBreak; +import org.w3c.css.properties.css.CssLinePadding; import org.w3c.css.properties.css.CssMarginBlock; import org.w3c.css.properties.css.CssMarginBlockEnd; import org.w3c.css.properties.css.CssMarginBlockStart; @@ -715,7 +716,17 @@ public class Css3Style extends ATSCStyle { public CssHyphenateLimitLines cssHyphenateLimitLines; public CssHyphenateLimitLast cssHyphenateLimitLast; public CssTextGroupAlign cssTextGroupAlign; + public CssLinePadding cssLinePadding; + public CssLinePadding getLinePadding() { + if (cssLinePadding == null) { + cssLinePadding = + (CssLinePadding) style.CascadingOrder(new CssLinePadding(), + style, selector); + } + return cssLinePadding; + } + public CssTextGroupAlign getTextGroupAlign() { if (cssTextGroupAlign == null) { cssTextGroupAlign = diff --git a/org/w3c/css/properties/css3/CssLinePadding.java b/org/w3c/css/properties/css3/CssLinePadding.java new file mode 100644 index 000000000..fd6b26df7 --- /dev/null +++ b/org/w3c/css/properties/css3/CssLinePadding.java @@ -0,0 +1,70 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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/2024/WD-css-text-4-20240219/#propdef-line-padding + */ +public class CssLinePadding extends org.w3c.css.properties.css.CssLinePadding { + + /** + * Create a new CssLinePadding + */ + public CssLinePadding() { + value = initial; + } + + /** + * Creates a new CssLinePadding + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssLinePadding(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + CssValue val = expression.getValue(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + + switch (val.getType()) { + case CssTypes.CSS_IDENT: + if (CssIdent.isCssWide(val.getIdent())) { + value = val; + break; + } + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkEqualsZero(ac, this); + case CssTypes.CSS_LENGTH: + value = val; + break; + default: + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + expression.next(); + } + + public CssLinePadding(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From 32c1b99661616707cab115c44d5d16d70bcf3ac8 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 11:39:23 +0900 Subject: [PATCH 32/37] text-autospace per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-autospace --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssTextAutospace.java | 112 +++++++++ org/w3c/css/properties/css3/Css3Style.java | 13 +- .../css/properties/css3/CssTextAutospace.java | 229 ++++++++++++++++++ 4 files changed, 354 insertions(+), 1 deletion(-) create mode 100644 org/w3c/css/properties/css/CssTextAutospace.java create mode 100644 org/w3c/css/properties/css3/CssTextAutospace.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 6c21a75a2..51bae7eb5 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -206,6 +206,7 @@ line-padding: org.w3c.css.properties.css3.CssLinePadding text-align: org.w3c.css.properties.css3.CssTextAlign text-align-all: org.w3c.css.properties.css3.CssTextAlignAll text-align-last: org.w3c.css.properties.css3.CssTextAlignLast +text-autospace: org.w3c.css.properties.css3.CssTextAutospace text-indent: org.w3c.css.properties.css3.CssTextIndent text-justify: org.w3c.css.properties.css3.CssTextJustify text-transform: org.w3c.css.properties.css3.CssTextTransform diff --git a/org/w3c/css/properties/css/CssTextAutospace.java b/org/w3c/css/properties/css/CssTextAutospace.java new file mode 100644 index 000000000..01f7ab2d9 --- /dev/null +++ b/org/w3c/css/properties/css/CssTextAutospace.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 CssTextAutospace extends CssProperty { + + /** + * Create a new CssTextAutospace + */ + public CssTextAutospace() { + } + + /** + * Creates a new CssTextAutospace + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextAutospace(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextAutospace(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 "text-autospace"; + } + + /** + * 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.cssTextAutospace != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextAutospace = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextAutospace && + value.equals(((CssTextAutospace) 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).getTextAutospace(); + } else { + return ((Css3Style) style).cssTextAutospace; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 52e37379d..edbc19d2f 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -262,6 +262,7 @@ import org.w3c.css.properties.css.CssTabSize; import org.w3c.css.properties.css.CssTextAlignAll; import org.w3c.css.properties.css.CssTextAlignLast; +import org.w3c.css.properties.css.CssTextAutospace; import org.w3c.css.properties.css.CssTextCombineUpright; import org.w3c.css.properties.css.CssTextDecorationColor; import org.w3c.css.properties.css.CssTextDecorationLine; @@ -717,7 +718,17 @@ public class Css3Style extends ATSCStyle { public CssHyphenateLimitLast cssHyphenateLimitLast; public CssTextGroupAlign cssTextGroupAlign; public CssLinePadding cssLinePadding; - + public CssTextAutospace cssTextAutospace; + + public CssTextAutospace getTextAutospace() { + if (cssTextAutospace == null) { + cssTextAutospace = + (CssTextAutospace) style.CascadingOrder(new CssTextAutospace(), + style, selector); + } + return cssTextAutospace; + } + public CssLinePadding getLinePadding() { if (cssLinePadding == null) { cssLinePadding = diff --git a/org/w3c/css/properties/css3/CssTextAutospace.java b/org/w3c/css/properties/css3/CssTextAutospace.java new file mode 100644 index 000000000..ec0a4e28a --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextAutospace.java @@ -0,0 +1,229 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +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; +import org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#text-autospace-property + */ +public class CssTextAutospace extends org.w3c.css.properties.css.CssTextAutospace { + + private static CssIdent[] allowed_values; + private static CssIdent[] ideograph_axis, behaviour_axis; + private static CssIdent single_val; + + static { + String[] id_values = {"normal", "auto", "no-autospace", "ideograph-alpha", "ideograph-numeric", "punctuation", + "insert", "replace"}; + String[] id_axis = {"ideograph-alpha", "ideograph-numeric", "punctuation"}; + String[] be_axis = {"insert", "replace"}; + single_val = CssIdent.getIdent("no-autospace"); + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + allowed_values[i++] = CssIdent.getIdent(s); + } + ideograph_axis = new CssIdent[id_axis.length]; + i = 0; + for (String s : id_axis) { + ideograph_axis[i++] = CssIdent.getIdent(s); + } + behaviour_axis = new CssIdent[be_axis.length]; + i = 0; + for (String s : be_axis) { + behaviour_axis[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getAllowedIdent(CssIdent ident) { + for (CssIdent id : allowed_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getAutospaceIdent(CssIdent ident) { + if (single_val.equals(ident)) { + return single_val; + } + for (CssIdent id : ideograph_axis) { + if (id.equals(ident)) { + return id; + } + } + for (CssIdent id : behaviour_axis) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static boolean isIdeographAxis(CssIdent ident) { + for (CssIdent id : ideograph_axis) { + if (id.equals(ident)) { + return true; + } + } + return false; + } + + public static boolean isBehaviourAxis(CssIdent ident) { + for (CssIdent id : behaviour_axis) { + if (id.equals(ident)) { + return true; + } + } + return false; + } + + /** + * Create a new CssTextAutospace + */ + public CssTextAutospace() { + value = initial; + } + + /** + * Creates a new CssTextAutospace + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextAutospace(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + CssIdent id; + + setByUser(); + CssValue val = expression.getValue(); + + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } else if (getAllowedIdent(id) != null) { + // ident or + if (getAutospaceIdent(id) != null) { + // + value = checkAutoSpace(ac, expression, this); + } else { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + + } + + + public CssTextAutospace(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + // this function only check if the expression is an + public static CssValue checkAutoSpace(ApplContext ac, CssExpression expression, CssProperty caller) + throws InvalidParamException { + ArrayList values = new ArrayList(); + CssValue val; + CssIdent id; + char op; + boolean got_behaviour = false; + + if (expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + caller.getPropertyName(), ac); + } + id = val.getIdent(); + if (getAutospaceIdent(id) != null) { + if (!isIdeographAxis(id) && !isBehaviourAxis(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + caller.getPropertyName(), ac); + } + values.add(val); + } else { + // check we don't have two of those + if (isBehaviourAxis(id)) { + if (got_behaviour) { + throw new InvalidParamException("value", + expression.getValue(), + caller.getPropertyName(), ac); + } else { + got_behaviour = true; + } + } + // avoid duplicates. TODO is that a good enough check? See attr/var + if (values.contains(id)) { + throw new InvalidParamException("value", + expression.getValue(), + caller.getPropertyName(), ac); + } + values.add(val); + } + } else { + throw new InvalidParamException("value", + expression.getValue(), + caller.getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + caller.getPropertyName(), ac); + } + expression.next(); + } + return (values.size() == 1) ? values.get(0) : new CssValueList(values); + + } + +} + From 6d481caceb2b4c49827ca14b7ce0afce8f5d4078 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 14:03:16 +0900 Subject: [PATCH 33/37] text-spacing-trim per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-spacing-trim --- .../css/properties/CSS3Properties.properties | 1 + .../properties/css/CssTextSpacingTrim.java | 112 ++++++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../properties/css3/CssTextSpacingTrim.java | 99 ++++++++++++++++ 4 files changed, 223 insertions(+) create mode 100644 org/w3c/css/properties/css/CssTextSpacingTrim.java create mode 100644 org/w3c/css/properties/css3/CssTextSpacingTrim.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 51bae7eb5..3daf75bc3 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -227,6 +227,7 @@ text-emphasis-position: org.w3c.css.properties.css3.CssTextEmpha text-emphasis-style: org.w3c.css.properties.css3.CssTextEmphasisStyle text-group-align: org.w3c.css.properties.css3.CssTextGroupAlign text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust +text-spacing-trim: org.w3c.css.properties.css3.CssTextSpacingTrim text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition text-wrap: org.w3c.css.properties.css3.CssTextWrap diff --git a/org/w3c/css/properties/css/CssTextSpacingTrim.java b/org/w3c/css/properties/css/CssTextSpacingTrim.java new file mode 100644 index 000000000..3184adf34 --- /dev/null +++ b/org/w3c/css/properties/css/CssTextSpacingTrim.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 CssTextSpacingTrim extends CssProperty { + + /** + * Create a new CssTextSpacingTrim + */ + public CssTextSpacingTrim() { + } + + /** + * Creates a new CssTextSpacingTrim + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextSpacingTrim(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextSpacingTrim(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 "text-spacing-trim"; + } + + /** + * 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.cssTextSpacingTrim != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextSpacingTrim = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextSpacingTrim && + value.equals(((CssTextSpacingTrim) 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).getTextSpacingTrim(); + } else { + return ((Css3Style) style).cssTextSpacingTrim; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index edbc19d2f..fd2698a52 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -283,6 +283,7 @@ import org.w3c.css.properties.css.CssTextOrientation; import org.w3c.css.properties.css.CssTextOverflow; import org.w3c.css.properties.css.CssTextSizeAdjust; +import org.w3c.css.properties.css.CssTextSpacingTrim; import org.w3c.css.properties.css.CssTextUnderlineOffset; import org.w3c.css.properties.css.CssTextUnderlinePosition; import org.w3c.css.properties.css.CssTextWrap; @@ -719,6 +720,16 @@ public class Css3Style extends ATSCStyle { public CssTextGroupAlign cssTextGroupAlign; public CssLinePadding cssLinePadding; public CssTextAutospace cssTextAutospace; + public CssTextSpacingTrim cssTextSpacingTrim; + + public CssTextSpacingTrim getTextSpacingTrim() { + if (cssTextSpacingTrim == null) { + cssTextSpacingTrim = + (CssTextSpacingTrim) style.CascadingOrder(new CssTextSpacingTrim(), + style, selector); + } + return cssTextSpacingTrim; + } public CssTextAutospace getTextAutospace() { if (cssTextAutospace == null) { diff --git a/org/w3c/css/properties/css3/CssTextSpacingTrim.java b/org/w3c/css/properties/css3/CssTextSpacingTrim.java new file mode 100644 index 000000000..27ff01cfc --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextSpacingTrim.java @@ -0,0 +1,99 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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/2024/WD-css-text-4-20240219/#propdef-text-spacing-trim + */ +public class CssTextSpacingTrim extends org.w3c.css.properties.css.CssTextSpacingTrim { + + private static CssIdent[] allowed_values; + private static CssIdent[] spacing_trim; + + static { + String[] id_values = {"space-all", "normal", "trim-auto", "trim-start", "space-first", "trim-all"}; + String[] other_values = {"auto"}; + allowed_values = new CssIdent[id_values.length + other_values.length]; + spacing_trim = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_values) { + spacing_trim[i] = CssIdent.getIdent(s); + allowed_values[i++] = CssIdent.getIdent(s); + } + for (String s : other_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; + } + + public static CssIdent getSpacingTrimIdent(CssIdent ident) { + for (CssIdent id : spacing_trim) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssTextSpacingTrim + */ + public CssTextSpacingTrim() { + value = initial; + } + + /** + * Creates a new CssTextSpacingTrim + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextSpacingTrim(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 + if (!CssIdent.isCssWide(val.getIdent()) && getAllowedIdent(val.getIdent()) == null) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + value = val; + expression.next(); + } + + public CssTextSpacingTrim(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From e95180ce3bfd74b0cd1eef80ddd15f377a865765 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 15:49:21 +0900 Subject: [PATCH 34/37] reverse the order as a value needs to be there before operator is set, see eef81b2d66859c308cfb45981e25e6fbe8fbeb92 --- org/w3c/css/properties/css3/CssWhiteSpace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssWhiteSpace.java b/org/w3c/css/properties/css3/CssWhiteSpace.java index 9fd69aba1..fa3c4c651 100644 --- a/org/w3c/css/properties/css3/CssWhiteSpace.java +++ b/org/w3c/css/properties/css3/CssWhiteSpace.java @@ -120,8 +120,8 @@ public CssWhiteSpace(ApplContext ac, CssExpression expression, boolean check) if (trimexp == null) { trimexp = new CssExpression(); } - trimexp.setOperator(op); trimexp.addValue(val); + trimexp.setOperator(op); } else { // nothing we know... throw new InvalidParamException("value", From 16eed8c943ba2be7bfab9ee4ef54ee2df7168e9e Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 15:50:17 +0900 Subject: [PATCH 35/37] text-spacing per https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-spacing --- .../css/properties/CSS3Properties.properties | 1 + .../css/properties/css/CssTextSpacing.java | 112 ++++++++++++++ org/w3c/css/properties/css3/Css3Style.java | 11 ++ .../css/properties/css3/CssTextSpacing.java | 137 ++++++++++++++++++ 4 files changed, 261 insertions(+) create mode 100644 org/w3c/css/properties/css/CssTextSpacing.java create mode 100644 org/w3c/css/properties/css3/CssTextSpacing.java diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 3daf75bc3..833340130 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -227,6 +227,7 @@ text-emphasis-position: org.w3c.css.properties.css3.CssTextEmpha text-emphasis-style: org.w3c.css.properties.css3.CssTextEmphasisStyle text-group-align: org.w3c.css.properties.css3.CssTextGroupAlign text-size-adjust: org.w3c.css.properties.css3.CssTextSizeAdjust +text-spacing: org.w3c.css.properties.css3.CssTextSpacing text-spacing-trim: org.w3c.css.properties.css3.CssTextSpacingTrim text-underline-offset: org.w3c.css.properties.css3.CssTextUnderlineOffset text-underline-position: org.w3c.css.properties.css3.CssTextUnderlinePosition diff --git a/org/w3c/css/properties/css/CssTextSpacing.java b/org/w3c/css/properties/css/CssTextSpacing.java new file mode 100644 index 000000000..1dfe4869d --- /dev/null +++ b/org/w3c/css/properties/css/CssTextSpacing.java @@ -0,0 +1,112 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT World Wide Web Consortium, 2024. +// 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 CssTextSpacing extends CssProperty { + + /** + * Create a new CssTextSpacing + */ + public CssTextSpacing() { + } + + /** + * Creates a new CssTextSpacing + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextSpacing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssTextSpacing(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 "text-spacing"; + } + + /** + * 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.cssTextSpacing != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssTextSpacing = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssTextSpacing && + value.equals(((CssTextSpacing) 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).getTextSpacing(); + } else { + return ((Css3Style) style).cssTextSpacing; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index fd2698a52..12c131b89 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -283,6 +283,7 @@ import org.w3c.css.properties.css.CssTextOrientation; import org.w3c.css.properties.css.CssTextOverflow; import org.w3c.css.properties.css.CssTextSizeAdjust; +import org.w3c.css.properties.css.CssTextSpacing; import org.w3c.css.properties.css.CssTextSpacingTrim; import org.w3c.css.properties.css.CssTextUnderlineOffset; import org.w3c.css.properties.css.CssTextUnderlinePosition; @@ -721,6 +722,16 @@ public class Css3Style extends ATSCStyle { public CssLinePadding cssLinePadding; public CssTextAutospace cssTextAutospace; public CssTextSpacingTrim cssTextSpacingTrim; + public CssTextSpacing cssTextSpacing; + + public CssTextSpacing getTextSpacing() { + if (cssTextSpacing == null) { + cssTextSpacing = + (CssTextSpacing) style.CascadingOrder(new CssTextSpacing(), + style, selector); + } + return cssTextSpacing; + } public CssTextSpacingTrim getTextSpacingTrim() { if (cssTextSpacingTrim == null) { diff --git a/org/w3c/css/properties/css3/CssTextSpacing.java b/org/w3c/css/properties/css3/CssTextSpacing.java new file mode 100644 index 000000000..ad8049f97 --- /dev/null +++ b/org/w3c/css/properties/css3/CssTextSpacing.java @@ -0,0 +1,137 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio University, Beihang, 2012. +// 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 org.w3c.css.values.CssValueList; + +import java.util.ArrayList; + +import static org.w3c.css.values.CssOperator.SPACE; + +/** + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-spacing + * @see CssTextAutospace + * @see CssTextSpacingTrim + */ +public class CssTextSpacing extends org.w3c.css.properties.css.CssTextSpacing { + + private static CssIdent[] allowed_values; + + static { + String[] id_values = {"none", "auto"}; + allowed_values = new CssIdent[id_values.length]; + int i = 0; + for (String s : id_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 CssTextSpacing + */ + public CssTextSpacing() { + value = initial; + } + + /** + * Creates a new CssTextSpacing + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssTextSpacing(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + ArrayList values = new ArrayList(); + CssValue val; + CssExpression spacexp = null; + boolean has_trim = false; + CssIdent id; + char op; + + setByUser(); + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (getAllowedIdent(id) != null) { + // the single values + if (expression.getCount() > 1) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + values.add(val); + } else if (CssTextSpacingTrim.getSpacingTrimIdent(id) != null) { + if (has_trim) { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + has_trim = true; + values.add(val); + } else if (CssTextAutospace.getAutospaceIdent(id) != null) { + if (spacexp == null) { + spacexp = new CssExpression(); + } + // FIXME one way would be to add _all_ the matching idents + // FIXME then refuse new ones (as avoid values being mixed between + // FIXME autospace and spacing-trim) + spacexp.addValue(val); + spacexp.setOperator(op); + } else { + throw new InvalidParamException("value", + expression.getValue(), + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", op, + getPropertyName(), ac); + } + expression.next(); + } + if (spacexp != null) { + values.add(CssTextAutospace.checkAutoSpace(ac, spacexp, this)); + } + value = (values.size() == 1) ? values.get(0) : new CssValueList(values); + } + + public CssTextSpacing(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + From a1ee3a2aa576a7439502fe0fbccc23d2766dec68 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 15:54:15 +0900 Subject: [PATCH 36/37] spec update --- org/w3c/css/properties/css3/CssTextIndent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssTextIndent.java b/org/w3c/css/properties/css3/CssTextIndent.java index 792cc90a5..81ac40870 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/2021/CRD-css-text-3-20210422/#propdef-text-indent + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-text-indent */ public class CssTextIndent extends org.w3c.css.properties.css.CssTextIndent { From 1f1786f0b2ed87803981755567f689e2c8b58103 Mon Sep 17 00:00:00 2001 From: Yves Lafon Date: Mon, 8 Apr 2024 15:55:02 +0900 Subject: [PATCH 37/37] spec update --- org/w3c/css/properties/css3/CssHangingPunctuation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org/w3c/css/properties/css3/CssHangingPunctuation.java b/org/w3c/css/properties/css3/CssHangingPunctuation.java index 759c2e98b..d45e95492 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/2021/CRD-css-text-3-20210422/#propdef-hanging-punctuation + * @spec https://www.w3.org/TR/2024/WD-css-text-4-20240219/#propdef-hanging-punctuation */ public class CssHangingPunctuation extends org.w3c.css.properties.css.CssHangingPunctuation {