Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: Source/devtools/front_end/cm/css.js

Issue 354833004: DevTools: [CodeMirror] roll CodeMirror to version @e20d175 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address comments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 // Distributed under an MIT license: http://codemirror.net/LICENSE
3
4 (function(mod) {
5 if (typeof exports == "object" && typeof module == "object") // CommonJS
6 mod(require("../../lib/codemirror"));
7 else if (typeof define == "function" && define.amd) // AMD
8 define(["../../lib/codemirror"], mod);
9 else // Plain browser env
10 mod(CodeMirror);
11 })(function(CodeMirror) {
12 "use strict";
13
1 CodeMirror.defineMode("css", function(config, parserConfig) { 14 CodeMirror.defineMode("css", function(config, parserConfig) {
2 "use strict";
3
4 if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("tex t/css"); 15 if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("tex t/css");
5 16
6 var indentUnit = config.indentUnit || config.tabSize || 2, 17 var indentUnit = config.indentUnit,
7 hooks = parserConfig.hooks || {}, 18 tokenHooks = parserConfig.tokenHooks,
8 atMediaTypes = parserConfig.atMediaTypes || {}, 19 mediaTypes = parserConfig.mediaTypes || {},
9 atMediaFeatures = parserConfig.atMediaFeatures || {}, 20 mediaFeatures = parserConfig.mediaFeatures || {},
10 propertyKeywords = parserConfig.propertyKeywords || {}, 21 propertyKeywords = parserConfig.propertyKeywords || {},
22 nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
11 colorKeywords = parserConfig.colorKeywords || {}, 23 colorKeywords = parserConfig.colorKeywords || {},
12 valueKeywords = parserConfig.valueKeywords || {}, 24 valueKeywords = parserConfig.valueKeywords || {},
13 allowNested = !!parserConfig.allowNested, 25 fontProperties = parserConfig.fontProperties || {},
14 type = null; 26 allowNested = parserConfig.allowNested;
15 27
28 var type, override;
16 function ret(style, tp) { type = tp; return style; } 29 function ret(style, tp) { type = tp; return style; }
17 30
31 // Tokenizers
32
18 function tokenBase(stream, state) { 33 function tokenBase(stream, state) {
19 var ch = stream.next(); 34 var ch = stream.next();
20 if (hooks[ch]) { 35 if (tokenHooks[ch]) {
21 // result[0] is style and result[1] is type 36 var result = tokenHooks[ch](stream, state);
22 var result = hooks[ch](stream, state);
23 if (result !== false) return result; 37 if (result !== false) return result;
24 } 38 }
25 if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.curren t());} 39 if (ch == "@") {
26 else if (ch == "=") ret(null, "compare"); 40 stream.eatWhile(/[\w\\\-]/);
27 else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "comp are"); 41 return ret("def", stream.current());
28 else if (ch == "\"" || ch == "'") { 42 } else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
43 return ret(null, "compare");
44 } else if (ch == "\"" || ch == "'") {
29 state.tokenize = tokenString(ch); 45 state.tokenize = tokenString(ch);
30 return state.tokenize(stream, state); 46 return state.tokenize(stream, state);
31 } 47 } else if (ch == "#") {
32 else if (ch == "#") {
33 stream.eatWhile(/[\w\\\-]/); 48 stream.eatWhile(/[\w\\\-]/);
34 return ret("atom", "hash"); 49 return ret("atom", "hash");
35 } 50 } else if (ch == "!") {
36 else if (ch == "!") {
37 stream.match(/^\s*\w*/); 51 stream.match(/^\s*\w*/);
38 return ret("keyword", "important"); 52 return ret("keyword", "important");
39 } 53 } else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
40 else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
41 stream.eatWhile(/[\w.%]/); 54 stream.eatWhile(/[\w.%]/);
42 return ret("number", "unit"); 55 return ret("number", "unit");
43 } 56 } else if (ch === "-") {
44 else if (ch === "-") { 57 if (/[\d.]/.test(stream.peek())) {
45 if (/\d/.test(stream.peek())) {
46 stream.eatWhile(/[\w.%]/); 58 stream.eatWhile(/[\w.%]/);
47 return ret("number", "unit"); 59 return ret("number", "unit");
48 } else if (stream.match(/^[^-]+-/)) { 60 } else if (stream.match(/^\w+-/)) {
49 return ret("meta", "meta"); 61 return ret("meta", "meta");
50 } 62 }
51 } 63 } else if (/[,+>*\/]/.test(ch)) {
52 else if (/[,+>*\/]/.test(ch)) {
53 return ret(null, "select-op"); 64 return ret(null, "select-op");
54 } 65 } else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
55 else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
56 return ret("qualifier", "qualifier"); 66 return ret("qualifier", "qualifier");
57 } 67 } else if (/[:;{}\[\]\(\)]/.test(ch)) {
58 else if (ch == ":") {
59 return ret("operator", ch);
60 }
61 else if (/[;{}\[\]\(\)]/.test(ch)) {
62 return ret(null, ch); 68 return ret(null, ch);
63 } 69 } else if (ch == "u" && stream.match("rl(")) {
64 else if (ch == "u" && stream.match("rl(")) {
65 stream.backUp(1); 70 stream.backUp(1);
66 state.tokenize = tokenParenthesized; 71 state.tokenize = tokenParenthesized;
67 return ret("property", "variable"); 72 return ret("property", "word");
68 } 73 } else if (/[\w\\\-]/.test(ch)) {
69 else {
70 stream.eatWhile(/[\w\\\-]/); 74 stream.eatWhile(/[\w\\\-]/);
71 return ret("property", "variable"); 75 return ret("property", "word");
72 } 76 } else {
73 } 77 return ret(null, null);
74 78 }
75 function tokenString(quote, nonInclusive) { 79 }
80
81 function tokenString(quote) {
76 return function(stream, state) { 82 return function(stream, state) {
77 var escaped = false, ch; 83 var escaped = false, ch;
78 while ((ch = stream.next()) != null) { 84 while ((ch = stream.next()) != null) {
79 if (ch == quote && !escaped) 85 if (ch == quote && !escaped) {
86 if (quote == ")") stream.backUp(1);
80 break; 87 break;
88 }
81 escaped = !escaped && ch == "\\"; 89 escaped = !escaped && ch == "\\";
82 } 90 }
83 if (!escaped) { 91 if (ch == quote || !escaped && quote != ")") state.tokenize = null;
84 if (nonInclusive) stream.backUp(1);
85 state.tokenize = tokenBase;
86 }
87 return ret("string", "string"); 92 return ret("string", "string");
88 }; 93 };
89 } 94 }
90 95
91 function tokenParenthesized(stream, state) { 96 function tokenParenthesized(stream, state) {
92 stream.next(); // Must be '(' 97 stream.next(); // Must be '('
93 if (!stream.match(/\s*[\"\']/, false)) 98 if (!stream.match(/\s*[\"\')]/, false))
94 state.tokenize = tokenString(")", true); 99 state.tokenize = tokenString(")");
95 else 100 else
96 state.tokenize = tokenBase; 101 state.tokenize = null;
97 return ret(null, "("); 102 return ret(null, "(");
98 } 103 }
99 104
105 // Context management
106
107 function Context(type, indent, prev) {
108 this.type = type;
109 this.indent = indent;
110 this.prev = prev;
111 }
112
113 function pushContext(state, stream, type) {
114 state.context = new Context(type, stream.indentation() + indentUnit, state.c ontext);
115 return type;
116 }
117
118 function popContext(state) {
119 state.context = state.context.prev;
120 return state.context.type;
121 }
122
123 function pass(type, stream, state) {
124 return states[state.context.type](type, stream, state);
125 }
126 function popAndPass(type, stream, state, n) {
127 for (var i = n || 1; i > 0; i--)
128 state.context = state.context.prev;
129 return pass(type, stream, state);
130 }
131
132 // Parser
133
134 function wordAsValue(stream) {
135 var word = stream.current().toLowerCase();
136 if (valueKeywords.hasOwnProperty(word))
137 override = "atom";
138 else if (colorKeywords.hasOwnProperty(word))
139 override = "keyword";
140 else
141 override = "variable";
142 }
143
144 var states = {};
145
146 states.top = function(type, stream, state) {
147 if (type == "{") {
148 return pushContext(state, stream, "block");
149 } else if (type == "}" && state.context.prev) {
150 return popContext(state);
151 } else if (type == "@media") {
152 return pushContext(state, stream, "media");
153 } else if (type == "@font-face") {
154 return "font_face_before";
155 } else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
156 return "keyframes";
157 } else if (type && type.charAt(0) == "@") {
158 return pushContext(state, stream, "at");
159 } else if (type == "hash") {
160 override = "builtin";
161 } else if (type == "word") {
162 override = "tag";
163 } else if (type == "variable-definition") {
164 return "maybeprop";
165 } else if (type == "interpolation") {
166 return pushContext(state, stream, "interpolation");
167 } else if (type == ":") {
168 return "pseudo";
169 } else if (allowNested && type == "(") {
170 return pushContext(state, stream, "parens");
171 }
172 return state.context.type;
173 };
174
175 states.block = function(type, stream, state) {
176 if (type == "word") {
177 var word = stream.current().toLowerCase();
178 if (propertyKeywords.hasOwnProperty(word)) {
179 override = "property";
180 return "maybeprop";
181 } else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
182 override = "string-2";
183 return "maybeprop";
184 } else if (allowNested) {
185 override = stream.match(/^\s*:/, false) ? "property" : "tag";
186 return "block";
187 } else {
188 override += " error";
189 return "maybeprop";
190 }
191 } else if (type == "meta") {
192 return "block";
193 } else if (!allowNested && (type == "hash" || type == "qualifier")) {
194 override = "error";
195 return "block";
196 } else {
197 return states.top(type, stream, state);
198 }
199 };
200
201 states.maybeprop = function(type, stream, state) {
202 if (type == ":") return pushContext(state, stream, "prop");
203 return pass(type, stream, state);
204 };
205
206 states.prop = function(type, stream, state) {
207 if (type == ";") return popContext(state);
208 if (type == "{" && allowNested) return pushContext(state, stream, "propBlock ");
209 if (type == "}" || type == "{") return popAndPass(type, stream, state);
210 if (type == "(") return pushContext(state, stream, "parens");
211
212 if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.curr ent())) {
213 override += " error";
214 } else if (type == "word") {
215 wordAsValue(stream);
216 } else if (type == "interpolation") {
217 return pushContext(state, stream, "interpolation");
218 }
219 return "prop";
220 };
221
222 states.propBlock = function(type, _stream, state) {
223 if (type == "}") return popContext(state);
224 if (type == "word") { override = "property"; return "maybeprop"; }
225 return state.context.type;
226 };
227
228 states.parens = function(type, stream, state) {
229 if (type == "{" || type == "}") return popAndPass(type, stream, state);
230 if (type == ")") return popContext(state);
231 if (type == "(") return pushContext(state, stream, "parens");
232 if (type == "word") wordAsValue(stream);
233 return "parens";
234 };
235
236 states.pseudo = function(type, stream, state) {
237 if (type == "word") {
238 override = "variable-3";
239 return state.context.type;
240 }
241 return pass(type, stream, state);
242 };
243
244 states.media = function(type, stream, state) {
245 if (type == "(") return pushContext(state, stream, "media_parens");
246 if (type == "}") return popAndPass(type, stream, state);
247 if (type == "{") return popContext(state) && pushContext(state, stream, allo wNested ? "block" : "top");
248
249 if (type == "word") {
250 var word = stream.current().toLowerCase();
251 if (word == "only" || word == "not" || word == "and")
252 override = "keyword";
253 else if (mediaTypes.hasOwnProperty(word))
254 override = "attribute";
255 else if (mediaFeatures.hasOwnProperty(word))
256 override = "property";
257 else
258 override = "error";
259 }
260 return state.context.type;
261 };
262
263 states.media_parens = function(type, stream, state) {
264 if (type == ")") return popContext(state);
265 if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
266 return states.media(type, stream, state);
267 };
268
269 states.font_face_before = function(type, stream, state) {
270 if (type == "{")
271 return pushContext(state, stream, "font_face");
272 return pass(type, stream, state);
273 };
274
275 states.font_face = function(type, stream, state) {
276 if (type == "}") return popContext(state);
277 if (type == "word") {
278 if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
279 override = "error";
280 else
281 override = "property";
282 return "maybeprop";
283 }
284 return "font_face";
285 };
286
287 states.keyframes = function(type, stream, state) {
288 if (type == "word") { override = "variable"; return "keyframes"; }
289 if (type == "{") return pushContext(state, stream, "top");
290 return pass(type, stream, state);
291 };
292
293 states.at = function(type, stream, state) {
294 if (type == ";") return popContext(state);
295 if (type == "{" || type == "}") return popAndPass(type, stream, state);
296 if (type == "word") override = "tag";
297 else if (type == "hash") override = "builtin";
298 return "at";
299 };
300
301 states.interpolation = function(type, stream, state) {
302 if (type == "}") return popContext(state);
303 if (type == "{" || type == ";") return popAndPass(type, stream, state);
304 if (type != "variable") override = "error";
305 return "interpolation";
306 };
307
100 return { 308 return {
101 startState: function(base) { 309 startState: function(base) {
102 return {tokenize: tokenBase, 310 return {tokenize: null,
103 baseIndent: base || 0, 311 state: "top",
104 stack: [], 312 context: new Context("top", base || 0, null)};
105 lastToken: null};
106 }, 313 },
107 314
108 token: function(stream, state) { 315 token: function(stream, state) {
109 316 if (!state.tokenize && stream.eatSpace()) return null;
110 // Use these terms when applicable (see http://www.xanthir.com/blog/b4E50) 317 var style = (state.tokenize || tokenBase)(stream, state);
111 // 318 if (style && typeof style == "object") {
112 // rule** or **ruleset: 319 type = style[1];
113 // A selector + braces combo, or an at-rule. 320 style = style[0];
114 // 321 }
115 // declaration block: 322 override = style;
116 // A sequence of declarations. 323 state.state = states[state.state](type, stream, state);
117 // 324 return override;
118 // declaration:
119 // A property + colon + value combo.
120 //
121 // property value:
122 // The entire value of a property.
123 //
124 // component value:
125 // A single piece of a property value. Like the 5px in
126 // text-shadow: 0 0 5px blue;. Can also refer to things that are
127 // multiple terms, like the 1-4 terms that make up the background-size
128 // portion of the background shorthand.
129 //
130 // term:
131 // The basic unit of author-facing CSS, like a single number (5),
132 // dimension (5px), string ("foo"), or function. Officially defined
133 // by the CSS 2.1 grammar (look for the 'term' production)
134 //
135 //
136 // simple selector:
137 // A single atomic selector, like a type selector, an attr selector, a
138 // class selector, etc.
139 //
140 // compound selector:
141 // One or more simple selectors without a combinator. div.example is
142 // compound, div > .example is not.
143 //
144 // complex selector:
145 // One or more compound selectors chained with combinators.
146 //
147 // combinator:
148 // The parts of selectors that express relationships. There are four
149 // currently - the space (descendant combinator), the greater-than
150 // bracket (child combinator), the plus sign (next sibling combinator),
151 // and the tilda (following sibling combinator).
152 //
153 // sequence of selectors:
154 // One or more of the named type of selector chained with commas.
155
156 state.tokenize = state.tokenize || tokenBase;
157 if (state.tokenize == tokenBase && stream.eatSpace()) return null;
158 var style = state.tokenize(stream, state);
159 if (style && typeof style != "string") style = ret(style[0], style[1]);
160
161 // Changing style returned based on context
162 var context = state.stack[state.stack.length-1];
163 if (style == "variable") {
164 if (type == "variable-definition") state.stack.push("propertyValue");
165 return state.lastToken = "variable-2";
166 } else if (style == "property") {
167 var word = stream.current().toLowerCase();
168 if (context == "propertyValue") {
169 if (valueKeywords.hasOwnProperty(word)) {
170 style = "string-2";
171 } else if (colorKeywords.hasOwnProperty(word)) {
172 style = "keyword";
173 } else {
174 style = "variable-2";
175 }
176 } else if (context == "rule") {
177 if (!propertyKeywords.hasOwnProperty(word)) {
178 style += " error";
179 }
180 } else if (context == "block") {
181 // if a value is present in both property, value, or color, the order
182 // of preference is property -> color -> value
183 if (propertyKeywords.hasOwnProperty(word)) {
184 style = "property";
185 } else if (colorKeywords.hasOwnProperty(word)) {
186 style = "keyword";
187 } else if (valueKeywords.hasOwnProperty(word)) {
188 style = "string-2";
189 } else {
190 style = "tag";
191 }
192 } else if (!context || context == "@media{") {
193 style = "tag";
194 } else if (context == "@media") {
195 if (atMediaTypes[stream.current()]) {
196 style = "attribute"; // Known attribute
197 } else if (/^(only|not)$/.test(word)) {
198 style = "keyword";
199 } else if (word == "and") {
200 style = "error"; // "and" is only allowed in @mediaType
201 } else if (atMediaFeatures.hasOwnProperty(word)) {
202 style = "error"; // Known property, should be in @mediaType(
203 } else {
204 // Unknown, expecting keyword or attribute, assuming attribute
205 style = "attribute error";
206 }
207 } else if (context == "@mediaType") {
208 if (atMediaTypes.hasOwnProperty(word)) {
209 style = "attribute";
210 } else if (word == "and") {
211 style = "operator";
212 } else if (/^(only|not)$/.test(word)) {
213 style = "error"; // Only allowed in @media
214 } else {
215 // Unknown attribute or property, but expecting property (preceded
216 // by "and"). Should be in parentheses
217 style = "error";
218 }
219 } else if (context == "@mediaType(") {
220 if (propertyKeywords.hasOwnProperty(word)) {
221 // do nothing, remains "property"
222 } else if (atMediaTypes.hasOwnProperty(word)) {
223 style = "error"; // Known property, should be in parentheses
224 } else if (word == "and") {
225 style = "operator";
226 } else if (/^(only|not)$/.test(word)) {
227 style = "error"; // Only allowed in @media
228 } else {
229 style += " error";
230 }
231 } else if (context == "@import") {
232 style = "tag";
233 } else {
234 style = "error";
235 }
236 } else if (style == "atom") {
237 if(!context || context == "@media{" || context == "block") {
238 style = "builtin";
239 } else if (context == "propertyValue") {
240 if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
241 style += " error";
242 }
243 } else {
244 style = "error";
245 }
246 } else if (context == "@media" && type == "{") {
247 style = "error";
248 }
249
250 // Push/pop context stack
251 if (type == "{") {
252 if (context == "@media" || context == "@mediaType") {
253 state.stack[state.stack.length-1] = "@media{";
254 }
255 else {
256 var newContext = allowNested ? "block" : "rule";
257 state.stack.push(newContext);
258 }
259 }
260 else if (type == "}") {
261 if (context == "interpolation") style = "operator";
262 // Pop off end of array until { is reached
263 while(state.stack.length){
264 var removed = state.stack.pop();
265 if(removed.indexOf("{") > -1 || removed == "block" || removed == "rule "){
266 break;
267 }
268 }
269 }
270 else if (type == "interpolation") state.stack.push("interpolation");
271 else if (type == "@media") state.stack.push("@media");
272 else if (type == "@import") state.stack.push("@import");
273 else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
274 state.stack[state.stack.length-1] = "@mediaType";
275 else if (context == "@mediaType" && stream.current() == ",")
276 state.stack[state.stack.length-1] = "@media";
277 else if (type == "(") {
278 if (context == "@media" || context == "@mediaType") {
279 // Make sure @mediaType is used to avoid error on {
280 state.stack[state.stack.length-1] = "@mediaType";
281 state.stack.push("@mediaType(");
282 }
283 else state.stack.push("(");
284 }
285 else if (type == ")") {
286 // Pop off end of array until ( is reached
287 while(state.stack.length){
288 var removed = state.stack.pop();
289 if(removed.indexOf("(") > -1){
290 break;
291 }
292 }
293 }
294 else if (type == ":" && state.lastToken == "property") state.stack.push("p ropertyValue");
295 else if (context == "propertyValue" && type == ";") state.stack.pop();
296 else if (context == "@import" && type == ";") state.stack.pop();
297
298 return state.lastToken = style;
299 }, 325 },
300 326
301 indent: function(state, textAfter) { 327 indent: function(state, textAfter) {
302 var n = state.stack.length; 328 var cx = state.context, ch = textAfter && textAfter.charAt(0);
303 if (/^\}/.test(textAfter)) 329 var indent = cx.indent;
304 n -= state.stack[n-1] == "propertyValue" ? 2 : 1; 330 if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
305 return state.baseIndent + n * indentUnit; 331 if (cx.prev &&
332 (ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "i nterpolation" || cx.type == "font_face") ||
333 ch == ")" && (cx.type == "parens" || cx.type == "media_parens") ||
334 ch == "{" && (cx.type == "at" || cx.type == "media"))) {
335 indent = cx.indent - indentUnit;
336 cx = cx.prev;
337 }
338 return indent;
306 }, 339 },
307 340
308 electricChars: "}", 341 electricChars: "}",
309 blockCommentStart: "/*", 342 blockCommentStart: "/*",
310 blockCommentEnd: "*/", 343 blockCommentEnd: "*/",
311 fold: "brace" 344 fold: "brace"
312 }; 345 };
313 }); 346 });
314 347
315 (function() {
316 function keySet(array) { 348 function keySet(array) {
317 var keys = {}; 349 var keys = {};
318 for (var i = 0; i < array.length; ++i) { 350 for (var i = 0; i < array.length; ++i) {
319 keys[array[i]] = true; 351 keys[array[i]] = true;
320 } 352 }
321 return keys; 353 return keys;
322 } 354 }
323 355
324 var atMediaTypes = keySet([ 356 var mediaTypes_ = [
325 "all", "aural", "braille", "handheld", "print", "projection", "screen", 357 "all", "aural", "braille", "handheld", "print", "projection", "screen",
326 "tty", "tv", "embossed" 358 "tty", "tv", "embossed"
327 ]); 359 ], mediaTypes = keySet(mediaTypes_);
328 360
329 var atMediaFeatures = keySet([ 361 var mediaFeatures_ = [
330 "width", "min-width", "max-width", "height", "min-height", "max-height", 362 "width", "min-width", "max-width", "height", "min-height", "max-height",
331 "device-width", "min-device-width", "max-device-width", "device-height", 363 "device-width", "min-device-width", "max-device-width", "device-height",
332 "min-device-height", "max-device-height", "aspect-ratio", 364 "min-device-height", "max-device-height", "aspect-ratio",
333 "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio", 365 "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
334 "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color", 366 "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
335 "max-color", "color-index", "min-color-index", "max-color-index", 367 "max-color", "color-index", "min-color-index", "max-color-index",
336 "monochrome", "min-monochrome", "max-monochrome", "resolution", 368 "monochrome", "min-monochrome", "max-monochrome", "resolution",
337 "min-resolution", "max-resolution", "scan", "grid" 369 "min-resolution", "max-resolution", "scan", "grid"
338 ]); 370 ], mediaFeatures = keySet(mediaFeatures_);
339 371
340 var propertyKeywords = keySet([ 372 var propertyKeywords_ = [
341 "align-content", "align-items", "align-self", "alignment-adjust", 373 "align-content", "align-items", "align-self", "alignment-adjust",
342 "alignment-baseline", "anchor-point", "animation", "animation-delay", 374 "alignment-baseline", "anchor-point", "animation", "animation-delay",
343 "animation-direction", "animation-duration", "animation-iteration-count", 375 "animation-direction", "animation-duration", "animation-fill-mode",
344 "animation-name", "animation-play-state", "animation-timing-function", 376 "animation-iteration-count", "animation-name", "animation-play-state",
345 "appearance", "azimuth", "backface-visibility", "background", 377 "animation-timing-function", "appearance", "azimuth", "backface-visibility",
346 "background-attachment", "background-clip", "background-color", 378 "background", "background-attachment", "background-clip", "background-color" ,
347 "background-image", "background-origin", "background-position", 379 "background-image", "background-origin", "background-position",
348 "background-repeat", "background-size", "baseline-shift", "binding", 380 "background-repeat", "background-size", "baseline-shift", "binding",
349 "bleed", "bookmark-label", "bookmark-level", "bookmark-state", 381 "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
350 "bookmark-target", "border", "border-bottom", "border-bottom-color", 382 "bookmark-target", "border", "border-bottom", "border-bottom-color",
351 "border-bottom-left-radius", "border-bottom-right-radius", 383 "border-bottom-left-radius", "border-bottom-right-radius",
352 "border-bottom-style", "border-bottom-width", "border-collapse", 384 "border-bottom-style", "border-bottom-width", "border-collapse",
353 "border-color", "border-image", "border-image-outset", 385 "border-color", "border-image", "border-image-outset",
354 "border-image-repeat", "border-image-slice", "border-image-source", 386 "border-image-repeat", "border-image-slice", "border-image-source",
355 "border-image-width", "border-left", "border-left-color", 387 "border-image-width", "border-left", "border-left-color",
356 "border-left-style", "border-left-width", "border-radius", "border-right", 388 "border-left-style", "border-left-width", "border-radius", "border-right",
(...skipping 10 matching lines...) Expand all
367 "dominant-baseline", "drop-initial-after-adjust", 399 "dominant-baseline", "drop-initial-after-adjust",
368 "drop-initial-after-align", "drop-initial-before-adjust", 400 "drop-initial-after-align", "drop-initial-before-adjust",
369 "drop-initial-before-align", "drop-initial-size", "drop-initial-value", 401 "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
370 "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis", 402 "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
371 "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", 403 "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
372 "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-set tings", 404 "float", "float-offset", "flow-from", "flow-into", "font", "font-feature-set tings",
373 "font-family", "font-kerning", "font-language-override", "font-size", "font- size-adjust", 405 "font-family", "font-kerning", "font-language-override", "font-size", "font- size-adjust",
374 "font-stretch", "font-style", "font-synthesis", "font-variant", 406 "font-stretch", "font-style", "font-synthesis", "font-variant",
375 "font-variant-alternates", "font-variant-caps", "font-variant-east-asian", 407 "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
376 "font-variant-ligatures", "font-variant-numeric", "font-variant-position", 408 "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
377 "font-weight", "grid-cell", "grid-column", "grid-column-align", 409 "font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
378 "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow", 410 "grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
379 "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span", 411 "grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
380 "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens", 412 "grid-template", "grid-template-areas", "grid-template-columns",
413 "grid-template-rows", "hanging-punctuation", "height", "hyphens",
381 "icon", "image-orientation", "image-rendering", "image-resolution", 414 "icon", "image-orientation", "image-rendering", "image-resolution",
382 "inline-box-align", "justify-content", "left", "letter-spacing", 415 "inline-box-align", "justify-content", "left", "letter-spacing",
383 "line-break", "line-height", "line-stacking", "line-stacking-ruby", 416 "line-break", "line-height", "line-stacking", "line-stacking-ruby",
384 "line-stacking-shift", "line-stacking-strategy", "list-style", 417 "line-stacking-shift", "line-stacking-strategy", "list-style",
385 "list-style-image", "list-style-position", "list-style-type", "margin", 418 "list-style-image", "list-style-position", "list-style-type", "margin",
386 "margin-bottom", "margin-left", "margin-right", "margin-top", 419 "margin-bottom", "margin-left", "margin-right", "margin-top",
387 "marker-offset", "marks", "marquee-direction", "marquee-loop", 420 "marker-offset", "marks", "marquee-direction", "marquee-loop",
388 "marquee-play-count", "marquee-speed", "marquee-style", "max-height", 421 "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
389 "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", 422 "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
390 "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline", 423 "nav-left", "nav-right", "nav-up", "object-fit", "object-position",
424 "opacity", "order", "orphans", "outline",
391 "outline-color", "outline-offset", "outline-style", "outline-width", 425 "outline-color", "outline-offset", "outline-style", "outline-width",
392 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y", 426 "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
393 "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", 427 "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
394 "page", "page-break-after", "page-break-before", "page-break-inside", 428 "page", "page-break-after", "page-break-before", "page-break-inside",
395 "page-policy", "pause", "pause-after", "pause-before", "perspective", 429 "page-policy", "pause", "pause-after", "pause-before", "perspective",
396 "perspective-origin", "pitch", "pitch-range", "play-during", "position", 430 "perspective-origin", "pitch", "pitch-range", "play-during", "position",
397 "presentation-level", "punctuation-trim", "quotes", "region-break-after", 431 "presentation-level", "punctuation-trim", "quotes", "region-break-after",
398 "region-break-before", "region-break-inside", "region-fragment", 432 "region-break-before", "region-break-inside", "region-fragment",
399 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness ", 433 "rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness ",
400 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang", 434 "right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
401 "ruby-position", "ruby-span", "shape-inside", "shape-outside", "size", 435 "ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shap e-margin",
402 "speak", "speak-as", "speak-header", 436 "shape-outside", "size", "speak", "speak-as", "speak-header",
403 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set", 437 "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
404 "tab-size", "table-layout", "target", "target-name", "target-new", 438 "tab-size", "table-layout", "target", "target-name", "target-new",
405 "target-position", "text-align", "text-align-last", "text-decoration", 439 "target-position", "text-align", "text-align-last", "text-decoration",
406 "text-decoration-color", "text-decoration-line", "text-decoration-skip", 440 "text-decoration-color", "text-decoration-line", "text-decoration-skip",
407 "text-decoration-style", "text-emphasis", "text-emphasis-color", 441 "text-decoration-style", "text-emphasis", "text-emphasis-color",
408 "text-emphasis-position", "text-emphasis-style", "text-height", 442 "text-emphasis-position", "text-emphasis-style", "text-height",
409 "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow ", 443 "text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow ",
410 "text-size-adjust", "text-space-collapse", "text-transform", "text-underline -position", 444 "text-size-adjust", "text-space-collapse", "text-transform", "text-underline -position",
411 "text-wrap", "top", "transform", "transform-origin", "transform-style", 445 "text-wrap", "top", "transform", "transform-origin", "transform-style",
412 "transition", "transition-delay", "transition-duration", 446 "transition", "transition-delay", "transition-duration",
413 "transition-property", "transition-timing-function", "unicode-bidi", 447 "transition-property", "transition-timing-function", "unicode-bidi",
414 "vertical-align", "visibility", "voice-balance", "voice-duration", 448 "vertical-align", "visibility", "voice-balance", "voice-duration",
415 "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress", 449 "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
416 "voice-volume", "volume", "white-space", "widows", "width", "word-break", 450 "voice-volume", "volume", "white-space", "widows", "width", "word-break",
417 "word-spacing", "word-wrap", "z-index", "zoom", 451 "word-spacing", "word-wrap", "z-index",
418 // SVG-specific 452 // SVG-specific
419 "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-colo r", 453 "clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-colo r",
420 "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-ev ents", 454 "flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-ev ents",
421 "color-interpolation", "color-interpolation-filters", "color-profile", 455 "color-interpolation", "color-interpolation-filters",
422 "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering", 456 "color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
423 "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "st roke", 457 "marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "st roke",
424 "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin" , 458 "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin" ,
425 "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering", 459 "stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
426 "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal", 460 "baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
427 "glyph-orientation-vertical", "kerning", "text-anchor", "writing-mode" 461 "glyph-orientation-vertical", "text-anchor", "writing-mode"
428 ]); 462 ], propertyKeywords = keySet(propertyKeywords_);
429 463
430 var colorKeywords = keySet([ 464 var nonStandardPropertyKeywords = [
465 "scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-colo r",
466 "scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color ",
467 "scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
468 "searchfield-cancel-button", "searchfield-decoration", "searchfield-results- button",
469 "searchfield-results-decoration", "zoom"
470 ], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords);
471
472 var colorKeywords_ = [
431 "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", 473 "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
432 "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", 474 "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
433 "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblu e", 475 "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblu e",
434 "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", 476 "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
435 "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", 477 "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
436 "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", 478 "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
437 "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", 479 "darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
438 "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", 480 "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
439 "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", 481 "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
440 "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew", 482 "gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
441 "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", 483 "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
442 "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", 484 "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
443 "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink", 485 "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
444 "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", 486 "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
445 "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", 487 "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
446 "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", 488 "maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
447 "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", 489 "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
448 "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", 490 "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
449 "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered ", 491 "navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered ",
450 "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", 492 "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
451 "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", 493 "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
452 "purple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", 494 "purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
453 "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", 495 "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue ",
454 "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", 496 "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
455 "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", 497 "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
456 "whitesmoke", "yellow", "yellowgreen" 498 "whitesmoke", "yellow", "yellowgreen"
457 ]); 499 ], colorKeywords = keySet(colorKeywords_);
458 500
459 var valueKeywords = keySet([ 501 var valueKeywords_ = [
460 "above", "absolute", "activeborder", "activecaption", "afar", 502 "above", "absolute", "activeborder", "activecaption", "afar",
461 "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate", 503 "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
462 "always", "amharic", "amharic-abegede", "antialiased", "appworkspace", 504 "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
463 "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "a void-page", 505 "arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "a void-page",
464 "avoid-region", "background", "backwards", "baseline", "below", "bidi-overri de", "binary", 506 "avoid-region", "background", "backwards", "baseline", "below", "bidi-overri de", "binary",
465 "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "bord er-box", 507 "bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "bord er-box",
466 "both", "bottom", "break", "break-all", "break-word", "button", "button-beve l", 508 "both", "bottom", "break", "break-all", "break-word", "button", "button-beve l",
467 "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian", 509 "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
468 "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret", 510 "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
469 "cell", "center", "checkbox", "circle", "cjk-earthly-branch", 511 "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight", 574 "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
533 "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er", 575 "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
534 "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top", 576 "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
535 "transparent", "ultra-condensed", "ultra-expanded", "underline", "up", 577 "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
536 "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal", 578 "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
537 "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url", 579 "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
538 "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted", 580 "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
539 "visibleStroke", "visual", "w-resize", "wait", "wave", "wider", 581 "visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
540 "window", "windowframe", "windowtext", "x-large", "x-small", "xor", 582 "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
541 "xx-large", "xx-small" 583 "xx-large", "xx-small"
542 ]); 584 ], valueKeywords = keySet(valueKeywords_);
585
586 var fontProperties_ = [
587 "font-family", "src", "unicode-range", "font-variant", "font-feature-setting s",
588 "font-stretch", "font-weight", "font-style"
589 ], fontProperties = keySet(fontProperties_);
590
591 var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
592 .concat(nonStandardPropertyKeywords).concat(colorKeywords_).concat(valueKeyw ords_);
593 CodeMirror.registerHelper("hintWords", "css", allWords);
543 594
544 function tokenCComment(stream, state) { 595 function tokenCComment(stream, state) {
545 var maybeEnd = false, ch; 596 var maybeEnd = false, ch;
546 while ((ch = stream.next()) != null) { 597 while ((ch = stream.next()) != null) {
547 if (maybeEnd && ch == "/") { 598 if (maybeEnd && ch == "/") {
548 state.tokenize = null; 599 state.tokenize = null;
549 break; 600 break;
550 } 601 }
551 maybeEnd = (ch == "*"); 602 maybeEnd = (ch == "*");
552 } 603 }
553 return ["comment", "comment"]; 604 return ["comment", "comment"];
554 } 605 }
555 606
607 function tokenSGMLComment(stream, state) {
608 if (stream.skipTo("-->")) {
609 stream.match("-->");
610 state.tokenize = null;
611 } else {
612 stream.skipToEnd();
613 }
614 return ["comment", "comment"];
615 }
616
556 CodeMirror.defineMIME("text/css", { 617 CodeMirror.defineMIME("text/css", {
557 atMediaTypes: atMediaTypes, 618 mediaTypes: mediaTypes,
558 atMediaFeatures: atMediaFeatures, 619 mediaFeatures: mediaFeatures,
559 propertyKeywords: propertyKeywords, 620 propertyKeywords: propertyKeywords,
621 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
560 colorKeywords: colorKeywords, 622 colorKeywords: colorKeywords,
561 valueKeywords: valueKeywords, 623 valueKeywords: valueKeywords,
562 hooks: { 624 fontProperties: fontProperties,
625 tokenHooks: {
563 "<": function(stream, state) { 626 "<": function(stream, state) {
564 function tokenSGMLComment(stream, state) { 627 if (!stream.match("!--")) return false;
565 var dashes = 0, ch; 628 state.tokenize = tokenSGMLComment;
566 while ((ch = stream.next()) != null) { 629 return tokenSGMLComment(stream, state);
567 if (dashes >= 2 && ch == ">") {
568 state.tokenize = null;
569 break;
570 }
571 dashes = (ch == "-") ? dashes + 1 : 0;
572 }
573 return ["comment", "comment"];
574 }
575 if (stream.eat("!")) {
576 state.tokenize = tokenSGMLComment;
577 return tokenSGMLComment(stream, state);
578 }
579 }, 630 },
580 "/": function(stream, state) { 631 "/": function(stream, state) {
581 if (stream.eat("*")) { 632 if (!stream.eat("*")) return false;
582 state.tokenize = tokenCComment; 633 state.tokenize = tokenCComment;
583 return tokenCComment(stream, state); 634 return tokenCComment(stream, state);
584 }
585 return false;
586 } 635 }
587 }, 636 },
588 name: "css" 637 name: "css"
589 }); 638 });
590 639
591 CodeMirror.defineMIME("text/x-scss", { 640 CodeMirror.defineMIME("text/x-scss", {
592 atMediaTypes: atMediaTypes, 641 mediaTypes: mediaTypes,
593 atMediaFeatures: atMediaFeatures, 642 mediaFeatures: mediaFeatures,
594 propertyKeywords: propertyKeywords, 643 propertyKeywords: propertyKeywords,
644 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
595 colorKeywords: colorKeywords, 645 colorKeywords: colorKeywords,
596 valueKeywords: valueKeywords, 646 valueKeywords: valueKeywords,
647 fontProperties: fontProperties,
597 allowNested: true, 648 allowNested: true,
598 hooks: { 649 tokenHooks: {
650 "/": function(stream, state) {
651 if (stream.eat("/")) {
652 stream.skipToEnd();
653 return ["comment", "comment"];
654 } else if (stream.eat("*")) {
655 state.tokenize = tokenCComment;
656 return tokenCComment(stream, state);
657 } else {
658 return ["operator", "operator"];
659 }
660 },
599 ":": function(stream) { 661 ":": function(stream) {
600 if (stream.match(/\s*{/)) { 662 if (stream.match(/\s*\{/))
601 return [null, "{"]; 663 return [null, "{"];
602 }
603 return false; 664 return false;
604 }, 665 },
605 "$": function(stream) { 666 "$": function(stream) {
606 stream.match(/^[\w-]+/); 667 stream.match(/^[\w-]+/);
607 if (stream.peek() == ":") { 668 if (stream.match(/^\s*:/, false))
608 return ["variable", "variable-definition"]; 669 return ["variable-2", "variable-definition"];
609 } 670 return ["variable-2", "variable"];
610 return ["variable", "variable"];
611 }, 671 },
612 ",": function(stream, state) { 672 "#": function(stream) {
613 if (state.stack[state.stack.length - 1] == "propertyValue" && stream.mat ch(/^ *\$/, false)) { 673 if (!stream.eat("{")) return false;
614 return ["operator", ";"]; 674 return [null, "interpolation"];
615 } 675 }
616 }, 676 },
677 name: "css",
678 helperType: "scss"
679 });
680
681 CodeMirror.defineMIME("text/x-less", {
682 mediaTypes: mediaTypes,
683 mediaFeatures: mediaFeatures,
684 propertyKeywords: propertyKeywords,
685 nonStandardPropertyKeywords: nonStandardPropertyKeywords,
686 colorKeywords: colorKeywords,
687 valueKeywords: valueKeywords,
688 fontProperties: fontProperties,
689 allowNested: true,
690 tokenHooks: {
617 "/": function(stream, state) { 691 "/": function(stream, state) {
618 if (stream.eat("/")) { 692 if (stream.eat("/")) {
619 stream.skipToEnd(); 693 stream.skipToEnd();
620 return ["comment", "comment"]; 694 return ["comment", "comment"];
621 } else if (stream.eat("*")) { 695 } else if (stream.eat("*")) {
622 state.tokenize = tokenCComment; 696 state.tokenize = tokenCComment;
623 return tokenCComment(stream, state); 697 return tokenCComment(stream, state);
624 } else { 698 } else {
625 return ["operator", "operator"]; 699 return ["operator", "operator"];
626 } 700 }
627 }, 701 },
628 "#": function(stream) { 702 "@": function(stream) {
629 if (stream.eat("{")) { 703 if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit )-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
630 return ["operator", "interpolation"]; 704 stream.eatWhile(/[\w\\\-]/);
631 } else { 705 if (stream.match(/^\s*:/, false))
632 stream.eatWhile(/[\w\\\-]/); 706 return ["variable-2", "variable-definition"];
633 return ["atom", "hash"]; 707 return ["variable-2", "variable"];
634 } 708 },
709 "&": function() {
710 return ["atom", "atom"];
635 } 711 }
636 }, 712 },
637 name: "css" 713 name: "css",
714 helperType: "less"
638 }); 715 });
639 })(); 716
717 });
OLDNEW
« no previous file with comments | « Source/devtools/front_end/cm/comment.js ('k') | Source/devtools/front_end/cm/headlesscodemirror.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698