Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions org/w3c/css/properties/CSS3Properties.properties
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,8 @@ zoom: org.w3c.css.properties.css3.CssZoom
@font-face.font-feature-settings: org.w3c.css.properties.css3.fontface.CssFontFeatureSettings
@font-face.font-language-override: org.w3c.css.properties.css3.fontface.CssFontLanguageOverride
@font-face.font-named-instance org.w3c.css.properties.css3.fontface.CssFontNamedInstance
@font-face.font-stretch: org.w3c.css.properties.css3.fontface.CssFontWidth
@font-face.font-width: org.w3c.css.properties.css3.fontface.CssFontWidth
@font-face.font-stretch: org.w3c.css.properties.css3.fontface.CSSFontStretch
@font-face.font-width: org.w3c.css.properties.css3.fontface.CssFontWidth
@font-face.font-style: org.w3c.css.properties.css3.fontface.CssFontStyle
@font-face.font-variation-settings: org.w3c.css.properties.css3.fontface.CssFontVariationSettings
@font-face.font-weight: org.w3c.css.properties.css3.fontface.CssFontWeight
Expand Down
100 changes: 100 additions & 0 deletions org/w3c/css/properties/css/fontface/CSSFontStretch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package org.w3c.css.properties.css.fontface;

import org.w3c.css.parser.CssStyle;
import org.w3c.css.properties.css.CssProperty;
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;

/**
* @version $Revision$
* @since CSS2
*/
public class CSSFontStretch extends CssProperty {

/**
* Create a new CSSFontStretch
*/
public CSSFontStretch() {
}

/**
* Creates a new CSSFontStretch
*
* @param expression The expression for this property
* @throws InvalidParamException Expressions are incorrect
*/
public CSSFontStretch(ApplContext ac, CssExpression expression, boolean check) throws InvalidParamException {
throw new InvalidParamException("value", expression.getValue().toString(), getPropertyName(), ac);
}

public CSSFontStretch(ApplContext ac, CssExpression expression) throws InvalidParamException {
this(ac, expression, false);
}

/**
* Returns the value of this property
*/
public Object get() {
return value;
}

/**
* Returns the name of this property
*/
public final String getPropertyName() {
return "font-stretch";
}

/**
* 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.fontFaceCssFontStretch != null) {
style.addRedefinitionWarning(ac, this);
}
s.fontFaceCssFontStretch = this;
}

/**
* Compares two properties for equality.
*
* @param property The other property.
*/
public boolean equals(CssProperty property) {
return (property instanceof CSSFontStretch && value.equals(property.value));
}

/**
* Get this property in the style.
*
* @param style The style where the property is
* @param resolve if true, resolve the style to find this property
*/
public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) {
if (resolve) {
return ((Css3Style) style).getFontFaceCssFontStretch();
} else {
return ((Css3Style) style).fontFaceCssFontStretch;
}
}
}
8 changes: 8 additions & 0 deletions org/w3c/css/properties/css3/Css3Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ public class Css3Style extends ATSCStyle {
public CssFontDisplay fontFaceCssFontDisplay;
public CssFontWeight fontFaceCssFontWeight;
public org.w3c.css.properties.css.fontface.CssFontWidth fontFaceCssFontWidth;
public org.w3c.css.properties.css.fontface.CSSFontStretch fontFaceCssFontStretch;
public CssFontStyle fontFaceCssFontStyle;
public org.w3c.css.properties.css.fontface.CssFontLanguageOverride fontFaceCssFontLanguageOverride;
public CssFontNamedInstance fontFaceCssFontNamedInstance;
Expand Down Expand Up @@ -1831,6 +1832,13 @@ public CssFontDisplay getFontFaceCssFontDisplay() {
return fontFaceCssFontDisplay;
}

public org.w3c.css.properties.css.fontface.CSSFontStretch getFontFaceCssFontStretch() {
if (fontFaceCssFontStretch == null) {
fontFaceCssFontStretch = (org.w3c.css.properties.css.fontface.CSSFontStretch) style.CascadingOrder(new org.w3c.css.properties.css.fontface.CSSFontStretch(), style, selector);
}
return fontFaceCssFontStretch;
}

public org.w3c.css.properties.css.fontface.CssFontWidth getFontFaceCssFontWidth() {
if (fontFaceCssFontWidth == null) {
fontFaceCssFontWidth =
Expand Down
88 changes: 88 additions & 0 deletions org/w3c/css/properties/css3/fontface/CSSFontStretch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.w3c.css.properties.css3.fontface;

import static org.w3c.css.properties.css3.CssFontWidth.getAllowedValue;
import static org.w3c.css.values.CssOperator.SPACE;

import java.util.ArrayList;

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;

/**
* @spec http://www.w3.org/TR/2008/REC-CSS2-20080411/fonts.html#propdef-font-stretch
*/
public class CSSFontStretch extends org.w3c.css.properties.css.fontface.CSSFontStretch {

public static final CssIdent auto = CssIdent.getIdent("auto");

/**
* Create a new CSSFontStretch
*/
public CSSFontStretch() {
value = initial;
}

/**
* Creates a new CSSFontStretch
*
* @param expression The expression for this property
* @throws InvalidParamException Expressions are incorrect
*/
public CSSFontStretch(ApplContext ac, CssExpression expression, boolean check)
throws InvalidParamException {
if (check && expression.getCount() > 2) {
throw new InvalidParamException("unrecognize", ac);
}

setByUser();

char op;
CssValue val;
ArrayList<CssValue> values = new ArrayList<>();

while (!expression.end()) {
val = expression.getValue();
op = expression.getOperator();

switch (val.getType()) {
case CssTypes.CSS_IDENT:
CssIdent id = val.getIdent();
if (auto.equals(id)) {
if (expression.getCount() > 1) {
throw new InvalidParamException("unrecognize", ac);
}
values.add(val);
break;
}
if (getAllowedValue(id) != null) {
values.add(val);
break;
}
default:
throw new InvalidParamException("value",
val.toString(),
getPropertyName(), ac);
}
if (op != SPACE) {
throw new InvalidParamException("operator",
Character.toString(op), ac);
}
expression.next();
}
if (values.isEmpty()) {
throw new InvalidParamException("few-value", getPropertyName(), ac);
}
value = (values.size() == 1) ? values.get(0) : new CssValueList(values);
}

public CSSFontStretch(ApplContext ac, CssExpression expression)
throws InvalidParamException {
this(ac, expression, false);
}

}