Index: /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8811)
+++ /trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8812)
@@ -249,6 +249,10 @@
         JCheckBox allElements = new JCheckBox(tr("all objects"), initialValues.allElements);
         allElements.setToolTipText(tr("Also include incomplete and deleted objects in search."));
-        final JCheckBox regexSearch   = new JCheckBox(tr("regular expression"), initialValues.regexSearch);
-        final JCheckBox addOnToolbar  = new JCheckBox(tr("add toolbar button"), false);
+        final JCheckBox regexSearch = new JCheckBox(tr("regular expression"), initialValues.regexSearch);
+        final JCheckBox mapCSSSearch = new JCheckBox(tr("MapCSS selector"), initialValues.mapCSSSearch);
+        final JCheckBox addOnToolbar = new JCheckBox(tr("add toolbar button"), false);
+        final ButtonGroup bg2 = new ButtonGroup();
+        bg2.add(regexSearch);
+        bg2.add(mapCSSSearch);
 
         JPanel top = new JPanel(new GridBagLayout());
@@ -264,4 +268,5 @@
             left.add(allElements, GBC.eol());
             left.add(regexSearch, GBC.eol());
+            left.add(mapCSSSearch, GBC.eol());
             left.add(addOnToolbar, GBC.eol());
         }
@@ -290,4 +295,5 @@
                         ss.caseSensitive = caseSensitive.isSelected();
                         ss.regexSearch = regexSearch.isSelected();
+                        ss.mapCSSSearch = mapCSSSearch.isSelected();
                         SearchCompiler.compile(ss);
                         super.buttonAction(buttonIndex, evt);
@@ -321,4 +327,5 @@
         initialValues.allElements = allElements.isSelected();
         initialValues.regexSearch = regexSearch.isSelected();
+        initialValues.mapCSSSearch = mapCSSSearch.isSelected();
 
         if (addOnToolbar.isSelected()) {
@@ -589,4 +596,5 @@
         public boolean caseSensitive;
         public boolean regexSearch;
+        public boolean mapCSSSearch;
         public boolean allElements;
 
@@ -602,4 +610,5 @@
             caseSensitive = original.caseSensitive;
             regexSearch = original.regexSearch;
+            mapCSSSearch = original.mapCSSSearch;
             allElements = original.allElements;
         }
@@ -612,7 +621,9 @@
             String rx = regexSearch ? ", " +
                             /*regex search*/ trc("search", "RX") : "";
+            String css = mapCSSSearch ? ", " +
+                            /*MapCSS search*/ trc("search", "CSS") : "";
             String all = allElements ? ", " +
                             /*all elements*/ trc("search", "A") : "";
-            return "\"" + text + "\" (" + cs + rx + all + ", " + mode + ")";
+            return "\"" + text + "\" (" + cs + rx + css + all + ", " + mode + ")";
         }
 
@@ -624,4 +635,5 @@
             return o.caseSensitive == this.caseSensitive
                     && o.regexSearch == this.regexSearch
+                    && o.mapCSSSearch == this.mapCSSSearch
                     && o.allElements == this.allElements
                     && o.mode.equals(this.mode)
@@ -655,4 +667,6 @@
                 } else if (s.charAt(index) == 'A') {
                     result.allElements = true;
+                } else if (s.charAt(index) == 'M') {
+                    result.mapCSSSearch = true;
                 } else if (s.charAt(index) == ' ') {
                     break;
@@ -685,4 +699,7 @@
                 result.append('R');
             }
+            if (mapCSSSearch) {
+                result.append('M');
+            }
             if (allElements) {
                 result.append('A');
Index: /trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 8811)
+++ /trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 8812)
@@ -28,4 +28,9 @@
 import org.openstreetmap.josm.data.osm.RelationMember;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.gui.mappaint.Environment;
+import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
+import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
+import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
+import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
 import org.openstreetmap.josm.tools.Geometry;
 import org.openstreetmap.josm.tools.Predicate;
@@ -1424,8 +1429,25 @@
      */
     public static Match compile(SearchAction.SearchSetting setting) throws ParseError {
+        if (setting.mapCSSSearch) {
+            return compileMapCSS(setting.text);
+        }
         return new SearchCompiler(setting.caseSensitive, setting.regexSearch,
                 new PushbackTokenizer(
                         new PushbackReader(new StringReader(setting.text))))
                 .parse();
+    }
+
+    static Match compileMapCSS(String mapCSS) throws ParseError {
+        try {
+            final Selector selector = new MapCSSParser(new StringReader(mapCSS)).selector();
+            return new Match() {
+                @Override
+                public boolean match(OsmPrimitive osm) {
+                    return selector.matches(new Environment(osm));
+                }
+            };
+        } catch (ParseException e) {
+            throw new ParseError(tr("Failed to parse MapCSS selector"), e);
+        }
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/Filter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/Filter.java	(revision 8811)
+++ /trunk/src/org/openstreetmap/josm/data/osm/Filter.java	(revision 8812)
@@ -40,4 +40,5 @@
         caseSensitive = e.case_sensitive;
         regexSearch = e.regex_search;
+        mapCSSSearch = e.mapCSS_search;
         enable = e.enable;
         hiding = e.hiding;
@@ -51,4 +52,5 @@
         @pref public boolean case_sensitive = false;
         @pref public boolean regex_search = false;
+        @pref public boolean mapCSS_search = false;
         @pref @writeExplicitly public boolean enable = true;
         @pref @writeExplicitly public boolean hiding = false;
@@ -63,4 +65,5 @@
         e.case_sensitive = caseSensitive;
         e.regex_search = regexSearch;
+        e.mapCSS_search = mapCSSSearch;
         e.enable = enable;
         e.hiding = hiding;
