The {@code css} map does not contain every property in the given{@link CssSchema} since some cannot be matched efficiently by values.See comments on {@code [ a || b ]*} constructs inline below.
This class examines a schema and builds a list of all allowed CSS properties. It then tries to convert each property's signature to a regular expression pattern. It may fail for some patterns, especially the aggregate ones like {@code background} which combine{@code background-image}, {@code background-style}, etc.
Next it optimizes the patterns it found. This includes flattening concatenation and union operators, and moving the {@code \s+} out of unions.Optimizing {@code /((blue\s+|red\s+|green\s+)|inherit\s+)/} might yield thesimpler expression {@code /(blue|red|green|inherit)\s+/}.
Once it has a mapping of property names to regular expressions it builds a constant pool by hashing on regular expression text. This allows properties with identical patterns such as {@code border-top} and{@code border-bottom} to share an instance.
Finally it builds a javascript parse tree that assigns the {@code css}namespace to an object whose keys are CSS property names, and whose values are regular expressions.
Some of the regular expressions do match URLs. If valid css text contains the string 'uri' case-insensitively, then a client may need to extract and rewrite URLs. Since all strings are double quoted, this should be doable without lexing CSS. @author mikesamuel@gmail.com
|
|
|
|
|
|
|
|
|
|