From ee550115d66fb22194d4687c2e0073ed67e754f7 Mon Sep 17 00:00:00 2001 From: torusrxxx Date: Wed, 4 Dec 2024 17:28:26 +0800 Subject: [PATCH 1/3] Fix incorrect CSS property names for border-top-left-radius and similar --- .../client/filter/CSSTokenizerFilter.java | 31 +++++-------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index ed091db40e..3d02c53ed8 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -161,10 +161,10 @@ public static T[] concat(T[] a, T[] b) { allelementVerifiers.add("border-left-width"); allelementVerifiers.add("border-right-width"); allelementVerifiers.add("border-radius"); - allelementVerifiers.add("border-top-radius"); - allelementVerifiers.add("border-bottom-radius"); - allelementVerifiers.add("border-left-radius"); - allelementVerifiers.add("border-right-radius"); + allelementVerifiers.add("border-bottom-left-radius"); + allelementVerifiers.add("border-bottom-right-radius"); + allelementVerifiers.add("border-top-left-radius"); + allelementVerifiers.add("border-top-right-radius"); allelementVerifiers.add("border-image-source"); allelementVerifiers.add("border-image-slice"); allelementVerifiers.add("border-image-width"); @@ -393,8 +393,6 @@ public static T[] concat(T[] a, T[] b) { // auxilaryVerifiers[61]=new CSSPropertyVerifier(Arrays.asList("border-box", "padding-box", "content-box"),null,null,null,true); - // - auxilaryVerifiers[64]=new CSSPropertyVerifier(null,Arrays.asList("le", "pe"),null,null,true); // auxilaryVerifiers[73]=new CSSPropertyVerifier(null, Arrays.asList("co"), null, null, true); @@ -741,27 +739,12 @@ else if("border".equalsIgnoreCase(element)) else if("border-radius".equalsIgnoreCase(element)) { auxilaryVerifiers[65]=new CSSPropertyVerifier(Arrays.asList("/"),null,null,null,true); - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("64<1,4>", "64<1,4> 65 64<1,4>"))); + elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40<1,4>", "40<1,4> 65 40<1,4>"))); allelementVerifiers.remove(element); } - else if("border-top-radius".equalsIgnoreCase(element)) + else if("border-bottom-left-radius".equalsIgnoreCase(element) || "border-bottom-right-radius".equalsIgnoreCase(element) || "border-top-left-radius".equalsIgnoreCase(element) || "border-top-right-radius".equalsIgnoreCase(element)) { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("64<1,2>"))); - allelementVerifiers.remove(element); - } - else if("border-bottom-radius".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("64<1,2>"))); - allelementVerifiers.remove(element); - } - else if("border-left-radius".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("64<1,2>"))); - allelementVerifiers.remove(element); - } - else if("border-right-radius".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("64<1,2>"))); + elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40<1,2>"))); allelementVerifiers.remove(element); } else if("border-image-source".equalsIgnoreCase(element)) From 99ec4e6d8392dafed3228fa7b91da3812a446cd6 Mon Sep 17 00:00:00 2001 From: torusrxxx Date: Wed, 4 Dec 2024 18:10:49 +0800 Subject: [PATCH 2/3] Add CSS property color-scheme --- src/freenet/client/filter/CSSTokenizerFilter.java | 7 +++++++ test/freenet/client/filter/CSSParserTest.java | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 3d02c53ed8..e28578ec54 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -184,6 +184,7 @@ public static T[] concat(T[] a, T[] b) { allelementVerifiers.add("break-before"); allelementVerifiers.add("break-after"); allelementVerifiers.add("break-inside"); + allelementVerifiers.add("color-scheme"); allelementVerifiers.add("column-count"); allelementVerifiers.add("column-fill"); allelementVerifiers.add("column-gap"); @@ -837,6 +838,12 @@ else if("break-inside".equalsIgnoreCase(element)) { elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto","avoid","avoid-page", "avoid-column"),ElementInfo.VISUALPAGEDMEDIA)); allelementVerifiers.remove(element); + } + else if("color-scheme".equalsIgnoreCase(element)) + { + auxilaryVerifiers[81]=new CSSPropertyVerifier(Arrays.asList("light","dark","only"),null,null,null,true); + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal"),ElementInfo.VISUALMEDIA,null,Arrays.asList("81<1,3>"))); + allelementVerifiers.remove(element); } else if("column-count".equalsIgnoreCase(element)) { diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index 578d1e4138..3698633131 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -1012,6 +1012,11 @@ public class CSSParserTest { propertyTests.put("#x { text-shadow: 1px 1px 2px 1px black; }", "#x { }"); // not possible to parse a comma separated list? //propertyTests.put("#x { text-shadow: 1px 1px 2px red, 0 0 1em blue, 0 0 0.2em blue; }", "#x { text-shadow: 1px 1px 2px red, 0 0 1em blue, 0 0 0.2em blue; }"); + + // dark mode + propertyTests.put(":root { color-scheme: light dark; }", ":root { color-scheme: light dark; }"); + propertyTests.put(":root { color-scheme: only light; }", ":root { color-scheme: only light; }"); + } FilterMIMEType cssMIMEType; From 44d057ba3fe8e7707528ba9231311482fabc35a1 Mon Sep 17 00:00:00 2001 From: torusrxxx Date: Thu, 12 Dec 2024 12:30:29 +0800 Subject: [PATCH 3/3] Add CSS property math-style --- src/freenet/client/filter/CSSTokenizerFilter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index e28578ec54..1f495edc87 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -250,6 +250,7 @@ public static T[] concat(T[] a, T[] b) { allelementVerifiers.add("margin-right"); allelementVerifiers.add("margin-top"); allelementVerifiers.add("margin"); + allelementVerifiers.add("math-style"); allelementVerifiers.add("max-block-size"); allelementVerifiers.add("max-height"); allelementVerifiers.add("max-inline-size"); @@ -1260,6 +1261,11 @@ else if("margin".equalsIgnoreCase(element)) elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36<1,4>"))); allelementVerifiers.remove(element); } + else if("math-style".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal","compact"),ElementInfo.VISUALMEDIA)); + allelementVerifiers.remove(element); + } else if("max-block-size".equalsIgnoreCase(element)) { elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("none"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));