Ignore:
Timestamp:
2011-03-30T22:25:20+02:00 (15 years ago)
Author:
bastiK
Message:

applied #6150 - mapcss - improve parent_tag (based on patch by Gubaer)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Expression.java

    r4008 r4011  
    1717import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive;
    19 import org.openstreetmap.josm.data.osm.Relation;
    2019import org.openstreetmap.josm.gui.mappaint.Cascade;
    2120import org.openstreetmap.josm.gui.mappaint.Environment;
     
    174173            }
    175174
    176             // FIXME: respect parent selector chain
    177175            public String parent_tag(String key) {
    178                 for (Relation parent: OsmPrimitive.getFilteredList(env.osm.getReferrers(), Relation.class)) {
    179                     String value = parent.get(key);
    180                     if (value != null) return value;
    181                 }
    182                 return null;
     176                if (env.getMatchingReferrers() == null) {
     177                    // we don't have a matched parent, so just search all referrers
     178                    for (OsmPrimitive parent : env.osm.getReferrers()) {
     179                        String value = parent.get(key);
     180                        if (value != null)
     181                            return value;
     182                    }
     183                    return null;
     184                }
     185                if (env.getMatchingReferrers().isEmpty())
     186                    return null;
     187                // use always the first matching referrer to have consistency
     188                // in an expression and declaration block
     189                return env.getMatchingReferrers().iterator().next().get(key);
    183190            }
    184191
Note: See TracChangeset for help on using the changeset viewer.