|
| 1 | +// |
| 2 | +// Author: Yves Lafon <ylafon@w3.org> |
| 3 | +// |
| 4 | +// (c) COPYRIGHT W3C, 2026. |
| 5 | +// Please first read the full copyright statement in file COPYRIGHT.html |
| 6 | +package org.w3c.css.properties.css; |
| 7 | + |
| 8 | +import org.w3c.css.parser.CssStyle; |
| 9 | +import org.w3c.css.properties.css3.Css3Style; |
| 10 | +import org.w3c.css.util.ApplContext; |
| 11 | +import org.w3c.css.util.InvalidParamException; |
| 12 | +import org.w3c.css.values.CssExpression; |
| 13 | + |
| 14 | +/** |
| 15 | + * @since CSS3 |
| 16 | + */ |
| 17 | +public class CssZoom extends CssProperty { |
| 18 | + |
| 19 | + |
| 20 | + /** |
| 21 | + * Create a new CssZoom |
| 22 | + */ |
| 23 | + public CssZoom() { |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Creates a new CssZoom |
| 28 | + * |
| 29 | + * @param expression The expression for this property |
| 30 | + * @throws InvalidParamException |
| 31 | + * Expressions are incorrect |
| 32 | + */ |
| 33 | + public CssZoom(ApplContext ac, CssExpression expression, boolean check) |
| 34 | + throws InvalidParamException { |
| 35 | + throw new InvalidParamException("value", |
| 36 | + expression.getValue().toString(), |
| 37 | + getPropertyName(), ac); |
| 38 | + } |
| 39 | + |
| 40 | + public CssZoom(ApplContext ac, CssExpression expression) |
| 41 | + throws InvalidParamException { |
| 42 | + this(ac, expression, false); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Returns the value of this property |
| 47 | + */ |
| 48 | + public Object get() { |
| 49 | + return value; |
| 50 | + } |
| 51 | + |
| 52 | + |
| 53 | + /** |
| 54 | + * Returns the name of this property |
| 55 | + */ |
| 56 | + public final String getPropertyName() { |
| 57 | + return "zoom"; |
| 58 | + } |
| 59 | + |
| 60 | + /** |
| 61 | + * Returns true if this property is "softly" inherited |
| 62 | + * e.g. his value is equals to inherit |
| 63 | + */ |
| 64 | + public boolean isSoftlyInherited() { |
| 65 | + return inherit.equals(value); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Returns a string representation of the object. |
| 70 | + */ |
| 71 | + public String toString() { |
| 72 | + return value.toString(); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Add this property to the CssStyle. |
| 77 | + * |
| 78 | + * @param style The CssStyle |
| 79 | + */ |
| 80 | + public void addToStyle(ApplContext ac, CssStyle style) { |
| 81 | + if (((Css3Style) style).cssZoom != null) |
| 82 | + style.addRedefinitionWarning(ac, this); |
| 83 | + ((Css3Style) style).cssZoom = this; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Compares two properties for equality. |
| 88 | + * |
| 89 | + * @param property The other property. |
| 90 | + */ |
| 91 | + public boolean equals(CssProperty property) { |
| 92 | + return (property instanceof CssZoom && |
| 93 | + value.equals(((CssZoom) property).value)); |
| 94 | + } |
| 95 | + |
| 96 | + |
| 97 | + /** |
| 98 | + * Get this property in the style. |
| 99 | + * |
| 100 | + * @param style The style where the property is |
| 101 | + * @param resolve if true, resolve the style to find this property |
| 102 | + */ |
| 103 | + public CssProperty getPropertyInStyle(CssStyle style, boolean resolve) { |
| 104 | + if (resolve) { |
| 105 | + return ((Css3Style) style).getZoom(); |
| 106 | + } else { |
| 107 | + return ((Css3Style) style).cssZoom; |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | + |
0 commit comments