Skip to content

Commit

Permalink
Merge remote-tracking branch 'torusrxxx/CSS' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Dec 1, 2024
2 parents e3d2e5a + b4d5b83 commit bf3833e
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 16 deletions.
145 changes: 129 additions & 16 deletions src/freenet/client/filter/CSSTokenizerFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,16 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("list-style-position");
allelementVerifiers.add("list-style-type");
allelementVerifiers.add("list-style");
allelementVerifiers.add("margin-right");
allelementVerifiers.add("margin-block");
allelementVerifiers.add("margin-block-end");
allelementVerifiers.add("margin-block-start");
allelementVerifiers.add("margin-bottom");
allelementVerifiers.add("margin-inline");
allelementVerifiers.add("margin-inline-end");
allelementVerifiers.add("margin-inline-start");
allelementVerifiers.add("margin-left");
allelementVerifiers.add("margin-right");
allelementVerifiers.add("margin-top");
allelementVerifiers.add("margin-bottom");
allelementVerifiers.add("margin");
allelementVerifiers.add("max-block-size");
allelementVerifiers.add("max-height");
Expand All @@ -267,10 +273,16 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("outline");
allelementVerifiers.add("overflow");
allelementVerifiers.add("overflow-wrap");
allelementVerifiers.add("padding-top");
allelementVerifiers.add("padding-right");
allelementVerifiers.add("padding-block");
allelementVerifiers.add("padding-block-end");
allelementVerifiers.add("padding-block-start");
allelementVerifiers.add("padding-bottom");
allelementVerifiers.add("padding-inline");
allelementVerifiers.add("padding-inline-end");
allelementVerifiers.add("padding-inline-start");
allelementVerifiers.add("padding-left");
allelementVerifiers.add("padding-right");
allelementVerifiers.add("padding-top");
allelementVerifiers.add("padding");
allelementVerifiers.add("page-break-after");
allelementVerifiers.add("page-break-before");
Expand All @@ -287,6 +299,10 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("resize");
allelementVerifiers.add("richness");
allelementVerifiers.add("right");
allelementVerifiers.add("scroll-behavior");
allelementVerifiers.add("scroll-snap-align");
allelementVerifiers.add("scroll-snap-stop");
allelementVerifiers.add("scroll-snap-type");
allelementVerifiers.add("speak-header");
allelementVerifiers.add("speak-numeral");
allelementVerifiers.add("speak-punctuation");
Expand All @@ -311,10 +327,12 @@ public static <T> T[] concat(T[] a, T[] b) {
allelementVerifiers.add("text-emphasis-style");
allelementVerifiers.add("text-indent");
allelementVerifiers.add("text-justify");
allelementVerifiers.add("text-orientation");
allelementVerifiers.add("text-outline");
allelementVerifiers.add("text-overflow");
allelementVerifiers.add("text-shadow");
allelementVerifiers.add("text-transform");
allelementVerifiers.add("text-underline-offset");
allelementVerifiers.add("text-underline-position");
allelementVerifiers.add("text-wrap");
allelementVerifiers.add("top");
Expand Down Expand Up @@ -367,6 +385,12 @@ public static <T> T[] concat(T[] a, T[] b) {
//list-style-type
auxilaryVerifiers[35]=new CSSPropertyVerifier(Arrays.asList("disc","circle","square","decimal","decimal-leading-zero","lower-roman","upper-roman","lower-greek","lower-latin","upper-latin","armenian","georgian","lower-alpha","upper-alpha","none","arabic-indic","bengali","cambodian","cjk-decimal","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","devanagari","disclosure-closed","disclosure-open","ethiopic-numeric","gujarati","gurmukhi","hebrew","hiragana","hiragana-iroha","japanese-formal","japanese-informal","kannada","katakana","katakana-iroha","khmer","korean-hangul-formal","korean-hanja-formal","lao","lower-armenian","malayalam","mongolian","myanmar","oriya","persian","simp-chinese-formal","simp-chinese-informal","tamil","telugu","thai","tibetan","trad-chinese-formal","trad-chinese-informal","upper-armenian"),Arrays.asList("st"),null,null,true);

//margin-width
auxilaryVerifiers[36]=new CSSPropertyVerifier(Arrays.asList("auto"),Arrays.asList("le","pe"),null,null,true);

//padding-width
auxilaryVerifiers[40]=new CSSPropertyVerifier(null,Arrays.asList("le","pe"),null,null,true);

// <background-clip> <background-origin>
auxilaryVerifiers[61]=new CSSPropertyVerifier(Arrays.asList("border-box", "padding-box", "content-box"),null,null,null,true);
// <border-radius>
Expand Down Expand Up @@ -1193,28 +1217,56 @@ else if("list-style".equalsIgnoreCase(element))
else if("margin-right".equalsIgnoreCase(element))
{
//margin-width=Length|Percentage|Auto
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-left".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-top".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-bottom".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-block".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36<1,2>")));
allelementVerifiers.remove(element);
}
else if("margin-block-end".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-block-start".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-inline".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36<1,2>")));
allelementVerifiers.remove(element);
}
else if("margin-inline-end".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin-inline-start".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("margin".equalsIgnoreCase(element))
{
//margin-width
auxilaryVerifiers[36]=new CSSPropertyVerifier(Arrays.asList("auto"),Arrays.asList("le","pe"),null,null,true);
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36<1,4>")));
allelementVerifiers.remove(element);
}
Expand Down Expand Up @@ -1328,29 +1380,57 @@ else if("overflow".equalsIgnoreCase(element))
}
else if("padding-top".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);

}
else if("padding-right".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-bottom".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-left".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-block".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40<1,2>")));
allelementVerifiers.remove(element);
}
else if("padding-block-end".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-block-start".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-inline".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40<1,2>")));
allelementVerifiers.remove(element);
}
else if("padding-inline-end".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding-inline-start".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40")));
allelementVerifiers.remove(element);
}
else if("padding".equalsIgnoreCase(element))
{
//padding-width
auxilaryVerifiers[40]=new CSSPropertyVerifier(null,Arrays.asList("le","pe"),null,null,true);
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("40<1,4>")));
allelementVerifiers.remove(element);
}
Expand Down Expand Up @@ -1444,6 +1524,29 @@ else if("right".equalsIgnoreCase(element))
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le","pe")));
allelementVerifiers.remove(element);
}
else if("scroll-behavior".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto","smooth"),ElementInfo.VISUALMEDIA));
allelementVerifiers.remove(element);
}
else if("scroll-snap-align".equalsIgnoreCase(element))
{
auxilaryVerifiers[82]=new CSSPropertyVerifier(Arrays.asList("none","start","end","center"),null,null,null,true);
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("82<1,2>")));
allelementVerifiers.remove(element);
}
else if("scroll-snap-stop".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal","always"),ElementInfo.VISUALMEDIA));
allelementVerifiers.remove(element);
}
else if("scroll-snap-type".equalsIgnoreCase(element))
{
auxilaryVerifiers[103]=new CSSPropertyVerifier(Arrays.asList("x","y","block","inline","both"),null,null,null,true);
auxilaryVerifiers[80]=new CSSPropertyVerifier(Arrays.asList("mandatory","proximity"),null,null,null,true);
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("none"),ElementInfo.VISUALMEDIA,null,Arrays.asList("103","103 80")));
allelementVerifiers.remove(element);
}
else if("speak-header".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("once","always"),ElementInfo.AURALMEDIA));
Expand Down Expand Up @@ -1587,6 +1690,11 @@ else if("text-justify".equalsIgnoreCase(element))
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,null,Arrays.asList("84a83")));
allelementVerifiers.remove(element);
}
else if("text-orientation".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("mixed","upright","sideways","sideways-right"),ElementInfo.VISUALMEDIA));
allelementVerifiers.remove(element);
}
else if("text-outline".equalsIgnoreCase(element))
{
auxilaryVerifiers[108]=new CSSPropertyVerifier(null,null,Arrays.asList("73 72 72<0,1>"),null,true);
Expand All @@ -1609,6 +1717,11 @@ else if("text-transform".equalsIgnoreCase(element))
elementVerifiers.put(element,new CSSPropertyVerifier( Arrays.asList("capitalize","uppercase","lowercase","none","fullwidth","full-size-kana","math-auto"),ElementInfo.VISUALMEDIA));
allelementVerifiers.remove(element);
}
else if("text-underline-offset".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("36")));
allelementVerifiers.remove(element);
}
else if("text-underline-position".equalsIgnoreCase(element))
{
elementVerifiers.put(element,new CSSPropertyVerifier( Arrays.asList("auto","under","left","right"),ElementInfo.VISUALMEDIA));
Expand Down
6 changes: 6 additions & 0 deletions test/freenet/client/filter/CSSParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,12 @@ public class CSSParserTest {
propertyTests.put("#x { text-combine-upright: all; }", "#x { text-combine-upright: all; }");
propertyTests.put("#x { text-decoration-thickness: 5px; }", "#x { text-decoration-thickness: 5px; }");
propertyTests.put("#x { dominant-baseline: alphabetic; }", "#x { dominant-baseline: alphabetic; }");
propertyTests.put("#x { margin-block: 3px 3%; margin-inline: 5%; margin-inline-end: 4px; margin-inline-start: auto; }", "#x { margin-block: 3px 3%; margin-inline: 5%; margin-inline-end: 4px; margin-inline-start: auto; }");
propertyTests.put("#x { padding-block: 3px 3%; padding-inline: 5%; padding-inline-end: 4px; padding-inline-start: 1em; }", "#x { padding-block: 3px 3%; padding-inline: 5%; padding-inline-end: 4px; padding-inline-start: 1em; }");
propertyTests.put("#x { text-orientation: upright; }", "#x { text-orientation: upright; }");
propertyTests.put("#x { scroll-snap-align: start end; }", "#x { scroll-snap-align: start end; }");
propertyTests.put("#x { scroll-snap-stop: always; }", "#x { scroll-snap-stop: always; }");
propertyTests.put("#x { scroll-snap-type: both proximity; }", "#x { scroll-snap-type: both proximity; }");

// text-emphasis
propertyTests.put("#x { text-emphasis: triangle blue; }", "#x { text-emphasis: triangle blue; }"); // java.lang.NullPointerException
Expand Down

0 comments on commit bf3833e

Please sign in to comment.