Update CodeMirror to 3.14.1.
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / External / CodeMirror / css.js
1 CodeMirror.defineMode("css", function(config) {
2   return CodeMirror.getMode(config, "text/css");
3 });
4
5 CodeMirror.defineMode("css-base", function(config, parserConfig) {
6   "use strict";
7
8   var indentUnit = config.indentUnit,
9       hooks = parserConfig.hooks || {},
10       atMediaTypes = parserConfig.atMediaTypes || {},
11       atMediaFeatures = parserConfig.atMediaFeatures || {},
12       propertyKeywords = parserConfig.propertyKeywords || {},
13       colorKeywords = parserConfig.colorKeywords || {},
14       valueKeywords = parserConfig.valueKeywords || {},
15       allowNested = !!parserConfig.allowNested,
16       type = null;
17
18   function ret(style, tp) { type = tp; return style; }
19
20   function tokenBase(stream, state) {
21     var ch = stream.next();
22     if (hooks[ch]) {
23       // result[0] is style and result[1] is type
24       var result = hooks[ch](stream, state);
25       if (result !== false) return result;
26     }
27     if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
28     else if (ch == "=") ret(null, "compare");
29     else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
30     else if (ch == "\"" || ch == "'") {
31       state.tokenize = tokenString(ch);
32       return state.tokenize(stream, state);
33     }
34     else if (ch == "#") {
35       stream.eatWhile(/[\w\\\-]/);
36       return ret("atom", "hash");
37     }
38     else if (ch == "!") {
39       stream.match(/^\s*\w*/);
40       return ret("keyword", "important");
41     }
42     else if (/\d/.test(ch)) {
43       stream.eatWhile(/[\w.%]/);
44       return ret("number", "unit");
45     }
46     else if (ch === "-") {
47       if (/\d/.test(stream.peek())) {
48         stream.eatWhile(/[\w.%]/);
49         return ret("number", "unit");
50       } else if (stream.match(/^[^-]+-/)) {
51         return ret("meta", "meta");
52       }
53     }
54     else if (/[,+>*\/]/.test(ch)) {
55       return ret(null, "select-op");
56     }
57     else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
58       return ret("qualifier", "qualifier");
59     }
60     else if (ch == ":") {
61       return ret("operator", ch);
62     }
63     else if (/[;{}\[\]\(\)]/.test(ch)) {
64       return ret(null, ch);
65     }
66     else if (ch == "u" && stream.match("rl(")) {
67       stream.backUp(1);
68       state.tokenize = tokenParenthesized;
69       return ret("property", "variable");
70     }
71     else {
72       stream.eatWhile(/[\w\\\-]/);
73       return ret("property", "variable");
74     }
75   }
76
77   function tokenString(quote, nonInclusive) {
78     return function(stream, state) {
79       var escaped = false, ch;
80       while ((ch = stream.next()) != null) {
81         if (ch == quote && !escaped)
82           break;
83         escaped = !escaped && ch == "\\";
84       }
85       if (!escaped) {
86         if (nonInclusive) stream.backUp(1);
87         state.tokenize = tokenBase;
88       }
89       return ret("string", "string");
90     };
91   }
92
93   function tokenParenthesized(stream, state) {
94     stream.next(); // Must be '('
95     if (!stream.match(/\s*[\"\']/, false))
96       state.tokenize = tokenString(")", true);
97     else
98       state.tokenize = tokenBase;
99     return ret(null, "(");
100   }
101
102   return {
103     startState: function(base) {
104       return {tokenize: tokenBase,
105               baseIndent: base || 0,
106               stack: [],
107               lastToken: null};
108     },
109
110     token: function(stream, state) {
111
112       // Use these terms when applicable (see http://www.xanthir.com/blog/b4E50)
113       //
114       // rule** or **ruleset:
115       // A selector + braces combo, or an at-rule.
116       //
117       // declaration block:
118       // A sequence of declarations.
119       //
120       // declaration:
121       // A property + colon + value combo.
122       //
123       // property value:
124       // The entire value of a property.
125       //
126       // component value:
127       // A single piece of a property value. Like the 5px in
128       // text-shadow: 0 0 5px blue;. Can also refer to things that are
129       // multiple terms, like the 1-4 terms that make up the background-size
130       // portion of the background shorthand.
131       //
132       // term:
133       // The basic unit of author-facing CSS, like a single number (5),
134       // dimension (5px), string ("foo"), or function. Officially defined
135       //  by the CSS 2.1 grammar (look for the 'term' production)
136       //
137       //
138       // simple selector:
139       // A single atomic selector, like a type selector, an attr selector, a
140       // class selector, etc.
141       //
142       // compound selector:
143       // One or more simple selectors without a combinator. div.example is
144       // compound, div > .example is not.
145       //
146       // complex selector:
147       // One or more compound selectors chained with combinators.
148       //
149       // combinator:
150       // The parts of selectors that express relationships. There are four
151       // currently - the space (descendant combinator), the greater-than
152       // bracket (child combinator), the plus sign (next sibling combinator),
153       // and the tilda (following sibling combinator).
154       //
155       // sequence of selectors:
156       // One or more of the named type of selector chained with commas.
157
158       state.tokenize = state.tokenize || tokenBase;
159       if (state.tokenize == tokenBase && stream.eatSpace()) return null;
160       var style = state.tokenize(stream, state);
161       if (style && typeof style != "string") style = ret(style[0], style[1]);
162
163       // Changing style returned based on context
164       var context = state.stack[state.stack.length-1];
165       if (style == "variable") {
166         if (type == "variable-definition") state.stack.push("propertyValue");
167         return state.lastToken = "variable-2";
168       } else if (style == "property") {
169         var word = stream.current().toLowerCase();
170         if (context == "propertyValue") {
171           if (valueKeywords.hasOwnProperty(word)) {
172             style = "string-2";
173           } else if (colorKeywords.hasOwnProperty(word)) {
174             style = "keyword";
175           } else {
176             style = "variable-2";
177           }
178         } else if (context == "rule") {
179           if (!propertyKeywords.hasOwnProperty(word)) {
180             style += " error";
181           }
182         } else if (context == "block") {
183           // if a value is present in both property, value, or color, the order
184           // of preference is property -> color -> value
185           if (propertyKeywords.hasOwnProperty(word)) {
186             style = "property";
187           } else if (colorKeywords.hasOwnProperty(word)) {
188             style = "keyword";
189           } else if (valueKeywords.hasOwnProperty(word)) {
190             style = "string-2";
191           } else {
192             style = "tag";
193           }
194         } else if (!context || context == "@media{") {
195           style = "tag";
196         } else if (context == "@media") {
197           if (atMediaTypes[stream.current()]) {
198             style = "attribute"; // Known attribute
199           } else if (/^(only|not)$/.test(word)) {
200             style = "keyword";
201           } else if (word == "and") {
202             style = "error"; // "and" is only allowed in @mediaType
203           } else if (atMediaFeatures.hasOwnProperty(word)) {
204             style = "error"; // Known property, should be in @mediaType(
205           } else {
206             // Unknown, expecting keyword or attribute, assuming attribute
207             style = "attribute error";
208           }
209         } else if (context == "@mediaType") {
210           if (atMediaTypes.hasOwnProperty(word)) {
211             style = "attribute";
212           } else if (word == "and") {
213             style = "operator";
214           } else if (/^(only|not)$/.test(word)) {
215             style = "error"; // Only allowed in @media
216           } else {
217             // Unknown attribute or property, but expecting property (preceded
218             // by "and"). Should be in parentheses
219             style = "error";
220           }
221         } else if (context == "@mediaType(") {
222           if (propertyKeywords.hasOwnProperty(word)) {
223             // do nothing, remains "property"
224           } else if (atMediaTypes.hasOwnProperty(word)) {
225             style = "error"; // Known property, should be in parentheses
226           } else if (word == "and") {
227             style = "operator";
228           } else if (/^(only|not)$/.test(word)) {
229             style = "error"; // Only allowed in @media
230           } else {
231             style += " error";
232           }
233         } else if (context == "@import") {
234           style = "tag";
235         } else {
236           style = "error";
237         }
238       } else if (style == "atom") {
239         if(!context || context == "@media{" || context == "block") {
240           style = "builtin";
241         } else if (context == "propertyValue") {
242           if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
243             style += " error";
244           }
245         } else {
246           style = "error";
247         }
248       } else if (context == "@media" && type == "{") {
249         style = "error";
250       }
251
252       // Push/pop context stack
253       if (type == "{") {
254         if (context == "@media" || context == "@mediaType") {
255           state.stack.pop();
256           state.stack[state.stack.length-1] = "@media{";
257         }
258         else {
259           var newContext = allowNested ? "block" : "rule";
260           state.stack.push(newContext);
261         }
262       }
263       else if (type == "}") {
264         var lastState = state.stack[state.stack.length - 1];
265         if (lastState == "interpolation") style = "operator";
266         state.stack.pop();
267         if (context == "propertyValue") state.stack.pop();
268       }
269       else if (type == "interpolation") state.stack.push("interpolation");
270       else if (type == "@media") state.stack.push("@media");
271       else if (type == "@import") state.stack.push("@import");
272       else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
273         state.stack.push("@mediaType");
274       else if (context == "@mediaType" && stream.current() == ",") state.stack.pop();
275       else if (context == "@mediaType" && type == "(") state.stack.push("@mediaType(");
276       else if (context == "@mediaType(" && type == ")") state.stack.pop();
277       else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
278       else if (context == "propertyValue" && type == ";") state.stack.pop();
279       else if (context == "@import" && type == ";") state.stack.pop();
280       return state.lastToken = style;
281     },
282
283     indent: function(state, textAfter) {
284       var n = state.stack.length;
285       if (/^\}/.test(textAfter))
286         n -= state.stack[state.stack.length-1] == "propertyValue" ? 2 : 1;
287       return state.baseIndent + n * indentUnit;
288     },
289
290     electricChars: "}",
291     blockCommentStart: "/*",
292     blockCommentEnd: "*/",
293     fold: "brace"
294   };
295 });
296
297 (function() {
298   function keySet(array) {
299     var keys = {};
300     for (var i = 0; i < array.length; ++i) {
301       keys[array[i]] = true;
302     }
303     return keys;
304   }
305
306   var atMediaTypes = keySet([
307     "all", "aural", "braille", "handheld", "print", "projection", "screen",
308     "tty", "tv", "embossed"
309   ]);
310
311   var atMediaFeatures = keySet([
312     "width", "min-width", "max-width", "height", "min-height", "max-height",
313     "device-width", "min-device-width", "max-device-width", "device-height",
314     "min-device-height", "max-device-height", "aspect-ratio",
315     "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
316     "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
317     "max-color", "color-index", "min-color-index", "max-color-index",
318     "monochrome", "min-monochrome", "max-monochrome", "resolution",
319     "min-resolution", "max-resolution", "scan", "grid"
320   ]);
321
322   var propertyKeywords = keySet([
323     "align-content", "align-items", "align-self", "alignment-adjust",
324     "alignment-baseline", "anchor-point", "animation", "animation-delay",
325     "animation-direction", "animation-duration", "animation-iteration-count",
326     "animation-name", "animation-play-state", "animation-timing-function",
327     "appearance", "azimuth", "backface-visibility", "background",
328     "background-attachment", "background-clip", "background-color",
329     "background-image", "background-origin", "background-position",
330     "background-repeat", "background-size", "baseline-shift", "binding",
331     "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
332     "bookmark-target", "border", "border-bottom", "border-bottom-color",
333     "border-bottom-left-radius", "border-bottom-right-radius",
334     "border-bottom-style", "border-bottom-width", "border-collapse",
335     "border-color", "border-image", "border-image-outset",
336     "border-image-repeat", "border-image-slice", "border-image-source",
337     "border-image-width", "border-left", "border-left-color",
338     "border-left-style", "border-left-width", "border-radius", "border-right",
339     "border-right-color", "border-right-style", "border-right-width",
340     "border-spacing", "border-style", "border-top", "border-top-color",
341     "border-top-left-radius", "border-top-right-radius", "border-top-style",
342     "border-top-width", "border-width", "bottom", "box-decoration-break",
343     "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
344     "caption-side", "clear", "clip", "color", "color-profile", "column-count",
345     "column-fill", "column-gap", "column-rule", "column-rule-color",
346     "column-rule-style", "column-rule-width", "column-span", "column-width",
347     "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
348     "cue-after", "cue-before", "cursor", "direction", "display",
349     "dominant-baseline", "drop-initial-after-adjust",
350     "drop-initial-after-align", "drop-initial-before-adjust",
351     "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
352     "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
353     "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
354     "float", "float-offset", "font", "font-feature-settings", "font-family",
355     "font-kerning", "font-language-override", "font-size", "font-size-adjust",
356     "font-stretch", "font-style", "font-synthesis", "font-variant",
357     "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
358     "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
359     "font-weight", "grid-cell", "grid-column", "grid-column-align",
360     "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow",
361     "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span",
362     "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens",
363     "icon", "image-orientation", "image-rendering", "image-resolution",
364     "inline-box-align", "justify-content", "left", "letter-spacing",
365     "line-break", "line-height", "line-stacking", "line-stacking-ruby",
366     "line-stacking-shift", "line-stacking-strategy", "list-style",
367     "list-style-image", "list-style-position", "list-style-type", "margin",
368     "margin-bottom", "margin-left", "margin-right", "margin-top",
369     "marker-offset", "marks", "marquee-direction", "marquee-loop",
370     "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
371     "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
372     "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
373     "outline-color", "outline-offset", "outline-style", "outline-width",
374     "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
375     "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
376     "page", "page-break-after", "page-break-before", "page-break-inside",
377     "page-policy", "pause", "pause-after", "pause-before", "perspective",
378     "perspective-origin", "pitch", "pitch-range", "play-during", "position",
379     "presentation-level", "punctuation-trim", "quotes", "rendering-intent",
380     "resize", "rest", "rest-after", "rest-before", "richness", "right",
381     "rotation", "rotation-point", "ruby-align", "ruby-overhang",
382     "ruby-position", "ruby-span", "size", "speak", "speak-as", "speak-header",
383     "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
384     "tab-size", "table-layout", "target", "target-name", "target-new",
385     "target-position", "text-align", "text-align-last", "text-decoration",
386     "text-decoration-color", "text-decoration-line", "text-decoration-skip",
387     "text-decoration-style", "text-emphasis", "text-emphasis-color",
388     "text-emphasis-position", "text-emphasis-style", "text-height",
389     "text-indent", "text-justify", "text-outline", "text-shadow",
390     "text-space-collapse", "text-transform", "text-underline-position",
391     "text-wrap", "top", "transform", "transform-origin", "transform-style",
392     "transition", "transition-delay", "transition-duration",
393     "transition-property", "transition-timing-function", "unicode-bidi",
394     "vertical-align", "visibility", "voice-balance", "voice-duration",
395     "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
396     "voice-volume", "volume", "white-space", "widows", "width", "word-break",
397     "word-spacing", "word-wrap", "z-index",
398     // SVG-specific
399     "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
400     "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
401     "color-interpolation", "color-interpolation-filters", "color-profile",
402     "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
403     "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
404     "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
405     "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
406     "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
407     "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
408   ]);
409
410   var colorKeywords = keySet([
411     "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
412     "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
413     "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
414     "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
415     "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
416     "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
417     "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
418     "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
419     "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
420     "gold", "goldenrod", "gray", "green", "greenyellow", "honeydew",
421     "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
422     "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
423     "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
424     "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
425     "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
426     "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
427     "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
428     "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
429     "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
430     "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
431     "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
432     "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
433     "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
434     "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
435     "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
436     "whitesmoke", "yellow", "yellowgreen"
437   ]);
438
439   var valueKeywords = keySet([
440     "above", "absolute", "activeborder", "activecaption", "afar",
441     "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
442     "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
443     "arabic-indic", "armenian", "asterisks", "auto", "avoid", "background",
444     "backwards", "baseline", "below", "bidi-override", "binary", "bengali",
445     "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
446     "both", "bottom", "break-all", "break-word", "button", "button-bevel",
447     "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
448     "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
449     "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
450     "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
451     "col-resize", "collapse", "compact", "condensed", "contain", "content",
452     "content-box", "context-menu", "continuous", "copy", "cover", "crop",
453     "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
454     "decimal-leading-zero", "default", "default-button", "destination-atop",
455     "destination-in", "destination-out", "destination-over", "devanagari",
456     "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
457     "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
458     "element", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
459     "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
460     "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
461     "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
462     "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
463     "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
464     "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
465     "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
466     "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
467     "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
468     "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
469     "help", "hidden", "hide", "higher", "highlight", "highlighttext",
470     "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
471     "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
472     "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
473     "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
474     "italic", "justify", "kannada", "katakana", "katakana-iroha", "khmer",
475     "landscape", "lao", "large", "larger", "left", "level", "lighter",
476     "line-through", "linear", "lines", "list-item", "listbox", "listitem",
477     "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
478     "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
479     "lower-roman", "lowercase", "ltr", "malayalam", "match",
480     "media-controls-background", "media-current-time-display",
481     "media-fullscreen-button", "media-mute-button", "media-play-button",
482     "media-return-to-realtime-button", "media-rewind-button",
483     "media-seek-back-button", "media-seek-forward-button", "media-slider",
484     "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
485     "media-volume-slider-container", "media-volume-sliderthumb", "medium",
486     "menu", "menulist", "menulist-button", "menulist-text",
487     "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
488     "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
489     "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
490     "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
491     "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
492     "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
493     "outside", "overlay", "overline", "padding", "padding-box", "painted",
494     "paused", "persian", "plus-darker", "plus-lighter", "pointer", "portrait",
495     "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
496     "radio", "read-only", "read-write", "read-write-plaintext-only", "relative",
497     "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
498     "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
499     "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
500     "searchfield-cancel-button", "searchfield-decoration",
501     "searchfield-results-button", "searchfield-results-decoration",
502     "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
503     "single", "skip-white-space", "slide", "slider-horizontal",
504     "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
505     "small", "small-caps", "small-caption", "smaller", "solid", "somali",
506     "source-atop", "source-in", "source-out", "source-over", "space", "square",
507     "square-button", "start", "static", "status-bar", "stretch", "stroke",
508     "sub", "subpixel-antialiased", "super", "sw-resize", "table",
509     "table-caption", "table-cell", "table-column", "table-column-group",
510     "table-footer-group", "table-header-group", "table-row", "table-row-group",
511     "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
512     "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
513     "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
514     "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
515     "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
516     "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
517     "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
518     "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
519     "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
520     "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
521     "xx-large", "xx-small"
522   ]);
523
524   function tokenCComment(stream, state) {
525     var maybeEnd = false, ch;
526     while ((ch = stream.next()) != null) {
527       if (maybeEnd && ch == "/") {
528         state.tokenize = null;
529         break;
530       }
531       maybeEnd = (ch == "*");
532     }
533     return ["comment", "comment"];
534   }
535
536   CodeMirror.defineMIME("text/css", {
537     atMediaTypes: atMediaTypes,
538     atMediaFeatures: atMediaFeatures,
539     propertyKeywords: propertyKeywords,
540     colorKeywords: colorKeywords,
541     valueKeywords: valueKeywords,
542     hooks: {
543       "<": function(stream, state) {
544         function tokenSGMLComment(stream, state) {
545           var dashes = 0, ch;
546           while ((ch = stream.next()) != null) {
547             if (dashes >= 2 && ch == ">") {
548               state.tokenize = null;
549               break;
550             }
551             dashes = (ch == "-") ? dashes + 1 : 0;
552           }
553           return ["comment", "comment"];
554         }
555         if (stream.eat("!")) {
556           state.tokenize = tokenSGMLComment;
557           return tokenSGMLComment(stream, state);
558         }
559       },
560       "/": function(stream, state) {
561         if (stream.eat("*")) {
562           state.tokenize = tokenCComment;
563           return tokenCComment(stream, state);
564         }
565         return false;
566       }
567     },
568     name: "css-base"
569   });
570
571   CodeMirror.defineMIME("text/x-scss", {
572     atMediaTypes: atMediaTypes,
573     atMediaFeatures: atMediaFeatures,
574     propertyKeywords: propertyKeywords,
575     colorKeywords: colorKeywords,
576     valueKeywords: valueKeywords,
577     allowNested: true,
578     hooks: {
579       "$": function(stream) {
580         stream.match(/^[\w-]+/);
581         if (stream.peek() == ":") {
582           return ["variable", "variable-definition"];
583         }
584         return ["variable", "variable"];
585       },
586       "/": function(stream, state) {
587         if (stream.eat("/")) {
588           stream.skipToEnd();
589           return ["comment", "comment"];
590         } else if (stream.eat("*")) {
591           state.tokenize = tokenCComment;
592           return tokenCComment(stream, state);
593         } else {
594           return ["operator", "operator"];
595         }
596       },
597       "#": function(stream) {
598         if (stream.eat("{")) {
599           return ["operator", "interpolation"];
600         } else {
601           stream.eatWhile(/[\w\\\-]/);
602           return ["atom", "hash"];
603         }
604       }
605     },
606     name: "css-base"
607   });
608 })();