Skip to content

Commit

Permalink
Add background-blend-mode and mix-blend-mode and CSS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
torusrxxx committed Oct 24, 2024
1 parent 46f36f7 commit 5e0d013
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/freenet/client/filter/CSSTokenizerFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("align-self");
allelementVerifiers.add("azimuth");
allelementVerifiers.add("background-attachment");
allelementVerifiers.add("background-blend-mode");
allelementVerifiers.add("background-clip");
allelementVerifiers.add("background-color");
allelementVerifiers.add("background-image");
Expand Down Expand Up @@ -242,6 +243,7 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("max-width");
allelementVerifiers.add("min-height");
allelementVerifiers.add("min-width");
allelementVerifiers.add("mix-blend-mode");
allelementVerifiers.add("nav-down");
allelementVerifiers.add("nav-left");
allelementVerifiers.add("nav-right");
Expand Down Expand Up @@ -331,7 +333,7 @@ public static <T> T[] concat(T[] a, T[] b) {
* Array for storing additional Verifier objects for validating Regular expressions in CSS Property value
* e.g. [ <color> | transparent]{1,4}. It is explained in detail in CSSPropertyVerifier class
*/
private final static CSSPropertyVerifier[] auxilaryVerifiers=new CSSPropertyVerifier[148];
private final static CSSPropertyVerifier[] auxilaryVerifiers=new CSSPropertyVerifier[149];
static
{
/*CSSPropertyVerifier(String[] allowedValues,String[] possibleValues,String expression,boolean onlyValueVerifier)*/
Expand Down Expand Up @@ -454,6 +456,11 @@ else if("background-attachment".equalsIgnoreCase(element)){
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("60<1,65535>"), true,true));
allelementVerifiers.remove(element);
}
else if("background-blend-mode".equalsIgnoreCase(element)){
auxilaryVerifiers[148] = new CSSPropertyVerifier(Arrays.asList("normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"), null, null, null, true);
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("148<1,2>"), true,true));
allelementVerifiers.remove(element);
}
else if("background-clip".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("61<1,65535>"), true,true));
Expand Down Expand Up @@ -1196,7 +1203,13 @@ else if("min-width".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
allelementVerifiers.remove(element);
} else if ("nav-down".equalsIgnoreCase(element)) {
}
else if("mix-blend-mode".equalsIgnoreCase(element)){
auxilaryVerifiers[148] = new CSSPropertyVerifier(Arrays.asList("normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"), null, null, null, true);
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("148<1,2>"), true,true));
allelementVerifiers.remove(element);
}
else if ("nav-down".equalsIgnoreCase(element)) {
elementVerifiers.put(element, new CSSPropertyVerifier(Arrays.asList("auto"), ElementInfo.VISUALINTERACTIVEMEDIA, null, Arrays.asList("143 144?")));
allelementVerifiers.remove(element);
} else if ("nav-left".equalsIgnoreCase(element)) {
Expand Down
12 changes: 12 additions & 0 deletions test/freenet/client/filter/CSSParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,18 @@ public class CSSParserTest {
propertyTests.put("div { transition-delay: \"test\"; }", "div { }");
propertyTests.put("div { transition-property: \"test\"; }", "div { }");
propertyTests.put("div { transition-timing-function: \"test\"; }", "div { }");

// writing mode
propertyTests.put("#a { writing-mode: vertical-rl; text-underline-position: left; } #b { writing-mode: horizontal-tb; text-underline-position: auto; }", "#a { writing-mode: vertical-rl; text-underline-position: left; } #b { writing-mode: horizontal-tb; text-underline-position: auto; }");

// Compositing and Blending
propertyTests.put("#foo { background: url(\"1.png\"); background-blend-mode: darken; }", "#foo { background: url(\"1.png\"); background-blend-mode: darken; }");
propertyTests.put("#foo {mix-blend-mode: luminosity; }", "#foo {mix-blend-mode: luminosity; }");

// new property values
propertyTests.put("div { overflow: clip; clear: inline-end; text-decoration: revert; float: inline-end;}", "div { overflow: clip; clear: inline-end; text-decoration: revert; float: inline-end;}");
propertyTests.put("#a {unicode-bidi: isolate;}", "#a {unicode-bidi: isolate;}");
propertyTests.put("textarea#x {caret-color: currentcolor;}", "textarea#x {caret-color: currentcolor;}");
}

FilterMIMEType cssMIMEType;
Expand Down

0 comments on commit 5e0d013

Please sign in to comment.