diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 6d841a977..eb95401d0 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -384,6 +384,12 @@ caret-shape: org.w3c.css.properties.css3.CssCaretShap aspect-ratio: org.w3c.css.properties.css3.CssAspectRatio accent-color: org.w3c.css.properties.css3.CssAccentColor +contain-intrinsic-block-size: org.w3c.css.properties.css3.CssContainIntrinsicBlockSize +contain-intrinsic-height: org.w3c.css.properties.css3.CssContainIntrinsicHeight +contain-intrinsic-inline-size: org.w3c.css.properties.css3.CssContainIntrinsicInlineSize +contain-intrinsic-size: org.w3c.css.properties.css3.CssContainIntrinsicSize +contain-intrinsic-width: org.w3c.css.properties.css3.CssContainIntrinsicWidth + overflow-anchor: org.w3c.css.properties.css3.CssOverflowAnchor word-spacing: org.w3c.css.properties.css3.CssWordSpacing diff --git a/org/w3c/css/properties/css/CssContainIntrinsicBlockSize.java b/org/w3c/css/properties/css/CssContainIntrinsicBlockSize.java new file mode 100644 index 000000000..16499fdb9 --- /dev/null +++ b/org/w3c/css/properties/css/CssContainIntrinsicBlockSize.java @@ -0,0 +1,111 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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 CssContainIntrinsicBlockSize extends CssProperty { + + + /** + * Create a new CssContainIntrinsicBlockSize + */ + public CssContainIntrinsicBlockSize() { + } + + /** + * Creates a new CssContainIntrinsicBlockSize + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssContainIntrinsicBlockSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssContainIntrinsicBlockSize(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 "contain-intrinsic-inline-size"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return inherit.equals(value); + } + + /** + * 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) { + if (((Css3Style) style).cssContainIntrinsicBlockSize != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssContainIntrinsicBlockSize = this; + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssContainIntrinsicBlockSize && + value.equals(((CssContainIntrinsicBlockSize) 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).getContainIntrinsicBlockSize(); + } else { + return ((Css3Style) style).cssContainIntrinsicBlockSize; + } + } +} + diff --git a/org/w3c/css/properties/css/CssContainIntrinsicHeight.java b/org/w3c/css/properties/css/CssContainIntrinsicHeight.java new file mode 100644 index 000000000..f67e8aa4f --- /dev/null +++ b/org/w3c/css/properties/css/CssContainIntrinsicHeight.java @@ -0,0 +1,111 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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 CssContainIntrinsicHeight extends CssProperty { + + + /** + * Create a new CssContainIntrinsicHeight + */ + public CssContainIntrinsicHeight() { + } + + /** + * Creates a new CssContainIntrinsicHeight + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssContainIntrinsicHeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssContainIntrinsicHeight(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 "contain-intrinsic-height"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return inherit.equals(value); + } + + /** + * 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) { + if (((Css3Style) style).cssContainIntrinsicHeight != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssContainIntrinsicHeight = this; + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssContainIntrinsicHeight && + value.equals(((CssContainIntrinsicHeight) 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).getContainIntrinsicHeight(); + } else { + return ((Css3Style) style).cssContainIntrinsicHeight; + } + } +} + diff --git a/org/w3c/css/properties/css/CssContainIntrinsicInlineSize.java b/org/w3c/css/properties/css/CssContainIntrinsicInlineSize.java new file mode 100644 index 000000000..a49ca8e79 --- /dev/null +++ b/org/w3c/css/properties/css/CssContainIntrinsicInlineSize.java @@ -0,0 +1,111 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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 CssContainIntrinsicInlineSize extends CssProperty { + + + /** + * Create a new CssContainIntrinsicInlineSize + */ + public CssContainIntrinsicInlineSize() { + } + + /** + * Creates a new CssContainIntrinsicInlineSize + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssContainIntrinsicInlineSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssContainIntrinsicInlineSize(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 "contain-intrinsic-inline-size"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return inherit.equals(value); + } + + /** + * 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) { + if (((Css3Style) style).cssContainIntrinsicInlineSize != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssContainIntrinsicInlineSize = this; + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssContainIntrinsicInlineSize && + value.equals(((CssContainIntrinsicInlineSize) 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).getContainIntrinsicInlineSize(); + } else { + return ((Css3Style) style).cssContainIntrinsicInlineSize; + } + } +} + diff --git a/org/w3c/css/properties/css/CssContainIntrinsicSize.java b/org/w3c/css/properties/css/CssContainIntrinsicSize.java new file mode 100644 index 000000000..764d1fea0 --- /dev/null +++ b/org/w3c/css/properties/css/CssContainIntrinsicSize.java @@ -0,0 +1,111 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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 CssContainIntrinsicSize extends CssProperty { + + + /** + * Create a new CssContainIntrinsicSize + */ + public CssContainIntrinsicSize() { + } + + /** + * Creates a new CssContainIntrinsicSize + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssContainIntrinsicSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssContainIntrinsicSize(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 "contain-intrinsic-size"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return inherit.equals(value); + } + + /** + * 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) { + if (((Css3Style) style).cssContainIntrinsicSize != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssContainIntrinsicSize = this; + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssContainIntrinsicSize && + value.equals(((CssContainIntrinsicSize) 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).getContainIntrinsicSize(); + } else { + return ((Css3Style) style).cssContainIntrinsicSize; + } + } +} + diff --git a/org/w3c/css/properties/css/CssContainIntrinsicWidth.java b/org/w3c/css/properties/css/CssContainIntrinsicWidth.java new file mode 100644 index 000000000..ee18633a3 --- /dev/null +++ b/org/w3c/css/properties/css/CssContainIntrinsicWidth.java @@ -0,0 +1,111 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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 CssContainIntrinsicWidth extends CssProperty { + + + /** + * Create a new CssContainIntrinsicWidth + */ + public CssContainIntrinsicWidth() { + } + + /** + * Creates a new CssContainIntrinsicWidth + * + * @param expression The expression for this property + * @throws InvalidParamException + * Expressions are incorrect + */ + public CssContainIntrinsicWidth(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssContainIntrinsicWidth(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 "contain-intrinsic-width"; + } + + /** + * Returns true if this property is "softly" inherited + * e.g. his value is equals to inherit + */ + public boolean isSoftlyInherited() { + return inherit.equals(value); + } + + /** + * 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) { + if (((Css3Style) style).cssContainIntrinsicWidth != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssContainIntrinsicWidth = this; + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssContainIntrinsicWidth && + value.equals(((CssContainIntrinsicWidth) 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).getContainIntrinsicWidth(); + } else { + return ((Css3Style) style).cssContainIntrinsicWidth; + } + } +} + diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index bc78d72d4..4fd5e2a70 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -91,6 +91,11 @@ import org.w3c.css.properties.css.CssColumnWidth; import org.w3c.css.properties.css.CssColumns; import org.w3c.css.properties.css.CssContain; +import org.w3c.css.properties.css.CssContainIntrinsicBlockSize; +import org.w3c.css.properties.css.CssContainIntrinsicHeight; +import org.w3c.css.properties.css.CssContainIntrinsicInlineSize; +import org.w3c.css.properties.css.CssContainIntrinsicSize; +import org.w3c.css.properties.css.CssContainIntrinsicWidth; import org.w3c.css.properties.css.CssContentVisibility; import org.w3c.css.properties.css.CssCounterSet; import org.w3c.css.properties.css.CssDominantBaseline; @@ -448,6 +453,12 @@ public class Css3Style extends ATSCStyle { public CssContain cssContain; + public CssContainIntrinsicSize cssContainIntrinsicSize; + public CssContainIntrinsicBlockSize cssContainIntrinsicBlockSize; + public CssContainIntrinsicInlineSize cssContainIntrinsicInlineSize; + public CssContainIntrinsicWidth cssContainIntrinsicWidth; + public CssContainIntrinsicHeight cssContainIntrinsicHeight; + public CssMixBlendMode cssMixBlendMode; public CssIsolation cssIsolation; public CssBackgroundBlendMode cssBackgroundBlendMode; @@ -2598,6 +2609,51 @@ public CssContain getContain() { return cssContain; } + public CssContainIntrinsicSize getContainIntrinsicSize() { + if (cssContainIntrinsicSize == null) { + cssContainIntrinsicSize = + (CssContainIntrinsicSize) style.CascadingOrder(new CssContainIntrinsicSize(), + style, selector); + } + return cssContainIntrinsicSize; + } + + public CssContainIntrinsicBlockSize getContainIntrinsicBlockSize() { + if (cssContainIntrinsicBlockSize == null) { + cssContainIntrinsicBlockSize = + (CssContainIntrinsicBlockSize) style.CascadingOrder(new CssContainIntrinsicBlockSize(), + style, selector); + } + return cssContainIntrinsicBlockSize; + } + + public CssContainIntrinsicInlineSize getContainIntrinsicInlineSize() { + if (cssContainIntrinsicInlineSize == null) { + cssContainIntrinsicInlineSize = + (CssContainIntrinsicInlineSize) style.CascadingOrder(new CssContainIntrinsicInlineSize(), + style, selector); + } + return cssContainIntrinsicInlineSize; + } + + public CssContainIntrinsicWidth getContainIntrinsicWidth() { + if (cssContainIntrinsicWidth == null) { + cssContainIntrinsicWidth = + (CssContainIntrinsicWidth) style.CascadingOrder(new CssContainIntrinsicWidth(), + style, selector); + } + return cssContainIntrinsicWidth; + } + + public CssContainIntrinsicHeight getContainIntrinsicHeight() { + if (cssContainIntrinsicHeight == null) { + cssContainIntrinsicHeight = + (CssContainIntrinsicHeight) style.CascadingOrder(new CssContainIntrinsicHeight(), + style, selector); + } + return cssContainIntrinsicHeight; + } + public CssMixBlendMode getMixBlendMode() { if (cssMixBlendMode == null) { cssMixBlendMode = diff --git a/org/w3c/css/properties/css3/CssContainIntrinsicBlockSize.java b/org/w3c/css/properties/css3/CssContainIntrinsicBlockSize.java new file mode 100644 index 000000000..ad20389b2 --- /dev/null +++ b/org/w3c/css/properties/css3/CssContainIntrinsicBlockSize.java @@ -0,0 +1,45 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#intrinsic-size-override + * @spec https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override may 12, 2026 + * @see CssContainIntrinsicBlockSize + */ +public class CssContainIntrinsicBlockSize extends org.w3c.css.properties.css.CssContainIntrinsicBlockSize { + + /** + * Create a new CssContainIntrinsicBlockSize + */ + public CssContainIntrinsicBlockSize() { + value = initial; + } + + /** + * Creates a new CssContainIntrinsicBlockSize + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssContainIntrinsicBlockSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + value = CssContainIntrinsicSize.parseContainIntrinsic(ac, expression, this); + } + + public CssContainIntrinsicBlockSize(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssContainIntrinsicHeight.java b/org/w3c/css/properties/css3/CssContainIntrinsicHeight.java new file mode 100644 index 000000000..ecf5aa3a2 --- /dev/null +++ b/org/w3c/css/properties/css3/CssContainIntrinsicHeight.java @@ -0,0 +1,46 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#intrinsic-size-override + * @spec https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override may 12, 2026 + * @see org.w3c.css.properties.css3.CssContainIntrinsicHeight + */ +public class CssContainIntrinsicHeight extends org.w3c.css.properties.css.CssContainIntrinsicHeight { + + /** + * Create a new CssContainIntrinsicHeight + */ + public CssContainIntrinsicHeight() { + value = initial; + } + + /** + * Creates a new CssContainIntrinsicHeight + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssContainIntrinsicHeight(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + value = CssContainIntrinsicSize.parseContainIntrinsic(ac, expression, this); + } + + public CssContainIntrinsicHeight(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + +} + diff --git a/org/w3c/css/properties/css3/CssContainIntrinsicInlineSize.java b/org/w3c/css/properties/css3/CssContainIntrinsicInlineSize.java new file mode 100644 index 000000000..5aed488d7 --- /dev/null +++ b/org/w3c/css/properties/css3/CssContainIntrinsicInlineSize.java @@ -0,0 +1,45 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#intrinsic-size-override + * @spec https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override may 12, 2026 + * @see CssContainIntrinsicInlineSize + */ +public class CssContainIntrinsicInlineSize extends org.w3c.css.properties.css.CssContainIntrinsicInlineSize { + + /** + * Create a new CssContainIntrinsicInlineSize + */ + public CssContainIntrinsicInlineSize() { + value = initial; + } + + /** + * Creates a new CssContainIntrinsicInlineSize + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssContainIntrinsicInlineSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + value = CssContainIntrinsicSize.parseContainIntrinsic(ac, expression, this); + } + + public CssContainIntrinsicInlineSize(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssContainIntrinsicSize.java b/org/w3c/css/properties/css3/CssContainIntrinsicSize.java new file mode 100644 index 000000000..4ae6c09d9 --- /dev/null +++ b/org/w3c/css/properties/css3/CssContainIntrinsicSize.java @@ -0,0 +1,261 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css3; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css.CssProperty; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssIdent; +import org.w3c.css.values.CssTypes; +import org.w3c.css.values.CssValue; +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/WD-css-sizing-4-20210520/#intrinsic-size-override + * @spec https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override may 12, 2026 + */ +public class CssContainIntrinsicSize extends org.w3c.css.properties.css.CssContainIntrinsicSize { + + private static CssIdent auto, none; + + private CssContainIntrinsicWidth widthValue; + private CssContainIntrinsicHeight heightValue; + + static { + auto = CssIdent.getIdent("auto"); + none = CssIdent.getIdent("none"); + } + + /** + * Create a new CssContainIntrinsicSize + */ + public CssContainIntrinsicSize() { + value = initial; + } + + /** + * Creates a new CssContainIntrinsicSize + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssContainIntrinsicSize(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + boolean got_auto = false; + boolean got_length = false; + boolean got_width = false; + CssValue val; + char op; + + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + + ArrayList v = new ArrayList(); + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkEqualsZero(ac, this); + case CssTypes.CSS_LENGTH: + if (got_width && got_length) { + throw new InvalidParamException("value", val, getPropertyName(), ac); + } + if (got_length) { + // second length, we dump width and will parse height + widthValue = new CssContainIntrinsicWidth(); + widthValue.value = value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + v = new ArrayList<>(); + got_width = true; + got_auto = false; // not really needed, but let the state be correct + } + val.getCheckableValue().checkPositiveness(ac, this); + v.add(val); + got_length = true; + break; + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + v.add(val); + break; + } + if (auto.equals(id)) { + if (!got_width) { + if (got_length) { + // second length, we dump width and will parse height + widthValue = new CssContainIntrinsicWidth(); + widthValue.value = value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + v = new ArrayList<>(); + v.add(val); + got_width = true; + got_length = false; + got_auto = true; + break; + } else { + if (!got_auto) { + v.add(val); + got_auto = true; + break; + } + // else fail in default: + } + } else { + if (!got_auto) { + v.add(val); + got_auto = true; + break; + } + // else fail in default: + } + } + if (none.equals(id)) { + if (got_length) { + // second length, we dump width and will parse height + widthValue = new CssContainIntrinsicWidth(); + widthValue.value = value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + v = new ArrayList<>(); + got_width = true; + got_auto = false; // not really needed, but let the state be correct + } + v.add(val); + got_length = true; + break; + } + default: + throw new InvalidParamException("value", val, + getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", val, + getPropertyName(), ac); + } + expression.next(); + } + if (got_width) { + heightValue = new CssContainIntrinsicHeight(); + heightValue.value = value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + CssValueList vl = new CssValueList(); + vl.add(widthValue.value); + vl.add(heightValue.value); + value = vl; + } else { + // we got only one value + value = (v.size() == 1) ? v.get(0) : new CssValueList(v); + heightValue = new CssContainIntrinsicHeight(); + heightValue.value = value; + widthValue = new CssContainIntrinsicWidth(); + widthValue.value = value; + } + } + + public void addToStyle(ApplContext ac, CssStyle style) { + super.addToStyle(ac, style); + Css3Style s3 = (Css3Style) style; + if (widthValue != null) { + if (s3.cssContainIntrinsicWidth != null) { + style.addRedefinitionWarning(ac, this); + } + s3.cssContainIntrinsicWidth = widthValue; + } + if (heightValue != null) { + if (s3.cssContainIntrinsicHeight != null) { + style.addRedefinitionWarning(ac, this); + } + s3.cssContainIntrinsicHeight = heightValue; + } + } + + public static CssValue parseContainIntrinsic(ApplContext ac, CssExpression expression, CssProperty caller) + throws InvalidParamException { + + boolean got_auto = false; + boolean got_length = false; + CssValue val; + char op; + + if (expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + + ArrayList v = new ArrayList(); + + while (!expression.end()) { + val = expression.getValue(); + op = expression.getOperator(); + + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkEqualsZero(ac, caller); + case CssTypes.CSS_LENGTH: + if (got_length) { + throw new InvalidParamException("value", val, caller.getPropertyName(), ac); + } + val.getCheckableValue().checkPositiveness(ac, caller); + v.add(val); + got_length = true; + break; + case CssTypes.CSS_IDENT: + CssIdent id = val.getIdent(); + if (CssIdent.isCssWide(id)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val, + caller.getPropertyName(), ac); + } + v.add(val); + break; + } + // auto can only be first, if present + if (!got_auto && !got_length && auto.equals(id)) { + v.add(val); + got_auto = true; + break; + } + if (!got_length && none.equals(id)) { + v.add(val); + got_length = true; + break; + } + default: + throw new InvalidParamException("value", val, + caller.getPropertyName(), ac); + } + if (op != SPACE) { + throw new InvalidParamException("operator", val, + caller.getPropertyName(), ac); + } + expression.next(); + } + // sanity check, we can't have only auto + if (!got_length) { + throw new InvalidParamException("value", v.get(0), + caller.getPropertyName(), ac); + } + return (v.size() == 1) ? v.get(0) : new CssValueList(v); + } + + public CssContainIntrinsicSize(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + +} + diff --git a/org/w3c/css/properties/css3/CssContainIntrinsicWidth.java b/org/w3c/css/properties/css3/CssContainIntrinsicWidth.java new file mode 100644 index 000000000..e8549a4f6 --- /dev/null +++ b/org/w3c/css/properties/css3/CssContainIntrinsicWidth.java @@ -0,0 +1,46 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT W3C, 2026. +// 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; + +/** + * @spec https://www.w3.org/TR/2021/WD-css-sizing-4-20210520/#intrinsic-size-override + * @spec https://drafts.csswg.org/css-sizing-4/#intrinsic-size-override may 12, 2026 + * @see CssContainIntrinsicWidth + */ +public class CssContainIntrinsicWidth extends org.w3c.css.properties.css.CssContainIntrinsicWidth { + + /** + * Create a new CssContainIntrinsicWidth + */ + public CssContainIntrinsicWidth() { + value = initial; + } + + /** + * Creates a new CssContainIntrinsicWidth + * + * @param expression The expression for this property + * @throws InvalidParamException Expressions are incorrect + */ + public CssContainIntrinsicWidth(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + setByUser(); + + value = CssContainIntrinsicSize.parseContainIntrinsic(ac, expression, this); + } + + public CssContainIntrinsicWidth(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + +} +