- Timestamp:
- 2018-04-15T16:21:00+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r13597 r13633 16 16 import java.util.HashMap; 17 17 import java.util.HashSet; 18 import java.util.Iterator;19 18 import java.util.LinkedHashMap; 20 19 import java.util.LinkedHashSet; … … 376 375 parser.sheet(source); 377 376 // Ignore "meta" rule(s) from external rules of JOSM wiki 378 removeMetaRules(source);377 source.removeMetaRules(); 379 378 // group rules with common declaration block 380 379 Map<Declaration, List<Selector>> g = new LinkedHashMap<>(); … … 399 398 } 400 399 return new ParseResult(parseChecks, source.getErrors()); 401 }402 403 private static void removeMetaRules(MapCSSStyleSource source) {404 for (Iterator<MapCSSRule> it = source.rules.iterator(); it.hasNext();) {405 MapCSSRule x = it.next();406 if (x.selector instanceof GeneralSelector) {407 GeneralSelector gs = (GeneralSelector) x.selector;408 if ("meta".equals(gs.base)) {409 it.remove();410 }411 }412 }413 400 } 414 401 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r13561 r13633 49 49 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.KeyValueCondition; 50 50 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op; 51 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.PseudoClassCondition; 51 52 import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.SimpleKeyValueCondition; 53 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.AbstractSelector; 52 54 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector; 53 55 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.GeneralSelector; … … 434 436 loadCanvas(); 435 437 loadSettings(); 438 // remove "areaStyle" pseudo classes intended only for validator (causes StackOverflowError otherwise) 439 removeAreaStyleClasses(); 436 440 } finally { 437 441 closeSourceInputStream(in); … … 715 719 } 716 720 721 /** 722 * Removes "meta" rules. Not needed for validator. 723 * @since 13633 724 */ 725 public void removeMetaRules() { 726 for (Iterator<MapCSSRule> it = rules.iterator(); it.hasNext();) { 727 MapCSSRule x = it.next(); 728 if (x.selector instanceof GeneralSelector) { 729 GeneralSelector gs = (GeneralSelector) x.selector; 730 if ("meta".equals(gs.base)) { 731 it.remove(); 732 } 733 } 734 } 735 } 736 737 /** 738 * Removes "areaStyle" pseudo-classes. Only needed for validator. 739 * @since 13633 740 */ 741 public void removeAreaStyleClasses() { 742 for (Iterator<MapCSSRule> it = rules.iterator(); it.hasNext();) { 743 removeAreaStyleClasses(it.next().selector); 744 } 745 } 746 747 private static void removeAreaStyleClasses(Selector sel) { 748 if (sel instanceof ChildOrParentSelector) { 749 removeAreaStyleClasses((ChildOrParentSelector) sel); 750 } else if (sel instanceof AbstractSelector) { 751 removeAreaStyleClasses((AbstractSelector) sel); 752 } 753 } 754 755 private static void removeAreaStyleClasses(ChildOrParentSelector sel) { 756 removeAreaStyleClasses(sel.left); 757 removeAreaStyleClasses(sel.right); 758 } 759 760 private static void removeAreaStyleClasses(AbstractSelector sel) { 761 if (sel.conds != null) { 762 for (Iterator<Condition> it = sel.conds.iterator(); it.hasNext();) { 763 Condition c = it.next(); 764 if (c instanceof PseudoClassCondition) { 765 PseudoClassCondition cc = (PseudoClassCondition) c; 766 if ("areaStyle".equals(cc.method.getName())) { 767 Logging.warn("Removing 'areaStyle' pseudo-class from "+sel+". This class is only meant for validator"); 768 it.remove(); 769 } 770 } 771 } 772 } 773 } 774 717 775 @Override 718 776 public String toString() {
Note:
See TracChangeset
for help on using the changeset viewer.