Changeset 15935 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2020-02-26T01:52:19+01:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r15910 r15935 702 702 <PLUS> { type = Selector.ChildOrParentSelectorType.SIBLING; } 703 703 ) 704 ( ( c=condition(Context.LINK) | c=class_or_pseudoclass(Context.LINK) ) { conditions.add(c); } )*704 ( ( c=condition(Context.LINK) | c=class_or_pseudoclass(Context.LINK) ) { if (c!= null) conditions.add(c); } )* 705 705 | 706 706 <SUBSET_OR_EQUAL> { type = Selector.ChildOrParentSelectorType.SUBSET_OR_EQUAL; } … … 735 735 ( base=<IDENT> | base=<STAR> ) 736 736 ( r=zoom() )? 737 ( ( c=condition(Context.PRIMITIVE) | c=class_or_pseudoclass(Context.PRIMITIVE) ) { conditions.add(c); } )*737 ( ( c=condition(Context.PRIMITIVE) | c=class_or_pseudoclass(Context.PRIMITIVE) ) { if (c!= null) conditions.add(c); } )* 738 738 ( sub=subpart() )? 739 739 { return new GeneralSelector(base.image, r, conditions, sub); } … … 887 887 ) 888 888 s=ident() 889 { return pseudo 890 ? ConditionFactory.createPseudoClassCondition(s, not, context) 891 : ConditionFactory.createClassCondition(s, not, context); } 889 { 890 if (pseudo && sheet != null && sheet.isRemoveAreaStylePseudoClass() && s.matches("areaStyle|area-style|area_style")) { 891 Logging.warn("Removing 'areaStyle' pseudo-class. This class is only meant for validator"); 892 return null; 893 } else if (pseudo) { 894 return ConditionFactory.createPseudoClassCondition(s, not, context); 895 } else { 896 return ConditionFactory.createClassCondition(s, not, context); 897 } 898 } 892 899 } 893 900 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r15731 r15935 55 55 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.KeyMatchType; 56 56 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.KeyValueCondition; 57 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.PseudoClassCondition;58 57 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.SimpleKeyValueCondition; 59 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.AbstractSelector;60 58 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector; 61 59 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector; … … 119 117 private ZipFile zipFile; 120 118 119 private boolean removeAreaStylePseudoClass; 120 121 121 /** 122 122 * This lock prevents concurrent execution of {@link MapCSSRuleIndex#clear() } / … … 430 430 multipolygonRules.clear(); 431 431 canvasRules.clear(); 432 // remove "areaStyle" pseudo classes intended only for validator (causes StackOverflowError otherwise), see #16183 433 removeAreaStylePseudoClass = true; 432 434 try (InputStream in = getSourceInputStream()) { 433 435 try (Reader reader = new BufferedReader(UTFInputStreamReader.create(in))) { … … 445 447 loadSettings(); 446 448 } 447 // remove "areaStyle" pseudo classes intended only for validator (causes StackOverflowError otherwise)448 removeAreaStyleClasses();449 449 } finally { 450 450 closeSourceInputStream(in); … … 770 770 771 771 /** 772 * Removes "areaStyle" pseudo-classes. Only needed for validator. 773 * @since 13633 774 */ 775 public void removeAreaStyleClasses() { 776 for (Iterator<MapCSSRule> it = rules.iterator(); it.hasNext();) { 777 removeAreaStyleClasses(it.next().selector); 778 } 779 } 780 781 private static void removeAreaStyleClasses(Selector sel) { 782 if (sel instanceof ChildOrParentSelector) { 783 removeAreaStyleClasses((ChildOrParentSelector) sel); 784 } else if (sel instanceof AbstractSelector) { 785 removeAreaStyleClasses((AbstractSelector) sel); 786 } 787 } 788 789 private static void removeAreaStyleClasses(ChildOrParentSelector sel) { 790 removeAreaStyleClasses(sel.left); 791 removeAreaStyleClasses(sel.right); 792 } 793 794 private static void removeAreaStyleClasses(AbstractSelector sel) { 795 if (sel.conds != null) { 796 for (Iterator<Condition> it = sel.conds.iterator(); it.hasNext();) { 797 Condition c = it.next(); 798 if (c instanceof PseudoClassCondition) { 799 PseudoClassCondition cc = (PseudoClassCondition) c; 800 if ("areaStyle".equals(cc.method.getName())) { 801 Logging.warn("Removing 'areaStyle' pseudo-class from "+sel+". This class is only meant for validator"); 802 it.remove(); 803 } 804 } 805 } 806 } 772 * Whether to remove "areaStyle" pseudo classes. Only for use in MapCSSParser! 773 * @return whether to remove "areaStyle" pseudo classes 774 */ 775 public boolean isRemoveAreaStylePseudoClass() { 776 return removeAreaStylePseudoClass; 807 777 } 808 778
Note:
See TracChangeset
for help on using the changeset viewer.