HtmlUnit / htmlunit-cssparser

CSS parser used by HtmlUnit
Apache License 2.0
5 stars 9 forks source link

CSS calc() function is not supported #1

Closed oswetto closed 4 years ago

oswetto commented 6 years ago

Hello @rbri htmlunit-cssparser not support css function calc()

Example 1

final String css = "#foo {width: calc(100px + 100px)}";
final InputSource source = new InputSource(new StringReader(css));
final CSSOMParser parser = new CSSOMParser();
final CSSStyleSheet sheet = parser.parseStyleSheet(source, null);
final CSSRuleList rules = sheet.getCssRules();
CSSRule rule = rules.item(0);
System.out.println(rule.getCssText()); 

 [1:26] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".)
*#foo { }

Example 2

final String css = "#foo {width: calc(100px+100px)}";
final InputSource source = new InputSource(new StringReader(css));
final CSSOMParser parser = new CSSOMParser();
final CSSStyleSheet sheet = parser.parseStyleSheet(source, null);
final CSSRuleList rules = sheet.getCssRules();
CSSRule rule = rules.item(0);
System.out.println(rule.getCssText()); ---- > Return  *#foo { width: calc(100px 100px) }

Example 3

final String css = "#foo {width: calc(100px/100px)}";
final InputSource source = new InputSource(new StringReader(css));
final CSSOMParser parser = new CSSOMParser();
final CSSStyleSheet sheet = parser.parseStyleSheet(source, null);
final CSSRuleList rules = sheet.getCssRules();
CSSRule rule = rules.item(0);
System.out.println(rule.getCssText());  Return  *#foo { width: calc(100px 100px) }

null [1:24] Error in expression. (Invalid token "/". Was expecting one of: <S>, <NUMBER>, "inherit", <IDENT>, <STRING>, ")", "-", "=", <PLUS>, <COMMA>, <HASH>, <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".)
*#foo { }

Example 4

final String css = "#foo {width: calc(100% - 100px)}";
final InputSource source = new InputSource(new StringReader(css));
final CSSOMParser parser = new CSSOMParser();
final CSSStyleSheet sheet = parser.parseStyleSheet(source, null);
final CSSRuleList rules = sheet.getCssRules();
CSSRule rule = rules.item(0);
System.out.println(rule.getCssText());

null [1:25] Error in expression. (Invalid token " ". Was expecting one of: <NUMBER>, "inherit", <IDENT>, <STRING>, <HASH>, <EMS>, <EXS>, <LENGTH_PX>, <LENGTH_CM>, <LENGTH_MM>, <LENGTH_IN>, <LENGTH_PT>, <LENGTH_PC>, <ANGLE_DEG>, <ANGLE_RAD>, <ANGLE_GRAD>, <TIME_MS>, <TIME_S>, <FREQ_HZ>, <FREQ_KHZ>, <RESOLUTION_DPI>, <RESOLUTION_DPCM>, <PERCENTAGE>, <DIMENSION>, <UNICODE_RANGE>, <URI>, <FUNCTION>, "progid:".)
*#foo { }
ghost commented 5 years ago

Any progress on this issue ?

rbri commented 5 years ago

Any progress on this issue ?

Sorry but no time at the moment and so many things to do. Any help is welcome

RBRi
rbri commented 4 years ago

calc support is on the way

rbri commented 4 years ago

release 1.6.0 is out