Better support for MapCSS 0.2, including subparts
[potlatch2.git] / net / systemeD / halcyon / styleparser / RuleSet.as
index 0bf9923a472bdc835cb3394f94e2fd5459bdd248..1c9f6be8a25ed21efd6bb0f578f6e4a700403249 100644 (file)
@@ -43,7 +43,7 @@ package net.systemeD.halcyon.styleparser {
                private static const CONDITION:RegExp   =/^ \[(.+?)\] \s* /sx;
                private static const OBJECT:RegExp              =/^ (\w+) \s* /sx;
                private static const DECLARATION:RegExp =/^ \{(.+?)\} \s* /sx;
-               private static const SUBPART:RegExp             =/^ ::(\S+) \s* /sx;
+               private static const SUBPART:RegExp             =/^ ::(\w+) \s* /sx;
                private static const UNKNOWN:RegExp             =/^ (\S+) \s* /sx;
 
                private static const ZOOM_MINMAX:RegExp =/^ (\d+)\-(\d+) $/sx;
@@ -75,6 +75,7 @@ package net.systemeD.halcyon.styleparser {
                private static const oCONDITION:uint=4;
                private static const oOBJECT:uint=5;
                private static const oDECLARATION:uint=6;
+               private static const oSUBPART:uint=7;
 
                private static const DASH:RegExp=/\-/g;
                private static const COLOR:RegExp=/color$/;
@@ -288,7 +289,7 @@ package net.systemeD.halcyon.styleparser {
                                        else if (style is ShieldStyle && ShieldStyle(style).shield_image) { filename=ShieldStyle(style).shield_image; }
                                        else { continue; }
                                        if (filename=='square' || filename=='circle') { continue; }
-                               
+                       
                                        iconsToLoad++;
                                        var request:DebugURLRequest=new DebugURLRequest(filename);
                                        var loader:ExtendedURLLoader=new ExtendedURLLoader();
@@ -410,6 +411,13 @@ package net.systemeD.halcyon.styleparser {
                                        sc.currentChain.addRule(o[1]);
                                        previous=oOBJECT;
 
+                               // Subpart - ::centreline
+                               } else if ((o=SUBPART.exec(css))) {
+                                       if (previous==oDECLARATION) { saveChooser(sc); sc=new StyleChooser(); }
+                                       css=css.replace(SUBPART,'');
+                                       sc.currentChain.setSubpart(o[1]);
+                                       previous=oSUBPART;
+
                                // Declaration - {...}
                                } else if ((o=DECLARATION.exec(css))) {
                                        css=css.replace(DECLARATION,'');