Skip to content

Commit

Permalink
Custom properties, conditional and property rules, CSS-wide keywords,…
Browse files Browse the repository at this point in the history
… calc() and attr()
  • Loading branch information
carlosame committed Oct 8, 2024
1 parent 06d8671 commit 3788c12
Show file tree
Hide file tree
Showing 159 changed files with 5,357 additions and 1,089 deletions.
1 change: 1 addition & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<suppress files="Test\.java$" checks="LineLength"/>

<!-- Header -->
<suppress files="[\\/]PropertyDefinition\.java$" checks="RegexpHeader"/>
<suppress files="[\\/]NodeXBL\.java$" checks="RegexpHeader"/>
<suppress files="[\\/]OriginalEvent\.java$" checks="RegexpHeader"/>
<suppress files="[\\/]ShadowTreeEvent\.java$" checks="RegexpHeader"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,9 @@ public Element getElement() {
return getAssociatedElement();
}

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return getAssociatedElement().getSVGContext().getPixelUnitToMillimeter();
public float getResolution() {
return getAssociatedElement().getSVGContext().getResolution();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
*/
package io.sf.carte.echosvg.anim.dom;

import org.w3c.css.om.unit.CSSUnit;
import org.w3c.dom.Attr;
import org.w3c.dom.DOMException;
import org.w3c.dom.svg.SVGAnimatedRect;
import org.w3c.dom.svg.SVGRect;

import io.sf.carte.doc.style.css.CSSUnit;
import io.sf.carte.doc.style.css.CSSExpressionValue;
import io.sf.carte.doc.style.css.CSSTypedValue;
import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.property.Evaluator;
import io.sf.carte.doc.style.css.property.ExpressionValue;
import io.sf.carte.doc.style.css.property.StyleValue;
import io.sf.carte.doc.style.css.property.TypedValue;
import io.sf.carte.doc.style.css.property.ValueFactory;
import io.sf.carte.doc.style.css.property.ValueList;
import io.sf.carte.echosvg.anim.values.AnimatableRectValue;
Expand Down Expand Up @@ -286,16 +286,16 @@ private boolean computeRectangle(StyleValue value, float[] numbers) throws DOMEx
if (item.getCssValueType() != CssType.TYPED) {
return false;
}
TypedValue typed = (TypedValue) item;
CSSTypedValue typed = (CSSTypedValue) item;
switch (item.getPrimitiveType()) {
case NUMERIC:
if (typed.getUnitType() != CSSUnit.CSS_NUMBER) {
return false;
}
break;
case EXPRESSION:
Evaluator eval = new Evaluator();
typed = eval.evaluateExpression((ExpressionValue) typed);
Evaluator eval = new Evaluator(CSSUnit.CSS_NUMBER);
typed = eval.evaluateExpression((CSSExpressionValue) typed);
if (typed.getUnitType() != CSSUnit.CSS_NUMBER) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,12 +877,9 @@ public Element getElement() {
return SVGOMElement.this;
}

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return getSVGContext().getPixelUnitToMillimeter();
public float getResolution() {
return getSVGContext().getResolution();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,9 @@ protected void fireBBoxChangeEvent() {

// SVGContext implementation ///////////////////////////////////////////

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return ctx.getUserAgent().getPixelUnitToMillimeter();
public float getResolution() {
return ctx.getUserAgent().getResolution();
}

protected SoftReference<Shape> bboxShape = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,9 @@ public void handleElement(BridgeContext ctx, Element e) {

// SVGContext ////////////////////////////////////////////////////////////

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return ctx.getUserAgent().getPixelUnitToMillimeter();
public float getResolution() {
return ctx.getUserAgent().getResolution();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
import io.sf.carte.echosvg.dom.events.NodeEventTarget;
import io.sf.carte.echosvg.dom.svg.SVGContext;
import io.sf.carte.echosvg.dom.xbl.XBLManager;
import io.sf.carte.echosvg.ext.awt.color.StandardColorSpaces;
import io.sf.carte.echosvg.ext.awt.color.ColorContext;
import io.sf.carte.echosvg.ext.awt.color.StandardColorSpaces;
import io.sf.carte.echosvg.gvt.CompositeGraphicsNode;
import io.sf.carte.echosvg.gvt.GraphicsNode;
import io.sf.carte.echosvg.script.Interpreter;
Expand Down Expand Up @@ -1830,12 +1830,23 @@ public float getBolderFontWeight(float f) {

/**
* Returns the size of a px CSS unit in millimeters.
*
* @deprecated Use {@link #getResolution()}.
*/
@Deprecated
@Override
public float getPixelUnitToMillimeter() {
return userAgent.getPixelUnitToMillimeter();
}

/**
* Returns the resolution in dpi.
*/
@Override
public float getResolution() {
return userAgent.getResolution();
}

/**
* Returns the medium font size.
*/
Expand Down Expand Up @@ -1877,6 +1888,14 @@ public void checkLoadExternalResource(ParsedURL resourceURL, ParsedURL docURL) t
userAgent.checkLoadExternalResource(resourceURL, docURL);
}

/**
* Get prefers-color-scheme.
*/
@Override
public String getPrefersColorScheme() {
return userAgent.getPrefersColorScheme();
}

/**
* Tells whether the given SVG document is dynamic.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.LinkedList;
import java.util.List;

import io.sf.carte.echosvg.css.dom.CSSValue.CssType;
import io.sf.carte.echosvg.css.dom.CSSValue.Type;
import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.CSSValue.Type;
import io.sf.carte.echosvg.css.engine.CSSEngine;
import io.sf.carte.echosvg.css.engine.FontFaceRule;
import io.sf.carte.echosvg.css.engine.SVGCSSEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

import org.w3c.dom.Element;

import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.CSSValue.Type;
import io.sf.carte.echosvg.anim.dom.SVGOMDocument;
import io.sf.carte.echosvg.constants.XMLConstants;
import io.sf.carte.echosvg.css.dom.CSSValue.CssType;
import io.sf.carte.echosvg.css.dom.CSSValue.Type;
import io.sf.carte.echosvg.css.engine.CSSEngine;
import io.sf.carte.echosvg.css.engine.CSSStylableElement;
import io.sf.carte.echosvg.css.engine.SVGCSSEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.w3c.dom.svg.SVGDocument;
import org.w3c.dom.svg.SVGPreserveAspectRatio;

import io.sf.carte.echosvg.css.dom.CSSValue.CssType;
import io.sf.carte.echosvg.css.dom.CSSValue.Type;
import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.CSSValue.Type;
import io.sf.carte.echosvg.css.engine.SVGCSSEngine;
import io.sf.carte.echosvg.css.engine.value.Value;
import io.sf.carte.echosvg.dom.AbstractNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.w3c.css.om.unit.CSSUnit;
import org.w3c.dom.Element;

import io.sf.carte.echosvg.css.dom.CSSValue.CssType;
import io.sf.carte.echosvg.css.dom.CSSValue.Type;
import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.CSSValue.Type;
import io.sf.carte.echosvg.css.engine.SVGCSSEngine;
import io.sf.carte.echosvg.css.engine.value.ColorFunction;
import io.sf.carte.echosvg.css.engine.value.ColorValue;
Expand Down Expand Up @@ -305,7 +305,8 @@ public static Paint convertPaint(Element paintedElement, GraphicsNode paintedNod
break;
}
}
throw new IllegalArgumentException("Paint argument is not an appropriate CSS value");
throw new IllegalArgumentException(
"Paint argument is not an appropriate CSS value (" + paintDef.getCssText() + ").");
}

/**
Expand Down Expand Up @@ -652,7 +653,7 @@ private static Color convert3Color(ColorSpace space, ColorFunction c, float opac
*/
private static float resolveColorComponent(NumericValue item) {
float f;
switch (item.getCSSUnit()) {
switch (item.getUnitType()) {
case CSSUnit.CSS_NUMBER:
f = item.getFloatValue();
if (f < 0f) {
Expand Down Expand Up @@ -831,7 +832,7 @@ public static int convertStrokeLinejoin(Value v) {
*/
private static float resolveAlphaComponent(Value v) {
float f;
switch (v.getCSSUnit()) {
switch (v.getUnitType()) {
case CSSUnit.CSS_PERCENTAGE:
f = v.getFloatValue();
f = (f > 100f) ? 100f : (f < 0f) ? 0f : f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,9 @@ public void dispose() {

// SVGContext ///////////////////////////////////////////////////////////

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return ctx.getUserAgent().getPixelUnitToMillimeter();
public float getResolution() {
return ctx.getUserAgent().getResolution();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import org.w3c.dom.svg.SVGLength;
import org.w3c.dom.svg.SVGPreserveAspectRatio;

import io.sf.carte.doc.style.css.CSSValue.CssType;
import io.sf.carte.doc.style.css.CSSValue.Type;
import io.sf.carte.doc.style.css.property.NumberValue;
import io.sf.carte.echosvg.anim.AnimationEngine;
import io.sf.carte.echosvg.anim.AnimationException;
Expand Down Expand Up @@ -67,8 +69,6 @@
import io.sf.carte.echosvg.anim.values.AnimatableStringValue;
import io.sf.carte.echosvg.anim.values.AnimatableValue;
import io.sf.carte.echosvg.constants.XMLConstants;
import io.sf.carte.echosvg.css.dom.CSSValue.CssType;
import io.sf.carte.echosvg.css.dom.CSSValue.Type;
import io.sf.carte.echosvg.css.engine.CSSEngine;
import io.sf.carte.echosvg.css.engine.CSSStylableElement;
import io.sf.carte.echosvg.css.engine.StyleMap;
Expand Down Expand Up @@ -1203,7 +1203,7 @@ public AnimatableValue createValue(AnimationTarget target, String ns, String ln,
*/
@Override
public AnimatableValue createValue(AnimationTarget target, String pn, Value v) {
switch (v.getCSSUnit()) {
switch (v.getUnitType()) {
case CSSUnit.CSS_PERCENTAGE:
return new AnimatableNumberOrPercentageValue(target, v.getFloatValue(), true);
case CSSUnit.CSS_NUMBER:
Expand Down Expand Up @@ -1767,7 +1767,7 @@ protected AnimatableValue createAnimatableValue(AnimationTarget target, String p
return new AnimatableLengthOrIdentValue(target, v.getIdentifierValue());
}
short pcInterp = target.getPercentageInterpretation(null, pn, true);
return new AnimatableLengthOrIdentValue(target, v.getCSSUnit(), v.getFloatValue(), pcInterp);
return new AnimatableLengthOrIdentValue(target, v.getUnitType(), v.getFloatValue(), pcInterp);
}

}
Expand Down Expand Up @@ -1805,7 +1805,7 @@ protected class AnimatableAngleValueFactory extends CSSValueFactory {
@Override
protected AnimatableValue createAnimatableValue(AnimationTarget target, String pn, Value v) {
short unit;
switch (v.getCSSUnit()) {
switch (v.getUnitType()) {
case CSSUnit.CSS_NUMBER:
case CSSUnit.CSS_DEG:
unit = SVGAngle.SVG_ANGLETYPE_DEG;
Expand All @@ -1818,7 +1818,7 @@ protected AnimatableValue createAnimatableValue(AnimationTarget target, String p
break;
default:
try {
float f = NumberValue.floatValueConversion(v.getFloatValue(), v.getCSSUnit(),
float f = NumberValue.floatValueConversion(v.getFloatValue(), v.getUnitType(),
CSSUnit.CSS_DEG);
return new AnimatableAngleOrIdentValue(target, f, SVGAngle.SVG_ANGLETYPE_DEG);
} catch (DOMException e) {
Expand All @@ -1842,7 +1842,7 @@ protected AnimatableValue createAnimatableValue(AnimationTarget target, String p
return new AnimatableAngleOrIdentValue(target, v.getIdentifierValue());
}
short unit;
switch (v.getCSSUnit()) {
switch (v.getUnitType()) {
case CSSUnit.CSS_NUMBER:
case CSSUnit.CSS_DEG:
unit = SVGAngle.SVG_ANGLETYPE_DEG;
Expand All @@ -1855,7 +1855,7 @@ protected AnimatableValue createAnimatableValue(AnimationTarget target, String p
break;
default:
try {
float f = NumberValue.floatValueConversion(v.getFloatValue(), v.getCSSUnit(),
float f = NumberValue.floatValueConversion(v.getFloatValue(), v.getUnitType(),
CSSUnit.CSS_DEG);
return new AnimatableAngleOrIdentValue(target, f, SVGAngle.SVG_ANGLETYPE_DEG);
} catch (DOMException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,9 @@ public void handleOtherAnimationChanged(String type) {

// SVGContext implementation ///////////////////////////////////////////

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return theCtx.getUserAgent().getPixelUnitToMillimeter();
public float getResolution() {
return theCtx.getUserAgent().getResolution();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,9 @@ public void dispose() {

// SVGContext //////////////////////////////////////////////////////////

/**
* Returns the size of a px CSS unit in millimeters.
*/
@Override
public float getPixelUnitToMillimeter() {
return ctx.getUserAgent().getPixelUnitToMillimeter();
public float getResolution() {
return ctx.getUserAgent().getResolution();
}

@Override
Expand Down
Loading

0 comments on commit 3788c12

Please sign in to comment.