diff --git a/org/w3c/css/properties/CSS3Properties.properties b/org/w3c/css/properties/CSS3Properties.properties index 03c82835d..eb7157fd2 100644 --- a/org/w3c/css/properties/CSS3Properties.properties +++ b/org/w3c/css/properties/CSS3Properties.properties @@ -93,18 +93,27 @@ grid-auto-flow: org.w3c.css.properties.css3.CssGridAutoF grid-auto-rows: org.w3c.css.properties.css3.CssGridAutoRows grid-column: org.w3c.css.properties.css3.CssGridColumn grid-column-end: org.w3c.css.properties.css3.CssGridColumnEnd -grid-column-gap: org.w3c.css.properties.css3.CssGridColumnGap +grid-column-gap: org.w3c.css.properties.css3.CssColumnGap grid-column-start: org.w3c.css.properties.css3.CssGridColumnStart -grid-gap: org.w3c.css.properties.css3.CssGridGap +grid-gap: org.w3c.css.properties.css3.CssGap grid-row: org.w3c.css.properties.css3.CssGridRow grid-row-end: org.w3c.css.properties.css3.CssGridRowEnd -grid-row-gap: org.w3c.css.properties.css3.CssGridRowGap +grid-row-gap: org.w3c.css.properties.css3.CssRowGap grid-row-start: org.w3c.css.properties.css3.CssGridRowStart grid-template: org.w3c.css.properties.css3.CssGridTemplate grid-template-areas: org.w3c.css.properties.css3.CssGridTemplateAreas grid-template-columns: org.w3c.css.properties.css3.CssGridTemplateColumns grid-template-rows: org.w3c.css.properties.css3.CssGridTemplateRows +# align +row-gap: org.w3c.css.properties.css3.CssRowGap +gap: org.w3c.css.properties.css3.CssGap +justify-items: org.w3c.css.properties.css3.CssJustifyItems +justify-self: org.w3c.css.properties.css3.CssJustifySelf +place-content: org.w3c.css.properties.css3.CssPlaceContent +place-items: org.w3c.css.properties.css3.CssPlaceItems +place-self: org.w3c.css.properties.css3.CssPlaceSelf + # text properties text-shadow: org.w3c.css.properties.css3.CssTextShadow diff --git a/org/w3c/css/properties/CSS3SVGProperties.properties b/org/w3c/css/properties/CSS3SVGProperties.properties index b8eaac944..b4e8ca36e 100644 --- a/org/w3c/css/properties/CSS3SVGProperties.properties +++ b/org/w3c/css/properties/CSS3SVGProperties.properties @@ -150,18 +150,27 @@ grid-auto-flow: org.w3c.css.properties.css3.CssGridAutoF grid-auto-rows: org.w3c.css.properties.css3.CssGridAutoRows grid-column: org.w3c.css.properties.css3.CssGridColumn grid-column-end: org.w3c.css.properties.css3.CssGridColumnEnd -grid-column-gap: org.w3c.css.properties.css3.CssGridColumnGap +grid-column-gap: org.w3c.css.properties.css3.CssColumnGap grid-column-start: org.w3c.css.properties.css3.CssGridColumnStart -grid-gap: org.w3c.css.properties.css3.CssGridGap +grid-gap: org.w3c.css.properties.css3.CssGap grid-row: org.w3c.css.properties.css3.CssGridRow grid-row-end: org.w3c.css.properties.css3.CssGridRowEnd -grid-row-gap: org.w3c.css.properties.css3.CssGridRowGap +grid-row-gap: org.w3c.css.properties.css3.CssRowGap grid-row-start: org.w3c.css.properties.css3.CssGridRowStart grid-template: org.w3c.css.properties.css3.CssGridTemplate grid-template-areas: org.w3c.css.properties.css3.CssGridTemplateAreas grid-template-columns: org.w3c.css.properties.css3.CssGridTemplateColumns grid-template-rows: org.w3c.css.properties.css3.CssGridTemplateRows +# align +row-gap: org.w3c.css.properties.css3.CssRowGap +gap: org.w3c.css.properties.css3.CssGap +justify-items: org.w3c.css.properties.css3.CssJustifyItems +justify-self: org.w3c.css.properties.css3.CssJustifySelf +place-content: org.w3c.css.properties.css3.CssPlaceContent +place-items: org.w3c.css.properties.css3.CssPlaceItems +place-self: org.w3c.css.properties.css3.CssPlaceSelf + # text properties text-shadow: org.w3c.css.properties.css3.CssTextShadow diff --git a/org/w3c/css/properties/css/CssGap.java b/org/w3c/css/properties/css/CssGap.java new file mode 100644 index 000000000..933da2fa6 --- /dev/null +++ b/org/w3c/css/properties/css/CssGap.java @@ -0,0 +1,118 @@ +// +// Author: Yves Lafon +// +// COPYRIGHT (c) 2018 World Wide Web Consortium, (MIT, ERCIM, Keio, Beihang) +// 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; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ + +public class CssGap extends CssProperty { + + private static final String propertyName = "gap"; + + public CssValue value; + + /** + * Create a new CssGap + */ + public CssGap() { + } + + /** + * Create a new CssGap + */ + public CssGap(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + + throw new InvalidParamException("unrecognize", ac); + } + + public CssGap(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) { + if (((Css3Style) style).cssGap != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssGap = this; + + } + + /** + * Get this property in the style. + * + * @param style The style where the property is + * @param resolve if true, resolve the style to find this property + */ + public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { + if (resolve) { + return ((Css3Style) style).getGap(); + } else { + return ((Css3Style) style).cssGap; + } + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssGap && + value.equals(((CssGap) property).value)); + } + + /** + * Returns the name of this property + */ + public final String getPropertyName() { + return propertyName; + } + + /** + * Returns the value of this property + */ + public Object get() { + return value; + } + + /** + * Returns true if this property is "softly" inherited + */ + public boolean isSoftlyInherited() { + return (inherit == value); + } + + /** + * Returns a string representation of the object + */ + public String toString() { + return value.toString(); + } + + /** + * Is the value of this property a default value + * It is used by all macro for the function print + */ + public boolean isDefault() { + return false; + } + +} diff --git a/org/w3c/css/properties/css/CssJustifyItems.java b/org/w3c/css/properties/css/CssJustifyItems.java new file mode 100644 index 000000000..5b0f82927 --- /dev/null +++ b/org/w3c/css/properties/css/CssJustifyItems.java @@ -0,0 +1,116 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ +public class CssJustifyItems extends CssProperty { + + public CssValue value; + + /** + * Create a new CssJustifyItems + */ + public CssJustifyItems() { + } + + /** + * Creates a new CssJustifyItems + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssJustifyItems(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssJustifyItems(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 "justify-items"; + } + + /** + * 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.cssJustifyItems != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssJustifyItems = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssJustifyItems && + value.equals(((CssJustifyItems) 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).getJustifyItems(); + } else { + return ((Css3Style) style).cssJustifyItems; + } + } +} + diff --git a/org/w3c/css/properties/css/CssJustifySelf.java b/org/w3c/css/properties/css/CssJustifySelf.java new file mode 100644 index 000000000..c1acbda74 --- /dev/null +++ b/org/w3c/css/properties/css/CssJustifySelf.java @@ -0,0 +1,116 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ +public class CssJustifySelf extends CssProperty { + + public CssValue value; + + /** + * Create a new CssJustifySelf + */ + public CssJustifySelf() { + } + + /** + * Creates a new CssJustifySelf + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssJustifySelf(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssJustifySelf(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 "justify-self"; + } + + /** + * 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.cssJustifySelf != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssJustifySelf = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssJustifySelf && + value.equals(((CssJustifySelf) 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).getJustifySelf(); + } else { + return ((Css3Style) style).cssJustifySelf; + } + } +} + diff --git a/org/w3c/css/properties/css/CssPlaceContent.java b/org/w3c/css/properties/css/CssPlaceContent.java new file mode 100644 index 000000000..6c8295765 --- /dev/null +++ b/org/w3c/css/properties/css/CssPlaceContent.java @@ -0,0 +1,116 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ +public class CssPlaceContent extends CssProperty { + + public CssValue value; + + /** + * Create a new CssPlaceContent + */ + public CssPlaceContent() { + } + + /** + * Creates a new CssPlaceContent + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceContent(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssPlaceContent(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 "place-content"; + } + + /** + * 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.cssPlaceContent != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssPlaceContent = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssPlaceContent && + value.equals(((CssPlaceContent) 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).getPlaceContent(); + } else { + return ((Css3Style) style).cssPlaceContent; + } + } +} + diff --git a/org/w3c/css/properties/css/CssPlaceItems.java b/org/w3c/css/properties/css/CssPlaceItems.java new file mode 100644 index 000000000..e5a5df9ce --- /dev/null +++ b/org/w3c/css/properties/css/CssPlaceItems.java @@ -0,0 +1,116 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ +public class CssPlaceItems extends CssProperty { + + public CssValue value; + + /** + * Create a new CssPlaceItems + */ + public CssPlaceItems() { + } + + /** + * Creates a new CssPlaceItems + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceItems(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssPlaceItems(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 "place-items"; + } + + /** + * 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.cssPlaceItems != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssPlaceItems = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssPlaceItems && + value.equals(((CssPlaceItems) 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).getPlaceItems(); + } else { + return ((Css3Style) style).cssPlaceItems; + } + } +} + diff --git a/org/w3c/css/properties/css/CssPlaceSelf.java b/org/w3c/css/properties/css/CssPlaceSelf.java new file mode 100644 index 000000000..89e1f859d --- /dev/null +++ b/org/w3c/css/properties/css/CssPlaceSelf.java @@ -0,0 +1,116 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.css; + +import org.w3c.css.parser.CssStyle; +import org.w3c.css.properties.css3.Css3Style; +import org.w3c.css.util.ApplContext; +import org.w3c.css.util.InvalidParamException; +import org.w3c.css.values.CssExpression; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ +public class CssPlaceSelf extends CssProperty { + + public CssValue value; + + /** + * Create a new CssPlaceSelf + */ + public CssPlaceSelf() { + } + + /** + * Creates a new CssPlaceSelf + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceSelf(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + throw new InvalidParamException("value", + expression.getValue().toString(), + getPropertyName(), ac); + } + + public CssPlaceSelf(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 "place-self"; + } + + /** + * 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.cssPlaceSelf != null) { + style.addRedefinitionWarning(ac, this); + } + s.cssPlaceSelf = this; + } + + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssPlaceSelf && + value.equals(((CssPlaceSelf) 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).getPlaceSelf(); + } else { + return ((Css3Style) style).cssPlaceSelf; + } + } +} + diff --git a/org/w3c/css/properties/css/CssRowGap.java b/org/w3c/css/properties/css/CssRowGap.java new file mode 100644 index 000000000..9f254332e --- /dev/null +++ b/org/w3c/css/properties/css/CssRowGap.java @@ -0,0 +1,118 @@ +// +// Author: Yves Lafon +// +// COPYRIGHT (c) 2018 World Wide Web Consortium, (MIT, ERCIM, Keio, Beihang) +// 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; +import org.w3c.css.values.CssValue; + +/** + * @since CSS3 + */ + +public class CssRowGap extends CssProperty { + + private static final String propertyName = "row-gap"; + + public CssValue value; + + /** + * Create a new CssRowGap + */ + public CssRowGap() { + } + + /** + * Create a new CssRowGap + */ + public CssRowGap(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + + throw new InvalidParamException("unrecognize", ac); + } + + public CssRowGap(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) { + if (((Css3Style) style).cssRowGap != null) + style.addRedefinitionWarning(ac, this); + ((Css3Style) style).cssRowGap = this; + + } + + /** + * Get this property in the style. + * + * @param style The style where the property is + * @param resolve if true, resolve the style to find this property + */ + public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { + if (resolve) { + return ((Css3Style) style).getRowGap(); + } else { + return ((Css3Style) style).cssRowGap; + } + } + + /** + * Compares two properties for equality. + * + * @param property The other property. + */ + public boolean equals(CssProperty property) { + return (property instanceof CssRowGap && + value.equals(((CssRowGap) property).value)); + } + + /** + * Returns the name of this property + */ + public final String getPropertyName() { + return propertyName; + } + + /** + * Returns the value of this property + */ + public Object get() { + return value; + } + + /** + * Returns true if this property is "softly" inherited + */ + public boolean isSoftlyInherited() { + return (inherit == value); + } + + /** + * Returns a string representation of the object + */ + public String toString() { + return value.toString(); + } + + /** + * Is the value of this property a default value + * It is used by all macro for the function print + */ + public boolean isDefault() { + return false; + } + +} diff --git a/org/w3c/css/properties/css3/Css3Style.java b/org/w3c/css/properties/css3/Css3Style.java index 769e57bc8..25044ac39 100644 --- a/org/w3c/css/properties/css3/Css3Style.java +++ b/org/w3c/css/properties/css3/Css3Style.java @@ -79,6 +79,7 @@ import org.w3c.css.properties.css.CssFontVariantLigatures; import org.w3c.css.properties.css.CssFontVariantNumeric; import org.w3c.css.properties.css.CssFontVariantPosition; +import org.w3c.css.properties.css.CssGap; import org.w3c.css.properties.css.CssGrid; import org.w3c.css.properties.css.CssGridArea; import org.w3c.css.properties.css.CssGridAutoColumns; @@ -108,6 +109,8 @@ import org.w3c.css.properties.css.CssInitialLetterWrap; import org.w3c.css.properties.css.CssIsolation; import org.w3c.css.properties.css.CssJustifyContent; +import org.w3c.css.properties.css.CssJustifyItems; +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.CssMarkerSide; @@ -131,10 +134,14 @@ import org.w3c.css.properties.css.CssOverflowY; import org.w3c.css.properties.css.CssPerspective; import org.w3c.css.properties.css.CssPerspectiveOrigin; +import org.w3c.css.properties.css.CssPlaceContent; +import org.w3c.css.properties.css.CssPlaceItems; +import org.w3c.css.properties.css.CssPlaceSelf; import org.w3c.css.properties.css.CssResize; import org.w3c.css.properties.css.CssRest; import org.w3c.css.properties.css.CssRestAfter; import org.w3c.css.properties.css.CssRestBefore; +import org.w3c.css.properties.css.CssRowGap; import org.w3c.css.properties.css.CssRubyAlign; import org.w3c.css.properties.css.CssRubyMerge; import org.w3c.css.properties.css.CssRubyPosition; @@ -464,6 +471,78 @@ public class Css3Style extends ATSCStyle { public CssTextCombineUpright cssTextCombineUpright; public CssTextOrientation cssTextOrientation; + public CssRowGap cssRowGap; + public CssGap cssGap; + public CssJustifySelf cssJustifySelf; + public CssPlaceSelf cssPlaceSelf; + public CssPlaceContent cssPlaceContent; + public CssJustifyItems cssJustifyItems; + public CssPlaceItems cssPlaceItems; + + + public CssPlaceItems getPlaceItems() { + if (cssPlaceItems == null) { + cssPlaceItems = + (CssPlaceItems) style.CascadingOrder(new CssPlaceItems(), + style, selector); + } + return cssPlaceItems; + } + + public CssJustifyItems getJustifyItems() { + if (cssJustifyItems == null) { + cssJustifyItems = + (CssJustifyItems) style.CascadingOrder(new CssJustifyItems(), + style, selector); + } + return cssJustifyItems; + } + + public CssPlaceContent getPlaceContent() { + if (cssPlaceContent == null) { + cssPlaceContent = + (CssPlaceContent) style.CascadingOrder(new CssPlaceContent(), + style, selector); + } + return cssPlaceContent; + } + + public CssPlaceSelf getPlaceSelf() { + if (cssPlaceSelf == null) { + cssPlaceSelf = + (CssPlaceSelf) style.CascadingOrder(new CssPlaceSelf(), + style, selector); + } + return cssPlaceSelf; + } + + public CssJustifySelf getJustifySelf() { + if (cssJustifySelf == null) { + cssJustifySelf = + (CssJustifySelf) style.CascadingOrder(new CssJustifySelf(), + style, selector); + } + return cssJustifySelf; + } + + public CssGap getGap() { + if (cssGap == null) { + cssGap = + (CssGap) style.CascadingOrder(new CssGap(), + style, selector); + } + return cssGap; + } + + public CssRowGap getRowGap() { + if (cssRowGap == null) { + cssRowGap = + (CssRowGap) style.CascadingOrder(new CssRowGap(), + style, selector); + } + return cssRowGap; + } + public CssTextCombineUpright getTextCombineUpright() { if (cssTextCombineUpright == null) { cssTextCombineUpright = diff --git a/org/w3c/css/properties/css3/CssAlignContent.java b/org/w3c/css/properties/css3/CssAlignContent.java index 380072084..a1f20d117 100644 --- a/org/w3c/css/properties/css3/CssAlignContent.java +++ b/org/w3c/css/properties/css3/CssAlignContent.java @@ -5,32 +5,90 @@ // 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/2016/CR-css-flexbox-1-20160526/#propdef-align-content + * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-align-content */ public class CssAlignContent extends org.w3c.css.properties.css.CssAlignContent { - public static final CssIdent[] allowed_values; + public static final CssIdent baseline, normal; + public static final CssIdent[] baseline_qualifier, content_distribution, + overflow_position, content_position; static { - String[] _allowed_values = {"flex-start", "flex-end", "center", "space-between", - "space-around", "stretch"}; - allowed_values = new CssIdent[_allowed_values.length]; + baseline = CssIdent.getIdent("baseline"); + normal = CssIdent.getIdent("normal"); + + String[] _baseline_qualifier_values = {"first", "last"}; + baseline_qualifier = new CssIdent[_baseline_qualifier_values.length]; int i = 0; - for (String s : _allowed_values) { - allowed_values[i++] = CssIdent.getIdent(s); + for (String s : _baseline_qualifier_values) { + baseline_qualifier[i++] = CssIdent.getIdent(s); + } + i = 0; + String[] _content_distribution_values = {"space-between", "space-around", + "space-evenly", "stretch"}; + content_distribution = new CssIdent[_content_distribution_values.length]; + for (String s : _content_distribution_values) { + content_distribution[i++] = CssIdent.getIdent(s); + } + i = 0; + String[] _overflow_position_values = {"unsafe", "safe"}; + overflow_position = new CssIdent[_overflow_position_values.length]; + for (String s : _overflow_position_values) { + overflow_position[i++] = CssIdent.getIdent(s); + } + i = 0; + String[] _content_position_values = {"center", "start", "end", + "flex-start", "flex-end"}; + content_position = new CssIdent[_content_position_values.length]; + for (String s : _content_position_values) { + content_position[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getBaselineQualifier(CssIdent ident) { + for (CssIdent id : baseline_qualifier) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getContentDistribution(CssIdent ident) { + for (CssIdent id : content_distribution) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getOverflowPosition(CssIdent ident) { + for (CssIdent id : overflow_position) { + if (id.equals(ident)) { + return id; + } } + return null; } - public static CssIdent getAllowedIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { + public static CssIdent getContentPosition(CssIdent ident) { + for (CssIdent id : content_position) { if (id.equals(ident)) { return id; } @@ -38,6 +96,7 @@ public static CssIdent getAllowedIdent(CssIdent ident) { return null; } + /** * Create a new CssAlignContent */ @@ -54,12 +113,22 @@ public CssAlignContent() { */ public CssAlignContent(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); - CssValue val; + value = parseAlignContent(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + } + + public static CssValue parseAlignContent(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); char op; val = expression.getValue(); @@ -68,22 +137,83 @@ public CssAlignContent(ApplContext ac, CssExpression expression, boolean check) if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = (CssIdent) val; if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + if (normal.equals(ident)) { + expression.next(); + return normal; + } + value = getContentDistribution(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + if (baseline.equals(ident)) { + expression.next(); + return baseline; + } + value = getContentPosition(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = getBaselineQualifier(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !baseline.equals(val)) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(baseline); + expression.next(); + return new CssValueList(values); + } + value = getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = getContentPosition((CssIdent) val); if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); } + values.add(value); + expression.next(); + return new CssValueList(values); } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - expression.next(); + } + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); } public CssAlignContent(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssAlignItems.java b/org/w3c/css/properties/css3/CssAlignItems.java index 4fcc323f4..49cf6a9f9 100644 --- a/org/w3c/css/properties/css3/CssAlignItems.java +++ b/org/w3c/css/properties/css3/CssAlignItems.java @@ -5,31 +5,39 @@ // 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/2016/CR-css-flexbox-1-20160526/#propdef-align-items + * replaced by + * https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-align-items */ public class CssAlignItems extends org.w3c.css.properties.css.CssAlignItems { - public static final CssIdent[] allowed_values; + public static final CssIdent[] single_align_items_values; static { - String[] _allowed_values = {"flex-start", "flex-end", "center", "baseline", "stretch"}; - allowed_values = new CssIdent[_allowed_values.length]; + String[] _single_values = {"normal", "stretch"}; + single_align_items_values = new CssIdent[_single_values.length]; int i = 0; - for (String s : _allowed_values) { - allowed_values[i++] = CssIdent.getIdent(s); + for (String s : _single_values) { + single_align_items_values[i++] = CssIdent.getIdent(s); } } - public static CssIdent getAllowedIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { + public static CssIdent getSingleAlignItemsValue(CssIdent ident) { + for (CssIdent id : single_align_items_values) { if (id.equals(ident)) { return id; } @@ -53,12 +61,23 @@ public CssAlignItems() { */ public CssAlignItems(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); - CssValue val; + value = parseAlignItems(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + + } + + public static CssValue parseAlignItems(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); char op; val = expression.getValue(); @@ -67,22 +86,79 @@ public CssAlignItems(ApplContext ac, CssExpression expression, boolean check) if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = (CssIdent) val; if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + value = getSingleAlignItemsValue(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + if (CssAlignContent.baseline.equals(ident)) { + expression.next(); + return CssAlignContent.baseline; + } + value = CssAlignSelf.getSelfPosition(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = CssAlignContent.getBaselineQualifier(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(CssAlignContent.baseline); + expression.next(); + return new CssValueList(values); + } + value = CssAlignContent.getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = CssAlignSelf.getSelfPosition((CssIdent) val); if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); } + values.add(value); + expression.next(); + return new CssValueList(values); } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - expression.next(); + } + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); } public CssAlignItems(ApplContext ac, CssExpression expression) diff --git a/org/w3c/css/properties/css3/CssAlignSelf.java b/org/w3c/css/properties/css3/CssAlignSelf.java index 4e33a82f6..8ebbf636f 100644 --- a/org/w3c/css/properties/css3/CssAlignSelf.java +++ b/org/w3c/css/properties/css3/CssAlignSelf.java @@ -5,32 +5,56 @@ // 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/2016/CR-css-flexbox-1-20160526/#propdef-align-self + * replaced by + * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#align-self-property */ public class CssAlignSelf extends org.w3c.css.properties.css.CssAlignSelf { - public static final CssIdent[] allowed_values; + public static final CssIdent[] single_align_self_values; + public static final CssIdent[] self_position; static { - String[] _allowed_values = {"auto", "flex-start", "flex-end", "center", - "baseline", "stretch"}; - allowed_values = new CssIdent[_allowed_values.length]; + String[] _single_values = {"auto", "normal", "stretch"}; + single_align_self_values = new CssIdent[_single_values.length]; int i = 0; - for (String s : _allowed_values) { - allowed_values[i++] = CssIdent.getIdent(s); + for (String s : _single_values) { + single_align_self_values[i++] = CssIdent.getIdent(s); + } + String[] _self_position_values = {"center", "start", "end", "self-start", + "self-end", "flex-start", "flex-end"}; + self_position = new CssIdent[_self_position_values.length]; + i = 0; + for (String s : _self_position_values) { + self_position[i++] = CssIdent.getIdent(s); } } - public static CssIdent getAllowedIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { + public static CssIdent getSingleAlignSelfValue(CssIdent ident) { + for (CssIdent id : single_align_self_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getSelfPosition(CssIdent ident) { + for (CssIdent id : self_position) { if (id.equals(ident)) { return id; } @@ -54,12 +78,22 @@ public CssAlignSelf() { */ public CssAlignSelf(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); - CssValue val; + value = parseAlignSelf(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + } + + public static CssValue parseAlignSelf(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); char op; val = expression.getValue(); @@ -68,24 +102,82 @@ public CssAlignSelf(ApplContext ac, CssExpression expression, boolean check) if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = (CssIdent) val; if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + value = getSingleAlignSelfValue(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + if (CssAlignContent.baseline.equals(ident)) { + expression.next(); + return CssAlignContent.baseline; + } + value = getSelfPosition(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = CssAlignContent.getBaselineQualifier(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(CssAlignContent.baseline); + expression.next(); + return new CssValueList(values); + } + value = CssAlignContent.getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = getSelfPosition((CssIdent) val); if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); } + values.add(value); + expression.next(); + return new CssValueList(values); } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); - } - expression.next(); + } + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); } + public CssAlignSelf(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); diff --git a/org/w3c/css/properties/css3/CssColumnGap.java b/org/w3c/css/properties/css3/CssColumnGap.java index 41e1b2d09..514e8aad0 100644 --- a/org/w3c/css/properties/css3/CssColumnGap.java +++ b/org/w3c/css/properties/css3/CssColumnGap.java @@ -7,7 +7,6 @@ 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.CssCheckableValue; @@ -18,6 +17,7 @@ /** * @spec https://www.w3.org/TR/2018/WD-css-multicol-1-20180528/#propdef-column-gap + * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-column-gap */ public class CssColumnGap extends org.w3c.css.properties.css.CssColumnGap { @@ -53,7 +53,6 @@ public CssColumnGap(ApplContext ac, CssExpression expression, value = val; break; case CssTypes.CSS_PERCENTAGE: - // warning percentage is at risk case CssTypes.CSS_LENGTH: CssCheckableValue l = val.getCheckableValue(); l.checkPositiveness(ac, this); @@ -80,37 +79,6 @@ public CssColumnGap(ApplContext ac, CssExpression expression) this(ac, expression, false); } - /** - * Compares two properties for equality. - * - * @param property The other property. - */ - public boolean equals(CssProperty property) { - return (property instanceof CssColumnGap && - value.equals(((CssColumnGap) property).value)); - } - - /** - * Returns the value of this property - */ - public Object get() { - return value; - } - - /** - * Returns true if this property is "softly" inherited - */ - public boolean isSoftlyInherited() { - return (inherit == value); - } - - /** - * Returns a string representation of the object - */ - public String toString() { - return value.toString(); - } - /** * Is the value of this property a default value * It is used by all macro for the function print diff --git a/org/w3c/css/properties/css3/CssGridGap.java b/org/w3c/css/properties/css3/CssGap.java similarity index 53% rename from org/w3c/css/properties/css3/CssGridGap.java rename to org/w3c/css/properties/css3/CssGap.java index 1c76416a7..177623dda 100644 --- a/org/w3c/css/properties/css3/CssGridGap.java +++ b/org/w3c/css/properties/css3/CssGap.java @@ -1,8 +1,9 @@ // // Author: Yves Lafon // -// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016. +// COPYRIGHT (c) 1995-2018 World Wide Web Consortium, (MIT, ERCIM, Keio, Beihang) // Please first read the full copyright statement in file COPYRIGHT.html + package org.w3c.css.properties.css3; import org.w3c.css.parser.CssStyle; @@ -17,31 +18,28 @@ import static org.w3c.css.values.CssOperator.SPACE; /** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-gap + * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-gap */ -public class CssGridGap extends org.w3c.css.properties.css.CssGridGap { - private CssGridColumnGap column; - private CssGridRowGap row; +public class CssGap extends org.w3c.css.properties.css.CssGap { + + private CssColumnGap columnGap; + private CssRowGap rowGap; /** - * Create a new CssGridGap + * Create a new CssGap */ - public CssGridGap() { + public CssGap() { value = initial; - column = new CssGridColumnGap(); - row = new CssGridRowGap(); + columnGap = new CssColumnGap(); + rowGap = new CssRowGap(); } /** - * Creates a new CssGridGap - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect + * Create a new CssGap */ - public CssGridGap(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { + public CssGap(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } @@ -50,11 +48,11 @@ public CssGridGap(ApplContext ac, CssExpression expression, boolean check) // get the separator now in case we need it. char op = expression.getOperator(); // create the values we will fill - column = new CssGridColumnGap(); - row = new CssGridRowGap(); + columnGap = new CssColumnGap(); + rowGap = new CssRowGap(); - val = CssGridRowGap.checkSyntax(ac, expression, false, this); - row.value = val; + val = CssRowGap.checkSyntax(ac, expression, this); + rowGap.value = val; if (!expression.end()) { if (op != SPACE) { throw new InvalidParamException("operator", @@ -65,23 +63,37 @@ public CssGridGap(ApplContext ac, CssExpression expression, boolean check) throw new InvalidParamException("value", val.toString(), getPropertyName(), ac); } - val = CssGridRowGap.checkSyntax(ac, expression, false, this); - column.value = val; + val = CssRowGap.checkSyntax(ac, expression, this); + // same for value #2 + if (inherit.equals(val)) { + throw new InvalidParamException("value", val.toString(), + getPropertyName(), ac); + } + columnGap.value = val; ArrayList v = new ArrayList<>(2); - v.add(row.value); - v.add(column.value); + v.add(rowGap.value); + v.add(columnGap.value); value = new CssValueList(v); } else { value = val; - row.value = val; + columnGap.value = val; } + } - public CssGridGap(ApplContext ac, CssExpression expression) + public CssGap(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); } + /** + * Is the value of this property a default value + * It is used by all macro for the function print + */ + public boolean isDefault() { + return (value == initial); + } + /** * Add this property to the CssStyle. * @@ -89,8 +101,7 @@ public CssGridGap(ApplContext ac, CssExpression expression) */ public void addToStyle(ApplContext ac, CssStyle style) { super.addToStyle(ac, style); - column.addToStyle(ac, style); - row.addToStyle(ac, style); + columnGap.addToStyle(ac, style); + rowGap.addToStyle(ac, style); } } - diff --git a/org/w3c/css/properties/css3/CssGrid.java b/org/w3c/css/properties/css3/CssGrid.java index 04ddfd7e7..885530310 100644 --- a/org/w3c/css/properties/css3/CssGrid.java +++ b/org/w3c/css/properties/css3/CssGrid.java @@ -37,8 +37,6 @@ public class CssGrid extends org.w3c.css.properties.css.CssGrid { private CssGridAutoColumns cssGridAutoColumns; private CssGridAutoFlow cssGridAutoFlow; private CssGridAutoRows cssGridAutoRows; - private CssGridColumnGap cssGridColumnGap; - private CssGridRowGap cssGridRowGap; /** * Create a new CssGridArea @@ -51,8 +49,6 @@ public CssGrid() { cssGridAutoColumns = new CssGridAutoColumns(); cssGridAutoFlow = new CssGridAutoFlow(); cssGridAutoRows = new CssGridAutoRows(); - cssGridColumnGap = new CssGridColumnGap(); - cssGridRowGap = new CssGridRowGap(); } /** @@ -75,8 +71,6 @@ public CssGrid(ApplContext ac, CssExpression expression, boolean check) cssGridAutoColumns = new CssGridAutoColumns(); cssGridAutoFlow = new CssGridAutoFlow(); cssGridAutoRows = new CssGridAutoRows(); - cssGridColumnGap = new CssGridColumnGap(); - cssGridRowGap = new CssGridRowGap(); ArrayList values = new ArrayList<>(); ArrayList autoFlowValues = new ArrayList<>(); @@ -336,8 +330,6 @@ public void addToStyle(ApplContext ac, CssStyle style) { cssGridAutoColumns.addToStyle(ac, style); cssGridAutoFlow.addToStyle(ac, style); cssGridAutoRows.addToStyle(ac, style); - cssGridColumnGap.addToStyle(ac, style); - cssGridRowGap.addToStyle(ac, style); } } diff --git a/org/w3c/css/properties/css3/CssGridColumnGap.java b/org/w3c/css/properties/css3/CssGridColumnGap.java deleted file mode 100644 index aa43f8110..000000000 --- a/org/w3c/css/properties/css3/CssGridColumnGap.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Author: Yves Lafon -// -// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016. -// 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/2017/CR-css-grid-1-20170209/#propdef-grid-column-gap - */ -public class CssGridColumnGap extends org.w3c.css.properties.css.CssGridColumnGap { - - /** - * Create a new CssGridColumnGap - */ - public CssGridColumnGap() { - value = initial; - } - - /** - * Creates a new CssGridColumnGap - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssGridColumnGap(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { - value = CssGridRowGap.checkSyntax(ac, expression, check, this); - } - - public CssGridColumnGap(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } - -} - diff --git a/org/w3c/css/properties/css3/CssGridRowGap.java b/org/w3c/css/properties/css3/CssGridRowGap.java deleted file mode 100644 index 6e8190d01..000000000 --- a/org/w3c/css/properties/css3/CssGridRowGap.java +++ /dev/null @@ -1,84 +0,0 @@ -// -// Author: Yves Lafon -// -// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016. -// 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.CssTypes; -import org.w3c.css.values.CssValue; - -/** - * @spec https://www.w3.org/TR/2017/CR-css-grid-1-20170209/#propdef-grid-row-gap - */ -public class CssGridRowGap extends org.w3c.css.properties.css.CssGridRowGap { - - /** - * Create a new CssGridRowGap - */ - public CssGridRowGap() { - value = initial; - } - - /** - * Creates a new CssGridRowGap - * - * @param expression The expression for this property - * @throws org.w3c.css.util.InvalidParamException - * Expressions are incorrect - */ - public CssGridRowGap(ApplContext ac, CssExpression expression, boolean check) - throws InvalidParamException { - value = checkSyntax(ac, expression, check, this); - } - - // as it is ued in other places, use a static checker function. - public static CssValue checkSyntax(ApplContext ac, CssExpression expression, boolean check, - CssProperty caller) - throws InvalidParamException { - if (check && expression.getCount() > 1) { - throw new InvalidParamException("unrecognize", ac); - } - caller.setByUser(); - - CssValue val, value; - char op; - - val = expression.getValue(); - op = expression.getOperator(); - - switch (val.getType()) { - case CssTypes.CSS_NUMBER: - val.getCheckableValue().checkEqualsZero(ac, caller); - value = val; - break; - case CssTypes.CSS_LENGTH: - case CssTypes.CSS_PERCENTAGE: - value = val; - break; - case CssTypes.CSS_IDENT: - if (inherit.equals(val)) { - value = inherit; - break; - } - default: - throw new InvalidParamException("value", - val.toString(), - caller.getPropertyName(), ac); - - } - expression.next(); - return value; - } - - public CssGridRowGap(ApplContext ac, CssExpression expression) - throws InvalidParamException { - this(ac, expression, false); - } - -} - diff --git a/org/w3c/css/properties/css3/CssJustifyContent.java b/org/w3c/css/properties/css3/CssJustifyContent.java index 4c619d97b..87318a02e 100644 --- a/org/w3c/css/properties/css3/CssJustifyContent.java +++ b/org/w3c/css/properties/css3/CssJustifyContent.java @@ -5,37 +5,47 @@ // 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; /** + * original * @spec https://www.w3.org/TR/2016/CR-css-flexbox-1-20160526/#propdef-justify-content + * replaced by + * @spec https://www.w3.org/TR/2018/WD-css-align-3-20180423/#propdef-justify-content */ public class CssJustifyContent extends org.w3c.css.properties.css.CssJustifyContent { - public static final CssIdent[] allowed_values; + public static final CssIdent[] content_position_extras; + public static final CssIdent normal; static { - String[] _allowed_values = {"flex-start", "flex-end", "center", - "space-between", "space-around"}; - allowed_values = new CssIdent[_allowed_values.length]; + normal = CssIdent.getIdent("normal"); + String[] _content_position_extras_values = {"left", "right"}; + content_position_extras = new CssIdent[_content_position_extras_values.length]; int i = 0; - for (String s : _allowed_values) { - allowed_values[i++] = CssIdent.getIdent(s); + for (String s : _content_position_extras_values) { + content_position_extras[i++] = CssIdent.getIdent(s); } } - public static CssIdent getAllowedIdent(CssIdent ident) { - for (CssIdent id : allowed_values) { + public static CssIdent getContentPositionAndExtras(CssIdent ident) { + for (CssIdent id : content_position_extras) { if (id.equals(ident)) { return id; } } - return null; + return CssAlignContent.getContentPosition(ident); } /** @@ -54,12 +64,22 @@ public CssJustifyContent() { */ public CssJustifyContent(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException { - if (check && expression.getCount() > 1) { + if (check && expression.getCount() > 2) { throw new InvalidParamException("unrecognize", ac); } setByUser(); - CssValue val; + value = parseJustifyContent(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + } + + public static CssValue parseJustifyContent(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); char op; val = expression.getValue(); @@ -68,24 +88,61 @@ public CssJustifyContent(ApplContext ac, CssExpression expression, boolean check if (val.getType() == CssTypes.CSS_IDENT) { CssIdent ident = (CssIdent) val; if (inherit.equals(ident)) { - value = inherit; - } else { - value = getAllowedIdent(ident); + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + if (normal.equals(ident)) { + expression.next(); + return normal; + } + value = CssAlignContent.getContentDistribution(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + value = getContentPositionAndExtras(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = CssAlignContent.getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = getContentPositionAndExtras((CssIdent) val); if (value == null) { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); } + values.add(value); + expression.next(); + return new CssValueList(values); } - } else { - throw new InvalidParamException("value", - val.toString(), - getPropertyName(), ac); } - expression.next(); - + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); } + public CssJustifyContent(ApplContext ac, CssExpression expression) throws InvalidParamException { this(ac, expression, false); diff --git a/org/w3c/css/properties/css3/CssJustifyItems.java b/org/w3c/css/properties/css3/CssJustifyItems.java new file mode 100644 index 000000000..2c3fa2e4d --- /dev/null +++ b/org/w3c/css/properties/css3/CssJustifyItems.java @@ -0,0 +1,249 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016. +// 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/2018/WD-css-align-3-20180423/#justify-items-property + */ +public class CssJustifyItems extends org.w3c.css.properties.css.CssJustifyItems { + + public static final CssIdent[] self_position_extras, legacy_qualifier, + single_justify_items_values; + public static final CssIdent legacy; + + static { + legacy = CssIdent.getIdent("legacy"); + String[] _single_values = {"normal", "stretch"}; + single_justify_items_values = new CssIdent[_single_values.length]; + int i = 0; + for (String s : _single_values) { + single_justify_items_values[i++] = CssIdent.getIdent(s); + } + String[] _self_position_extra_values = {"left", "right"}; + self_position_extras = new CssIdent[_self_position_extra_values.length]; + i = 0; + for (String s : _self_position_extra_values) { + self_position_extras[i++] = CssIdent.getIdent(s); + } + String[] _legacy_qualifier_values = {"left", "right", "center"}; + legacy_qualifier = new CssIdent[_legacy_qualifier_values.length]; + i = 0; + for (String s : _legacy_qualifier_values) { + legacy_qualifier[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getSelfPositionAddExtras(CssIdent ident) { + for (CssIdent id : self_position_extras) { + if (id.equals(ident)) { + return id; + } + } + return CssAlignSelf.getSelfPosition(ident); + } + + public static CssIdent getLegacyQualifier(CssIdent ident) { + for (CssIdent id : legacy_qualifier) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + public static CssIdent getSingleJustifyItemsValue(CssIdent ident) { + for (CssIdent id : single_justify_items_values) { + if (id.equals(ident)) { + return id; + } + } + return null; + } + + /** + * Create a new CssAlignSelf + */ + public CssJustifyItems() { + value = initial; + } + + /** + * Creates a new CssAlignSelf + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssJustifyItems(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + value = parseJustifyItems(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + } + + public static CssValue parseJustifyItems(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() == CssTypes.CSS_IDENT) { + CssIdent ident = (CssIdent) val; + if (inherit.equals(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + value = getSingleJustifyItemsValue(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + if (CssAlignContent.baseline.equals(ident)) { + expression.next(); + return CssAlignContent.baseline; + } + // we must check the extras first + value = getLegacyQualifier(ident); + // legacy qualifier are part of self-position, so we may have nothing + if (value != null) { + expression.next(); + if (expression.end()) { + return value; + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !legacy.equals(val)) { + return value; + } + // ok, we got a leagacy, operator check and return + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + values.add(value); + values.add(legacy); + expression.next(); + return new CssValueList(values); + } + + value = getSelfPositionAddExtras(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = CssAlignContent.getBaselineQualifier(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(CssAlignContent.baseline); + expression.next(); + return new CssValueList(values); + } + value = CssAlignContent.getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = getSelfPositionAddExtras((CssIdent) val); + if (value == null) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(value); + expression.next(); + return new CssValueList(values); + } + // now we need to do guess work and possibly backtrack. + if (legacy.equals(ident)) { + // we can have nothing or a qualifier here. + expression.next(); + if (expression.end()) { + return legacy; + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + return legacy; // let the caller check and fail if necessary + } + value = getLegacyQualifier((CssIdent) val); + if (value == null) { + return legacy; + } + // so we got something, check the operator + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + values.add(legacy); + values.add(value); + expression.next(); + return new CssValueList(values); + } + + } + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); + } + + + public CssJustifyItems(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssJustifySelf.java b/org/w3c/css/properties/css3/CssJustifySelf.java new file mode 100644 index 000000000..5b1c43c72 --- /dev/null +++ b/org/w3c/css/properties/css3/CssJustifySelf.java @@ -0,0 +1,168 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2016. +// 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/2018/WD-css-align-3-20180423/#justify-self-property + */ +public class CssJustifySelf extends org.w3c.css.properties.css.CssJustifySelf { + + public static final CssIdent[] self_position_extras; + + static { + String[] _self_position_extra_values = {"left", "right"}; + self_position_extras = new CssIdent[_self_position_extra_values.length]; + int i = 0; + for (String s : _self_position_extra_values) { + self_position_extras[i++] = CssIdent.getIdent(s); + } + } + + public static CssIdent getSelfPositionAddExtras(CssIdent ident) { + for (CssIdent id : self_position_extras) { + if (id.equals(ident)) { + return id; + } + } + return CssAlignSelf.getSelfPosition(ident); + } + + /** + * Create a new CssAlignSelf + */ + public CssJustifySelf() { + value = initial; + } + + /** + * Creates a new CssAlignSelf + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssJustifySelf(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 2) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + value = parseJustifySelf(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + } + + public static CssValue parseJustifySelf(ApplContext ac, CssExpression expression, + CssProperty caller) + throws InvalidParamException { + CssValue val, value; + ArrayList values = new ArrayList<>(); + char op; + + val = expression.getValue(); + op = expression.getOperator(); + + if (val.getType() == CssTypes.CSS_IDENT) { + CssIdent ident = (CssIdent) val; + if (inherit.equals(ident)) { + if (expression.getCount() > 1) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + expression.next(); + return inherit; + } + value = CssAlignSelf.getSingleAlignSelfValue(ident); + if (value != null) { + expression.next(); + return value; + } + // now try the two-values position, starting first with only one. + if (CssAlignContent.baseline.equals(ident)) { + expression.next(); + return CssAlignContent.baseline; + } + value = getSelfPositionAddExtras(ident); + if (value != null) { + expression.next(); + return value; + } + // ok, at that point we need two values. + value = CssAlignContent.getBaselineQualifier(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT || !CssAlignContent.baseline.equals(val)) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(CssAlignContent.baseline); + expression.next(); + return new CssValueList(values); + } + value = CssAlignContent.getOverflowPosition(ident); + if (value != null) { + values.add(value); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + expression.next(); + if (expression.end()) { + throw new InvalidParamException("unrecognize", ac); + } + val = expression.getValue(); + if (val.getType() != CssTypes.CSS_IDENT) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + value = getSelfPositionAddExtras((CssIdent) val); + if (value == null) { + throw new InvalidParamException("value", val.toString(), + caller.getPropertyName(), ac); + } + values.add(value); + expression.next(); + return new CssValueList(values); + } + + } + throw new InvalidParamException("value", + val.toString(), + caller.getPropertyName(), ac); + } + + + public CssJustifySelf(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + +} + diff --git a/org/w3c/css/properties/css3/CssPlaceContent.java b/org/w3c/css/properties/css3/CssPlaceContent.java new file mode 100644 index 000000000..d19f4d176 --- /dev/null +++ b/org/w3c/css/properties/css3/CssPlaceContent.java @@ -0,0 +1,98 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.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.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/2018/WD-css-align-3-20180423/#place-content-property + */ +public class CssPlaceContent extends org.w3c.css.properties.css.CssPlaceContent { + + private CssAlignContent alignContent; + private CssJustifyContent justifyContent; + + /** + * Create a new CssAlignContent + */ + public CssPlaceContent() { + value = initial; + alignContent = new CssAlignContent(); + justifyContent = new CssJustifyContent(); + } + + /** + * Creates a new CssAlignContent + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceContent(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + alignContent = new CssAlignContent(); + justifyContent = new CssJustifyContent(); + + ArrayList values = new ArrayList<>(); + CssValue val; + + val = CssAlignContent.parseAlignContent(ac, expression, this); + if (expression.end()) { + value = val; + alignContent.value = val; + justifyContent.value = val; + } else { + char op = expression.getOperator(); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + values.add(val); + alignContent.value = val; + + val = CssJustifyContent.parseJustifyContent(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("value", expression.getValue().toString(), + getPropertyName(), ac); + } + values.add(val); + justifyContent.value = val; + value = new CssValueList(values); + } + } + + public CssPlaceContent(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); + alignContent.addToStyle(ac, style); + justifyContent.addToStyle(ac, style); + } +} + diff --git a/org/w3c/css/properties/css3/CssPlaceItems.java b/org/w3c/css/properties/css3/CssPlaceItems.java new file mode 100644 index 000000000..fb7427483 --- /dev/null +++ b/org/w3c/css/properties/css3/CssPlaceItems.java @@ -0,0 +1,98 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.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.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/2018/WD-css-align-3-20180423/#place-items-property + */ +public class CssPlaceItems extends org.w3c.css.properties.css.CssPlaceItems { + + private CssAlignItems alignItems; + private CssJustifyItems justifyItems; + + /** + * Create a new CssAlignItems + */ + public CssPlaceItems() { + value = initial; + alignItems = new CssAlignItems(); + justifyItems = new CssJustifyItems(); + } + + /** + * Creates a new CssAlignItems + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceItems(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + alignItems = new CssAlignItems(); + justifyItems = new CssJustifyItems(); + + ArrayList values = new ArrayList<>(); + CssValue val; + + val = CssAlignItems.parseAlignItems(ac, expression, this); + if (expression.end()) { + value = val; + alignItems.value = val; + justifyItems.value = val; + } else { + char op = expression.getOperator(); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + values.add(val); + alignItems.value = val; + + val = CssJustifyItems.parseJustifyItems(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("value", expression.getValue().toString(), + getPropertyName(), ac); + } + values.add(val); + justifyItems.value = val; + value = new CssValueList(values); + } + } + + public CssPlaceItems(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); + alignItems.addToStyle(ac, style); + justifyItems.addToStyle(ac, style); + } +} + diff --git a/org/w3c/css/properties/css3/CssPlaceSelf.java b/org/w3c/css/properties/css3/CssPlaceSelf.java new file mode 100644 index 000000000..8e1e3c818 --- /dev/null +++ b/org/w3c/css/properties/css3/CssPlaceSelf.java @@ -0,0 +1,98 @@ +// +// Author: Yves Lafon +// +// (c) COPYRIGHT MIT, ERCIM, Keio, Beihang, 2018. +// Please first read the full copyright statement in file COPYRIGHT.html +package org.w3c.css.properties.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.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/2018/WD-css-align-3-20180423/#place-self-property + */ +public class CssPlaceSelf extends org.w3c.css.properties.css.CssPlaceSelf { + + private CssAlignSelf alignSelf; + private CssJustifySelf justifySelf; + + /** + * Create a new CssAlignSelf + */ + public CssPlaceSelf() { + value = initial; + alignSelf = new CssAlignSelf(); + justifySelf = new CssJustifySelf(); + } + + /** + * Creates a new CssAlignSelf + * + * @param expression The expression for this property + * @throws org.w3c.css.util.InvalidParamException + * Expressions are incorrect + */ + public CssPlaceSelf(ApplContext ac, CssExpression expression, boolean check) + throws InvalidParamException { + if (check && expression.getCount() > 4) { + throw new InvalidParamException("unrecognize", ac); + } + setByUser(); + + alignSelf = new CssAlignSelf(); + justifySelf = new CssJustifySelf(); + + ArrayList values = new ArrayList<>(); + CssValue val; + + val = CssAlignSelf.parseAlignSelf(ac, expression, this); + if (expression.end()) { + value = val; + alignSelf.value = val; + justifySelf.value = val; + } else { + char op = expression.getOperator(); + if (op != SPACE) { + throw new InvalidParamException("operator", + ((new Character(op)).toString()), ac); + } + values.add(val); + alignSelf.value = val; + + val = CssJustifySelf.parseJustifySelf(ac, expression, this); + if (!expression.end()) { + throw new InvalidParamException("value", expression.getValue().toString(), + getPropertyName(), ac); + } + values.add(val); + justifySelf.value = val; + value = new CssValueList(values); + } + } + + public CssPlaceSelf(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); + alignSelf.addToStyle(ac, style); + justifySelf.addToStyle(ac, style); + } +} + diff --git a/org/w3c/css/properties/css3/CssRowGap.java b/org/w3c/css/properties/css3/CssRowGap.java new file mode 100644 index 000000000..05abc439a --- /dev/null +++ b/org/w3c/css/properties/css3/CssRowGap.java @@ -0,0 +1,94 @@ +// +// Author: Yves Lafon +// +// COPYRIGHT (c) 2018 World Wide Web Consortium, (MIT, ERCIM, Keio, Beihang) +// 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.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/2018/WD-css-align-3-20180423/#propdef-row-gap + */ + +public class CssRowGap extends org.w3c.css.properties.css.CssColumnGap { + + static CssIdent normal; + + static { + normal = CssIdent.getIdent("normal"); + } + + /** + * Create a new CssColumnGap + */ + public CssRowGap() { + value = initial; + } + + /** + * Create a new CssColumnGap + */ + public CssRowGap(ApplContext ac, CssExpression expression, + boolean check) throws InvalidParamException { + setByUser(); + + if (check && expression.getCount() > 1) { + throw new InvalidParamException("unrecognize", ac); + } + value = checkSyntax(ac, expression, this); + } + + public static CssValue checkSyntax(ApplContext ac, CssExpression expression, CssProperty caller) + throws InvalidParamException { + CssValue val = expression.getValue(); + + switch (val.getType()) { + case CssTypes.CSS_NUMBER: + val.getCheckableValue().checkEqualsZero(ac, caller); + break; + case CssTypes.CSS_PERCENTAGE: + case CssTypes.CSS_LENGTH: + CssCheckableValue l = val.getCheckableValue(); + l.checkPositiveness(ac, caller); + break; + case CssTypes.CSS_IDENT: + if (normal.equals(val)) { + val = normal; + break; + } + if (inherit.equals(val)) { + val = inherit; + break; + } + default: + throw new InvalidParamException("value", expression.getValue(), + caller.getPropertyName(), ac); + } + expression.next(); + return val; + + } + + public CssRowGap(ApplContext ac, CssExpression expression) + throws InvalidParamException { + this(ac, expression, false); + } + + /** + * Is the value of this property a default value + * It is used by all macro for the function print + */ + public boolean isDefault() { + return (value == initial); + } + +}