<https://webkit.org/b/120165> Web Inspector: Update CodeMirror to 3.16.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[state.stack.length-1] = "@media{";
256         }
257         else {
258           var newContext = allowNested ? "block" : "rule";
259           state.stack.push(newContext);
260         }
261       }
262       else if (type == "}") {
263         if (context == "interpolation") style = "operator";
264         state.stack.pop();
265         if (context == "propertyValue") state.stack.pop();
266       }
267       else if (type == "interpolation") state.stack.push("interpolation");
268       else if (type == "@media") state.stack.push("@media");
269       else if (type == "@import") state.stack.push("@import");
270       else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
271         state.stack[state.stack.length-1] = "@mediaType";
272       else if (context == "@mediaType" && stream.current() == ",")
273         state.stack[state.stack.length-1] = "@media";
274       else if (type == "(") {
275         if (context == "@media" || context == "@mediaType") {
276           // Make sure @mediaType is used to avoid error on {
277           state.stack[state.stack.length-1] = "@mediaType";
278           state.stack.push("@mediaType(");
279         }
280       }
281       else if (type == ")") {
282         if (context == "propertyValue" && state.stack[state.stack.length-2] == "@mediaType(") {
283           // In @mediaType( without closing ; after propertyValue
284           state.stack.pop();
285           state.stack.pop();
286         }
287         else if (context == "@mediaType(") {
288           state.stack.pop();
289         }
290       }
291       else if (type == ":" && state.lastToken == "property") state.stack.push("propertyValue");
292       else if (context == "propertyValue" && type == ";") state.stack.pop();
293       else if (context == "@import" && type == ";") state.stack.pop();
294
295       return state.lastToken = style;
296     },
297
298     indent: function(state, textAfter) {
299       var n = state.stack.length;
300       if (/^\}/.test(textAfter))
301         n -= state.stack[n-1] == "propertyValue" ? 2 : 1;
302       return state.baseIndent + n * indentUnit;
303     },
304
305     electricChars: "}",
306     blockCommentStart: "/*",
307     blockCommentEnd: "*/",
308     fold: "brace"
309   };
310 });
311
312 (function() {
313   function keySet(array) {
314     var keys = {};
315     for (var i = 0; i < array.length; ++i) {
316       keys[array[i]] = true;
317     }
318     return keys;
319   }
320
321   var atMediaTypes = keySet([
322     "all", "aural", "braille", "handheld", "print", "projection", "screen",
323     "tty", "tv", "embossed"
324   ]);
325
326   var atMediaFeatures = keySet([
327     "width", "min-width", "max-width", "height", "min-height", "max-height",
328     "device-width", "min-device-width", "max-device-width", "device-height",
329     "min-device-height", "max-device-height", "aspect-ratio",
330     "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
331     "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
332     "max-color", "color-index", "min-color-index", "max-color-index",
333     "monochrome", "min-monochrome", "max-monochrome", "resolution",
334     "min-resolution", "max-resolution", "scan", "grid"
335   ]);
336
337   var propertyKeywords = keySet([
338     "align-content", "align-items", "align-self", "alignment-adjust",
339     "alignment-baseline", "anchor-point", "animation", "animation-delay",
340     "animation-direction", "animation-duration", "animation-iteration-count",
341     "animation-name", "animation-play-state", "animation-timing-function",
342     "appearance", "azimuth", "backface-visibility", "background",
343     "background-attachment", "background-clip", "background-color",
344     "background-image", "background-origin", "background-position",
345     "background-repeat", "background-size", "baseline-shift", "binding",
346     "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
347     "bookmark-target", "border", "border-bottom", "border-bottom-color",
348     "border-bottom-left-radius", "border-bottom-right-radius",
349     "border-bottom-style", "border-bottom-width", "border-collapse",
350     "border-color", "border-image", "border-image-outset",
351     "border-image-repeat", "border-image-slice", "border-image-source",
352     "border-image-width", "border-left", "border-left-color",
353     "border-left-style", "border-left-width", "border-radius", "border-right",
354     "border-right-color", "border-right-style", "border-right-width",
355     "border-spacing", "border-style", "border-top", "border-top-color",
356     "border-top-left-radius", "border-top-right-radius", "border-top-style",
357     "border-top-width", "border-width", "bottom", "box-decoration-break",
358     "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
359     "caption-side", "clear", "clip", "color", "color-profile", "column-count",
360     "column-fill", "column-gap", "column-rule", "column-rule-color",
361     "column-rule-style", "column-rule-width", "column-span", "column-width",
362     "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
363     "cue-after", "cue-before", "cursor", "direction", "display",
364     "dominant-baseline", "drop-initial-after-adjust",
365     "drop-initial-after-align", "drop-initial-before-adjust",
366     "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
367     "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
368     "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
369     "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
370     "font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
371     "font-stretch", "font-style", "font-synthesis", "font-variant",
372     "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
373     "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
374     "font-weight", "grid-cell", "grid-column", "grid-column-align",
375     "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow",
376     "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span",
377     "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens",
378     "icon", "image-orientation", "image-rendering", "image-resolution",
379     "inline-box-align", "justify-content", "left", "letter-spacing",
380     "line-break", "line-height", "line-stacking", "line-stacking-ruby",
381     "line-stacking-shift", "line-stacking-strategy", "list-style",
382     "list-style-image", "list-style-position", "list-style-type", "margin",
383     "margin-bottom", "margin-left", "margin-right", "margin-top",
384     "marker-offset", "marks", "marquee-direction", "marquee-loop",
385     "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
386     "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
387     "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
388     "outline-color", "outline-offset", "outline-style", "outline-width",
389     "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
390     "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
391     "page", "page-break-after", "page-break-before", "page-break-inside",
392     "page-policy", "pause", "pause-after", "pause-before", "perspective",
393     "perspective-origin", "pitch", "pitch-range", "play-during", "position",
394     "presentation-level", "punctuation-trim", "quotes", "region-break-after",
395     "region-break-before", "region-break-inside", "region-fragment",
396     "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
397     "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
398     "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size",
399     "speak", "speak-as", "speak-header",
400     "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
401     "tab-size", "table-layout", "target", "target-name", "target-new",
402     "target-position", "text-align", "text-align-last", "text-decoration",
403     "text-decoration-color", "text-decoration-line", "text-decoration-skip",
404     "text-decoration-style", "text-emphasis", "text-emphasis-color",
405     "text-emphasis-position", "text-emphasis-style", "text-height",
406     "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
407     "text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
408     "text-wrap", "top", "transform", "transform-origin", "transform-style",
409     "transition", "transition-delay", "transition-duration",
410     "transition-property", "transition-timing-function", "unicode-bidi",
411     "vertical-align", "visibility", "voice-balance", "voice-duration",
412     "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
413     "voice-volume", "volume", "white-space", "widows", "width", "word-break",
414     "word-spacing", "word-wrap", "z-index", "zoom",
415     // SVG-specific
416     "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
417     "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
418     "color-interpolation", "color-interpolation-filters", "color-profile",
419     "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
420     "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
421     "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
422     "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
423     "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
424     "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode"
425   ]);
426
427   var colorKeywords = keySet([
428     "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
429     "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
430     "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
431     "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
432     "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
433     "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
434     "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
435     "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
436     "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
437     "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
438     "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
439     "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
440     "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
441     "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
442     "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
443     "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
444     "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
445     "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
446     "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
447     "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
448     "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
449     "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon",
450     "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
451     "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
452     "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
453     "whitesmoke", "yellow", "yellowgreen"
454   ]);
455
456   var valueKeywords = keySet([
457     "above", "absolute", "activeborder", "activecaption", "afar",
458     "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
459     "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
460     "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
461     "avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
462     "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
463     "both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
464     "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
465     "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
466     "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
467     "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
468     "col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
469     "content-box", "context-menu", "continuous", "copy", "cover", "crop",
470     "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
471     "decimal-leading-zero", "default", "default-button", "destination-atop",
472     "destination-in", "destination-out", "destination-over", "devanagari",
473     "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
474     "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
475     "element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
476     "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
477     "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
478     "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
479     "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
480     "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
481     "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
482     "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
483     "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
484     "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
485     "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
486     "help", "hidden", "hide", "higher", "highlight", "highlighttext",
487     "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
488     "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
489     "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
490     "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
491     "italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
492     "landscape", "lao", "large", "larger", "left", "level", "lighter",
493     "line-through", "linear", "lines", "list-item", "listbox", "listitem",
494     "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
495     "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
496     "lower-roman", "lowercase", "ltr", "malayalam", "match",
497     "media-controls-background", "media-current-time-display",
498     "media-fullscreen-button", "media-mute-button", "media-play-button",
499     "media-return-to-realtime-button", "media-rewind-button",
500     "media-seek-back-button", "media-seek-forward-button", "media-slider",
501     "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
502     "media-volume-slider-container", "media-volume-sliderthumb", "medium",
503     "menu", "menulist", "menulist-button", "menulist-text",
504     "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
505     "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
506     "narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
507     "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
508     "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
509     "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
510     "outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
511     "painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
512     "polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
513     "radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
514     "relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
515     "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
516     "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
517     "searchfield-cancel-button", "searchfield-decoration",
518     "searchfield-results-button", "searchfield-results-decoration",
519     "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
520     "single", "skip-white-space", "slide", "slider-horizontal",
521     "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
522     "small", "small-caps", "small-caption", "smaller", "solid", "somali",
523     "source-atop", "source-in", "source-out", "source-over", "space", "square",
524     "square-button", "start", "static", "status-bar", "stretch", "stroke",
525     "sub", "subpixel-antialiased", "super", "sw-resize", "table",
526     "table-caption", "table-cell", "table-column", "table-column-group",
527     "table-footer-group", "table-header-group", "table-row", "table-row-group",
528     "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
529     "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
530     "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
531     "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
532     "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
533     "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
534     "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
535     "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
536     "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
537     "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
538     "xx-large", "xx-small"
539   ]);
540
541   function tokenCComment(stream, state) {
542     var maybeEnd = false, ch;
543     while ((ch = stream.next()) != null) {
544       if (maybeEnd && ch == "/") {
545         state.tokenize = null;
546         break;
547       }
548       maybeEnd = (ch == "*");
549     }
550     return ["comment", "comment"];
551   }
552
553   CodeMirror.defineMIME("text/css", {
554     atMediaTypes: atMediaTypes,
555     atMediaFeatures: atMediaFeatures,
556     propertyKeywords: propertyKeywords,
557     colorKeywords: colorKeywords,
558     valueKeywords: valueKeywords,
559     hooks: {
560       "<": function(stream, state) {
561         function tokenSGMLComment(stream, state) {
562           var dashes = 0, ch;
563           while ((ch = stream.next()) != null) {
564             if (dashes >= 2 && ch == ">") {
565               state.tokenize = null;
566               break;
567             }
568             dashes = (ch == "-") ? dashes + 1 : 0;
569           }
570           return ["comment", "comment"];
571         }
572         if (stream.eat("!")) {
573           state.tokenize = tokenSGMLComment;
574           return tokenSGMLComment(stream, state);
575         }
576       },
577       "/": function(stream, state) {
578         if (stream.eat("*")) {
579           state.tokenize = tokenCComment;
580           return tokenCComment(stream, state);
581         }
582         return false;
583       }
584     },
585     name: "css-base"
586   });
587
588   CodeMirror.defineMIME("text/x-scss", {
589     atMediaTypes: atMediaTypes,
590     atMediaFeatures: atMediaFeatures,
591     propertyKeywords: propertyKeywords,
592     colorKeywords: colorKeywords,
593     valueKeywords: valueKeywords,
594     allowNested: true,
595     hooks: {
596       "$": function(stream) {
597         stream.match(/^[\w-]+/);
598         if (stream.peek() == ":") {
599           return ["variable", "variable-definition"];
600         }
601         return ["variable", "variable"];
602       },
603       "/": function(stream, state) {
604         if (stream.eat("/")) {
605           stream.skipToEnd();
606           return ["comment", "comment"];
607         } else if (stream.eat("*")) {
608           state.tokenize = tokenCComment;
609           return tokenCComment(stream, state);
610         } else {
611           return ["operator", "operator"];
612         }
613       },
614       "#": function(stream) {
615         if (stream.eat("{")) {
616           return ["operator", "interpolation"];
617         } else {
618           stream.eatWhile(/[\w\\\-]/);
619           return ["atom", "hash"];
620         }
621       }
622     },
623     name: "css-base"
624   });
625 })();