Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/worker-css.js

raw symbols SCIP
1 "no use strict";
2 !(function(window) {
3 if (typeof window.window != "undefined" && window.document)
4 return;
5 if (window.require && window.define)
6 return;
7
8 if (!window.console) {
9 window.console = function() {
10 var msgs = Array.prototype.slice.call(arguments, 0);
11 postMessage({type: "log", data: msgs});
12 };
13 window.console.error =
14 window.console.warn =
15 window.console.log =
16 window.console.trace = window.console;
17 }
18 window.window = window;
19 window.ace = window;
20
21 window.onerror = function(message, file, line, col, err) {
22 postMessage({type: "error", data: {
23 message: message,
24 data: err && err.data,
25 file: file,
26 line: line,
27 col: col,
28 stack: err && err.stack
29 }});
30 };
31
32 window.normalizeModule = function(parentId, moduleName) {
33 // normalize plugin requires
34 if (moduleName.indexOf("!") !== -1) {
35 var chunks = moduleName.split("!");
36 return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
37 }
38 // normalize relative requires
39 if (moduleName.charAt(0) == ".") {
40 var base = parentId.split("/").slice(0, -1).join("/");
41 moduleName = (base ? base + "/" : "") + moduleName;
42
43 while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
44 var previous = moduleName;
45 moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
46 }
47 }
48
49 return moduleName;
50 };
51
52 window.require = function require(parentId, id) {
53 if (!id) {
54 id = parentId;
55 parentId = null;
56 }
57 if (!id.charAt)
58 throw new Error("worker.js require() accepts only (parentId, id) as arguments");
59
60 id = window.normalizeModule(parentId, id);
61
62 var module = window.require.modules[id];
63 if (module) {
64 if (!module.initialized) {
65 module.initialized = true;
66 module.exports = module.factory().exports;
67 }
68 return module.exports;
69 }
70
71 if (!window.require.tlns)
72 return console.log("unable to load " + id);
73
74 var path = resolveModuleId(id, window.require.tlns);
75 if (path.slice(-3) != ".js") path += ".js";
76
77 window.require.id = id;
78 window.require.modules[id] = {}; // prevent infinite loop on broken modules
79 importScripts(path);
80 return window.require(parentId, id);
81 };
82 function resolveModuleId(id, paths) {
83 var testPath = id, tail = "";
84 while (testPath) {
85 var alias = paths[testPath];
86 if (typeof alias == "string") {
87 return alias + tail;
88 } else if (alias) {
89 return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
90 } else if (alias === false) {
91 return "";
92 }
93 var i = testPath.lastIndexOf("/");
94 if (i === -1) break;
95 tail = testPath.substr(i) + tail;
96 testPath = testPath.slice(0, i);
97 }
98 return id;
99 }
100 window.require.modules = {};
101 window.require.tlns = {};
102
103 window.define = function(id, deps, factory) {
104 if (arguments.length == 2) {
105 factory = deps;
106 if (typeof id != "string") {
107 deps = id;
108 id = window.require.id;
109 }
110 } else if (arguments.length == 1) {
111 factory = id;
112 deps = [];
113 id = window.require.id;
114 }
115
116 if (typeof factory != "function") {
117 window.require.modules[id] = {
118 exports: factory,
119 initialized: true
120 };
121 return;
122 }
123
124 if (!deps.length)
125 // If there is no dependencies, we inject "require", "exports" and
126 // "module" as dependencies, to provide CommonJS compatibility.
127 deps = ["require", "exports", "module"];
128
129 var req = function(childId) {
130 return window.require(id, childId);
131 };
132
133 window.require.modules[id] = {
134 exports: {},
135 factory: function() {
136 var module = this;
137 var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
138 switch (dep) {
139 // Because "require", "exports" and "module" aren't actual
140 // dependencies, we must handle them seperately.
141 case "require": return req;
142 case "exports": return module.exports;
143 case "module": return module;
144 // But for all other dependencies, we can just go ahead and
145 // require them.
146 default: return req(dep);
147 }
148 }));
149 if (returnExports)
150 module.exports = returnExports;
151 return module;
152 }
153 };
154 };
155 window.define.amd = {};
156 window.require.tlns = {};
157 window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
158 for (var i in topLevelNamespaces)
159 this.require.tlns[i] = topLevelNamespaces[i];
160 };
161
162 window.initSender = function initSender() {
163
164 var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
165 var oop = window.require("ace/lib/oop");
166
167 var Sender = function() {};
168
169 (function() {
170
171 oop.implement(this, EventEmitter);
172
173 this.callback = function(data, callbackId) {
174 postMessage({
175 type: "call",
176 id: callbackId,
177 data: data
178 });
179 };
180
181 this.emit = function(name, data) {
182 postMessage({
183 type: "event",
184 name: name,
185 data: data
186 });
187 };
188
189 }).call(Sender.prototype);
190
191 return new Sender();
192 };
193
194 var main = window.main = null;
195 var sender = window.sender = null;
196
197 window.onmessage = function(e) {
198 var msg = e.data;
199 if (msg.event && sender) {
200 sender._signal(msg.event, msg.data);
201 }
202 else if (msg.command) {
203 if (main[msg.command])
204 main[msg.command].apply(main, msg.args);
205 else if (window[msg.command])
206 window[msg.command].apply(window, msg.args);
207 else
208 throw new Error("Unknown command:" + msg.command);
209 }
210 else if (msg.init) {
211 window.initBaseUrls(msg.tlns);
212 sender = window.sender = window.initSender();
213 var clazz = this.require(msg.module)[msg.classname];
214 main = window.main = new clazz(sender);
215 }
216 };
217 })(this);
218
219 ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
220 exports.inherits = function (ctor, superCtor) {
221 ctor.super_ = superCtor;
222 ctor.prototype = Object.create(superCtor.prototype, {
223 constructor: {
224 value: ctor,
225 enumerable: false,
226 writable: true,
227 configurable: true
228 }
229 });
230 };
231 exports.mixin = function (obj, mixin) {
232 for (var key in mixin) {
233 obj[key] = mixin[key];
234 }
235 return obj;
236 };
237 exports.implement = function (proto, mixin) {
238 exports.mixin(proto, mixin);
239 };
240
241 });
242
243 ace.define("ace/lib/deep_copy",[], function(require, exports, module){exports.deepCopy = function deepCopy(obj) {
244 if (typeof obj !== "object" || !obj)
245 return obj;
246 var copy;
247 if (Array.isArray(obj)) {
248 copy = [];
249 for (var key = 0; key < obj.length; key++) {
250 copy[key] = deepCopy(obj[key]);
251 }
252 return copy;
253 }
254 if (Object.prototype.toString.call(obj) !== "[object Object]")
255 return obj;
256 copy = {};
257 for (var key in obj)
258 copy[key] = deepCopy(obj[key]);
259 return copy;
260 };
261
262 });
263
264 ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
265 exports.last = function (a) {
266 return a[a.length - 1];
267 };
268 exports.stringReverse = function (string) {
269 return string.split("").reverse().join("");
270 };
271 exports.stringRepeat = function (string, count) {
272 var result = '';
273 while (count > 0) {
274 if (count & 1)
275 result += string;
276 if (count >>= 1)
277 string += string;
278 }
279 return result;
280 };
281 var trimBeginRegexp = /^\s\s*/;
282 var trimEndRegexp = /\s\s*$/;
283 exports.stringTrimLeft = function (string) {
284 return string.replace(trimBeginRegexp, '');
285 };
286 exports.stringTrimRight = function (string) {
287 return string.replace(trimEndRegexp, '');
288 };
289 exports.copyObject = function (obj) {
290 var copy = {};
291 for (var key in obj) {
292 copy[key] = obj[key];
293 }
294 return copy;
295 };
296 exports.copyArray = function (array) {
297 var copy = [];
298 for (var i = 0, l = array.length; i < l; i++) {
299 if (array[i] && typeof array[i] == "object")
300 copy[i] = this.copyObject(array[i]);
301 else
302 copy[i] = array[i];
303 }
304 return copy;
305 };
306 exports.deepCopy = require("./deep_copy").deepCopy;
307 exports.arrayToMap = function (arr) {
308 var map = {};
309 for (var i = 0; i < arr.length; i++) {
310 map[arr[i]] = 1;
311 }
312 return map;
313 };
314 exports.createMap = function (props) {
315 var map = Object.create(null);
316 for (var i in props) {
317 map[i] = props[i];
318 }
319 return map;
320 };
321 exports.arrayRemove = function (array, value) {
322 for (var i = 0; i <= array.length; i++) {
323 if (value === array[i]) {
324 array.splice(i, 1);
325 }
326 }
327 };
328 exports.escapeRegExp = function (str) {
329 return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
330 };
331 exports.escapeHTML = function (str) {
332 return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
333 };
334 exports.getMatchOffsets = function (string, regExp) {
335 var matches = [];
336 string.replace(regExp, function (str) {
337 matches.push({
338 offset: arguments[arguments.length - 2],
339 length: str.length
340 });
341 });
342 return matches;
343 };
344 exports.deferredCall = function (fcn) {
345 var timer = null;
346 var callback = function () {
347 timer = null;
348 fcn();
349 };
350 var deferred = function (timeout) {
351 deferred.cancel();
352 timer = setTimeout(callback, timeout || 0);
353 return deferred;
354 };
355 deferred.schedule = deferred;
356 deferred.call = function () {
357 this.cancel();
358 fcn();
359 return deferred;
360 };
361 deferred.cancel = function () {
362 clearTimeout(timer);
363 timer = null;
364 return deferred;
365 };
366 deferred.isPending = function () {
367 return timer;
368 };
369 return deferred;
370 };
371 exports.delayedCall = function (fcn, defaultTimeout) {
372 var timer = null;
373 var callback = function () {
374 timer = null;
375 fcn();
376 };
377 var _self = function (timeout) {
378 if (timer == null)
379 timer = setTimeout(callback, timeout || defaultTimeout);
380 };
381 _self.delay = function (timeout) {
382 timer && clearTimeout(timer);
383 timer = setTimeout(callback, timeout || defaultTimeout);
384 };
385 _self.schedule = _self;
386 _self.call = function () {
387 this.cancel();
388 fcn();
389 };
390 _self.cancel = function () {
391 timer && clearTimeout(timer);
392 timer = null;
393 };
394 _self.isPending = function () {
395 return timer;
396 };
397 return _self;
398 };
399 exports.supportsLookbehind = function () {
400 try {
401 new RegExp('(?<=.)');
402 }
403 catch (e) {
404 return false;
405 }
406 return true;
407 };
408 exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) {
409 return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1;
410 };
411
412 });
413
414 ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
415 function throwDeltaError(delta, errorText) {
416 console.log("Invalid Delta:", delta);
417 throw "Invalid Delta: " + errorText;
418 }
419 function positionInDocument(docLines, position) {
420 return position.row >= 0 && position.row < docLines.length &&
421 position.column >= 0 && position.column <= docLines[position.row].length;
422 }
423 function validateDelta(docLines, delta) {
424 if (delta.action != "insert" && delta.action != "remove")
425 throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
426 if (!(delta.lines instanceof Array))
427 throwDeltaError(delta, "delta.lines must be an Array");
428 if (!delta.start || !delta.end)
429 throwDeltaError(delta, "delta.start/end must be an present");
430 var start = delta.start;
431 if (!positionInDocument(docLines, delta.start))
432 throwDeltaError(delta, "delta.start must be contained in document");
433 var end = delta.end;
434 if (delta.action == "remove" && !positionInDocument(docLines, end))
435 throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
436 var numRangeRows = end.row - start.row;
437 var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
438 if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
439 throwDeltaError(delta, "delta.range must match delta lines");
440 }
441 exports.applyDelta = function (docLines, delta, doNotValidate) {
442 var row = delta.start.row;
443 var startColumn = delta.start.column;
444 var line = docLines[row] || "";
445 switch (delta.action) {
446 case "insert":
447 var lines = delta.lines;
448 if (lines.length === 1) {
449 docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
450 }
451 else {
452 var args = [row, 1].concat(delta.lines);
453 docLines.splice.apply(docLines, args);
454 docLines[row] = line.substring(0, startColumn) + docLines[row];
455 docLines[row + delta.lines.length - 1] += line.substring(startColumn);
456 }
457 break;
458 case "remove":
459 var endColumn = delta.end.column;
460 var endRow = delta.end.row;
461 if (row === endRow) {
462 docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
463 }
464 else {
465 docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
466 }
467 break;
468 }
469 };
470
471 });
472
473 ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
474 var EventEmitter = {};
475 var stopPropagation = function () { this.propagationStopped = true; };
476 var preventDefault = function () { this.defaultPrevented = true; };
477 EventEmitter._emit =
478 EventEmitter._dispatchEvent = function (eventName, e) {
479 this._eventRegistry || (this._eventRegistry = {});
480 this._defaultHandlers || (this._defaultHandlers = {});
481 var listeners = this._eventRegistry[eventName] || [];
482 var defaultHandler = this._defaultHandlers[eventName];
483 if (!listeners.length && !defaultHandler)
484 return;
485 if (typeof e != "object" || !e)
486 e = {};
487 if (!e.type)
488 e.type = eventName;
489 if (!e.stopPropagation)
490 e.stopPropagation = stopPropagation;
491 if (!e.preventDefault)
492 e.preventDefault = preventDefault;
493 listeners = listeners.slice();
494 for (var i = 0; i < listeners.length; i++) {
495 listeners[i](e, this);
496 if (e.propagationStopped)
497 break;
498 }
499 if (defaultHandler && !e.defaultPrevented)
500 return defaultHandler(e, this);
501 };
502 EventEmitter._signal = function (eventName, e) {
503 var listeners = (this._eventRegistry || {})[eventName];
504 if (!listeners)
505 return;
506 listeners = listeners.slice();
507 for (var i = 0; i < listeners.length; i++)
508 listeners[i](e, this);
509 };
510 EventEmitter.once = function (eventName, callback) {
511 var _self = this;
512 this.on(eventName, function newCallback() {
513 _self.off(eventName, newCallback);
514 callback.apply(null, arguments);
515 });
516 if (!callback) {
517 return new Promise(function (resolve) {
518 callback = resolve;
519 });
520 }
521 };
522 EventEmitter.setDefaultHandler = function (eventName, callback) {
523 var handlers = this._defaultHandlers;
524 if (!handlers)
525 handlers = this._defaultHandlers = { _disabled_: {} };
526 if (handlers[eventName]) {
527 var old = handlers[eventName];
528 var disabled = handlers._disabled_[eventName];
529 if (!disabled)
530 handlers._disabled_[eventName] = disabled = [];
531 disabled.push(old);
532 var i = disabled.indexOf(callback);
533 if (i != -1)
534 disabled.splice(i, 1);
535 }
536 handlers[eventName] = callback;
537 };
538 EventEmitter.removeDefaultHandler = function (eventName, callback) {
539 var handlers = this._defaultHandlers;
540 if (!handlers)
541 return;
542 var disabled = handlers._disabled_[eventName];
543 if (handlers[eventName] == callback) {
544 if (disabled)
545 this.setDefaultHandler(eventName, disabled.pop());
546 }
547 else if (disabled) {
548 var i = disabled.indexOf(callback);
549 if (i != -1)
550 disabled.splice(i, 1);
551 }
552 };
553 EventEmitter.on =
554 EventEmitter.addEventListener = function (eventName, callback, capturing) {
555 this._eventRegistry = this._eventRegistry || {};
556 var listeners = this._eventRegistry[eventName];
557 if (!listeners)
558 listeners = this._eventRegistry[eventName] = [];
559 if (listeners.indexOf(callback) == -1)
560 listeners[capturing ? "unshift" : "push"](callback);
561 return callback;
562 };
563 EventEmitter.off =
564 EventEmitter.removeListener =
565 EventEmitter.removeEventListener = function (eventName, callback) {
566 this._eventRegistry = this._eventRegistry || {};
567 var listeners = this._eventRegistry[eventName];
568 if (!listeners)
569 return;
570 var index = listeners.indexOf(callback);
571 if (index !== -1)
572 listeners.splice(index, 1);
573 };
574 EventEmitter.removeAllListeners = function (eventName) {
575 if (!eventName)
576 this._eventRegistry = this._defaultHandlers = undefined;
577 if (this._eventRegistry)
578 this._eventRegistry[eventName] = undefined;
579 if (this._defaultHandlers)
580 this._defaultHandlers[eventName] = undefined;
581 };
582 exports.EventEmitter = EventEmitter;
583
584 });
585
586 ace.define("ace/range",[], function(require, exports, module){"use strict";
587 var Range = /** @class */ (function () {
588 function Range(startRow, startColumn, endRow, endColumn) {
589 this.start = {
590 row: startRow,
591 column: startColumn
592 };
593 this.end = {
594 row: endRow,
595 column: endColumn
596 };
597 }
598 Range.prototype.isEqual = function (range) {
599 return this.start.row === range.start.row &&
600 this.end.row === range.end.row &&
601 this.start.column === range.start.column &&
602 this.end.column === range.end.column;
603 };
604 Range.prototype.toString = function () {
605 return ("Range: [" + this.start.row + "/" + this.start.column +
606 "] -> [" + this.end.row + "/" + this.end.column + "]");
607 };
608 Range.prototype.contains = function (row, column) {
609 return this.compare(row, column) == 0;
610 };
611 Range.prototype.compareRange = function (range) {
612 var cmp, end = range.end, start = range.start;
613 cmp = this.compare(end.row, end.column);
614 if (cmp == 1) {
615 cmp = this.compare(start.row, start.column);
616 if (cmp == 1) {
617 return 2;
618 }
619 else if (cmp == 0) {
620 return 1;
621 }
622 else {
623 return 0;
624 }
625 }
626 else if (cmp == -1) {
627 return -2;
628 }
629 else {
630 cmp = this.compare(start.row, start.column);
631 if (cmp == -1) {
632 return -1;
633 }
634 else if (cmp == 1) {
635 return 42;
636 }
637 else {
638 return 0;
639 }
640 }
641 };
642 Range.prototype.comparePoint = function (p) {
643 return this.compare(p.row, p.column);
644 };
645 Range.prototype.containsRange = function (range) {
646 return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
647 };
648 Range.prototype.intersects = function (range) {
649 var cmp = this.compareRange(range);
650 return (cmp == -1 || cmp == 0 || cmp == 1);
651 };
652 Range.prototype.isEnd = function (row, column) {
653 return this.end.row == row && this.end.column == column;
654 };
655 Range.prototype.isStart = function (row, column) {
656 return this.start.row == row && this.start.column == column;
657 };
658 Range.prototype.setStart = function (row, column) {
659 if (typeof row == "object") {
660 this.start.column = row.column;
661 this.start.row = row.row;
662 }
663 else {
664 this.start.row = row;
665 this.start.column = column;
666 }
667 };
668 Range.prototype.setEnd = function (row, column) {
669 if (typeof row == "object") {
670 this.end.column = row.column;
671 this.end.row = row.row;
672 }
673 else {
674 this.end.row = row;
675 this.end.column = column;
676 }
677 };
678 Range.prototype.inside = function (row, column) {
679 if (this.compare(row, column) == 0) {
680 if (this.isEnd(row, column) || this.isStart(row, column)) {
681 return false;
682 }
683 else {
684 return true;
685 }
686 }
687 return false;
688 };
689 Range.prototype.insideStart = function (row, column) {
690 if (this.compare(row, column) == 0) {
691 if (this.isEnd(row, column)) {
692 return false;
693 }
694 else {
695 return true;
696 }
697 }
698 return false;
699 };
700 Range.prototype.insideEnd = function (row, column) {
701 if (this.compare(row, column) == 0) {
702 if (this.isStart(row, column)) {
703 return false;
704 }
705 else {
706 return true;
707 }
708 }
709 return false;
710 };
711 Range.prototype.compare = function (row, column) {
712 if (!this.isMultiLine()) {
713 if (row === this.start.row) {
714 return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
715 }
716 }
717 if (row < this.start.row)
718 return -1;
719 if (row > this.end.row)
720 return 1;
721 if (this.start.row === row)
722 return column >= this.start.column ? 0 : -1;
723 if (this.end.row === row)
724 return column <= this.end.column ? 0 : 1;
725 return 0;
726 };
727 Range.prototype.compareStart = function (row, column) {
728 if (this.start.row == row && this.start.column == column) {
729 return -1;
730 }
731 else {
732 return this.compare(row, column);
733 }
734 };
735 Range.prototype.compareEnd = function (row, column) {
736 if (this.end.row == row && this.end.column == column) {
737 return 1;
738 }
739 else {
740 return this.compare(row, column);
741 }
742 };
743 Range.prototype.compareInside = function (row, column) {
744 if (this.end.row == row && this.end.column == column) {
745 return 1;
746 }
747 else if (this.start.row == row && this.start.column == column) {
748 return -1;
749 }
750 else {
751 return this.compare(row, column);
752 }
753 };
754 Range.prototype.clipRows = function (firstRow, lastRow) {
755 if (this.end.row > lastRow)
756 var end = { row: lastRow + 1, column: 0 };
757 else if (this.end.row < firstRow)
758 var end = { row: firstRow, column: 0 };
759 if (this.start.row > lastRow)
760 var start = { row: lastRow + 1, column: 0 };
761 else if (this.start.row < firstRow)
762 var start = { row: firstRow, column: 0 };
763 return Range.fromPoints(start || this.start, end || this.end);
764 };
765 Range.prototype.extend = function (row, column) {
766 var cmp = this.compare(row, column);
767 if (cmp == 0)
768 return this;
769 else if (cmp == -1)
770 var start = { row: row, column: column };
771 else
772 var end = { row: row, column: column };
773 return Range.fromPoints(start || this.start, end || this.end);
774 };
775 Range.prototype.isEmpty = function () {
776 return (this.start.row === this.end.row && this.start.column === this.end.column);
777 };
778 Range.prototype.isMultiLine = function () {
779 return (this.start.row !== this.end.row);
780 };
781 Range.prototype.clone = function () {
782 return Range.fromPoints(this.start, this.end);
783 };
784 Range.prototype.collapseRows = function () {
785 if (this.end.column == 0)
786 return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
787 else
788 return new Range(this.start.row, 0, this.end.row, 0);
789 };
790 Range.prototype.toScreenRange = function (session) {
791 var screenPosStart = session.documentToScreenPosition(this.start);
792 var screenPosEnd = session.documentToScreenPosition(this.end);
793 return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
794 };
795 Range.prototype.moveBy = function (row, column) {
796 this.start.row += row;
797 this.start.column += column;
798 this.end.row += row;
799 this.end.column += column;
800 };
801 return Range;
802 }());
803 Range.fromPoints = function (start, end) {
804 return new Range(start.row, start.column, end.row, end.column);
805 };
806 Range.comparePoints = function (p1, p2) {
807 return p1.row - p2.row || p1.column - p2.column;
808 };
809 exports.Range = Range;
810
811 });
812
813 ace.define("ace/anchor",[], function(require, exports, module){"use strict";
814 var oop = require("./lib/oop");
815 var EventEmitter = require("./lib/event_emitter").EventEmitter;
816 var Anchor = /** @class */ (function () {
817 function Anchor(doc, row, column) {
818 this.$onChange = this.onChange.bind(this);
819 this.attach(doc);
820 if (typeof row != "number")
821 this.setPosition(row.row, row.column);
822 else
823 this.setPosition(row, column);
824 }
825 Anchor.prototype.getPosition = function () {
826 return this.$clipPositionToDocument(this.row, this.column);
827 };
828 Anchor.prototype.getDocument = function () {
829 return this.document;
830 };
831 Anchor.prototype.onChange = function (delta) {
832 if (delta.start.row == delta.end.row && delta.start.row != this.row)
833 return;
834 if (delta.start.row > this.row)
835 return;
836 var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
837 this.setPosition(point.row, point.column, true);
838 };
839 Anchor.prototype.setPosition = function (row, column, noClip) {
840 var pos;
841 if (noClip) {
842 pos = {
843 row: row,
844 column: column
845 };
846 }
847 else {
848 pos = this.$clipPositionToDocument(row, column);
849 }
850 if (this.row == pos.row && this.column == pos.column)
851 return;
852 var old = {
853 row: this.row,
854 column: this.column
855 };
856 this.row = pos.row;
857 this.column = pos.column;
858 this._signal("change", {
859 old: old,
860 value: pos
861 });
862 };
863 Anchor.prototype.detach = function () {
864 this.document.off("change", this.$onChange);
865 };
866 Anchor.prototype.attach = function (doc) {
867 this.document = doc || this.document;
868 this.document.on("change", this.$onChange);
869 };
870 Anchor.prototype.$clipPositionToDocument = function (row, column) {
871 var pos = {};
872 if (row >= this.document.getLength()) {
873 pos.row = Math.max(0, this.document.getLength() - 1);
874 pos.column = this.document.getLine(pos.row).length;
875 }
876 else if (row < 0) {
877 pos.row = 0;
878 pos.column = 0;
879 }
880 else {
881 pos.row = row;
882 pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
883 }
884 if (column < 0)
885 pos.column = 0;
886 return pos;
887 };
888 return Anchor;
889 }());
890 Anchor.prototype.$insertRight = false;
891 oop.implement(Anchor.prototype, EventEmitter);
892 function $pointsInOrder(point1, point2, equalPointsInOrder) {
893 var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
894 return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
895 }
896 function $getTransformedPoint(delta, point, moveIfEqual) {
897 var deltaIsInsert = delta.action == "insert";
898 var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
899 var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
900 var deltaStart = delta.start;
901 var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
902 if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
903 return {
904 row: point.row,
905 column: point.column
906 };
907 }
908 if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
909 return {
910 row: point.row + deltaRowShift,
911 column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
912 };
913 }
914 return {
915 row: deltaStart.row,
916 column: deltaStart.column
917 };
918 }
919 exports.Anchor = Anchor;
920
921 });
922
923 ace.define("ace/document",[], function(require, exports, module){"use strict";
924 var oop = require("./lib/oop");
925 var applyDelta = require("./apply_delta").applyDelta;
926 var EventEmitter = require("./lib/event_emitter").EventEmitter;
927 var Range = require("./range").Range;
928 var Anchor = require("./anchor").Anchor;
929 var Document = /** @class */ (function () {
930 function Document(textOrLines) {
931 this.$lines = [""];
932 if (textOrLines.length === 0) {
933 this.$lines = [""];
934 }
935 else if (Array.isArray(textOrLines)) {
936 this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
937 }
938 else {
939 this.insert({ row: 0, column: 0 }, textOrLines);
940 }
941 }
942 Document.prototype.setValue = function (text) {
943 var len = this.getLength() - 1;
944 this.remove(new Range(0, 0, len, this.getLine(len).length));
945 this.insert({ row: 0, column: 0 }, text || "");
946 };
947 Document.prototype.getValue = function () {
948 return this.getAllLines().join(this.getNewLineCharacter());
949 };
950 Document.prototype.createAnchor = function (row, column) {
951 return new Anchor(this, row, column);
952 };
953 Document.prototype.$detectNewLine = function (text) {
954 var match = text.match(/^.*?(\r\n|\r|\n)/m);
955 this.$autoNewLine = match ? match[1] : "\n";
956 this._signal("changeNewLineMode");
957 };
958 Document.prototype.getNewLineCharacter = function () {
959 switch (this.$newLineMode) {
960 case "windows":
961 return "\r\n";
962 case "unix":
963 return "\n";
964 default:
965 return this.$autoNewLine || "\n";
966 }
967 };
968 Document.prototype.setNewLineMode = function (newLineMode) {
969 if (this.$newLineMode === newLineMode)
970 return;
971 this.$newLineMode = newLineMode;
972 this._signal("changeNewLineMode");
973 };
974 Document.prototype.getNewLineMode = function () {
975 return this.$newLineMode;
976 };
977 Document.prototype.isNewLine = function (text) {
978 return (text == "\r\n" || text == "\r" || text == "\n");
979 };
980 Document.prototype.getLine = function (row) {
981 return this.$lines[row] || "";
982 };
983 Document.prototype.getLines = function (firstRow, lastRow) {
984 return this.$lines.slice(firstRow, lastRow + 1);
985 };
986 Document.prototype.getAllLines = function () {
987 return this.getLines(0, this.getLength());
988 };
989 Document.prototype.getLength = function () {
990 return this.$lines.length;
991 };
992 Document.prototype.getTextRange = function (range) {
993 return this.getLinesForRange(range).join(this.getNewLineCharacter());
994 };
995 Document.prototype.getLinesForRange = function (range) {
996 var lines;
997 if (range.start.row === range.end.row) {
998 lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
999 }
1000 else {
1001 lines = this.getLines(range.start.row, range.end.row);
1002 lines[0] = (lines[0] || "").substring(range.start.column);
1003 var l = lines.length - 1;
1004 if (range.end.row - range.start.row == l)
1005 lines[l] = lines[l].substring(0, range.end.column);
1006 }
1007 return lines;
1008 };
1009 Document.prototype.insertLines = function (row, lines) {
1010 console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
1011 return this.insertFullLines(row, lines);
1012 };
1013 Document.prototype.removeLines = function (firstRow, lastRow) {
1014 console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
1015 return this.removeFullLines(firstRow, lastRow);
1016 };
1017 Document.prototype.insertNewLine = function (position) {
1018 console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
1019 return this.insertMergedLines(position, ["", ""]);
1020 };
1021 Document.prototype.insert = function (position, text) {
1022 if (this.getLength() <= 1)
1023 this.$detectNewLine(text);
1024 return this.insertMergedLines(position, this.$split(text));
1025 };
1026 Document.prototype.insertInLine = function (position, text) {
1027 var start = this.clippedPos(position.row, position.column);
1028 var end = this.pos(position.row, position.column + text.length);
1029 this.applyDelta({
1030 start: start,
1031 end: end,
1032 action: "insert",
1033 lines: [text]
1034 }, true);
1035 return this.clonePos(end);
1036 };
1037 Document.prototype.clippedPos = function (row, column) {
1038 var length = this.getLength();
1039 if (row === undefined) {
1040 row = length;
1041 }
1042 else if (row < 0) {
1043 row = 0;
1044 }
1045 else if (row >= length) {
1046 row = length - 1;
1047 column = undefined;
1048 }
1049 var line = this.getLine(row);
1050 if (column == undefined)
1051 column = line.length;
1052 column = Math.min(Math.max(column, 0), line.length);
1053 return { row: row, column: column };
1054 };
1055 Document.prototype.clonePos = function (pos) {
1056 return { row: pos.row, column: pos.column };
1057 };
1058 Document.prototype.pos = function (row, column) {
1059 return { row: row, column: column };
1060 };
1061 Document.prototype.$clipPosition = function (position) {
1062 var length = this.getLength();
1063 if (position.row >= length) {
1064 position.row = Math.max(0, length - 1);
1065 position.column = this.getLine(length - 1).length;
1066 }
1067 else {
1068 position.row = Math.max(0, position.row);
1069 position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
1070 }
1071 return position;
1072 };
1073 Document.prototype.insertFullLines = function (row, lines) {
1074 row = Math.min(Math.max(row, 0), this.getLength());
1075 var column = 0;
1076 if (row < this.getLength()) {
1077 lines = lines.concat([""]);
1078 column = 0;
1079 }
1080 else {
1081 lines = [""].concat(lines);
1082 row--;
1083 column = this.$lines[row].length;
1084 }
1085 this.insertMergedLines({ row: row, column: column }, lines);
1086 };
1087 Document.prototype.insertMergedLines = function (position, lines) {
1088 var start = this.clippedPos(position.row, position.column);
1089 var end = {
1090 row: start.row + lines.length - 1,
1091 column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
1092 };
1093 this.applyDelta({
1094 start: start,
1095 end: end,
1096 action: "insert",
1097 lines: lines
1098 });
1099 return this.clonePos(end);
1100 };
1101 Document.prototype.remove = function (range) {
1102 var start = this.clippedPos(range.start.row, range.start.column);
1103 var end = this.clippedPos(range.end.row, range.end.column);
1104 this.applyDelta({
1105 start: start,
1106 end: end,
1107 action: "remove",
1108 lines: this.getLinesForRange({ start: start, end: end })
1109 });
1110 return this.clonePos(start);
1111 };
1112 Document.prototype.removeInLine = function (row, startColumn, endColumn) {
1113 var start = this.clippedPos(row, startColumn);
1114 var end = this.clippedPos(row, endColumn);
1115 this.applyDelta({
1116 start: start,
1117 end: end,
1118 action: "remove",
1119 lines: this.getLinesForRange({ start: start, end: end })
1120 }, true);
1121 return this.clonePos(start);
1122 };
1123 Document.prototype.removeFullLines = function (firstRow, lastRow) {
1124 firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
1125 lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
1126 var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
1127 var deleteLastNewLine = lastRow < this.getLength() - 1;
1128 var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
1129 var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
1130 var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
1131 var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
1132 var range = new Range(startRow, startCol, endRow, endCol);
1133 var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
1134 this.applyDelta({
1135 start: range.start,
1136 end: range.end,
1137 action: "remove",
1138 lines: this.getLinesForRange(range)
1139 });
1140 return deletedLines;
1141 };
1142 Document.prototype.removeNewLine = function (row) {
1143 if (row < this.getLength() - 1 && row >= 0) {
1144 this.applyDelta({
1145 start: this.pos(row, this.getLine(row).length),
1146 end: this.pos(row + 1, 0),
1147 action: "remove",
1148 lines: ["", ""]
1149 });
1150 }
1151 };
1152 Document.prototype.replace = function (range, text) {
1153 if (!(range instanceof Range))
1154 range = Range.fromPoints(range.start, range.end);
1155 if (text.length === 0 && range.isEmpty())
1156 return range.start;
1157 if (text == this.getTextRange(range))
1158 return range.end;
1159 this.remove(range);
1160 var end;
1161 if (text) {
1162 end = this.insert(range.start, text);
1163 }
1164 else {
1165 end = range.start;
1166 }
1167 return end;
1168 };
1169 Document.prototype.applyDeltas = function (deltas) {
1170 for (var i = 0; i < deltas.length; i++) {
1171 this.applyDelta(deltas[i]);
1172 }
1173 };
1174 Document.prototype.revertDeltas = function (deltas) {
1175 for (var i = deltas.length - 1; i >= 0; i--) {
1176 this.revertDelta(deltas[i]);
1177 }
1178 };
1179 Document.prototype.applyDelta = function (delta, doNotValidate) {
1180 var isInsert = delta.action == "insert";
1181 if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
1182 : !Range.comparePoints(delta.start, delta.end)) {
1183 return;
1184 }
1185 if (isInsert && delta.lines.length > 20000) {
1186 this.$splitAndapplyLargeDelta(delta, 20000);
1187 }
1188 else {
1189 applyDelta(this.$lines, delta, doNotValidate);
1190 this._signal("change", delta);
1191 }
1192 };
1193 Document.prototype.$safeApplyDelta = function (delta) {
1194 var docLength = this.$lines.length;
1195 if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
1196 || delta.action == "insert" && delta.start.row <= docLength) {
1197 this.applyDelta(delta);
1198 }
1199 };
1200 Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) {
1201 var lines = delta.lines;
1202 var l = lines.length - MAX + 1;
1203 var row = delta.start.row;
1204 var column = delta.start.column;
1205 for (var from = 0, to = 0; from < l; from = to) {
1206 to += MAX - 1;
1207 var chunk = lines.slice(from, to);
1208 chunk.push("");
1209 this.applyDelta({
1210 start: this.pos(row + from, column),
1211 end: this.pos(row + to, column = 0),
1212 action: delta.action,
1213 lines: chunk
1214 }, true);
1215 }
1216 delta.lines = lines.slice(from);
1217 delta.start.row = row + from;
1218 delta.start.column = column;
1219 this.applyDelta(delta, true);
1220 };
1221 Document.prototype.revertDelta = function (delta) {
1222 this.$safeApplyDelta({
1223 start: this.clonePos(delta.start),
1224 end: this.clonePos(delta.end),
1225 action: (delta.action == "insert" ? "remove" : "insert"),
1226 lines: delta.lines.slice()
1227 });
1228 };
1229 Document.prototype.indexToPosition = function (index, startRow) {
1230 var lines = this.$lines || this.getAllLines();
1231 var newlineLength = this.getNewLineCharacter().length;
1232 for (var i = startRow || 0, l = lines.length; i < l; i++) {
1233 index -= lines[i].length + newlineLength;
1234 if (index < 0)
1235 return { row: i, column: index + lines[i].length + newlineLength };
1236 }
1237 return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
1238 };
1239 Document.prototype.positionToIndex = function (pos, startRow) {
1240 var lines = this.$lines || this.getAllLines();
1241 var newlineLength = this.getNewLineCharacter().length;
1242 var index = 0;
1243 var row = Math.min(pos.row, lines.length);
1244 for (var i = startRow || 0; i < row; ++i)
1245 index += lines[i].length + newlineLength;
1246 return index + pos.column;
1247 };
1248 Document.prototype.$split = function (text) {
1249 return text.split(/\r\n|\r|\n/);
1250 };
1251 return Document;
1252 }());
1253 Document.prototype.$autoNewLine = "";
1254 Document.prototype.$newLineMode = "auto";
1255 oop.implement(Document.prototype, EventEmitter);
1256 exports.Document = Document;
1257
1258 });
1259
1260 ace.define("ace/worker/mirror",[], function(require, exports, module) {
1261 "use strict";
1262
1263 var Document = require("../document").Document;
1264 var lang = require("../lib/lang");
1265
1266 var Mirror = exports.Mirror = function(sender) {
1267 this.sender = sender;
1268 var doc = this.doc = new Document("");
1269
1270 var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
1271
1272 var _self = this;
1273 sender.on("change", function(e) {
1274 var data = e.data;
1275 if (data[0].start) {
1276 doc.applyDeltas(data);
1277 } else {
1278 for (var i = 0; i < data.length; i += 2) {
1279 var d, err;
1280 if (Array.isArray(data[i+1])) {
1281 d = {action: "insert", start: data[i], lines: data[i+1]};
1282 } else {
1283 d = {action: "remove", start: data[i], end: data[i+1]};
1284 }
1285
1286 if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
1287 err = new Error("Invalid delta");
1288 err.data = {
1289 path: _self.$path,
1290 linesLength: doc.$lines.length,
1291 start: d.start,
1292 end: d.end
1293 };
1294 throw err;
1295 }
1296
1297 doc.applyDelta(d, true);
1298 }
1299 }
1300 if (_self.$timeout)
1301 return deferredUpdate.schedule(_self.$timeout);
1302 _self.onUpdate();
1303 });
1304 };
1305
1306 (function() {
1307
1308 this.$timeout = 500;
1309
1310 this.setTimeout = function(timeout) {
1311 this.$timeout = timeout;
1312 };
1313
1314 this.setValue = function(value) {
1315 this.doc.setValue(value);
1316 this.deferredUpdate.schedule(this.$timeout);
1317 };
1318
1319 this.getValue = function(callbackId) {
1320 this.sender.callback(this.doc.getValue(), callbackId);
1321 };
1322
1323 this.onUpdate = function() {
1324 };
1325
1326 this.isPending = function() {
1327 return this.deferredUpdate.isPending();
1328 };
1329
1330 }).call(Mirror.prototype);
1331
1332 });
1333
1334 ace.define("ace/mode/css/csslint",[], function(require, exports, module) {
1335
1336 var CSSLint = (function(){
1337 var module = module || {},
1338 exports = exports || {};
1339 var parserlib = (function () {
1340 var require;
1341 require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
1342
1343 "use strict";
1344
1345 var Colors = module.exports = {
1346 __proto__ : null,
1347 aliceblue : "#f0f8ff",
1348 antiquewhite : "#faebd7",
1349 aqua : "#00ffff",
1350 aquamarine : "#7fffd4",
1351 azure : "#f0ffff",
1352 beige : "#f5f5dc",
1353 bisque : "#ffe4c4",
1354 black : "#000000",
1355 blanchedalmond : "#ffebcd",
1356 blue : "#0000ff",
1357 blueviolet : "#8a2be2",
1358 brown : "#a52a2a",
1359 burlywood : "#deb887",
1360 cadetblue : "#5f9ea0",
1361 chartreuse : "#7fff00",
1362 chocolate : "#d2691e",
1363 coral : "#ff7f50",
1364 cornflowerblue : "#6495ed",
1365 cornsilk : "#fff8dc",
1366 crimson : "#dc143c",
1367 cyan : "#00ffff",
1368 darkblue : "#00008b",
1369 darkcyan : "#008b8b",
1370 darkgoldenrod : "#b8860b",
1371 darkgray : "#a9a9a9",
1372 darkgreen : "#006400",
1373 darkgrey : "#a9a9a9",
1374 darkkhaki : "#bdb76b",
1375 darkmagenta : "#8b008b",
1376 darkolivegreen : "#556b2f",
1377 darkorange : "#ff8c00",
1378 darkorchid : "#9932cc",
1379 darkred : "#8b0000",
1380 darksalmon : "#e9967a",
1381 darkseagreen : "#8fbc8f",
1382 darkslateblue : "#483d8b",
1383 darkslategray : "#2f4f4f",
1384 darkslategrey : "#2f4f4f",
1385 darkturquoise : "#00ced1",
1386 darkviolet : "#9400d3",
1387 deeppink : "#ff1493",
1388 deepskyblue : "#00bfff",
1389 dimgray : "#696969",
1390 dimgrey : "#696969",
1391 dodgerblue : "#1e90ff",
1392 firebrick : "#b22222",
1393 floralwhite : "#fffaf0",
1394 forestgreen : "#228b22",
1395 fuchsia : "#ff00ff",
1396 gainsboro : "#dcdcdc",
1397 ghostwhite : "#f8f8ff",
1398 gold : "#ffd700",
1399 goldenrod : "#daa520",
1400 gray : "#808080",
1401 green : "#008000",
1402 greenyellow : "#adff2f",
1403 grey : "#808080",
1404 honeydew : "#f0fff0",
1405 hotpink : "#ff69b4",
1406 indianred : "#cd5c5c",
1407 indigo : "#4b0082",
1408 ivory : "#fffff0",
1409 khaki : "#f0e68c",
1410 lavender : "#e6e6fa",
1411 lavenderblush : "#fff0f5",
1412 lawngreen : "#7cfc00",
1413 lemonchiffon : "#fffacd",
1414 lightblue : "#add8e6",
1415 lightcoral : "#f08080",
1416 lightcyan : "#e0ffff",
1417 lightgoldenrodyellow : "#fafad2",
1418 lightgray : "#d3d3d3",
1419 lightgreen : "#90ee90",
1420 lightgrey : "#d3d3d3",
1421 lightpink : "#ffb6c1",
1422 lightsalmon : "#ffa07a",
1423 lightseagreen : "#20b2aa",
1424 lightskyblue : "#87cefa",
1425 lightslategray : "#778899",
1426 lightslategrey : "#778899",
1427 lightsteelblue : "#b0c4de",
1428 lightyellow : "#ffffe0",
1429 lime : "#00ff00",
1430 limegreen : "#32cd32",
1431 linen : "#faf0e6",
1432 magenta : "#ff00ff",
1433 maroon : "#800000",
1434 mediumaquamarine : "#66cdaa",
1435 mediumblue : "#0000cd",
1436 mediumorchid : "#ba55d3",
1437 mediumpurple : "#9370db",
1438 mediumseagreen : "#3cb371",
1439 mediumslateblue : "#7b68ee",
1440 mediumspringgreen : "#00fa9a",
1441 mediumturquoise : "#48d1cc",
1442 mediumvioletred : "#c71585",
1443 midnightblue : "#191970",
1444 mintcream : "#f5fffa",
1445 mistyrose : "#ffe4e1",
1446 moccasin : "#ffe4b5",
1447 navajowhite : "#ffdead",
1448 navy : "#000080",
1449 oldlace : "#fdf5e6",
1450 olive : "#808000",
1451 olivedrab : "#6b8e23",
1452 orange : "#ffa500",
1453 orangered : "#ff4500",
1454 orchid : "#da70d6",
1455 palegoldenrod : "#eee8aa",
1456 palegreen : "#98fb98",
1457 paleturquoise : "#afeeee",
1458 palevioletred : "#db7093",
1459 papayawhip : "#ffefd5",
1460 peachpuff : "#ffdab9",
1461 peru : "#cd853f",
1462 pink : "#ffc0cb",
1463 plum : "#dda0dd",
1464 powderblue : "#b0e0e6",
1465 purple : "#800080",
1466 rebeccapurple : "#663399",
1467 red : "#ff0000",
1468 rosybrown : "#bc8f8f",
1469 royalblue : "#4169e1",
1470 saddlebrown : "#8b4513",
1471 salmon : "#fa8072",
1472 sandybrown : "#f4a460",
1473 seagreen : "#2e8b57",
1474 seashell : "#fff5ee",
1475 sienna : "#a0522d",
1476 silver : "#c0c0c0",
1477 skyblue : "#87ceeb",
1478 slateblue : "#6a5acd",
1479 slategray : "#708090",
1480 slategrey : "#708090",
1481 snow : "#fffafa",
1482 springgreen : "#00ff7f",
1483 steelblue : "#4682b4",
1484 tan : "#d2b48c",
1485 teal : "#008080",
1486 thistle : "#d8bfd8",
1487 tomato : "#ff6347",
1488 turquoise : "#40e0d0",
1489 violet : "#ee82ee",
1490 wheat : "#f5deb3",
1491 white : "#ffffff",
1492 whitesmoke : "#f5f5f5",
1493 yellow : "#ffff00",
1494 yellowgreen : "#9acd32",
1495 currentColor : "The value of the 'color' property.",
1496 activeborder : "Active window border.",
1497 activecaption : "Active window caption.",
1498 appworkspace : "Background color of multiple document interface.",
1499 background : "Desktop background.",
1500 buttonface : "The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
1501 buttonhighlight : "The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
1502 buttonshadow : "The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
1503 buttontext : "Text on push buttons.",
1504 captiontext : "Text in caption, size box, and scrollbar arrow box.",
1505 graytext : "Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
1506 greytext : "Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
1507 highlight : "Item(s) selected in a control.",
1508 highlighttext : "Text of item(s) selected in a control.",
1509 inactiveborder : "Inactive window border.",
1510 inactivecaption : "Inactive window caption.",
1511 inactivecaptiontext : "Color of text in an inactive caption.",
1512 infobackground : "Background color for tooltip controls.",
1513 infotext : "Text color for tooltip controls.",
1514 menu : "Menu background.",
1515 menutext : "Text in menus.",
1516 scrollbar : "Scroll bar gray area.",
1517 threeddarkshadow : "The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1518 threedface : "The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1519 threedhighlight : "The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1520 threedlightshadow : "The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1521 threedshadow : "The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1522 window : "Window background.",
1523 windowframe : "Window frame.",
1524 windowtext : "Text in windows."
1525 };
1526
1527 },{}],2:[function(require,module,exports){
1528 "use strict";
1529
1530 module.exports = Combinator;
1531
1532 var SyntaxUnit = require("../util/SyntaxUnit");
1533
1534 var Parser = require("./Parser");
1535 function Combinator(text, line, col) {
1536
1537 SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
1538 this.type = "unknown";
1539 if (/^\s+$/.test(text)) {
1540 this.type = "descendant";
1541 } else if (text === ">") {
1542 this.type = "child";
1543 } else if (text === "+") {
1544 this.type = "adjacent-sibling";
1545 } else if (text === "~") {
1546 this.type = "sibling";
1547 }
1548
1549 }
1550
1551 Combinator.prototype = new SyntaxUnit();
1552 Combinator.prototype.constructor = Combinator;
1553
1554
1555 },{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){
1556 "use strict";
1557
1558 module.exports = Matcher;
1559
1560 var StringReader = require("../util/StringReader");
1561 var SyntaxError = require("../util/SyntaxError");
1562 function Matcher(matchFunc, toString) {
1563 this.match = function(expression) {
1564 var result;
1565 expression.mark();
1566 result = matchFunc(expression);
1567 if (result) {
1568 expression.drop();
1569 } else {
1570 expression.restore();
1571 }
1572 return result;
1573 };
1574 this.toString = typeof toString === "function" ? toString : function() {
1575 return toString;
1576 };
1577 }
1578 Matcher.prec = {
1579 MOD: 5,
1580 SEQ: 4,
1581 ANDAND: 3,
1582 OROR: 2,
1583 ALT: 1
1584 };
1585 Matcher.parse = function(str) {
1586 var reader, eat, expr, oror, andand, seq, mod, term, result;
1587 reader = new StringReader(str);
1588 eat = function(matcher) {
1589 var result = reader.readMatch(matcher);
1590 if (result === null) {
1591 throw new SyntaxError(
1592 "Expected " + matcher, reader.getLine(), reader.getCol());
1593 }
1594 return result;
1595 };
1596 expr = function() {
1597 var m = [ oror() ];
1598 while (reader.readMatch(" | ") !== null) {
1599 m.push(oror());
1600 }
1601 return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m);
1602 };
1603 oror = function() {
1604 var m = [ andand() ];
1605 while (reader.readMatch(" || ") !== null) {
1606 m.push(andand());
1607 }
1608 return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m);
1609 };
1610 andand = function() {
1611 var m = [ seq() ];
1612 while (reader.readMatch(" && ") !== null) {
1613 m.push(seq());
1614 }
1615 return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m);
1616 };
1617 seq = function() {
1618 var m = [ mod() ];
1619 while (reader.readMatch(/^ (?![&|\]])/) !== null) {
1620 m.push(mod());
1621 }
1622 return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m);
1623 };
1624 mod = function() {
1625 var m = term();
1626 if (reader.readMatch("?") !== null) {
1627 return m.question();
1628 } else if (reader.readMatch("*") !== null) {
1629 return m.star();
1630 } else if (reader.readMatch("+") !== null) {
1631 return m.plus();
1632 } else if (reader.readMatch("#") !== null) {
1633 return m.hash();
1634 } else if (reader.readMatch(/^\{\s*/) !== null) {
1635 var min = eat(/^\d+/);
1636 eat(/^\s*,\s*/);
1637 var max = eat(/^\d+/);
1638 eat(/^\s*\}/);
1639 return m.braces(Number(min), Number(max));
1640 }
1641 return m;
1642 };
1643 term = function() {
1644 if (reader.readMatch("[ ") !== null) {
1645 var m = expr();
1646 eat(" ]");
1647 return m;
1648 }
1649 return Matcher.fromType(eat(/^[^ ?*+#{]+/));
1650 };
1651 result = expr();
1652 if (!reader.eof()) {
1653 throw new SyntaxError(
1654 "Expected end of string", reader.getLine(), reader.getCol());
1655 }
1656 return result;
1657 };
1658 Matcher.cast = function(m) {
1659 if (m instanceof Matcher) {
1660 return m;
1661 }
1662 return Matcher.parse(m);
1663 };
1664 Matcher.fromType = function(type) {
1665 var ValidationTypes = require("./ValidationTypes");
1666 return new Matcher(function(expression) {
1667 return expression.hasNext() && ValidationTypes.isType(expression, type);
1668 }, type);
1669 };
1670 Matcher.seq = function() {
1671 var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
1672 if (ms.length === 1) {
1673 return ms[0];
1674 }
1675 return new Matcher(function(expression) {
1676 var i, result = true;
1677 for (i = 0; result && i < ms.length; i++) {
1678 result = ms[i].match(expression);
1679 }
1680 return result;
1681 }, function(prec) {
1682 var p = Matcher.prec.SEQ;
1683 var s = ms.map(function(m) {
1684 return m.toString(p);
1685 }).join(" ");
1686 if (prec > p) {
1687 s = "[ " + s + " ]";
1688 }
1689 return s;
1690 });
1691 };
1692 Matcher.alt = function() {
1693 var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
1694 if (ms.length === 1) {
1695 return ms[0];
1696 }
1697 return new Matcher(function(expression) {
1698 var i, result = false;
1699 for (i = 0; !result && i < ms.length; i++) {
1700 result = ms[i].match(expression);
1701 }
1702 return result;
1703 }, function(prec) {
1704 var p = Matcher.prec.ALT;
1705 var s = ms.map(function(m) {
1706 return m.toString(p);
1707 }).join(" | ");
1708 if (prec > p) {
1709 s = "[ " + s + " ]";
1710 }
1711 return s;
1712 });
1713 };
1714 Matcher.many = function(required) {
1715 var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) {
1716 if (v.expand) {
1717 var ValidationTypes = require("./ValidationTypes");
1718 acc.push.apply(acc, ValidationTypes.complex[v.expand].options);
1719 } else {
1720 acc.push(Matcher.cast(v));
1721 }
1722 return acc;
1723 }, []);
1724
1725 if (required === true) {
1726 required = ms.map(function() {
1727 return true;
1728 });
1729 }
1730
1731 var result = new Matcher(function(expression) {
1732 var seen = [], max = 0, pass = 0;
1733 var success = function(matchCount) {
1734 if (pass === 0) {
1735 max = Math.max(matchCount, max);
1736 return matchCount === ms.length;
1737 } else {
1738 return matchCount === max;
1739 }
1740 };
1741 var tryMatch = function(matchCount) {
1742 for (var i = 0; i < ms.length; i++) {
1743 if (seen[i]) {
1744 continue;
1745 }
1746 expression.mark();
1747 if (ms[i].match(expression)) {
1748 seen[i] = true;
1749 if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) {
1750 expression.drop();
1751 return true;
1752 }
1753 expression.restore();
1754 seen[i] = false;
1755 } else {
1756 expression.drop();
1757 }
1758 }
1759 return success(matchCount);
1760 };
1761 if (!tryMatch(0)) {
1762 pass++;
1763 tryMatch(0);
1764 }
1765
1766 if (required === false) {
1767 return max > 0;
1768 }
1769 for (var i = 0; i < ms.length; i++) {
1770 if (required[i] && !seen[i]) {
1771 return false;
1772 }
1773 }
1774 return true;
1775 }, function(prec) {
1776 var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND;
1777 var s = ms.map(function(m, i) {
1778 if (required !== false && !required[i]) {
1779 return m.toString(Matcher.prec.MOD) + "?";
1780 }
1781 return m.toString(p);
1782 }).join(required === false ? " || " : " && ");
1783 if (prec > p) {
1784 s = "[ " + s + " ]";
1785 }
1786 return s;
1787 });
1788 result.options = ms;
1789 return result;
1790 };
1791 Matcher.andand = function() {
1792 var args = Array.prototype.slice.call(arguments);
1793 args.unshift(true);
1794 return Matcher.many.apply(Matcher, args);
1795 };
1796 Matcher.oror = function() {
1797 var args = Array.prototype.slice.call(arguments);
1798 args.unshift(false);
1799 return Matcher.many.apply(Matcher, args);
1800 };
1801 Matcher.prototype = {
1802 constructor: Matcher,
1803 match: function() {
1804 throw new Error("unimplemented");
1805 },
1806 toString: function() {
1807 throw new Error("unimplemented");
1808 },
1809 func: function() {
1810 return this.match.bind(this);
1811 },
1812 then: function(m) {
1813 return Matcher.seq(this, m);
1814 },
1815 or: function(m) {
1816 return Matcher.alt(this, m);
1817 },
1818 andand: function(m) {
1819 return Matcher.many(true, this, m);
1820 },
1821 oror: function(m) {
1822 return Matcher.many(false, this, m);
1823 },
1824 star: function() {
1825 return this.braces(0, Infinity, "*");
1826 },
1827 plus: function() {
1828 return this.braces(1, Infinity, "+");
1829 },
1830 question: function() {
1831 return this.braces(0, 1, "?");
1832 },
1833 hash: function() {
1834 return this.braces(1, Infinity, "#", Matcher.cast(","));
1835 },
1836 braces: function(min, max, marker, optSep) {
1837 var m1 = this, m2 = optSep ? optSep.then(this) : this;
1838 if (!marker) {
1839 marker = "{" + min + "," + max + "}";
1840 }
1841 return new Matcher(function(expression) {
1842 var result = true, i;
1843 for (i = 0; i < max; i++) {
1844 if (i > 0 && optSep) {
1845 result = m2.match(expression);
1846 } else {
1847 result = m1.match(expression);
1848 }
1849 if (!result) {
1850 break;
1851 }
1852 }
1853 return i >= min;
1854 }, function() {
1855 return m1.toString(Matcher.prec.MOD) + marker;
1856 });
1857 }
1858 };
1859
1860 },{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){
1861 "use strict";
1862
1863 module.exports = MediaFeature;
1864
1865 var SyntaxUnit = require("../util/SyntaxUnit");
1866
1867 var Parser = require("./Parser");
1868 function MediaFeature(name, value) {
1869
1870 SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
1871 this.name = name;
1872 this.value = value;
1873 }
1874
1875 MediaFeature.prototype = new SyntaxUnit();
1876 MediaFeature.prototype.constructor = MediaFeature;
1877
1878
1879 },{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){
1880 "use strict";
1881
1882 module.exports = MediaQuery;
1883
1884 var SyntaxUnit = require("../util/SyntaxUnit");
1885
1886 var Parser = require("./Parser");
1887 function MediaQuery(modifier, mediaType, features, line, col) {
1888
1889 SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
1890 this.modifier = modifier;
1891 this.mediaType = mediaType;
1892 this.features = features;
1893
1894 }
1895
1896 MediaQuery.prototype = new SyntaxUnit();
1897 MediaQuery.prototype.constructor = MediaQuery;
1898
1899
1900 },{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){
1901 "use strict";
1902
1903 module.exports = Parser;
1904
1905 var EventTarget = require("../util/EventTarget");
1906 var SyntaxError = require("../util/SyntaxError");
1907 var SyntaxUnit = require("../util/SyntaxUnit");
1908
1909 var Combinator = require("./Combinator");
1910 var MediaFeature = require("./MediaFeature");
1911 var MediaQuery = require("./MediaQuery");
1912 var PropertyName = require("./PropertyName");
1913 var PropertyValue = require("./PropertyValue");
1914 var PropertyValuePart = require("./PropertyValuePart");
1915 var Selector = require("./Selector");
1916 var SelectorPart = require("./SelectorPart");
1917 var SelectorSubPart = require("./SelectorSubPart");
1918 var TokenStream = require("./TokenStream");
1919 var Tokens = require("./Tokens");
1920 var Validation = require("./Validation");
1921 function Parser(options) {
1922 EventTarget.call(this);
1923
1924
1925 this.options = options || {};
1926
1927 this._tokenStream = null;
1928 }
1929 Parser.DEFAULT_TYPE = 0;
1930 Parser.COMBINATOR_TYPE = 1;
1931 Parser.MEDIA_FEATURE_TYPE = 2;
1932 Parser.MEDIA_QUERY_TYPE = 3;
1933 Parser.PROPERTY_NAME_TYPE = 4;
1934 Parser.PROPERTY_VALUE_TYPE = 5;
1935 Parser.PROPERTY_VALUE_PART_TYPE = 6;
1936 Parser.SELECTOR_TYPE = 7;
1937 Parser.SELECTOR_PART_TYPE = 8;
1938 Parser.SELECTOR_SUB_PART_TYPE = 9;
1939
1940 Parser.prototype = function() {
1941
1942 var proto = new EventTarget(), // new prototype
1943 prop,
1944 additions = {
1945 __proto__: null,
1946 constructor: Parser,
1947 DEFAULT_TYPE : 0,
1948 COMBINATOR_TYPE : 1,
1949 MEDIA_FEATURE_TYPE : 2,
1950 MEDIA_QUERY_TYPE : 3,
1951 PROPERTY_NAME_TYPE : 4,
1952 PROPERTY_VALUE_TYPE : 5,
1953 PROPERTY_VALUE_PART_TYPE : 6,
1954 SELECTOR_TYPE : 7,
1955 SELECTOR_PART_TYPE : 8,
1956 SELECTOR_SUB_PART_TYPE : 9,
1957
1958 _stylesheet: function() {
1959
1960 var tokenStream = this._tokenStream,
1961 count,
1962 token,
1963 tt;
1964
1965 this.fire("startstylesheet");
1966 this._charset();
1967
1968 this._skipCruft();
1969 while (tokenStream.peek() === Tokens.IMPORT_SYM) {
1970 this._import();
1971 this._skipCruft();
1972 }
1973 while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
1974 this._namespace();
1975 this._skipCruft();
1976 }
1977 tt = tokenStream.peek();
1978 while (tt > Tokens.EOF) {
1979
1980 try {
1981
1982 switch (tt) {
1983 case Tokens.MEDIA_SYM:
1984 this._media();
1985 this._skipCruft();
1986 break;
1987 case Tokens.PAGE_SYM:
1988 this._page();
1989 this._skipCruft();
1990 break;
1991 case Tokens.FONT_FACE_SYM:
1992 this._font_face();
1993 this._skipCruft();
1994 break;
1995 case Tokens.KEYFRAMES_SYM:
1996 this._keyframes();
1997 this._skipCruft();
1998 break;
1999 case Tokens.VIEWPORT_SYM:
2000 this._viewport();
2001 this._skipCruft();
2002 break;
2003 case Tokens.DOCUMENT_SYM:
2004 this._document();
2005 this._skipCruft();
2006 break;
2007 case Tokens.SUPPORTS_SYM:
2008 this._supports();
2009 this._skipCruft();
2010 break;
2011 case Tokens.UNKNOWN_SYM: // unknown @ rule
2012 tokenStream.get();
2013 if (!this.options.strict) {
2014 this.fire({
2015 type: "error",
2016 error: null,
2017 message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
2018 line: tokenStream.LT(0).startLine,
2019 col: tokenStream.LT(0).startCol
2020 });
2021 count = 0;
2022 while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
2023 count++; // keep track of nesting depth
2024 }
2025
2026 while (count) {
2027 tokenStream.advance([Tokens.RBRACE]);
2028 count--;
2029 }
2030
2031 } else {
2032 throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
2033 }
2034 break;
2035 case Tokens.S:
2036 this._readWhitespace();
2037 break;
2038 default:
2039 if (!this._ruleset()) {
2040 switch (tt) {
2041 case Tokens.CHARSET_SYM:
2042 token = tokenStream.LT(1);
2043 this._charset(false);
2044 throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
2045 case Tokens.IMPORT_SYM:
2046 token = tokenStream.LT(1);
2047 this._import(false);
2048 throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
2049 case Tokens.NAMESPACE_SYM:
2050 token = tokenStream.LT(1);
2051 this._namespace(false);
2052 throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
2053 default:
2054 tokenStream.get(); // get the last token
2055 this._unexpectedToken(tokenStream.token());
2056 }
2057
2058 }
2059 }
2060 } catch (ex) {
2061 if (ex instanceof SyntaxError && !this.options.strict) {
2062 this.fire({
2063 type: "error",
2064 error: ex,
2065 message: ex.message,
2066 line: ex.line,
2067 col: ex.col
2068 });
2069 } else {
2070 throw ex;
2071 }
2072 }
2073
2074 tt = tokenStream.peek();
2075 }
2076
2077 if (tt !== Tokens.EOF) {
2078 this._unexpectedToken(tokenStream.token());
2079 }
2080
2081 this.fire("endstylesheet");
2082 },
2083
2084 _charset: function(emit) {
2085 var tokenStream = this._tokenStream,
2086 charset,
2087 token,
2088 line,
2089 col;
2090
2091 if (tokenStream.match(Tokens.CHARSET_SYM)) {
2092 line = tokenStream.token().startLine;
2093 col = tokenStream.token().startCol;
2094
2095 this._readWhitespace();
2096 tokenStream.mustMatch(Tokens.STRING);
2097
2098 token = tokenStream.token();
2099 charset = token.value;
2100
2101 this._readWhitespace();
2102 tokenStream.mustMatch(Tokens.SEMICOLON);
2103
2104 if (emit !== false) {
2105 this.fire({
2106 type: "charset",
2107 charset:charset,
2108 line: line,
2109 col: col
2110 });
2111 }
2112 }
2113 },
2114
2115 _import: function(emit) {
2116
2117 var tokenStream = this._tokenStream,
2118 uri,
2119 importToken,
2120 mediaList = [];
2121 tokenStream.mustMatch(Tokens.IMPORT_SYM);
2122 importToken = tokenStream.token();
2123 this._readWhitespace();
2124
2125 tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
2126 uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
2127
2128 this._readWhitespace();
2129
2130 mediaList = this._media_query_list();
2131 tokenStream.mustMatch(Tokens.SEMICOLON);
2132 this._readWhitespace();
2133
2134 if (emit !== false) {
2135 this.fire({
2136 type: "import",
2137 uri: uri,
2138 media: mediaList,
2139 line: importToken.startLine,
2140 col: importToken.startCol
2141 });
2142 }
2143
2144 },
2145
2146 _namespace: function(emit) {
2147
2148 var tokenStream = this._tokenStream,
2149 line,
2150 col,
2151 prefix,
2152 uri;
2153 tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
2154 line = tokenStream.token().startLine;
2155 col = tokenStream.token().startCol;
2156 this._readWhitespace();
2157 if (tokenStream.match(Tokens.IDENT)) {
2158 prefix = tokenStream.token().value;
2159 this._readWhitespace();
2160 }
2161
2162 tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
2163 uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
2164
2165 this._readWhitespace();
2166 tokenStream.mustMatch(Tokens.SEMICOLON);
2167 this._readWhitespace();
2168
2169 if (emit !== false) {
2170 this.fire({
2171 type: "namespace",
2172 prefix: prefix,
2173 uri: uri,
2174 line: line,
2175 col: col
2176 });
2177 }
2178
2179 },
2180
2181 _supports: function(emit) {
2182 var tokenStream = this._tokenStream,
2183 line,
2184 col;
2185
2186 if (tokenStream.match(Tokens.SUPPORTS_SYM)) {
2187 line = tokenStream.token().startLine;
2188 col = tokenStream.token().startCol;
2189
2190 this._readWhitespace();
2191 this._supports_condition();
2192 this._readWhitespace();
2193
2194 tokenStream.mustMatch(Tokens.LBRACE);
2195 this._readWhitespace();
2196
2197 if (emit !== false) {
2198 this.fire({
2199 type: "startsupports",
2200 line: line,
2201 col: col
2202 });
2203 }
2204
2205 while (true) {
2206 if (!this._ruleset()) {
2207 break;
2208 }
2209 }
2210
2211 tokenStream.mustMatch(Tokens.RBRACE);
2212 this._readWhitespace();
2213
2214 this.fire({
2215 type: "endsupports",
2216 line: line,
2217 col: col
2218 });
2219 }
2220 },
2221
2222 _supports_condition: function() {
2223 var tokenStream = this._tokenStream,
2224 ident;
2225
2226 if (tokenStream.match(Tokens.IDENT)) {
2227 ident = tokenStream.token().value.toLowerCase();
2228
2229 if (ident === "not") {
2230 tokenStream.mustMatch(Tokens.S);
2231 this._supports_condition_in_parens();
2232 } else {
2233 tokenStream.unget();
2234 }
2235 } else {
2236 this._supports_condition_in_parens();
2237 this._readWhitespace();
2238
2239 while (tokenStream.peek() === Tokens.IDENT) {
2240 ident = tokenStream.LT(1).value.toLowerCase();
2241 if (ident === "and" || ident === "or") {
2242 tokenStream.mustMatch(Tokens.IDENT);
2243 this._readWhitespace();
2244 this._supports_condition_in_parens();
2245 this._readWhitespace();
2246 }
2247 }
2248 }
2249 },
2250
2251 _supports_condition_in_parens: function() {
2252 var tokenStream = this._tokenStream,
2253 ident;
2254
2255 if (tokenStream.match(Tokens.LPAREN)) {
2256 this._readWhitespace();
2257 if (tokenStream.match(Tokens.IDENT)) {
2258 ident = tokenStream.token().value.toLowerCase();
2259 if (ident === "not") {
2260 this._readWhitespace();
2261 this._supports_condition();
2262 this._readWhitespace();
2263 tokenStream.mustMatch(Tokens.RPAREN);
2264 } else {
2265 tokenStream.unget();
2266 this._supports_declaration_condition(false);
2267 }
2268 } else {
2269 this._supports_condition();
2270 this._readWhitespace();
2271 tokenStream.mustMatch(Tokens.RPAREN);
2272 }
2273 } else {
2274 this._supports_declaration_condition();
2275 }
2276 },
2277
2278 _supports_declaration_condition: function(requireStartParen) {
2279 var tokenStream = this._tokenStream;
2280
2281 if (requireStartParen !== false) {
2282 tokenStream.mustMatch(Tokens.LPAREN);
2283 }
2284 this._readWhitespace();
2285 this._declaration();
2286 tokenStream.mustMatch(Tokens.RPAREN);
2287 },
2288
2289 _media: function() {
2290 var tokenStream = this._tokenStream,
2291 line,
2292 col,
2293 mediaList; // = [];
2294 tokenStream.mustMatch(Tokens.MEDIA_SYM);
2295 line = tokenStream.token().startLine;
2296 col = tokenStream.token().startCol;
2297
2298 this._readWhitespace();
2299
2300 mediaList = this._media_query_list();
2301
2302 tokenStream.mustMatch(Tokens.LBRACE);
2303 this._readWhitespace();
2304
2305 this.fire({
2306 type: "startmedia",
2307 media: mediaList,
2308 line: line,
2309 col: col
2310 });
2311
2312 while (true) {
2313 if (tokenStream.peek() === Tokens.PAGE_SYM) {
2314 this._page();
2315 } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
2316 this._font_face();
2317 } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
2318 this._viewport();
2319 } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
2320 this._document();
2321 } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) {
2322 this._supports();
2323 } else if (tokenStream.peek() === Tokens.MEDIA_SYM) {
2324 this._media();
2325 } else if (!this._ruleset()) {
2326 break;
2327 }
2328 }
2329
2330 tokenStream.mustMatch(Tokens.RBRACE);
2331 this._readWhitespace();
2332
2333 this.fire({
2334 type: "endmedia",
2335 media: mediaList,
2336 line: line,
2337 col: col
2338 });
2339 },
2340 _media_query_list: function() {
2341 var tokenStream = this._tokenStream,
2342 mediaList = [];
2343
2344
2345 this._readWhitespace();
2346
2347 if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
2348 mediaList.push(this._media_query());
2349 }
2350
2351 while (tokenStream.match(Tokens.COMMA)) {
2352 this._readWhitespace();
2353 mediaList.push(this._media_query());
2354 }
2355
2356 return mediaList;
2357 },
2358 _media_query: function() {
2359 var tokenStream = this._tokenStream,
2360 type = null,
2361 ident = null,
2362 token = null,
2363 expressions = [];
2364
2365 if (tokenStream.match(Tokens.IDENT)) {
2366 ident = tokenStream.token().value.toLowerCase();
2367 if (ident !== "only" && ident !== "not") {
2368 tokenStream.unget();
2369 ident = null;
2370 } else {
2371 token = tokenStream.token();
2372 }
2373 }
2374
2375 this._readWhitespace();
2376
2377 if (tokenStream.peek() === Tokens.IDENT) {
2378 type = this._media_type();
2379 if (token === null) {
2380 token = tokenStream.token();
2381 }
2382 } else if (tokenStream.peek() === Tokens.LPAREN) {
2383 if (token === null) {
2384 token = tokenStream.LT(1);
2385 }
2386 expressions.push(this._media_expression());
2387 }
2388
2389 if (type === null && expressions.length === 0) {
2390 return null;
2391 } else {
2392 this._readWhitespace();
2393 while (tokenStream.match(Tokens.IDENT)) {
2394 if (tokenStream.token().value.toLowerCase() !== "and") {
2395 this._unexpectedToken(tokenStream.token());
2396 }
2397
2398 this._readWhitespace();
2399 expressions.push(this._media_expression());
2400 }
2401 }
2402
2403 return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
2404 },
2405 _media_type: function() {
2406 return this._media_feature();
2407 },
2408 _media_expression: function() {
2409 var tokenStream = this._tokenStream,
2410 feature = null,
2411 token,
2412 expression = null;
2413
2414 tokenStream.mustMatch(Tokens.LPAREN);
2415 this._readWhitespace();
2416
2417 feature = this._media_feature();
2418 this._readWhitespace();
2419
2420 if (tokenStream.match(Tokens.COLON)) {
2421 this._readWhitespace();
2422 token = tokenStream.LT(1);
2423 expression = this._expression();
2424 }
2425
2426 tokenStream.mustMatch(Tokens.RPAREN);
2427 this._readWhitespace();
2428
2429 return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
2430 },
2431 _media_feature: function() {
2432 var tokenStream = this._tokenStream;
2433
2434 this._readWhitespace();
2435
2436 tokenStream.mustMatch(Tokens.IDENT);
2437
2438 return SyntaxUnit.fromToken(tokenStream.token());
2439 },
2440 _page: function() {
2441 var tokenStream = this._tokenStream,
2442 line,
2443 col,
2444 identifier = null,
2445 pseudoPage = null;
2446 tokenStream.mustMatch(Tokens.PAGE_SYM);
2447 line = tokenStream.token().startLine;
2448 col = tokenStream.token().startCol;
2449
2450 this._readWhitespace();
2451
2452 if (tokenStream.match(Tokens.IDENT)) {
2453 identifier = tokenStream.token().value;
2454 if (identifier.toLowerCase() === "auto") {
2455 this._unexpectedToken(tokenStream.token());
2456 }
2457 }
2458 if (tokenStream.peek() === Tokens.COLON) {
2459 pseudoPage = this._pseudo_page();
2460 }
2461
2462 this._readWhitespace();
2463
2464 this.fire({
2465 type: "startpage",
2466 id: identifier,
2467 pseudo: pseudoPage,
2468 line: line,
2469 col: col
2470 });
2471
2472 this._readDeclarations(true, true);
2473
2474 this.fire({
2475 type: "endpage",
2476 id: identifier,
2477 pseudo: pseudoPage,
2478 line: line,
2479 col: col
2480 });
2481
2482 },
2483 _margin: function() {
2484 var tokenStream = this._tokenStream,
2485 line,
2486 col,
2487 marginSym = this._margin_sym();
2488
2489 if (marginSym) {
2490 line = tokenStream.token().startLine;
2491 col = tokenStream.token().startCol;
2492
2493 this.fire({
2494 type: "startpagemargin",
2495 margin: marginSym,
2496 line: line,
2497 col: col
2498 });
2499
2500 this._readDeclarations(true);
2501
2502 this.fire({
2503 type: "endpagemargin",
2504 margin: marginSym,
2505 line: line,
2506 col: col
2507 });
2508 return true;
2509 } else {
2510 return false;
2511 }
2512 },
2513 _margin_sym: function() {
2514
2515 var tokenStream = this._tokenStream;
2516
2517 if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
2518 Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
2519 Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
2520 Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
2521 Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
2522 Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
2523 Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) {
2524 return SyntaxUnit.fromToken(tokenStream.token());
2525 } else {
2526 return null;
2527 }
2528
2529 },
2530
2531 _pseudo_page: function() {
2532
2533 var tokenStream = this._tokenStream;
2534
2535 tokenStream.mustMatch(Tokens.COLON);
2536 tokenStream.mustMatch(Tokens.IDENT);
2537
2538 return tokenStream.token().value;
2539 },
2540
2541 _font_face: function() {
2542 var tokenStream = this._tokenStream,
2543 line,
2544 col;
2545 tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
2546 line = tokenStream.token().startLine;
2547 col = tokenStream.token().startCol;
2548
2549 this._readWhitespace();
2550
2551 this.fire({
2552 type: "startfontface",
2553 line: line,
2554 col: col
2555 });
2556
2557 this._readDeclarations(true);
2558
2559 this.fire({
2560 type: "endfontface",
2561 line: line,
2562 col: col
2563 });
2564 },
2565
2566 _viewport: function() {
2567 var tokenStream = this._tokenStream,
2568 line,
2569 col;
2570
2571 tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
2572 line = tokenStream.token().startLine;
2573 col = tokenStream.token().startCol;
2574
2575 this._readWhitespace();
2576
2577 this.fire({
2578 type: "startviewport",
2579 line: line,
2580 col: col
2581 });
2582
2583 this._readDeclarations(true);
2584
2585 this.fire({
2586 type: "endviewport",
2587 line: line,
2588 col: col
2589 });
2590
2591 },
2592
2593 _document: function() {
2594
2595 var tokenStream = this._tokenStream,
2596 token,
2597 functions = [],
2598 prefix = "";
2599
2600 tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
2601 token = tokenStream.token();
2602 if (/^@-([^-]+)-/.test(token.value)) {
2603 prefix = RegExp.$1;
2604 }
2605
2606 this._readWhitespace();
2607 functions.push(this._document_function());
2608
2609 while (tokenStream.match(Tokens.COMMA)) {
2610 this._readWhitespace();
2611 functions.push(this._document_function());
2612 }
2613
2614 tokenStream.mustMatch(Tokens.LBRACE);
2615 this._readWhitespace();
2616
2617 this.fire({
2618 type: "startdocument",
2619 functions: functions,
2620 prefix: prefix,
2621 line: token.startLine,
2622 col: token.startCol
2623 });
2624
2625 var ok = true;
2626 while (ok) {
2627 switch (tokenStream.peek()) {
2628 case Tokens.PAGE_SYM:
2629 this._page();
2630 break;
2631 case Tokens.FONT_FACE_SYM:
2632 this._font_face();
2633 break;
2634 case Tokens.VIEWPORT_SYM:
2635 this._viewport();
2636 break;
2637 case Tokens.MEDIA_SYM:
2638 this._media();
2639 break;
2640 case Tokens.KEYFRAMES_SYM:
2641 this._keyframes();
2642 break;
2643 case Tokens.DOCUMENT_SYM:
2644 this._document();
2645 break;
2646 default:
2647 ok = Boolean(this._ruleset());
2648 }
2649 }
2650
2651 tokenStream.mustMatch(Tokens.RBRACE);
2652 token = tokenStream.token();
2653 this._readWhitespace();
2654
2655 this.fire({
2656 type: "enddocument",
2657 functions: functions,
2658 prefix: prefix,
2659 line: token.startLine,
2660 col: token.startCol
2661 });
2662 },
2663
2664 _document_function: function() {
2665
2666 var tokenStream = this._tokenStream,
2667 value;
2668
2669 if (tokenStream.match(Tokens.URI)) {
2670 value = tokenStream.token().value;
2671 this._readWhitespace();
2672 } else {
2673 value = this._function();
2674 }
2675
2676 return value;
2677 },
2678
2679 _operator: function(inFunction) {
2680
2681 var tokenStream = this._tokenStream,
2682 token = null;
2683
2684 if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
2685 inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) {
2686 token = tokenStream.token();
2687 this._readWhitespace();
2688 }
2689 return token ? PropertyValuePart.fromToken(token) : null;
2690
2691 },
2692
2693 _combinator: function() {
2694
2695 var tokenStream = this._tokenStream,
2696 value = null,
2697 token;
2698
2699 if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
2700 token = tokenStream.token();
2701 value = new Combinator(token.value, token.startLine, token.startCol);
2702 this._readWhitespace();
2703 }
2704
2705 return value;
2706 },
2707
2708 _unary_operator: function() {
2709
2710 var tokenStream = this._tokenStream;
2711
2712 if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
2713 return tokenStream.token().value;
2714 } else {
2715 return null;
2716 }
2717 },
2718
2719 _property: function() {
2720
2721 var tokenStream = this._tokenStream,
2722 value = null,
2723 hack = null,
2724 propertyName = "",
2725 token,
2726 line,
2727 col;
2728 if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
2729 tokenStream.get();
2730 token = tokenStream.token();
2731 hack = token.value;
2732 line = token.startLine;
2733 col = token.startCol;
2734 }
2735 if (tokenStream.peek() === Tokens.MINUS) {
2736 tokenStream.get();
2737 token = tokenStream.token();
2738 propertyName = token.value;
2739 line = token.startLine;
2740 col = token.startCol;
2741 }
2742
2743 if (tokenStream.match(Tokens.IDENT)) {
2744 token = tokenStream.token();
2745 propertyName += token.value;
2746 if (propertyName.charAt(0) === "_" && this.options.underscoreHack) {
2747 hack = "_";
2748 propertyName = propertyName.substring(1);
2749 }
2750
2751 value = new PropertyName(propertyName, hack, line || token.startLine, col || token.startCol);
2752 this._readWhitespace();
2753 } else {
2754 var tt = tokenStream.peek();
2755 if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
2756 this._unexpectedToken(tokenStream.LT(1));
2757 }
2758 }
2759
2760 return value;
2761 },
2762 _ruleset: function() {
2763
2764 var tokenStream = this._tokenStream,
2765 tt,
2766 selectors;
2767 try {
2768 selectors = this._selectors_group();
2769 } catch (ex) {
2770 if (ex instanceof SyntaxError && !this.options.strict) {
2771 this.fire({
2772 type: "error",
2773 error: ex,
2774 message: ex.message,
2775 line: ex.line,
2776 col: ex.col
2777 });
2778 tt = tokenStream.advance([Tokens.RBRACE]);
2779 if (tt === Tokens.RBRACE) {
2780 } else {
2781 throw ex;
2782 }
2783
2784 } else {
2785 throw ex;
2786 }
2787 return true;
2788 }
2789 if (selectors) {
2790
2791 this.fire({
2792 type: "startrule",
2793 selectors: selectors,
2794 line: selectors[0].line,
2795 col: selectors[0].col
2796 });
2797
2798 this._readDeclarations(true);
2799
2800 this.fire({
2801 type: "endrule",
2802 selectors: selectors,
2803 line: selectors[0].line,
2804 col: selectors[0].col
2805 });
2806
2807 }
2808
2809 return selectors;
2810
2811 },
2812 _selectors_group: function() {
2813 var tokenStream = this._tokenStream,
2814 selectors = [],
2815 selector;
2816
2817 selector = this._selector();
2818 if (selector !== null) {
2819
2820 selectors.push(selector);
2821 while (tokenStream.match(Tokens.COMMA)) {
2822 this._readWhitespace();
2823 selector = this._selector();
2824 if (selector !== null) {
2825 selectors.push(selector);
2826 } else {
2827 this._unexpectedToken(tokenStream.LT(1));
2828 }
2829 }
2830 }
2831
2832 return selectors.length ? selectors : null;
2833 },
2834 _selector: function() {
2835
2836 var tokenStream = this._tokenStream,
2837 selector = [],
2838 nextSelector = null,
2839 combinator = null,
2840 ws = null;
2841 nextSelector = this._simple_selector_sequence();
2842 if (nextSelector === null) {
2843 return null;
2844 }
2845
2846 selector.push(nextSelector);
2847
2848 do {
2849 combinator = this._combinator();
2850
2851 if (combinator !== null) {
2852 selector.push(combinator);
2853 nextSelector = this._simple_selector_sequence();
2854 if (nextSelector === null) {
2855 this._unexpectedToken(tokenStream.LT(1));
2856 } else {
2857 selector.push(nextSelector);
2858 }
2859 } else {
2860 if (this._readWhitespace()) {
2861 ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
2862 combinator = this._combinator();
2863 nextSelector = this._simple_selector_sequence();
2864 if (nextSelector === null) {
2865 if (combinator !== null) {
2866 this._unexpectedToken(tokenStream.LT(1));
2867 }
2868 } else {
2869
2870 if (combinator !== null) {
2871 selector.push(combinator);
2872 } else {
2873 selector.push(ws);
2874 }
2875
2876 selector.push(nextSelector);
2877 }
2878 } else {
2879 break;
2880 }
2881
2882 }
2883 } while (true);
2884
2885 return new Selector(selector, selector[0].line, selector[0].col);
2886 },
2887 _simple_selector_sequence: function() {
2888
2889 var tokenStream = this._tokenStream,
2890 elementName = null,
2891 modifiers = [],
2892 selectorText = "",
2893 components = [
2894 function() {
2895 return tokenStream.match(Tokens.HASH) ?
2896 new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
2897 null;
2898 },
2899 this._class,
2900 this._attrib,
2901 this._pseudo,
2902 this._negation
2903 ],
2904 i = 0,
2905 len = components.length,
2906 component = null,
2907 line,
2908 col;
2909 line = tokenStream.LT(1).startLine;
2910 col = tokenStream.LT(1).startCol;
2911
2912 elementName = this._type_selector();
2913 if (!elementName) {
2914 elementName = this._universal();
2915 }
2916
2917 if (elementName !== null) {
2918 selectorText += elementName;
2919 }
2920
2921 while (true) {
2922 if (tokenStream.peek() === Tokens.S) {
2923 break;
2924 }
2925 while (i < len && component === null) {
2926 component = components[i++].call(this);
2927 }
2928
2929 if (component === null) {
2930 if (selectorText === "") {
2931 return null;
2932 } else {
2933 break;
2934 }
2935 } else {
2936 i = 0;
2937 modifiers.push(component);
2938 selectorText += component.toString();
2939 component = null;
2940 }
2941 }
2942
2943
2944 return selectorText !== "" ?
2945 new SelectorPart(elementName, modifiers, selectorText, line, col) :
2946 null;
2947 },
2948 _type_selector: function() {
2949
2950 var tokenStream = this._tokenStream,
2951 ns = this._namespace_prefix(),
2952 elementName = this._element_name();
2953
2954 if (!elementName) {
2955 if (ns) {
2956 tokenStream.unget();
2957 if (ns.length > 1) {
2958 tokenStream.unget();
2959 }
2960 }
2961
2962 return null;
2963 } else {
2964 if (ns) {
2965 elementName.text = ns + elementName.text;
2966 elementName.col -= ns.length;
2967 }
2968 return elementName;
2969 }
2970 },
2971 _class: function() {
2972
2973 var tokenStream = this._tokenStream,
2974 token;
2975
2976 if (tokenStream.match(Tokens.DOT)) {
2977 tokenStream.mustMatch(Tokens.IDENT);
2978 token = tokenStream.token();
2979 return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
2980 } else {
2981 return null;
2982 }
2983
2984 },
2985 _element_name: function() {
2986
2987 var tokenStream = this._tokenStream,
2988 token;
2989
2990 if (tokenStream.match(Tokens.IDENT)) {
2991 token = tokenStream.token();
2992 return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
2993
2994 } else {
2995 return null;
2996 }
2997 },
2998 _namespace_prefix: function() {
2999 var tokenStream = this._tokenStream,
3000 value = "";
3001 if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
3002
3003 if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
3004 value += tokenStream.token().value;
3005 }
3006
3007 tokenStream.mustMatch(Tokens.PIPE);
3008 value += "|";
3009
3010 }
3011
3012 return value.length ? value : null;
3013 },
3014 _universal: function() {
3015 var tokenStream = this._tokenStream,
3016 value = "",
3017 ns;
3018
3019 ns = this._namespace_prefix();
3020 if (ns) {
3021 value += ns;
3022 }
3023
3024 if (tokenStream.match(Tokens.STAR)) {
3025 value += "*";
3026 }
3027
3028 return value.length ? value : null;
3029
3030 },
3031 _attrib: function() {
3032
3033 var tokenStream = this._tokenStream,
3034 value = null,
3035 ns,
3036 token;
3037
3038 if (tokenStream.match(Tokens.LBRACKET)) {
3039 token = tokenStream.token();
3040 value = token.value;
3041 value += this._readWhitespace();
3042
3043 ns = this._namespace_prefix();
3044
3045 if (ns) {
3046 value += ns;
3047 }
3048
3049 tokenStream.mustMatch(Tokens.IDENT);
3050 value += tokenStream.token().value;
3051 value += this._readWhitespace();
3052
3053 if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
3054 Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) {
3055
3056 value += tokenStream.token().value;
3057 value += this._readWhitespace();
3058
3059 tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
3060 value += tokenStream.token().value;
3061 value += this._readWhitespace();
3062 }
3063
3064 tokenStream.mustMatch(Tokens.RBRACKET);
3065
3066 return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
3067 } else {
3068 return null;
3069 }
3070 },
3071 _pseudo: function() {
3072
3073 var tokenStream = this._tokenStream,
3074 pseudo = null,
3075 colons = ":",
3076 line,
3077 col;
3078
3079 if (tokenStream.match(Tokens.COLON)) {
3080
3081 if (tokenStream.match(Tokens.COLON)) {
3082 colons += ":";
3083 }
3084
3085 if (tokenStream.match(Tokens.IDENT)) {
3086 pseudo = tokenStream.token().value;
3087 line = tokenStream.token().startLine;
3088 col = tokenStream.token().startCol - colons.length;
3089 } else if (tokenStream.peek() === Tokens.FUNCTION) {
3090 line = tokenStream.LT(1).startLine;
3091 col = tokenStream.LT(1).startCol - colons.length;
3092 pseudo = this._functional_pseudo();
3093 }
3094
3095 if (pseudo) {
3096 pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
3097 } else {
3098 var startLine = tokenStream.LT(1).startLine,
3099 startCol = tokenStream.LT(0).startCol;
3100 throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
3101 }
3102 }
3103
3104 return pseudo;
3105 },
3106 _functional_pseudo: function() {
3107
3108 var tokenStream = this._tokenStream,
3109 value = null;
3110
3111 if (tokenStream.match(Tokens.FUNCTION)) {
3112 value = tokenStream.token().value;
3113 value += this._readWhitespace();
3114 value += this._expression();
3115 tokenStream.mustMatch(Tokens.RPAREN);
3116 value += ")";
3117 }
3118
3119 return value;
3120 },
3121 _expression: function() {
3122
3123 var tokenStream = this._tokenStream,
3124 value = "";
3125
3126 while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
3127 Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
3128 Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
3129 Tokens.RESOLUTION, Tokens.SLASH])) {
3130
3131 value += tokenStream.token().value;
3132 value += this._readWhitespace();
3133 }
3134
3135 return value.length ? value : null;
3136
3137 },
3138 _negation: function() {
3139
3140 var tokenStream = this._tokenStream,
3141 line,
3142 col,
3143 value = "",
3144 arg,
3145 subpart = null;
3146
3147 if (tokenStream.match(Tokens.NOT)) {
3148 value = tokenStream.token().value;
3149 line = tokenStream.token().startLine;
3150 col = tokenStream.token().startCol;
3151 value += this._readWhitespace();
3152 arg = this._negation_arg();
3153 value += arg;
3154 value += this._readWhitespace();
3155 tokenStream.match(Tokens.RPAREN);
3156 value += tokenStream.token().value;
3157
3158 subpart = new SelectorSubPart(value, "not", line, col);
3159 subpart.args.push(arg);
3160 }
3161
3162 return subpart;
3163 },
3164 _negation_arg: function() {
3165
3166 var tokenStream = this._tokenStream,
3167 args = [
3168 this._type_selector,
3169 this._universal,
3170 function() {
3171 return tokenStream.match(Tokens.HASH) ?
3172 new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
3173 null;
3174 },
3175 this._class,
3176 this._attrib,
3177 this._pseudo
3178 ],
3179 arg = null,
3180 i = 0,
3181 len = args.length,
3182 line,
3183 col,
3184 part;
3185
3186 line = tokenStream.LT(1).startLine;
3187 col = tokenStream.LT(1).startCol;
3188
3189 while (i < len && arg === null) {
3190
3191 arg = args[i].call(this);
3192 i++;
3193 }
3194 if (arg === null) {
3195 this._unexpectedToken(tokenStream.LT(1));
3196 }
3197 if (arg.type === "elementName") {
3198 part = new SelectorPart(arg, [], arg.toString(), line, col);
3199 } else {
3200 part = new SelectorPart(null, [arg], arg.toString(), line, col);
3201 }
3202
3203 return part;
3204 },
3205
3206 _declaration: function() {
3207
3208 var tokenStream = this._tokenStream,
3209 property = null,
3210 expr = null,
3211 prio = null,
3212 invalid = null,
3213 propertyName = "";
3214
3215 property = this._property();
3216 if (property !== null) {
3217
3218 tokenStream.mustMatch(Tokens.COLON);
3219 this._readWhitespace();
3220
3221 expr = this._expr();
3222 if (!expr || expr.length === 0) {
3223 this._unexpectedToken(tokenStream.LT(1));
3224 }
3225
3226 prio = this._prio();
3227 propertyName = property.toString();
3228 if (this.options.starHack && property.hack === "*" ||
3229 this.options.underscoreHack && property.hack === "_") {
3230
3231 propertyName = property.text;
3232 }
3233
3234 try {
3235 this._validateProperty(propertyName, expr);
3236 } catch (ex) {
3237 invalid = ex;
3238 }
3239
3240 this.fire({
3241 type: "property",
3242 property: property,
3243 value: expr,
3244 important: prio,
3245 line: property.line,
3246 col: property.col,
3247 invalid: invalid
3248 });
3249
3250 return true;
3251 } else {
3252 return false;
3253 }
3254 },
3255
3256 _prio: function() {
3257
3258 var tokenStream = this._tokenStream,
3259 result = tokenStream.match(Tokens.IMPORTANT_SYM);
3260
3261 this._readWhitespace();
3262 return result;
3263 },
3264
3265 _expr: function(inFunction) {
3266
3267 var values = [],
3268 value = null,
3269 operator = null;
3270
3271 value = this._term(inFunction);
3272 if (value !== null) {
3273
3274 values.push(value);
3275
3276 do {
3277 operator = this._operator(inFunction);
3278 if (operator) {
3279 values.push(operator);
3280 } /*else {
3281 values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
3282 valueParts = [];
3283 }*/
3284
3285 value = this._term(inFunction);
3286
3287 if (value === null) {
3288 break;
3289 } else {
3290 values.push(value);
3291 }
3292 } while (true);
3293 }
3294
3295 return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
3296 },
3297
3298 _term: function(inFunction) {
3299
3300 var tokenStream = this._tokenStream,
3301 unary = null,
3302 value = null,
3303 endChar = null,
3304 part = null,
3305 token,
3306 line,
3307 col;
3308 unary = this._unary_operator();
3309 if (unary !== null) {
3310 line = tokenStream.token().startLine;
3311 col = tokenStream.token().startCol;
3312 }
3313 if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
3314
3315 value = this._ie_function();
3316 if (unary === null) {
3317 line = tokenStream.token().startLine;
3318 col = tokenStream.token().startCol;
3319 }
3320 } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
3321
3322 token = tokenStream.token();
3323 endChar = token.endChar;
3324 value = token.value + this._expr(inFunction).text;
3325 if (unary === null) {
3326 line = tokenStream.token().startLine;
3327 col = tokenStream.token().startCol;
3328 }
3329 tokenStream.mustMatch(Tokens.type(endChar));
3330 value += endChar;
3331 this._readWhitespace();
3332 } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
3333 Tokens.ANGLE, Tokens.TIME,
3334 Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) {
3335
3336 value = tokenStream.token().value;
3337 if (unary === null) {
3338 line = tokenStream.token().startLine;
3339 col = tokenStream.token().startCol;
3340 part = PropertyValuePart.fromToken(tokenStream.token());
3341 }
3342 this._readWhitespace();
3343 } else {
3344 token = this._hexcolor();
3345 if (token === null) {
3346 if (unary === null) {
3347 line = tokenStream.LT(1).startLine;
3348 col = tokenStream.LT(1).startCol;
3349 }
3350 if (value === null) {
3351 if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
3352 value = this._ie_function();
3353 } else {
3354 value = this._function();
3355 }
3356 }
3357
3358 } else {
3359 value = token.value;
3360 if (unary === null) {
3361 line = token.startLine;
3362 col = token.startCol;
3363 }
3364 }
3365
3366 }
3367
3368 return part !== null ? part : value !== null ?
3369 new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
3370 null;
3371
3372 },
3373
3374 _function: function() {
3375
3376 var tokenStream = this._tokenStream,
3377 functionText = null,
3378 expr = null,
3379 lt;
3380
3381 if (tokenStream.match(Tokens.FUNCTION)) {
3382 functionText = tokenStream.token().value;
3383 this._readWhitespace();
3384 expr = this._expr(true);
3385 functionText += expr;
3386 if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
3387 do {
3388
3389 if (this._readWhitespace()) {
3390 functionText += tokenStream.token().value;
3391 }
3392 if (tokenStream.LA(0) === Tokens.COMMA) {
3393 functionText += tokenStream.token().value;
3394 }
3395
3396 tokenStream.match(Tokens.IDENT);
3397 functionText += tokenStream.token().value;
3398
3399 tokenStream.match(Tokens.EQUALS);
3400 functionText += tokenStream.token().value;
3401 lt = tokenStream.peek();
3402 while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
3403 tokenStream.get();
3404 functionText += tokenStream.token().value;
3405 lt = tokenStream.peek();
3406 }
3407 } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
3408 }
3409
3410 tokenStream.match(Tokens.RPAREN);
3411 functionText += ")";
3412 this._readWhitespace();
3413 }
3414
3415 return functionText;
3416 },
3417
3418 _ie_function: function() {
3419
3420 var tokenStream = this._tokenStream,
3421 functionText = null,
3422 lt;
3423 if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
3424 functionText = tokenStream.token().value;
3425
3426 do {
3427
3428 if (this._readWhitespace()) {
3429 functionText += tokenStream.token().value;
3430 }
3431 if (tokenStream.LA(0) === Tokens.COMMA) {
3432 functionText += tokenStream.token().value;
3433 }
3434
3435 tokenStream.match(Tokens.IDENT);
3436 functionText += tokenStream.token().value;
3437
3438 tokenStream.match(Tokens.EQUALS);
3439 functionText += tokenStream.token().value;
3440 lt = tokenStream.peek();
3441 while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
3442 tokenStream.get();
3443 functionText += tokenStream.token().value;
3444 lt = tokenStream.peek();
3445 }
3446 } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
3447
3448 tokenStream.match(Tokens.RPAREN);
3449 functionText += ")";
3450 this._readWhitespace();
3451 }
3452
3453 return functionText;
3454 },
3455
3456 _hexcolor: function() {
3457
3458 var tokenStream = this._tokenStream,
3459 token = null,
3460 color;
3461
3462 if (tokenStream.match(Tokens.HASH)) {
3463
3464 token = tokenStream.token();
3465 color = token.value;
3466 if (!/#[a-f0-9]{3,6}/i.test(color)) {
3467 throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
3468 }
3469 this._readWhitespace();
3470 }
3471
3472 return token;
3473 },
3474
3475 _keyframes: function() {
3476 var tokenStream = this._tokenStream,
3477 token,
3478 tt,
3479 name,
3480 prefix = "";
3481
3482 tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
3483 token = tokenStream.token();
3484 if (/^@-([^-]+)-/.test(token.value)) {
3485 prefix = RegExp.$1;
3486 }
3487
3488 this._readWhitespace();
3489 name = this._keyframe_name();
3490
3491 this._readWhitespace();
3492 tokenStream.mustMatch(Tokens.LBRACE);
3493
3494 this.fire({
3495 type: "startkeyframes",
3496 name: name,
3497 prefix: prefix,
3498 line: token.startLine,
3499 col: token.startCol
3500 });
3501
3502 this._readWhitespace();
3503 tt = tokenStream.peek();
3504 while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
3505 this._keyframe_rule();
3506 this._readWhitespace();
3507 tt = tokenStream.peek();
3508 }
3509
3510 this.fire({
3511 type: "endkeyframes",
3512 name: name,
3513 prefix: prefix,
3514 line: token.startLine,
3515 col: token.startCol
3516 });
3517
3518 this._readWhitespace();
3519 tokenStream.mustMatch(Tokens.RBRACE);
3520 this._readWhitespace();
3521
3522 },
3523
3524 _keyframe_name: function() {
3525 var tokenStream = this._tokenStream;
3526
3527 tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
3528 return SyntaxUnit.fromToken(tokenStream.token());
3529 },
3530
3531 _keyframe_rule: function() {
3532 var keyList = this._key_list();
3533
3534 this.fire({
3535 type: "startkeyframerule",
3536 keys: keyList,
3537 line: keyList[0].line,
3538 col: keyList[0].col
3539 });
3540
3541 this._readDeclarations(true);
3542
3543 this.fire({
3544 type: "endkeyframerule",
3545 keys: keyList,
3546 line: keyList[0].line,
3547 col: keyList[0].col
3548 });
3549
3550 },
3551
3552 _key_list: function() {
3553 var tokenStream = this._tokenStream,
3554 keyList = [];
3555 keyList.push(this._key());
3556
3557 this._readWhitespace();
3558
3559 while (tokenStream.match(Tokens.COMMA)) {
3560 this._readWhitespace();
3561 keyList.push(this._key());
3562 this._readWhitespace();
3563 }
3564
3565 return keyList;
3566 },
3567
3568 _key: function() {
3569
3570 var tokenStream = this._tokenStream,
3571 token;
3572
3573 if (tokenStream.match(Tokens.PERCENTAGE)) {
3574 return SyntaxUnit.fromToken(tokenStream.token());
3575 } else if (tokenStream.match(Tokens.IDENT)) {
3576 token = tokenStream.token();
3577
3578 if (/from|to/i.test(token.value)) {
3579 return SyntaxUnit.fromToken(token);
3580 }
3581
3582 tokenStream.unget();
3583 }
3584 this._unexpectedToken(tokenStream.LT(1));
3585 },
3586 _skipCruft: function() {
3587 while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
3588 }
3589 },
3590 _readDeclarations: function(checkStart, readMargins) {
3591 var tokenStream = this._tokenStream,
3592 tt;
3593
3594
3595 this._readWhitespace();
3596
3597 if (checkStart) {
3598 tokenStream.mustMatch(Tokens.LBRACE);
3599 }
3600
3601 this._readWhitespace();
3602
3603 try {
3604
3605 while (true) {
3606
3607 if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
3608 } else if (this._declaration()) {
3609 if (!tokenStream.match(Tokens.SEMICOLON)) {
3610 break;
3611 }
3612 } else {
3613 break;
3614 }
3615 this._readWhitespace();
3616 }
3617
3618 tokenStream.mustMatch(Tokens.RBRACE);
3619 this._readWhitespace();
3620
3621 } catch (ex) {
3622 if (ex instanceof SyntaxError && !this.options.strict) {
3623 this.fire({
3624 type: "error",
3625 error: ex,
3626 message: ex.message,
3627 line: ex.line,
3628 col: ex.col
3629 });
3630 tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
3631 if (tt === Tokens.SEMICOLON) {
3632 this._readDeclarations(false, readMargins);
3633 } else if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
3634 throw ex;
3635 }
3636
3637 } else {
3638 throw ex;
3639 }
3640 }
3641
3642 },
3643 _readWhitespace: function() {
3644
3645 var tokenStream = this._tokenStream,
3646 ws = "";
3647
3648 while (tokenStream.match(Tokens.S)) {
3649 ws += tokenStream.token().value;
3650 }
3651
3652 return ws;
3653 },
3654 _unexpectedToken: function(token) {
3655 throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
3656 },
3657 _verifyEnd: function() {
3658 if (this._tokenStream.LA(1) !== Tokens.EOF) {
3659 this._unexpectedToken(this._tokenStream.LT(1));
3660 }
3661 },
3662 _validateProperty: function(property, value) {
3663 Validation.validate(property, value);
3664 },
3665
3666 parse: function(input) {
3667 this._tokenStream = new TokenStream(input, Tokens);
3668 this._stylesheet();
3669 },
3670
3671 parseStyleSheet: function(input) {
3672 return this.parse(input);
3673 },
3674
3675 parseMediaQuery: function(input) {
3676 this._tokenStream = new TokenStream(input, Tokens);
3677 var result = this._media_query();
3678 this._verifyEnd();
3679 return result;
3680 },
3681 parsePropertyValue: function(input) {
3682
3683 this._tokenStream = new TokenStream(input, Tokens);
3684 this._readWhitespace();
3685
3686 var result = this._expr();
3687 this._readWhitespace();
3688 this._verifyEnd();
3689 return result;
3690 },
3691 parseRule: function(input) {
3692 this._tokenStream = new TokenStream(input, Tokens);
3693 this._readWhitespace();
3694
3695 var result = this._ruleset();
3696 this._readWhitespace();
3697 this._verifyEnd();
3698 return result;
3699 },
3700 parseSelector: function(input) {
3701
3702 this._tokenStream = new TokenStream(input, Tokens);
3703 this._readWhitespace();
3704
3705 var result = this._selector();
3706 this._readWhitespace();
3707 this._verifyEnd();
3708 return result;
3709 },
3710 parseStyleAttribute: function(input) {
3711 input += "}"; // for error recovery in _readDeclarations()
3712 this._tokenStream = new TokenStream(input, Tokens);
3713 this._readDeclarations();
3714 }
3715 };
3716 for (prop in additions) {
3717 if (Object.prototype.hasOwnProperty.call(additions, prop)) {
3718 proto[prop] = additions[prop];
3719 }
3720 }
3721
3722 return proto;
3723 }();
3724
3725 },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){
3726
3727 "use strict";
3728
3729 var Properties = module.exports = {
3730 __proto__: null,
3731 "align-items" : "flex-start | flex-end | center | baseline | stretch",
3732 "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
3733 "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
3734 "all" : "initial | inherit | unset",
3735 "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
3736 "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
3737 "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
3738 "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
3739 "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3740 "animation" : 1,
3741 "animation-delay" : "<time>#",
3742 "animation-direction" : "<single-animation-direction>#",
3743 "animation-duration" : "<time>#",
3744 "animation-fill-mode" : "[ none | forwards | backwards | both ]#",
3745 "animation-iteration-count" : "[ <number> | infinite ]#",
3746 "animation-name" : "[ none | <single-animation-name> ]#",
3747 "animation-play-state" : "[ running | paused ]#",
3748 "animation-timing-function" : 1,
3749 "-moz-animation-delay" : "<time>#",
3750 "-moz-animation-direction" : "[ normal | alternate ]#",
3751 "-moz-animation-duration" : "<time>#",
3752 "-moz-animation-iteration-count" : "[ <number> | infinite ]#",
3753 "-moz-animation-name" : "[ none | <single-animation-name> ]#",
3754 "-moz-animation-play-state" : "[ running | paused ]#",
3755
3756 "-ms-animation-delay" : "<time>#",
3757 "-ms-animation-direction" : "[ normal | alternate ]#",
3758 "-ms-animation-duration" : "<time>#",
3759 "-ms-animation-iteration-count" : "[ <number> | infinite ]#",
3760 "-ms-animation-name" : "[ none | <single-animation-name> ]#",
3761 "-ms-animation-play-state" : "[ running | paused ]#",
3762
3763 "-webkit-animation-delay" : "<time>#",
3764 "-webkit-animation-direction" : "[ normal | alternate ]#",
3765 "-webkit-animation-duration" : "<time>#",
3766 "-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
3767 "-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
3768 "-webkit-animation-name" : "[ none | <single-animation-name> ]#",
3769 "-webkit-animation-play-state" : "[ running | paused ]#",
3770
3771 "-o-animation-delay" : "<time>#",
3772 "-o-animation-direction" : "[ normal | alternate ]#",
3773 "-o-animation-duration" : "<time>#",
3774 "-o-animation-iteration-count" : "[ <number> | infinite ]#",
3775 "-o-animation-name" : "[ none | <single-animation-name> ]#",
3776 "-o-animation-play-state" : "[ running | paused ]#",
3777
3778 "appearance" : "none | auto",
3779 "-moz-appearance" : "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized",
3780 "-ms-appearance" : "none | icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
3781 "-webkit-appearance" : "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical",
3782 "-o-appearance" : "none | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
3783
3784 "azimuth" : "<azimuth>",
3785 "backface-visibility" : "visible | hidden",
3786 "background" : 1,
3787 "background-attachment" : "<attachment>#",
3788 "background-clip" : "<box>#",
3789 "background-color" : "<color>",
3790 "background-image" : "<bg-image>#",
3791 "background-origin" : "<box>#",
3792 "background-position" : "<bg-position>",
3793 "background-repeat" : "<repeat-style>#",
3794 "background-size" : "<bg-size>#",
3795 "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
3796 "behavior" : 1,
3797 "binding" : 1,
3798 "bleed" : "<length>",
3799 "bookmark-label" : "<content> | <attr> | <string>",
3800 "bookmark-level" : "none | <integer>",
3801 "bookmark-state" : "open | closed",
3802 "bookmark-target" : "none | <uri> | <attr>",
3803 "border" : "<border-width> || <border-style> || <color>",
3804 "border-bottom" : "<border-width> || <border-style> || <color>",
3805 "border-bottom-color" : "<color>",
3806 "border-bottom-left-radius" : "<x-one-radius>",
3807 "border-bottom-right-radius" : "<x-one-radius>",
3808 "border-bottom-style" : "<border-style>",
3809 "border-bottom-width" : "<border-width>",
3810 "border-collapse" : "collapse | separate",
3811 "border-color" : "<color>{1,4}",
3812 "border-image" : 1,
3813 "border-image-outset" : "[ <length> | <number> ]{1,4}",
3814 "border-image-repeat" : "[ stretch | repeat | round | space ]{1,2}",
3815 "border-image-slice" : "<border-image-slice>",
3816 "border-image-source" : "<image> | none",
3817 "border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
3818 "border-left" : "<border-width> || <border-style> || <color>",
3819 "border-left-color" : "<color>",
3820 "border-left-style" : "<border-style>",
3821 "border-left-width" : "<border-width>",
3822 "border-radius" : "<border-radius>",
3823 "border-right" : "<border-width> || <border-style> || <color>",
3824 "border-right-color" : "<color>",
3825 "border-right-style" : "<border-style>",
3826 "border-right-width" : "<border-width>",
3827 "border-spacing" : "<length>{1,2}",
3828 "border-style" : "<border-style>{1,4}",
3829 "border-top" : "<border-width> || <border-style> || <color>",
3830 "border-top-color" : "<color>",
3831 "border-top-left-radius" : "<x-one-radius>",
3832 "border-top-right-radius" : "<x-one-radius>",
3833 "border-top-style" : "<border-style>",
3834 "border-top-width" : "<border-width>",
3835 "border-width" : "<border-width>{1,4}",
3836 "bottom" : "<margin-width>",
3837 "-moz-box-align" : "start | end | center | baseline | stretch",
3838 "-moz-box-decoration-break" : "slice | clone",
3839 "-moz-box-direction" : "normal | reverse",
3840 "-moz-box-flex" : "<number>",
3841 "-moz-box-flex-group" : "<integer>",
3842 "-moz-box-lines" : "single | multiple",
3843 "-moz-box-ordinal-group" : "<integer>",
3844 "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
3845 "-moz-box-pack" : "start | end | center | justify",
3846 "-o-box-decoration-break" : "slice | clone",
3847 "-webkit-box-align" : "start | end | center | baseline | stretch",
3848 "-webkit-box-decoration-break" : "slice | clone",
3849 "-webkit-box-direction" : "normal | reverse",
3850 "-webkit-box-flex" : "<number>",
3851 "-webkit-box-flex-group" : "<integer>",
3852 "-webkit-box-lines" : "single | multiple",
3853 "-webkit-box-ordinal-group" : "<integer>",
3854 "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
3855 "-webkit-box-pack" : "start | end | center | justify",
3856 "box-decoration-break" : "slice | clone",
3857 "box-shadow" : "<box-shadow>",
3858 "box-sizing" : "content-box | border-box",
3859 "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3860 "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
3861 "break-inside" : "auto | avoid | avoid-page | avoid-column",
3862 "caption-side" : "top | bottom",
3863 "clear" : "none | right | left | both",
3864 "clip" : "<shape> | auto",
3865 "-webkit-clip-path" : "<clip-source> | <clip-path> | none",
3866 "clip-path" : "<clip-source> | <clip-path> | none",
3867 "clip-rule" : "nonzero | evenodd",
3868 "color" : "<color>",
3869 "color-interpolation" : "auto | sRGB | linearRGB",
3870 "color-interpolation-filters" : "auto | sRGB | linearRGB",
3871 "color-profile" : 1,
3872 "color-rendering" : "auto | optimizeSpeed | optimizeQuality",
3873 "column-count" : "<integer> | auto", // https ://www.w3.org/TR/css3-multicol/
3874 "column-fill" : "auto | balance",
3875 "column-gap" : "<length> | normal",
3876 "column-rule" : "<border-width> || <border-style> || <color>",
3877 "column-rule-color" : "<color>",
3878 "column-rule-style" : "<border-style>",
3879 "column-rule-width" : "<border-width>",
3880 "column-span" : "none | all",
3881 "column-width" : "<length> | auto",
3882 "columns" : 1,
3883 "content" : 1,
3884 "counter-increment" : 1,
3885 "counter-reset" : 1,
3886 "crop" : "<shape> | auto",
3887 "cue" : "cue-after | cue-before",
3888 "cue-after" : 1,
3889 "cue-before" : 1,
3890 "cursor" : 1,
3891 "direction" : "ltr | rtl",
3892 "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
3893 "dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
3894 "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
3895 "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3896 "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
3897 "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
3898 "drop-initial-size" : "auto | line | <length> | <percentage>",
3899 "drop-initial-value" : "<integer>",
3900 "elevation" : "<angle> | below | level | above | higher | lower",
3901 "empty-cells" : "show | hide",
3902 "enable-background" : 1,
3903 "fill" : "<paint>",
3904 "fill-opacity" : "<opacity-value>",
3905 "fill-rule" : "nonzero | evenodd",
3906 "filter" : "<filter-function-list> | none",
3907 "fit" : "fill | hidden | meet | slice",
3908 "fit-position" : 1,
3909 "flex" : "<flex>",
3910 "flex-basis" : "<width>",
3911 "flex-direction" : "row | row-reverse | column | column-reverse",
3912 "flex-flow" : "<flex-direction> || <flex-wrap>",
3913 "flex-grow" : "<number>",
3914 "flex-shrink" : "<number>",
3915 "flex-wrap" : "nowrap | wrap | wrap-reverse",
3916 "-webkit-flex" : "<flex>",
3917 "-webkit-flex-basis" : "<width>",
3918 "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
3919 "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
3920 "-webkit-flex-grow" : "<number>",
3921 "-webkit-flex-shrink" : "<number>",
3922 "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
3923 "-ms-flex" : "<flex>",
3924 "-ms-flex-align" : "start | end | center | stretch | baseline",
3925 "-ms-flex-direction" : "row | row-reverse | column | column-reverse",
3926 "-ms-flex-order" : "<number>",
3927 "-ms-flex-pack" : "start | end | center | justify | distribute",
3928 "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
3929 "float" : "left | right | none",
3930 "float-offset" : 1,
3931 "flood-color" : 1,
3932 "flood-opacity" : "<opacity-value>",
3933 "font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar",
3934 "font-family" : "<font-family>",
3935 "font-feature-settings" : "<feature-tag-value> | normal",
3936 "font-kerning" : "auto | normal | none",
3937 "font-size" : "<font-size>",
3938 "font-size-adjust" : "<number> | none",
3939 "font-stretch" : "<font-stretch>",
3940 "font-style" : "<font-style>",
3941 "font-variant" : "<font-variant> | normal | none",
3942 "font-variant-alternates" : "<font-variant-alternates> | normal",
3943 "font-variant-caps" : "<font-variant-caps> | normal",
3944 "font-variant-east-asian" : "<font-variant-east-asian> | normal",
3945 "font-variant-ligatures" : "<font-variant-ligatures> | normal | none",
3946 "font-variant-numeric" : "<font-variant-numeric> | normal",
3947 "font-variant-position" : "normal | sub | super",
3948 "font-weight" : "<font-weight>",
3949 "gap" : "[ <length> | <percentage> ]{1,2}",
3950 "glyph-orientation-horizontal" : "<glyph-angle>",
3951 "glyph-orientation-vertical" : "auto | <glyph-angle>",
3952 "grid" : 1,
3953 "grid-area" : 1,
3954 "grid-auto-columns" : 1,
3955 "grid-auto-flow" : 1,
3956 "grid-auto-position" : 1,
3957 "grid-auto-rows" : 1,
3958 "grid-cell-stacking" : "columns | rows | layer",
3959 "grid-column" : 1,
3960 "grid-columns" : 1,
3961 "grid-column-align" : "start | end | center | stretch",
3962 "grid-column-sizing" : 1,
3963 "grid-column-start" : 1,
3964 "grid-column-end" : 1,
3965 "grid-column-span" : "<integer>",
3966 "grid-flow" : "none | rows | columns",
3967 "grid-gap" : "[ <length> | <percentage> ]{1,2}",
3968 "grid-layer" : "<integer>",
3969 "grid-row" : 1,
3970 "grid-rows" : 1,
3971 "grid-row-align" : "start | end | center | stretch",
3972 "grid-row-gap" : 1,
3973 "grid-row-start" : 1,
3974 "grid-row-end" : 1,
3975 "grid-row-span" : "<integer>",
3976 "grid-row-sizing" : 1,
3977 "grid-template" : 1,
3978 "grid-template-areas" : 1,
3979 "grid-template-columns" : 1,
3980 "grid-template-rows" : 1,
3981 "hanging-punctuation" : 1,
3982 "height" : "<margin-width> | <content-sizing>",
3983 "hyphenate-after" : "<integer> | auto",
3984 "hyphenate-before" : "<integer> | auto",
3985 "hyphenate-character" : "<string> | auto",
3986 "hyphenate-lines" : "no-limit | <integer>",
3987 "hyphenate-resource" : 1,
3988 "hyphens" : "none | manual | auto",
3989 "icon" : 1,
3990 "image-orientation" : "angle | auto",
3991 "image-rendering" : "auto | optimizeSpeed | optimizeQuality",
3992 "image-resolution" : 1,
3993 "ime-mode" : "auto | normal | active | inactive | disabled",
3994 "inline-box-align" : "last | <integer>",
3995 "justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
3996 "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
3997 "kerning" : "auto | <length>",
3998 "left" : "<margin-width>",
3999 "letter-spacing" : "<length> | normal",
4000 "line-height" : "<line-height>",
4001 "line-break" : "auto | loose | normal | strict",
4002 "line-stacking" : 1,
4003 "line-stacking-ruby" : "exclude-ruby | include-ruby",
4004 "line-stacking-shift" : "consider-shifts | disregard-shifts",
4005 "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
4006 "list-style" : 1,
4007 "list-style-image" : "<uri> | none",
4008 "list-style-position" : "inside | outside",
4009 "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",
4010 "margin" : "<margin-width>{1,4}",
4011 "margin-bottom" : "<margin-width>",
4012 "margin-left" : "<margin-width>",
4013 "margin-right" : "<margin-width>",
4014 "margin-top" : "<margin-width>",
4015 "mark" : 1,
4016 "mark-after" : 1,
4017 "mark-before" : 1,
4018 "marker" : 1,
4019 "marker-end" : 1,
4020 "marker-mid" : 1,
4021 "marker-start" : 1,
4022 "marks" : 1,
4023 "marquee-direction" : 1,
4024 "marquee-play-count" : 1,
4025 "marquee-speed" : 1,
4026 "marquee-style" : 1,
4027 "mask" : 1,
4028 "max-height" : "<length> | <percentage> | <content-sizing> | none",
4029 "max-width" : "<length> | <percentage> | <content-sizing> | none",
4030 "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
4031 "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
4032 "mix-blend-mode" : "<blend-mode>",
4033 "move-to" : 1,
4034 "nav-down" : 1,
4035 "nav-index" : 1,
4036 "nav-left" : 1,
4037 "nav-right" : 1,
4038 "nav-up" : 1,
4039 "object-fit" : "fill | contain | cover | none | scale-down",
4040 "object-position" : "<position>",
4041 "opacity" : "<opacity-value>",
4042 "order" : "<integer>",
4043 "-webkit-order" : "<integer>",
4044 "orphans" : "<integer>",
4045 "outline" : 1,
4046 "outline-color" : "<color> | invert",
4047 "outline-offset" : 1,
4048 "outline-style" : "<border-style>",
4049 "outline-width" : "<border-width>",
4050 "overflow" : "visible | hidden | scroll | auto",
4051 "overflow-style" : 1,
4052 "overflow-wrap" : "normal | break-word",
4053 "overflow-x" : 1,
4054 "overflow-y" : 1,
4055 "padding" : "<padding-width>{1,4}",
4056 "padding-bottom" : "<padding-width>",
4057 "padding-left" : "<padding-width>",
4058 "padding-right" : "<padding-width>",
4059 "padding-top" : "<padding-width>",
4060 "page" : 1,
4061 "page-break-after" : "auto | always | avoid | left | right",
4062 "page-break-before" : "auto | always | avoid | left | right",
4063 "page-break-inside" : "auto | avoid",
4064 "page-policy" : 1,
4065 "pause" : 1,
4066 "pause-after" : 1,
4067 "pause-before" : 1,
4068 "perspective" : 1,
4069 "perspective-origin" : 1,
4070 "phonemes" : 1,
4071 "pitch" : 1,
4072 "pitch-range" : 1,
4073 "play-during" : 1,
4074 "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",
4075 "position" : "static | relative | absolute | fixed | sticky | -webkit-sticky",
4076 "presentation-level" : 1,
4077 "punctuation-trim" : 1,
4078 "quotes" : 1,
4079 "rendering-intent" : 1,
4080 "resize" : 1,
4081 "rest" : 1,
4082 "rest-after" : 1,
4083 "rest-before" : 1,
4084 "richness" : 1,
4085 "right" : "<margin-width>",
4086 "rotation" : 1,
4087 "rotation-point" : 1,
4088 "ruby-align" : 1,
4089 "ruby-overhang" : 1,
4090 "ruby-position" : 1,
4091 "ruby-span" : 1,
4092 "shape-rendering" : "auto | optimizeSpeed | crispEdges | geometricPrecision",
4093 "size" : 1,
4094 "speak" : "normal | none | spell-out",
4095 "speak-header" : "once | always",
4096 "speak-numeral" : "digits | continuous",
4097 "speak-punctuation" : "code | none",
4098 "speech-rate" : 1,
4099 "src" : 1,
4100 "stop-color" : 1,
4101 "stop-opacity" : "<opacity-value>",
4102 "stress" : 1,
4103 "string-set" : 1,
4104 "stroke" : "<paint>",
4105 "stroke-dasharray" : "none | <dasharray>",
4106 "stroke-dashoffset" : "<percentage> | <length>",
4107 "stroke-linecap" : "butt | round | square",
4108 "stroke-linejoin" : "miter | round | bevel",
4109 "stroke-miterlimit" : "<miterlimit>",
4110 "stroke-opacity" : "<opacity-value>",
4111 "stroke-width" : "<percentage> | <length>",
4112
4113 "table-layout" : "auto | fixed",
4114 "tab-size" : "<integer> | <length>",
4115 "target" : 1,
4116 "target-name" : 1,
4117 "target-new" : 1,
4118 "target-position" : 1,
4119 "text-align" : "left | right | center | justify | match-parent | start | end",
4120 "text-align-last" : 1,
4121 "text-anchor" : "start | middle | end",
4122 "text-decoration" : "<text-decoration-line> || <text-decoration-style> || <text-decoration-color>",
4123 "text-decoration-color" : "<text-decoration-color>",
4124 "text-decoration-line" : "<text-decoration-line>",
4125 "text-decoration-style" : "<text-decoration-style>",
4126 "text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
4127 "-webkit-text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
4128 "text-underline-position" : "auto | [ under || [ left | right ] ]",
4129 "text-emphasis" : 1,
4130 "text-height" : 1,
4131 "text-indent" : "<length> | <percentage>",
4132 "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
4133 "text-outline" : 1,
4134 "text-overflow" : 1,
4135 "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision",
4136 "text-shadow" : 1,
4137 "text-transform" : "capitalize | uppercase | lowercase | none",
4138 "text-wrap" : "normal | none | avoid",
4139 "top" : "<margin-width>",
4140 "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
4141 "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
4142 "transform" : 1,
4143 "transform-origin" : 1,
4144 "transform-style" : 1,
4145 "transition" : 1,
4146 "transition-delay" : 1,
4147 "transition-duration" : 1,
4148 "transition-property" : 1,
4149 "transition-timing-function" : 1,
4150 "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext",
4151 "user-modify" : "read-only | read-write | write-only",
4152 "user-select" : "auto | text | none | contain | all",
4153 "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
4154 "visibility" : "visible | hidden | collapse",
4155 "voice-balance" : 1,
4156 "voice-duration" : 1,
4157 "voice-family" : 1,
4158 "voice-pitch" : 1,
4159 "voice-pitch-range" : 1,
4160 "voice-rate" : 1,
4161 "voice-stress" : 1,
4162 "voice-volume" : 1,
4163 "volume" : 1,
4164 "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", // https ://perishablepress.com/wrapping-content/
4165 "white-space-collapse" : 1,
4166 "widows" : "<integer>",
4167 "width" : "<length> | <percentage> | <content-sizing> | auto",
4168 "will-change" : "<will-change>",
4169 "word-break" : "normal | keep-all | break-all | break-word",
4170 "word-spacing" : "<length> | normal",
4171 "word-wrap" : "normal | break-word",
4172 "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb",
4173 "z-index" : "<integer> | auto",
4174 "zoom" : "<number> | <percentage> | normal"
4175 };
4176
4177 },{}],8:[function(require,module,exports){
4178 "use strict";
4179
4180 module.exports = PropertyName;
4181
4182 var SyntaxUnit = require("../util/SyntaxUnit");
4183
4184 var Parser = require("./Parser");
4185 function PropertyName(text, hack, line, col) {
4186
4187 SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
4188 this.hack = hack;
4189
4190 }
4191
4192 PropertyName.prototype = new SyntaxUnit();
4193 PropertyName.prototype.constructor = PropertyName;
4194 PropertyName.prototype.toString = function() {
4195 return (this.hack ? this.hack : "") + this.text;
4196 };
4197
4198 },{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(require,module,exports){
4199 "use strict";
4200
4201 module.exports = PropertyValue;
4202
4203 var SyntaxUnit = require("../util/SyntaxUnit");
4204
4205 var Parser = require("./Parser");
4206 function PropertyValue(parts, line, col) {
4207
4208 SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
4209 this.parts = parts;
4210
4211 }
4212
4213 PropertyValue.prototype = new SyntaxUnit();
4214 PropertyValue.prototype.constructor = PropertyValue;
4215
4216
4217 },{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(require,module,exports){
4218 "use strict";
4219
4220 module.exports = PropertyValueIterator;
4221 function PropertyValueIterator(value) {
4222 this._i = 0;
4223 this._parts = value.parts;
4224 this._marks = [];
4225 this.value = value;
4226
4227 }
4228 PropertyValueIterator.prototype.count = function() {
4229 return this._parts.length;
4230 };
4231 PropertyValueIterator.prototype.isFirst = function() {
4232 return this._i === 0;
4233 };
4234 PropertyValueIterator.prototype.hasNext = function() {
4235 return this._i < this._parts.length;
4236 };
4237 PropertyValueIterator.prototype.mark = function() {
4238 this._marks.push(this._i);
4239 };
4240 PropertyValueIterator.prototype.peek = function(count) {
4241 return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
4242 };
4243 PropertyValueIterator.prototype.next = function() {
4244 return this.hasNext() ? this._parts[this._i++] : null;
4245 };
4246 PropertyValueIterator.prototype.previous = function() {
4247 return this._i > 0 ? this._parts[--this._i] : null;
4248 };
4249 PropertyValueIterator.prototype.restore = function() {
4250 if (this._marks.length) {
4251 this._i = this._marks.pop();
4252 }
4253 };
4254 PropertyValueIterator.prototype.drop = function() {
4255 this._marks.pop();
4256 };
4257
4258 },{}],11:[function(require,module,exports){
4259 "use strict";
4260
4261 module.exports = PropertyValuePart;
4262
4263 var SyntaxUnit = require("../util/SyntaxUnit");
4264
4265 var Colors = require("./Colors");
4266 var Parser = require("./Parser");
4267 var Tokens = require("./Tokens");
4268 function PropertyValuePart(text, line, col, optionalHint) {
4269 var hint = optionalHint || {};
4270
4271 SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
4272 this.type = "unknown";
4273
4274 var temp;
4275 if (/^([+-]?[\d.]+)([a-z]+)$/i.test(text)) { // dimension
4276 this.type = "dimension";
4277 this.value = Number(RegExp.$1);
4278 this.units = RegExp.$2;
4279 switch (this.units.toLowerCase()) {
4280
4281 case "em":
4282 case "rem":
4283 case "ex":
4284 case "px":
4285 case "cm":
4286 case "mm":
4287 case "in":
4288 case "pt":
4289 case "pc":
4290 case "ch":
4291 case "vh":
4292 case "vw":
4293 case "vmax":
4294 case "vmin":
4295 this.type = "length";
4296 break;
4297
4298 case "fr":
4299 this.type = "grid";
4300 break;
4301
4302 case "deg":
4303 case "rad":
4304 case "grad":
4305 case "turn":
4306 this.type = "angle";
4307 break;
4308
4309 case "ms":
4310 case "s":
4311 this.type = "time";
4312 break;
4313
4314 case "hz":
4315 case "khz":
4316 this.type = "frequency";
4317 break;
4318
4319 case "dpi":
4320 case "dpcm":
4321 this.type = "resolution";
4322 break;
4323
4324 }
4325
4326 } else if (/^([+-]?[\d.]+)%$/i.test(text)) { // percentage
4327 this.type = "percentage";
4328 this.value = Number(RegExp.$1);
4329 } else if (/^([+-]?\d+)$/i.test(text)) { // integer
4330 this.type = "integer";
4331 this.value = Number(RegExp.$1);
4332 } else if (/^([+-]?[\d.]+)$/i.test(text)) { // number
4333 this.type = "number";
4334 this.value = Number(RegExp.$1);
4335
4336 } else if (/^#([a-f0-9]{3,6})/i.test(text)) { // hexcolor
4337 this.type = "color";
4338 temp = RegExp.$1;
4339 if (temp.length === 3) {
4340 this.red = parseInt(temp.charAt(0) + temp.charAt(0), 16);
4341 this.green = parseInt(temp.charAt(1) + temp.charAt(1), 16);
4342 this.blue = parseInt(temp.charAt(2) + temp.charAt(2), 16);
4343 } else {
4344 this.red = parseInt(temp.substring(0, 2), 16);
4345 this.green = parseInt(temp.substring(2, 4), 16);
4346 this.blue = parseInt(temp.substring(4, 6), 16);
4347 }
4348 } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { // rgb() color with absolute numbers
4349 this.type = "color";
4350 this.red = Number(RegExp.$1);
4351 this.green = Number(RegExp.$2);
4352 this.blue = Number(RegExp.$3);
4353 } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // rgb() color with percentages
4354 this.type = "color";
4355 this.red = Number(RegExp.$1) * 255 / 100;
4356 this.green = Number(RegExp.$2) * 255 / 100;
4357 this.blue = Number(RegExp.$3) * 255 / 100;
4358 } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with absolute numbers
4359 this.type = "color";
4360 this.red = Number(RegExp.$1);
4361 this.green = Number(RegExp.$2);
4362 this.blue = Number(RegExp.$3);
4363 this.alpha = Number(RegExp.$4);
4364 } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with percentages
4365 this.type = "color";
4366 this.red = Number(RegExp.$1) * 255 / 100;
4367 this.green = Number(RegExp.$2) * 255 / 100;
4368 this.blue = Number(RegExp.$3) * 255 / 100;
4369 this.alpha = Number(RegExp.$4);
4370 } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // hsl()
4371 this.type = "color";
4372 this.hue = Number(RegExp.$1);
4373 this.saturation = Number(RegExp.$2) / 100;
4374 this.lightness = Number(RegExp.$3) / 100;
4375 } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // hsla() color with percentages
4376 this.type = "color";
4377 this.hue = Number(RegExp.$1);
4378 this.saturation = Number(RegExp.$2) / 100;
4379 this.lightness = Number(RegExp.$3) / 100;
4380 this.alpha = Number(RegExp.$4);
4381 } else if (/^url\(("([^\\"]|\.)*")\)/i.test(text)) { // URI
4382 this.type = "uri";
4383 this.uri = PropertyValuePart.parseString(RegExp.$1);
4384 } else if (/^([^(]+)\(/i.test(text)) {
4385 this.type = "function";
4386 this.name = RegExp.$1;
4387 this.value = text;
4388 } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { // double-quoted string
4389 this.type = "string";
4390 this.value = PropertyValuePart.parseString(text);
4391 } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { // single-quoted string
4392 this.type = "string";
4393 this.value = PropertyValuePart.parseString(text);
4394 } else if (Colors[text.toLowerCase()]) { // named color
4395 this.type = "color";
4396 temp = Colors[text.toLowerCase()].substring(1);
4397 this.red = parseInt(temp.substring(0, 2), 16);
4398 this.green = parseInt(temp.substring(2, 4), 16);
4399 this.blue = parseInt(temp.substring(4, 6), 16);
4400 } else if (/^[,/]$/.test(text)) {
4401 this.type = "operator";
4402 this.value = text;
4403 } else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
4404 this.type = "identifier";
4405 this.value = text;
4406 }
4407 this.wasIdent = Boolean(hint.ident);
4408
4409 }
4410
4411 PropertyValuePart.prototype = new SyntaxUnit();
4412 PropertyValuePart.prototype.constructor = PropertyValuePart;
4413 PropertyValuePart.parseString = function(str) {
4414 str = str.slice(1, -1); // Strip surrounding single/double quotes
4415 var replacer = function(match, esc) {
4416 if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
4417 return "";
4418 }
4419 var m = /^[0-9a-f]{1,6}/i.exec(esc);
4420 if (m) {
4421 var codePoint = parseInt(m[0], 16);
4422 if (String.fromCodePoint) {
4423 return String.fromCodePoint(codePoint);
4424 } else {
4425 return String.fromCharCode(codePoint);
4426 }
4427 }
4428 return esc;
4429 };
4430 return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
4431 replacer);
4432 };
4433 PropertyValuePart.serializeString = function(value) {
4434 var replacer = function(match, c) {
4435 if (c === "\"") {
4436 return "\\" + c;
4437 }
4438 var cp = String.codePointAt ? String.codePointAt(0) :
4439 String.charCodeAt(0);
4440 return "\\" + cp.toString(16) + " ";
4441 };
4442 return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
4443 };
4444 PropertyValuePart.fromToken = function(token) {
4445 var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
4446 ident: token.type === Tokens.IDENT
4447 });
4448 return part;
4449 };
4450
4451 },{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
4452 "use strict";
4453
4454 var Pseudos = module.exports = {
4455 __proto__: null,
4456 ":first-letter": 1,
4457 ":first-line": 1,
4458 ":before": 1,
4459 ":after": 1
4460 };
4461
4462 Pseudos.ELEMENT = 1;
4463 Pseudos.CLASS = 2;
4464
4465 Pseudos.isElement = function(pseudo) {
4466 return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
4467 };
4468
4469 },{}],13:[function(require,module,exports){
4470 "use strict";
4471
4472 module.exports = Selector;
4473
4474 var SyntaxUnit = require("../util/SyntaxUnit");
4475
4476 var Parser = require("./Parser");
4477 var Specificity = require("./Specificity");
4478 function Selector(parts, line, col) {
4479
4480 SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
4481 this.parts = parts;
4482 this.specificity = Specificity.calculate(this);
4483
4484 }
4485
4486 Selector.prototype = new SyntaxUnit();
4487 Selector.prototype.constructor = Selector;
4488
4489
4490 },{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
4491 "use strict";
4492
4493 module.exports = SelectorPart;
4494
4495 var SyntaxUnit = require("../util/SyntaxUnit");
4496
4497 var Parser = require("./Parser");
4498 function SelectorPart(elementName, modifiers, text, line, col) {
4499
4500 SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
4501 this.elementName = elementName;
4502 this.modifiers = modifiers;
4503
4504 }
4505
4506 SelectorPart.prototype = new SyntaxUnit();
4507 SelectorPart.prototype.constructor = SelectorPart;
4508
4509
4510 },{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
4511 "use strict";
4512
4513 module.exports = SelectorSubPart;
4514
4515 var SyntaxUnit = require("../util/SyntaxUnit");
4516
4517 var Parser = require("./Parser");
4518 function SelectorSubPart(text, type, line, col) {
4519
4520 SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
4521 this.type = type;
4522 this.args = [];
4523
4524 }
4525
4526 SelectorSubPart.prototype = new SyntaxUnit();
4527 SelectorSubPart.prototype.constructor = SelectorSubPart;
4528
4529
4530 },{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
4531 "use strict";
4532
4533 module.exports = Specificity;
4534
4535 var Pseudos = require("./Pseudos");
4536 var SelectorPart = require("./SelectorPart");
4537 function Specificity(a, b, c, d) {
4538 this.a = a;
4539 this.b = b;
4540 this.c = c;
4541 this.d = d;
4542 }
4543
4544 Specificity.prototype = {
4545 constructor: Specificity,
4546 compare: function(other) {
4547 var comps = ["a", "b", "c", "d"],
4548 i, len;
4549
4550 for (i = 0, len = comps.length; i < len; i++) {
4551 if (this[comps[i]] < other[comps[i]]) {
4552 return -1;
4553 } else if (this[comps[i]] > other[comps[i]]) {
4554 return 1;
4555 }
4556 }
4557
4558 return 0;
4559 },
4560 valueOf: function() {
4561 return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
4562 },
4563 toString: function() {
4564 return this.a + "," + this.b + "," + this.c + "," + this.d;
4565 }
4566
4567 };
4568 Specificity.calculate = function(selector) {
4569
4570 var i,
4571 len,
4572 part,
4573 b = 0,
4574 c = 0,
4575 d = 0;
4576
4577 function updateValues(part) {
4578
4579 var i, j, len, num,
4580 elementName = part.elementName ? part.elementName.text : "",
4581 modifier;
4582
4583 if (elementName && elementName.charAt(elementName.length - 1) !== "*") {
4584 d++;
4585 }
4586
4587 for (i = 0, len = part.modifiers.length; i < len; i++) {
4588 modifier = part.modifiers[i];
4589 switch (modifier.type) {
4590 case "class":
4591 case "attribute":
4592 c++;
4593 break;
4594
4595 case "id":
4596 b++;
4597 break;
4598
4599 case "pseudo":
4600 if (Pseudos.isElement(modifier.text)) {
4601 d++;
4602 } else {
4603 c++;
4604 }
4605 break;
4606
4607 case "not":
4608 for (j = 0, num = modifier.args.length; j < num; j++) {
4609 updateValues(modifier.args[j]);
4610 }
4611 }
4612 }
4613 }
4614
4615 for (i = 0, len = selector.parts.length; i < len; i++) {
4616 part = selector.parts[i];
4617
4618 if (part instanceof SelectorPart) {
4619 updateValues(part);
4620 }
4621 }
4622
4623 return new Specificity(0, b, c, d);
4624 };
4625
4626 },{"./Pseudos":12,"./SelectorPart":14}],17:[function(require,module,exports){
4627 "use strict";
4628
4629 module.exports = TokenStream;
4630
4631 var TokenStreamBase = require("../util/TokenStreamBase");
4632
4633 var PropertyValuePart = require("./PropertyValuePart");
4634 var Tokens = require("./Tokens");
4635
4636 var h = /^[0-9a-fA-F]$/,
4637 nonascii = /^[\u00A0-\uFFFF]$/,
4638 nl = /\n|\r\n|\r|\f/,
4639 whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
4640
4641
4642 function isHexDigit(c) {
4643 return c != null && h.test(c);
4644 }
4645
4646 function isDigit(c) {
4647 return c != null && /\d/.test(c);
4648 }
4649
4650 function isWhitespace(c) {
4651 return c != null && whitespace.test(c);
4652 }
4653
4654 function isNewLine(c) {
4655 return c != null && nl.test(c);
4656 }
4657
4658 function isNameStart(c) {
4659 return c != null && /[a-z_\u00A0-\uFFFF\\]/i.test(c);
4660 }
4661
4662 function isNameChar(c) {
4663 return c != null && (isNameStart(c) || /[0-9\-\\]/.test(c));
4664 }
4665
4666 function isIdentStart(c) {
4667 return c != null && (isNameStart(c) || /-\\/.test(c));
4668 }
4669
4670 function mix(receiver, supplier) {
4671 for (var prop in supplier) {
4672 if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
4673 receiver[prop] = supplier[prop];
4674 }
4675 }
4676 return receiver;
4677 }
4678
4679 function wouldStartIdent(twoCodePoints) {
4680 return typeof twoCodePoints === "string" &&
4681 (twoCodePoints[0] === "-" && isNameStart(twoCodePoints[1]) || isNameStart(twoCodePoints[0]));
4682 }
4683
4684 function wouldStartUnsignedNumber(twoCodePoints) {
4685 return typeof twoCodePoints === "string" &&
4686 (isDigit(twoCodePoints[0]) || (twoCodePoints[0] === "." && isDigit(twoCodePoints[1])));
4687 }
4688 function TokenStream(input) {
4689 TokenStreamBase.call(this, input, Tokens);
4690 }
4691
4692 TokenStream.prototype = mix(new TokenStreamBase(), {
4693 _getToken: function() {
4694
4695 var c,
4696 reader = this._reader,
4697 token = null,
4698 startLine = reader.getLine(),
4699 startCol = reader.getCol();
4700
4701 c = reader.read();
4702
4703 while (c) {
4704 switch (c) {
4705 case "/":
4706
4707 if (reader.peek() === "*") {
4708 token = this.commentToken(c, startLine, startCol);
4709 } else {
4710 token = this.charToken(c, startLine, startCol);
4711 }
4712 break;
4713 case "|":
4714 case "~":
4715 case "^":
4716 case "$":
4717 case "*":
4718 if (reader.peek() === "=") {
4719 token = this.comparisonToken(c, startLine, startCol);
4720 } else {
4721 token = this.charToken(c, startLine, startCol);
4722 }
4723 break;
4724 case "\"":
4725 case "'":
4726 token = this.stringToken(c, startLine, startCol);
4727 break;
4728 case "#":
4729 if (isNameChar(reader.peek())) {
4730 token = this.hashToken(c, startLine, startCol);
4731 } else {
4732 token = this.charToken(c, startLine, startCol);
4733 }
4734 break;
4735 case ".":
4736 if (isDigit(reader.peek())) {
4737 token = this.numberToken(c, startLine, startCol);
4738 } else {
4739 token = this.charToken(c, startLine, startCol);
4740 }
4741 break;
4742 case "-":
4743 if (wouldStartUnsignedNumber(reader.peekCount(2))) {
4744 token = this.numberToken(c, startLine, startCol);
4745 break;
4746 } else if (reader.peekCount(2) === "->") {
4747 token = this.htmlCommentEndToken(c, startLine, startCol);
4748 } else {
4749 token = this._getDefaultToken(c, startLine, startCol);
4750 }
4751 break;
4752 case "+":
4753 if (wouldStartUnsignedNumber(reader.peekCount(2))) {
4754 token = this.numberToken(c, startLine, startCol);
4755 } else {
4756 token = this.charToken(c, startLine, startCol);
4757 }
4758 break;
4759 case "!":
4760 token = this.importantToken(c, startLine, startCol);
4761 break;
4762 case "@":
4763 token = this.atRuleToken(c, startLine, startCol);
4764 break;
4765 case ":":
4766 token = this.notToken(c, startLine, startCol);
4767 break;
4768 case "<":
4769 token = this.htmlCommentStartToken(c, startLine, startCol);
4770 break;
4771 case "\\":
4772 if (/[^\r\n\f]/.test(reader.peek())) {
4773 token = this.identOrFunctionToken(this.readEscape(c, true), startLine, startCol);
4774 } else {
4775 token = this.charToken(c, startLine, startCol);
4776 }
4777 break;
4778 case "U":
4779 case "u":
4780 if (reader.peek() === "+") {
4781 token = this.unicodeRangeToken(c, startLine, startCol);
4782 } else {
4783 token = this._getDefaultToken(c, startLine, startCol);
4784 }
4785 break;
4786
4787 default:
4788 token = this._getDefaultToken(c, startLine, startCol);
4789
4790 }
4791 break;
4792 }
4793
4794 if (!token && c === null) {
4795 token = this.createToken(Tokens.EOF, null, startLine, startCol);
4796 }
4797
4798 return token;
4799 },
4800 _getDefaultToken: function(c, startLine, startCol) {
4801 var reader = this._reader,
4802 token = null;
4803
4804 if (isDigit(c)) {
4805 token = this.numberToken(c, startLine, startCol);
4806 } else
4807 if (isWhitespace(c)) {
4808 token = this.whitespaceToken(c, startLine, startCol);
4809 } else
4810 if (wouldStartIdent(c + reader.peekCount(1))) {
4811 token = this.identOrFunctionToken(c, startLine, startCol);
4812 } else {
4813 token = this.charToken(c, startLine, startCol);
4814 }
4815
4816 return token;
4817 },
4818 createToken: function(tt, value, startLine, startCol, options) {
4819 var reader = this._reader;
4820 options = options || {};
4821
4822 return {
4823 value: value,
4824 type: tt,
4825 channel: options.channel,
4826 endChar: options.endChar,
4827 hide: options.hide || false,
4828 startLine: startLine,
4829 startCol: startCol,
4830 endLine: reader.getLine(),
4831 endCol: reader.getCol()
4832 };
4833 },
4834 atRuleToken: function(first, startLine, startCol) {
4835 var rule = first,
4836 reader = this._reader,
4837 tt = Tokens.CHAR,
4838 ident;
4839 reader.mark();
4840 ident = this.readName();
4841 rule = first + ident;
4842 tt = Tokens.type(rule.toLowerCase());
4843 if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
4844 if (rule.length > 1) {
4845 tt = Tokens.UNKNOWN_SYM;
4846 } else {
4847 tt = Tokens.CHAR;
4848 rule = first;
4849 reader.reset();
4850 }
4851 }
4852
4853 return this.createToken(tt, rule, startLine, startCol);
4854 },
4855 charToken: function(c, startLine, startCol) {
4856 var tt = Tokens.type(c);
4857 var opts = {};
4858
4859 if (tt === -1) {
4860 tt = Tokens.CHAR;
4861 } else {
4862 opts.endChar = Tokens[tt].endChar;
4863 }
4864
4865 return this.createToken(tt, c, startLine, startCol, opts);
4866 },
4867 commentToken: function(first, startLine, startCol) {
4868 var comment = this.readComment(first);
4869
4870 return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
4871 },
4872 comparisonToken: function(c, startLine, startCol) {
4873 var reader = this._reader,
4874 comparison = c + reader.read(),
4875 tt = Tokens.type(comparison) || Tokens.CHAR;
4876
4877 return this.createToken(tt, comparison, startLine, startCol);
4878 },
4879 hashToken: function(first, startLine, startCol) {
4880 var name = this.readName(first);
4881
4882 return this.createToken(Tokens.HASH, name, startLine, startCol);
4883 },
4884 htmlCommentStartToken: function(first, startLine, startCol) {
4885 var reader = this._reader,
4886 text = first;
4887
4888 reader.mark();
4889 text += reader.readCount(3);
4890
4891 if (text === "<!--") {
4892 return this.createToken(Tokens.CDO, text, startLine, startCol);
4893 } else {
4894 reader.reset();
4895 return this.charToken(first, startLine, startCol);
4896 }
4897 },
4898 htmlCommentEndToken: function(first, startLine, startCol) {
4899 var reader = this._reader,
4900 text = first;
4901
4902 reader.mark();
4903 text += reader.readCount(2);
4904
4905 if (text === "-->") {
4906 return this.createToken(Tokens.CDC, text, startLine, startCol);
4907 } else {
4908 reader.reset();
4909 return this.charToken(first, startLine, startCol);
4910 }
4911 },
4912 identOrFunctionToken: function(first, startLine, startCol) {
4913 var reader = this._reader,
4914 ident = this.readName(first),
4915 tt = Tokens.IDENT,
4916 uriFns = ["url(", "url-prefix(", "domain("],
4917 uri;
4918 if (reader.peek() === "(") {
4919 ident += reader.read();
4920 if (uriFns.indexOf(ident.toLowerCase()) > -1) {
4921 reader.mark();
4922 uri = this.readURI(ident);
4923 if (uri === null) {
4924 reader.reset();
4925 tt = Tokens.FUNCTION;
4926 } else {
4927 tt = Tokens.URI;
4928 ident = uri;
4929 }
4930 } else {
4931 tt = Tokens.FUNCTION;
4932 }
4933 } else if (reader.peek() === ":") { // might be an IE function
4934 if (ident.toLowerCase() === "progid") {
4935 ident += reader.readTo("(");
4936 tt = Tokens.IE_FUNCTION;
4937 }
4938 }
4939
4940 return this.createToken(tt, ident, startLine, startCol);
4941 },
4942 importantToken: function(first, startLine, startCol) {
4943 var reader = this._reader,
4944 important = first,
4945 tt = Tokens.CHAR,
4946 temp,
4947 c;
4948
4949 reader.mark();
4950 c = reader.read();
4951
4952 while (c) {
4953 if (c === "/") {
4954 if (reader.peek() !== "*") {
4955 break;
4956 } else {
4957 temp = this.readComment(c);
4958 if (temp === "") { // broken!
4959 break;
4960 }
4961 }
4962 } else if (isWhitespace(c)) {
4963 important += c + this.readWhitespace();
4964 } else if (/i/i.test(c)) {
4965 temp = reader.readCount(8);
4966 if (/mportant/i.test(temp)) {
4967 important += c + temp;
4968 tt = Tokens.IMPORTANT_SYM;
4969
4970 }
4971 break; // we're done
4972 } else {
4973 break;
4974 }
4975
4976 c = reader.read();
4977 }
4978
4979 if (tt === Tokens.CHAR) {
4980 reader.reset();
4981 return this.charToken(first, startLine, startCol);
4982 } else {
4983 return this.createToken(tt, important, startLine, startCol);
4984 }
4985
4986
4987 },
4988 notToken: function(first, startLine, startCol) {
4989 var reader = this._reader,
4990 text = first;
4991
4992 reader.mark();
4993 text += reader.readCount(4);
4994
4995 if (text.toLowerCase() === ":not(") {
4996 return this.createToken(Tokens.NOT, text, startLine, startCol);
4997 } else {
4998 reader.reset();
4999 return this.charToken(first, startLine, startCol);
5000 }
5001 },
5002 numberToken: function(first, startLine, startCol) {
5003 var reader = this._reader,
5004 value = this.readNumber(first),
5005 ident,
5006 tt = Tokens.NUMBER,
5007 c = reader.peek();
5008
5009 if (isIdentStart(c)) {
5010 ident = this.readName(reader.read());
5011 value += ident;
5012
5013 if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^fr$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
5014 tt = Tokens.LENGTH;
5015 } else if (/^deg|^rad$|^grad$|^turn$/i.test(ident)) {
5016 tt = Tokens.ANGLE;
5017 } else if (/^ms$|^s$/i.test(ident)) {
5018 tt = Tokens.TIME;
5019 } else if (/^hz$|^khz$/i.test(ident)) {
5020 tt = Tokens.FREQ;
5021 } else if (/^dpi$|^dpcm$/i.test(ident)) {
5022 tt = Tokens.RESOLUTION;
5023 } else {
5024 tt = Tokens.DIMENSION;
5025 }
5026
5027 } else if (c === "%") {
5028 value += reader.read();
5029 tt = Tokens.PERCENTAGE;
5030 }
5031
5032 return this.createToken(tt, value, startLine, startCol);
5033 },
5034 stringToken: function(first, startLine, startCol) {
5035 var delim = first,
5036 string = first,
5037 reader = this._reader,
5038 tt = Tokens.STRING,
5039 c = reader.read(),
5040 i;
5041
5042 while (c) {
5043 string += c;
5044
5045 if (c === "\\") {
5046 c = reader.read();
5047 if (c === null) {
5048 break; // premature EOF after backslash
5049 } else if (/[^\r\n\f0-9a-f]/i.test(c)) {
5050 string += c;
5051 } else {
5052 for (i = 0; isHexDigit(c) && i < 6; i++) {
5053 string += c;
5054 c = reader.read();
5055 }
5056 if (c === "\r" && reader.peek() === "\n") {
5057 string += c;
5058 c = reader.read();
5059 }
5060 if (isWhitespace(c)) {
5061 string += c;
5062 } else {
5063 continue;
5064 }
5065 }
5066 } else if (c === delim) {
5067 break; // delimiter found.
5068 } else if (isNewLine(reader.peek())) {
5069 tt = Tokens.INVALID;
5070 break;
5071 }
5072 c = reader.read();
5073 }
5074 if (c === null) {
5075 tt = Tokens.INVALID;
5076 }
5077
5078 return this.createToken(tt, string, startLine, startCol);
5079 },
5080
5081 unicodeRangeToken: function(first, startLine, startCol) {
5082 var reader = this._reader,
5083 value = first,
5084 temp,
5085 tt = Tokens.CHAR;
5086 if (reader.peek() === "+") {
5087 reader.mark();
5088 value += reader.read();
5089 value += this.readUnicodeRangePart(true);
5090 if (value.length === 2) {
5091 reader.reset();
5092 } else {
5093
5094 tt = Tokens.UNICODE_RANGE;
5095 if (value.indexOf("?") === -1) {
5096
5097 if (reader.peek() === "-") {
5098 reader.mark();
5099 temp = reader.read();
5100 temp += this.readUnicodeRangePart(false);
5101 if (temp.length === 1) {
5102 reader.reset();
5103 } else {
5104 value += temp;
5105 }
5106 }
5107
5108 }
5109 }
5110 }
5111
5112 return this.createToken(tt, value, startLine, startCol);
5113 },
5114 whitespaceToken: function(first, startLine, startCol) {
5115 var value = first + this.readWhitespace();
5116 return this.createToken(Tokens.S, value, startLine, startCol);
5117 },
5118
5119 readUnicodeRangePart: function(allowQuestionMark) {
5120 var reader = this._reader,
5121 part = "",
5122 c = reader.peek();
5123 while (isHexDigit(c) && part.length < 6) {
5124 reader.read();
5125 part += c;
5126 c = reader.peek();
5127 }
5128 if (allowQuestionMark) {
5129 while (c === "?" && part.length < 6) {
5130 reader.read();
5131 part += c;
5132 c = reader.peek();
5133 }
5134 }
5135
5136 return part;
5137 },
5138
5139 readWhitespace: function() {
5140 var reader = this._reader,
5141 whitespace = "",
5142 c = reader.peek();
5143
5144 while (isWhitespace(c)) {
5145 reader.read();
5146 whitespace += c;
5147 c = reader.peek();
5148 }
5149
5150 return whitespace;
5151 },
5152 readNumber: function(first) {
5153 var reader = this._reader,
5154 number = first,
5155 hasDot = first === ".",
5156 c = reader.peek();
5157
5158
5159 while (c) {
5160 if (isDigit(c)) {
5161 number += reader.read();
5162 } else if (c === ".") {
5163 if (hasDot) {
5164 break;
5165 } else {
5166 hasDot = true;
5167 number += reader.read();
5168 }
5169 } else {
5170 break;
5171 }
5172
5173 c = reader.peek();
5174 }
5175
5176 return number;
5177 },
5178 readString: function() {
5179 var token = this.stringToken(this._reader.read(), 0, 0);
5180 return token.type === Tokens.INVALID ? null : token.value;
5181 },
5182 readURI: function(first) {
5183 var reader = this._reader,
5184 uri = first,
5185 inner = "",
5186 c = reader.peek();
5187 while (c && isWhitespace(c)) {
5188 reader.read();
5189 c = reader.peek();
5190 }
5191 if (c === "'" || c === "\"") {
5192 inner = this.readString();
5193 if (inner !== null) {
5194 inner = PropertyValuePart.parseString(inner);
5195 }
5196 } else {
5197 inner = this.readUnquotedURL();
5198 }
5199
5200 c = reader.peek();
5201 while (c && isWhitespace(c)) {
5202 reader.read();
5203 c = reader.peek();
5204 }
5205 if (inner === null || c !== ")") {
5206 uri = null;
5207 } else {
5208 uri += PropertyValuePart.serializeString(inner) + reader.read();
5209 }
5210
5211 return uri;
5212 },
5213 readUnquotedURL: function(first) {
5214 var reader = this._reader,
5215 url = first || "",
5216 c;
5217
5218 for (c = reader.peek(); c; c = reader.peek()) {
5219 if (nonascii.test(c) || /^[-!#$%&*-[\]-~]$/.test(c)) {
5220 url += c;
5221 reader.read();
5222 } else if (c === "\\") {
5223 if (/^[^\r\n\f]$/.test(reader.peek(2))) {
5224 url += this.readEscape(reader.read(), true);
5225 } else {
5226 break; // bad escape sequence.
5227 }
5228 } else {
5229 break; // bad character
5230 }
5231 }
5232
5233 return url;
5234 },
5235
5236 readName: function(first) {
5237 var reader = this._reader,
5238 ident = first || "",
5239 c;
5240
5241 for (c = reader.peek(); c; c = reader.peek()) {
5242 if (c === "\\") {
5243 if (/^[^\r\n\f]$/.test(reader.peek(2))) {
5244 ident += this.readEscape(reader.read(), true);
5245 } else {
5246 break;
5247 }
5248 } else if (isNameChar(c)) {
5249 ident += reader.read();
5250 } else {
5251 break;
5252 }
5253 }
5254
5255 return ident;
5256 },
5257
5258 readEscape: function(first, unescape) {
5259 var reader = this._reader,
5260 cssEscape = first || "",
5261 i = 0,
5262 c = reader.peek();
5263
5264 if (isHexDigit(c)) {
5265 do {
5266 cssEscape += reader.read();
5267 c = reader.peek();
5268 } while (c && isHexDigit(c) && ++i < 6);
5269 }
5270
5271 if (cssEscape.length === 1) {
5272 if (/^[^\r\n\f0-9a-f]$/.test(c)) {
5273 reader.read();
5274 if (unescape) {
5275 return c;
5276 }
5277 } else {
5278 throw new Error("Bad escape sequence.");
5279 }
5280 } else if (c === "\r") {
5281 reader.read();
5282 if (reader.peek() === "\n") {
5283 c += reader.read();
5284 }
5285 } else if (/^[ \t\n\f]$/.test(c)) {
5286 reader.read();
5287 } else {
5288 c = "";
5289 }
5290
5291 if (unescape) {
5292 var cp = parseInt(cssEscape.slice(first.length), 16);
5293 return String.fromCodePoint ? String.fromCodePoint(cp) :
5294 String.fromCharCode(cp);
5295 }
5296 return cssEscape + c;
5297 },
5298
5299 readComment: function(first) {
5300 var reader = this._reader,
5301 comment = first || "",
5302 c = reader.read();
5303
5304 if (c === "*") {
5305 while (c) {
5306 comment += c;
5307 if (comment.length > 2 && c === "*" && reader.peek() === "/") {
5308 comment += reader.read();
5309 break;
5310 }
5311
5312 c = reader.read();
5313 }
5314
5315 return comment;
5316 } else {
5317 return "";
5318 }
5319
5320 }
5321 });
5322
5323 },{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
5324 "use strict";
5325
5326 var Tokens = module.exports = [
5327 { name: "CDO" },
5328 { name: "CDC" },
5329 { name: "S", whitespace: true/*, channel: "ws"*/ },
5330 { name: "COMMENT", comment: true, hide: true, channel: "comment" },
5331 { name: "INCLUDES", text: "~=" },
5332 { name: "DASHMATCH", text: "|=" },
5333 { name: "PREFIXMATCH", text: "^=" },
5334 { name: "SUFFIXMATCH", text: "$=" },
5335 { name: "SUBSTRINGMATCH", text: "*=" },
5336 { name: "STRING" },
5337 { name: "IDENT" },
5338 { name: "HASH" },
5339 { name: "IMPORT_SYM", text: "@import" },
5340 { name: "PAGE_SYM", text: "@page" },
5341 { name: "MEDIA_SYM", text: "@media" },
5342 { name: "FONT_FACE_SYM", text: "@font-face" },
5343 { name: "CHARSET_SYM", text: "@charset" },
5344 { name: "NAMESPACE_SYM", text: "@namespace" },
5345 { name: "SUPPORTS_SYM", text: "@supports" },
5346 { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
5347 { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
5348 { name: "UNKNOWN_SYM" },
5349 { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
5350 { name: "IMPORTANT_SYM" },
5351 { name: "LENGTH" },
5352 { name: "ANGLE" },
5353 { name: "TIME" },
5354 { name: "FREQ" },
5355 { name: "DIMENSION" },
5356 { name: "PERCENTAGE" },
5357 { name: "NUMBER" },
5358 { name: "URI" },
5359 { name: "FUNCTION" },
5360 { name: "UNICODE_RANGE" },
5361 { name: "INVALID" },
5362 { name: "PLUS", text: "+" },
5363 { name: "GREATER", text: ">" },
5364 { name: "COMMA", text: "," },
5365 { name: "TILDE", text: "~" },
5366 { name: "NOT" },
5367 { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
5368 { name: "TOPLEFT_SYM", text: "@top-left" },
5369 { name: "TOPCENTER_SYM", text: "@top-center" },
5370 { name: "TOPRIGHT_SYM", text: "@top-right" },
5371 { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
5372 { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
5373 { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
5374 { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
5375 { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
5376 { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
5377 { name: "LEFTTOP_SYM", text: "@left-top" },
5378 { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
5379 { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
5380 { name: "RIGHTTOP_SYM", text: "@right-top" },
5381 { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
5382 { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
5383 { name: "RESOLUTION", state: "media" },
5384 { name: "IE_FUNCTION" },
5385 { name: "CHAR" },
5386 {
5387 name: "PIPE",
5388 text: "|"
5389 },
5390 {
5391 name: "SLASH",
5392 text: "/"
5393 },
5394 {
5395 name: "MINUS",
5396 text: "-"
5397 },
5398 {
5399 name: "STAR",
5400 text: "*"
5401 },
5402
5403 {
5404 name: "LBRACE",
5405 endChar: "}",
5406 text: "{"
5407 },
5408 {
5409 name: "RBRACE",
5410 text: "}"
5411 },
5412 {
5413 name: "LBRACKET",
5414 endChar: "]",
5415 text: "["
5416 },
5417 {
5418 name: "RBRACKET",
5419 text: "]"
5420 },
5421 {
5422 name: "EQUALS",
5423 text: "="
5424 },
5425 {
5426 name: "COLON",
5427 text: ":"
5428 },
5429 {
5430 name: "SEMICOLON",
5431 text: ";"
5432 },
5433 {
5434 name: "LPAREN",
5435 endChar: ")",
5436 text: "("
5437 },
5438 {
5439 name: "RPAREN",
5440 text: ")"
5441 },
5442 {
5443 name: "DOT",
5444 text: "."
5445 }
5446 ];
5447
5448 (function() {
5449 var nameMap = [],
5450 typeMap = Object.create(null);
5451
5452 Tokens.UNKNOWN = -1;
5453 Tokens.unshift({ name:"EOF" });
5454 for (var i = 0, len = Tokens.length; i < len; i++) {
5455 nameMap.push(Tokens[i].name);
5456 Tokens[Tokens[i].name] = i;
5457 if (Tokens[i].text) {
5458 if (Tokens[i].text instanceof Array) {
5459 for (var j = 0; j < Tokens[i].text.length; j++) {
5460 typeMap[Tokens[i].text[j]] = i;
5461 }
5462 } else {
5463 typeMap[Tokens[i].text] = i;
5464 }
5465 }
5466 }
5467
5468 Tokens.name = function(tt) {
5469 return nameMap[tt];
5470 };
5471
5472 Tokens.type = function(c) {
5473 return typeMap[c] || -1;
5474 };
5475 })();
5476
5477 },{}],19:[function(require,module,exports){
5478
5479 "use strict";
5480
5481 var Matcher = require("./Matcher");
5482 var Properties = require("./Properties");
5483 var ValidationTypes = require("./ValidationTypes");
5484 var ValidationError = require("./ValidationError");
5485 var PropertyValueIterator = require("./PropertyValueIterator");
5486
5487 var Validation = module.exports = {
5488
5489 validate: function(property, value) {
5490 var name = property.toString().toLowerCase(),
5491 expression = new PropertyValueIterator(value),
5492 spec = Properties[name],
5493 part;
5494
5495 if (!spec) {
5496 if (name.indexOf("-") !== 0) { // vendor prefixed are ok
5497 throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
5498 }
5499 } else if (typeof spec !== "number") {
5500 if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
5501 if (expression.hasNext()) {
5502 part = expression.next();
5503 throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5504 }
5505 return;
5506 }
5507 this.singleProperty(spec, expression);
5508
5509 }
5510
5511 },
5512
5513 singleProperty: function(types, expression) {
5514
5515 var result = false,
5516 value = expression.value,
5517 part;
5518
5519 result = Matcher.parse(types).match(expression);
5520
5521 if (!result) {
5522 if (expression.hasNext() && !expression.isFirst()) {
5523 part = expression.peek();
5524 throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5525 } else {
5526 throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
5527 }
5528 } else if (expression.hasNext()) {
5529 part = expression.next();
5530 throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
5531 }
5532
5533 }
5534
5535 };
5536
5537 },{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
5538 "use strict";
5539
5540 module.exports = ValidationError;
5541 function ValidationError(message, line, col) {
5542 this.col = col;
5543 this.line = line;
5544 this.message = message;
5545
5546 }
5547 ValidationError.prototype = new Error();
5548
5549 },{}],21:[function(require,module,exports){
5550 "use strict";
5551
5552 var ValidationTypes = module.exports;
5553
5554 var Matcher = require("./Matcher");
5555
5556 function copy(to, from) {
5557 Object.keys(from).forEach(function(prop) {
5558 to[prop] = from[prop];
5559 });
5560 }
5561 copy(ValidationTypes, {
5562
5563 isLiteral: function (part, literals) {
5564 var text = part.text.toString().toLowerCase(),
5565 args = literals.split(" | "),
5566 i,
5567 len,
5568 found = false;
5569
5570 for (i = 0, len = args.length; i < len && !found; i++) {
5571 if (args[i].charAt(0) === "<") {
5572 found = this.simple[args[i]](part);
5573 } else if (args[i].slice(-2) === "()") {
5574 found = (part.type === "function" &&
5575 part.name === args[i].slice(0, -2));
5576 } else if (text === args[i].toLowerCase()) {
5577 found = true;
5578 }
5579 }
5580
5581 return found;
5582 },
5583
5584 isSimple: function(type) {
5585 return Boolean(this.simple[type]);
5586 },
5587
5588 isComplex: function(type) {
5589 return Boolean(this.complex[type]);
5590 },
5591
5592 describe: function(type) {
5593 if (this.complex[type] instanceof Matcher) {
5594 return this.complex[type].toString(0);
5595 }
5596 return type;
5597 },
5598 isAny: function (expression, types) {
5599 var args = types.split(" | "),
5600 i,
5601 len,
5602 found = false;
5603
5604 for (i = 0, len = args.length; i < len && !found && expression.hasNext(); i++) {
5605 found = this.isType(expression, args[i]);
5606 }
5607
5608 return found;
5609 },
5610 isAnyOfGroup: function(expression, types) {
5611 var args = types.split(" || "),
5612 i,
5613 len,
5614 found = false;
5615
5616 for (i = 0, len = args.length; i < len && !found; i++) {
5617 found = this.isType(expression, args[i]);
5618 }
5619
5620 return found ? args[i - 1] : false;
5621 },
5622 isType: function (expression, type) {
5623 var part = expression.peek(),
5624 result = false;
5625
5626 if (type.charAt(0) !== "<") {
5627 result = this.isLiteral(part, type);
5628 if (result) {
5629 expression.next();
5630 }
5631 } else if (this.simple[type]) {
5632 result = this.simple[type](part);
5633 if (result) {
5634 expression.next();
5635 }
5636 } else if (this.complex[type] instanceof Matcher) {
5637 result = this.complex[type].match(expression);
5638 } else {
5639 result = this.complex[type](expression);
5640 }
5641
5642 return result;
5643 },
5644
5645
5646 simple: {
5647 __proto__: null,
5648
5649 "<absolute-size>":
5650 "xx-small | x-small | small | medium | large | x-large | xx-large",
5651
5652 "<animateable-feature>":
5653 "scroll-position | contents | <animateable-feature-name>",
5654
5655 "<animateable-feature-name>": function(part) {
5656 return this["<ident>"](part) &&
5657 !/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
5658 },
5659
5660 "<angle>": function(part) {
5661 return part.type === "angle";
5662 },
5663
5664 "<attachment>": "scroll | fixed | local",
5665
5666 "<attr>": "attr()",
5667 "<basic-shape>": "inset() | circle() | ellipse() | polygon()",
5668
5669 "<bg-image>": "<image> | <gradient> | none",
5670
5671 "<border-style>":
5672 "none | hidden | dotted | dashed | solid | double | groove | " +
5673 "ridge | inset | outset",
5674
5675 "<border-width>": "<length> | thin | medium | thick",
5676
5677 "<box>": "padding-box | border-box | content-box",
5678
5679 "<clip-source>": "<uri>",
5680
5681 "<color>": function(part) {
5682 return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
5683 },
5684 "<color-svg>": function(part) {
5685 return part.type === "color";
5686 },
5687
5688 "<content>": "content()",
5689 "<content-sizing>":
5690 "fill-available | -moz-available | -webkit-fill-available | " +
5691 "max-content | -moz-max-content | -webkit-max-content | " +
5692 "min-content | -moz-min-content | -webkit-min-content | " +
5693 "fit-content | -moz-fit-content | -webkit-fit-content",
5694
5695 "<feature-tag-value>": function(part) {
5696 return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
5697 },
5698 "<filter-function>":
5699 "blur() | brightness() | contrast() | custom() | " +
5700 "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
5701 "opacity() | saturate() | sepia()",
5702
5703 "<flex-basis>": "<width>",
5704
5705 "<flex-direction>": "row | row-reverse | column | column-reverse",
5706
5707 "<flex-grow>": "<number>",
5708
5709 "<flex-shrink>": "<number>",
5710
5711 "<flex-wrap>": "nowrap | wrap | wrap-reverse",
5712
5713 "<font-size>":
5714 "<absolute-size> | <relative-size> | <length> | <percentage>",
5715
5716 "<font-stretch>":
5717 "normal | ultra-condensed | extra-condensed | condensed | " +
5718 "semi-condensed | semi-expanded | expanded | extra-expanded | " +
5719 "ultra-expanded",
5720
5721 "<font-style>": "normal | italic | oblique",
5722
5723 "<font-variant-caps>":
5724 "small-caps | all-small-caps | petite-caps | all-petite-caps | " +
5725 "unicase | titling-caps",
5726
5727 "<font-variant-css21>": "normal | small-caps",
5728
5729 "<font-weight>":
5730 "normal | bold | bolder | lighter | " +
5731 "100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900",
5732
5733 "<generic-family>":
5734 "serif | sans-serif | cursive | fantasy | monospace",
5735
5736 "<geometry-box>": "<shape-box> | fill-box | stroke-box | view-box",
5737
5738 "<glyph-angle>": function(part) {
5739 return part.type === "angle" && part.units === "deg";
5740 },
5741
5742 "<gradient>": function(part) {
5743 return part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?(?:repeating-)?(?:radial-|linear-)?gradient/i.test(part);
5744 },
5745
5746 "<icccolor>":
5747 "cielab() | cielch() | cielchab() | " +
5748 "icc-color() | icc-named-color()",
5749 "<ident>": function(part) {
5750 return part.type === "identifier" || part.wasIdent;
5751 },
5752
5753 "<ident-not-generic-family>": function(part) {
5754 return this["<ident>"](part) && !this["<generic-family>"](part);
5755 },
5756
5757 "<image>": "<uri>",
5758
5759 "<integer>": function(part) {
5760 return part.type === "integer";
5761 },
5762
5763 "<length>": function(part) {
5764 if (part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?calc/i.test(part)) {
5765 return true;
5766 } else {
5767 return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
5768 }
5769 },
5770
5771 "<line>": function(part) {
5772 return part.type === "integer";
5773 },
5774
5775 "<line-height>": "<number> | <length> | <percentage> | normal",
5776
5777 "<margin-width>": "<length> | <percentage> | auto",
5778
5779 "<miterlimit>": function(part) {
5780 return this["<number>"](part) && part.value >= 1;
5781 },
5782
5783 "<nonnegative-length-or-percentage>": function(part) {
5784 return (this["<length>"](part) || this["<percentage>"](part)) &&
5785 (String(part) === "0" || part.type === "function" || (part.value) >= 0);
5786 },
5787
5788 "<nonnegative-number-or-percentage>": function(part) {
5789 return (this["<number>"](part) || this["<percentage>"](part)) &&
5790 (String(part) === "0" || part.type === "function" || (part.value) >= 0);
5791 },
5792
5793 "<number>": function(part) {
5794 return part.type === "number" || this["<integer>"](part);
5795 },
5796
5797 "<opacity-value>": function(part) {
5798 return this["<number>"](part) && part.value >= 0 && part.value <= 1;
5799 },
5800
5801 "<padding-width>": "<nonnegative-length-or-percentage>",
5802
5803 "<percentage>": function(part) {
5804 return part.type === "percentage" || String(part) === "0";
5805 },
5806
5807 "<relative-size>": "smaller | larger",
5808
5809 "<shape>": "rect() | inset-rect()",
5810
5811 "<shape-box>": "<box> | margin-box",
5812
5813 "<single-animation-direction>":
5814 "normal | reverse | alternate | alternate-reverse",
5815
5816 "<single-animation-name>": function(part) {
5817 return this["<ident>"](part) &&
5818 /^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
5819 !/^(none|unset|initial|inherit)$/i.test(part);
5820 },
5821
5822 "<string>": function(part) {
5823 return part.type === "string";
5824 },
5825
5826 "<time>": function(part) {
5827 return part.type === "time";
5828 },
5829
5830 "<uri>": function(part) {
5831 return part.type === "uri";
5832 },
5833
5834 "<width>": "<margin-width>"
5835 },
5836
5837 complex: {
5838 __proto__: null,
5839
5840 "<azimuth>":
5841 "<angle>" +
5842 " | " +
5843 "[ [ left-side | far-left | left | center-left | center | " +
5844 "center-right | right | far-right | right-side ] || behind ]" +
5845 " | " +
5846 "leftwards | rightwards",
5847
5848 "<bg-position>": "<position>#",
5849
5850 "<bg-size>":
5851 "[ <length> | <percentage> | auto ]{1,2} | cover | contain",
5852
5853 "<blend-mode>":
5854 "normal | multiply | screen | overlay | darken | lighten | color-dodge | " +
5855 "color-burn | hard-light | soft-light | difference | exclusion | hue | " +
5856 "saturation | color | luminosity",
5857
5858 "<border-image-slice>":
5859 Matcher.many([true /* first element is required */],
5860 Matcher.cast("<nonnegative-number-or-percentage>"),
5861 Matcher.cast("<nonnegative-number-or-percentage>"),
5862 Matcher.cast("<nonnegative-number-or-percentage>"),
5863 Matcher.cast("<nonnegative-number-or-percentage>"),
5864 "fill"),
5865
5866 "<border-radius>":
5867 "<nonnegative-length-or-percentage>{1,4} " +
5868 "[ / <nonnegative-length-or-percentage>{1,4} ]?",
5869
5870 "<box-shadow>": "none | <shadow>#",
5871
5872 "<clip-path>": "<basic-shape> || <geometry-box>",
5873
5874 "<dasharray>":
5875 Matcher.cast("<nonnegative-length-or-percentage>")
5876 .braces(1, Infinity, "#", Matcher.cast(",").question()),
5877
5878 "<family-name>":
5879 "<string> | <ident-not-generic-family> <ident>*",
5880
5881 "<filter-function-list>": "[ <filter-function> | <uri> ]+",
5882 "<flex>":
5883 "none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]",
5884
5885 "<font-family>": "[ <generic-family> | <family-name> ]#",
5886
5887 "<font-shorthand>":
5888 "[ <font-style> || <font-variant-css21> || " +
5889 "<font-weight> || <font-stretch> ]? <font-size> " +
5890 "[ / <line-height> ]? <font-family>",
5891
5892 "<font-variant-alternates>":
5893 "stylistic() || " +
5894 "historical-forms || " +
5895 "styleset() || " +
5896 "character-variant() || " +
5897 "swash() || " +
5898 "ornaments() || " +
5899 "annotation()",
5900
5901 "<font-variant-ligatures>":
5902 "[ common-ligatures | no-common-ligatures ] || " +
5903 "[ discretionary-ligatures | no-discretionary-ligatures ] || " +
5904 "[ historical-ligatures | no-historical-ligatures ] || " +
5905 "[ contextual | no-contextual ]",
5906
5907 "<font-variant-numeric>":
5908 "[ lining-nums | oldstyle-nums ] || " +
5909 "[ proportional-nums | tabular-nums ] || " +
5910 "[ diagonal-fractions | stacked-fractions ] || " +
5911 "ordinal || slashed-zero",
5912
5913 "<font-variant-east-asian>":
5914 "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || " +
5915 "[ full-width | proportional-width ] || " +
5916 "ruby",
5917 "<paint>": "<paint-basic> | <uri> <paint-basic>?",
5918 "<paint-basic>": "none | currentColor | <color-svg> <icccolor>?",
5919
5920 "<position>":
5921 "[ center | [ left | right ] [ <percentage> | <length> ]? ] && " +
5922 "[ center | [ top | bottom ] [ <percentage> | <length> ]? ]" +
5923 " | " +
5924 "[ left | center | right | <percentage> | <length> ] " +
5925 "[ top | center | bottom | <percentage> | <length> ]" +
5926 " | " +
5927 "[ left | center | right | top | bottom | <percentage> | <length> ]",
5928
5929 "<repeat-style>":
5930 "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}",
5931
5932 "<shadow>":
5933 Matcher.many([true /* length is required */],
5934 Matcher.cast("<length>").braces(2, 4), "inset", "<color>"),
5935
5936 "<text-decoration-color>":
5937 "<color>",
5938
5939 "<text-decoration-line>":
5940 "none | [ underline || overline || line-through || blink ]",
5941
5942 "<text-decoration-style>":
5943 "solid | double | dotted | dashed | wavy",
5944
5945 "<will-change>":
5946 "auto | <animateable-feature>#",
5947
5948 "<x-one-radius>":
5949 "[ <length> | <percentage> ]{1,2}"
5950 }
5951 });
5952
5953 Object.keys(ValidationTypes.simple).forEach(function(nt) {
5954 var rule = ValidationTypes.simple[nt];
5955 if (typeof rule === "string") {
5956 ValidationTypes.simple[nt] = function(part) {
5957 return ValidationTypes.isLiteral(part, rule);
5958 };
5959 }
5960 });
5961
5962 Object.keys(ValidationTypes.complex).forEach(function(nt) {
5963 var rule = ValidationTypes.complex[nt];
5964 if (typeof rule === "string") {
5965 ValidationTypes.complex[nt] = Matcher.parse(rule);
5966 }
5967 });
5968 ValidationTypes.complex["<font-variant>"] =
5969 Matcher.oror({ expand: "<font-variant-ligatures>" },
5970 { expand: "<font-variant-alternates>" },
5971 "<font-variant-caps>",
5972 { expand: "<font-variant-numeric>" },
5973 { expand: "<font-variant-east-asian>" });
5974
5975 },{"./Matcher":3}],22:[function(require,module,exports){
5976 "use strict";
5977
5978 module.exports = {
5979 Colors : require("./Colors"),
5980 Combinator : require("./Combinator"),
5981 Parser : require("./Parser"),
5982 PropertyName : require("./PropertyName"),
5983 PropertyValue : require("./PropertyValue"),
5984 PropertyValuePart : require("./PropertyValuePart"),
5985 Matcher : require("./Matcher"),
5986 MediaFeature : require("./MediaFeature"),
5987 MediaQuery : require("./MediaQuery"),
5988 Selector : require("./Selector"),
5989 SelectorPart : require("./SelectorPart"),
5990 SelectorSubPart : require("./SelectorSubPart"),
5991 Specificity : require("./Specificity"),
5992 TokenStream : require("./TokenStream"),
5993 Tokens : require("./Tokens"),
5994 ValidationError : require("./ValidationError")
5995 };
5996
5997 },{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(require,module,exports){
5998 "use strict";
5999
6000 module.exports = EventTarget;
6001 function EventTarget() {
6002 this._listeners = Object.create(null);
6003 }
6004
6005 EventTarget.prototype = {
6006 constructor: EventTarget,
6007 addListener: function(type, listener) {
6008 if (!this._listeners[type]) {
6009 this._listeners[type] = [];
6010 }
6011
6012 this._listeners[type].push(listener);
6013 },
6014 fire: function(event) {
6015 if (typeof event === "string") {
6016 event = { type: event };
6017 }
6018 if (typeof event.target !== "undefined") {
6019 event.target = this;
6020 }
6021
6022 if (typeof event.type === "undefined") {
6023 throw new Error("Event object missing 'type' property.");
6024 }
6025
6026 if (this._listeners[event.type]) {
6027 var listeners = this._listeners[event.type].concat();
6028 for (var i = 0, len = listeners.length; i < len; i++) {
6029 listeners[i].call(this, event);
6030 }
6031 }
6032 },
6033 removeListener: function(type, listener) {
6034 if (this._listeners[type]) {
6035 var listeners = this._listeners[type];
6036 for (var i = 0, len = listeners.length; i < len; i++) {
6037 if (listeners[i] === listener) {
6038 listeners.splice(i, 1);
6039 break;
6040 }
6041 }
6042
6043
6044 }
6045 }
6046 };
6047
6048 },{}],24:[function(require,module,exports){
6049 "use strict";
6050
6051 module.exports = StringReader;
6052 function StringReader(text) {
6053 this._input = text.replace(/(\r\n?|\n)/g, "\n");
6054 this._line = 1;
6055 this._col = 1;
6056 this._cursor = 0;
6057 }
6058
6059 StringReader.prototype = {
6060 constructor: StringReader,
6061 getCol: function() {
6062 return this._col;
6063 },
6064 getLine: function() {
6065 return this._line;
6066 },
6067 eof: function() {
6068 return this._cursor === this._input.length;
6069 },
6070 peek: function(count) {
6071 var c = null;
6072 count = typeof count === "undefined" ? 1 : count;
6073 if (this._cursor < this._input.length) {
6074 c = this._input.charAt(this._cursor + count - 1);
6075 }
6076
6077 return c;
6078 },
6079 read: function() {
6080 var c = null;
6081 if (this._cursor < this._input.length) {
6082 if (this._input.charAt(this._cursor) === "\n") {
6083 this._line++;
6084 this._col = 1;
6085 } else {
6086 this._col++;
6087 }
6088 c = this._input.charAt(this._cursor++);
6089 }
6090
6091 return c;
6092 },
6093 mark: function() {
6094 this._bookmark = {
6095 cursor: this._cursor,
6096 line: this._line,
6097 col: this._col
6098 };
6099 },
6100
6101 reset: function() {
6102 if (this._bookmark) {
6103 this._cursor = this._bookmark.cursor;
6104 this._line = this._bookmark.line;
6105 this._col = this._bookmark.col;
6106 delete this._bookmark;
6107 }
6108 },
6109 peekCount: function(count) {
6110 count = typeof count === "undefined" ? 1 : Math.max(count, 0);
6111 return this._input.substring(this._cursor, this._cursor + count);
6112 },
6113 readTo: function(pattern) {
6114
6115 var buffer = "",
6116 c;
6117 while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
6118 c = this.read();
6119 if (c) {
6120 buffer += c;
6121 } else {
6122 throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
6123 }
6124 }
6125
6126 return buffer;
6127
6128 },
6129 readWhile: function(filter) {
6130
6131 var buffer = "",
6132 c = this.peek();
6133
6134 while (c !== null && filter(c)) {
6135 buffer += this.read();
6136 c = this.peek();
6137 }
6138
6139 return buffer;
6140
6141 },
6142 readMatch: function(matcher) {
6143
6144 var source = this._input.substring(this._cursor),
6145 value = null;
6146 if (typeof matcher === "string") {
6147 if (source.slice(0, matcher.length) === matcher) {
6148 value = this.readCount(matcher.length);
6149 }
6150 } else if (matcher instanceof RegExp) {
6151 if (matcher.test(source)) {
6152 value = this.readCount(RegExp.lastMatch.length);
6153 }
6154 }
6155
6156 return value;
6157 },
6158 readCount: function(count) {
6159 var buffer = "";
6160
6161 while (count--) {
6162 buffer += this.read();
6163 }
6164
6165 return buffer;
6166 }
6167
6168 };
6169
6170 },{}],25:[function(require,module,exports){
6171 "use strict";
6172
6173 module.exports = SyntaxError;
6174 function SyntaxError(message, line, col) {
6175 Error.call(this);
6176 this.name = this.constructor.name;
6177 this.col = col;
6178 this.line = line;
6179 this.message = message;
6180
6181 }
6182 SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
6183 SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
6184
6185 },{}],26:[function(require,module,exports){
6186 "use strict";
6187
6188 module.exports = SyntaxUnit;
6189 function SyntaxUnit(text, line, col, type) {
6190 this.col = col;
6191 this.line = line;
6192 this.text = text;
6193 this.type = type;
6194 }
6195 SyntaxUnit.fromToken = function(token) {
6196 return new SyntaxUnit(token.value, token.startLine, token.startCol);
6197 };
6198
6199 SyntaxUnit.prototype = {
6200 constructor: SyntaxUnit,
6201 valueOf: function() {
6202 return this.toString();
6203 },
6204 toString: function() {
6205 return this.text;
6206 }
6207
6208 };
6209
6210 },{}],27:[function(require,module,exports){
6211 "use strict";
6212
6213 module.exports = TokenStreamBase;
6214
6215 var StringReader = require("./StringReader");
6216 var SyntaxError = require("./SyntaxError");
6217 function TokenStreamBase(input, tokenData) {
6218 this._reader = new StringReader(input ? input.toString() : "");
6219 this._token = null;
6220 this._tokenData = tokenData;
6221 this._lt = [];
6222 this._ltIndex = 0;
6223
6224 this._ltIndexCache = [];
6225 }
6226 TokenStreamBase.createTokenData = function(tokens) {
6227
6228 var nameMap = [],
6229 typeMap = Object.create(null),
6230 tokenData = tokens.concat([]),
6231 i = 0,
6232 len = tokenData.length + 1;
6233
6234 tokenData.UNKNOWN = -1;
6235 tokenData.unshift({ name:"EOF" });
6236
6237 for (; i < len; i++) {
6238 nameMap.push(tokenData[i].name);
6239 tokenData[tokenData[i].name] = i;
6240 if (tokenData[i].text) {
6241 typeMap[tokenData[i].text] = i;
6242 }
6243 }
6244
6245 tokenData.name = function(tt) {
6246 return nameMap[tt];
6247 };
6248
6249 tokenData.type = function(c) {
6250 return typeMap[c];
6251 };
6252
6253 return tokenData;
6254 };
6255
6256 TokenStreamBase.prototype = {
6257 constructor: TokenStreamBase,
6258 match: function(tokenTypes, channel) {
6259 if (!(tokenTypes instanceof Array)) {
6260 tokenTypes = [tokenTypes];
6261 }
6262
6263 var tt = this.get(channel),
6264 i = 0,
6265 len = tokenTypes.length;
6266
6267 while (i < len) {
6268 if (tt === tokenTypes[i++]) {
6269 return true;
6270 }
6271 }
6272 this.unget();
6273 return false;
6274 },
6275 mustMatch: function(tokenTypes) {
6276
6277 var token;
6278 if (!(tokenTypes instanceof Array)) {
6279 tokenTypes = [tokenTypes];
6280 }
6281
6282 if (!this.match.apply(this, arguments)) {
6283 token = this.LT(1);
6284 throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
6285 " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
6286 }
6287 },
6288 advance: function(tokenTypes, channel) {
6289
6290 while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
6291 this.get();
6292 }
6293
6294 return this.LA(0);
6295 },
6296 get: function(channel) {
6297
6298 var tokenInfo = this._tokenData,
6299 i = 0,
6300 token,
6301 info;
6302 if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
6303
6304 i++;
6305 this._token = this._lt[this._ltIndex++];
6306 info = tokenInfo[this._token.type];
6307 while ((typeof info.channel !== "undefined" && channel !== info.channel) &&
6308 this._ltIndex < this._lt.length) {
6309 this._token = this._lt[this._ltIndex++];
6310 info = tokenInfo[this._token.type];
6311 i++;
6312 }
6313 if ((typeof info.channel === "undefined" || channel === info.channel) &&
6314 this._ltIndex <= this._lt.length) {
6315 this._ltIndexCache.push(i);
6316 return this._token.type;
6317 }
6318 }
6319 token = this._getToken();
6320 if (token.type > -1 && !tokenInfo[token.type].hide) {
6321 token.channel = tokenInfo[token.type].channel;
6322 this._token = token;
6323 this._lt.push(token);
6324 this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
6325 if (this._lt.length > 5) {
6326 this._lt.shift();
6327 }
6328 if (this._ltIndexCache.length > 5) {
6329 this._ltIndexCache.shift();
6330 }
6331 this._ltIndex = this._lt.length;
6332 }
6333 info = tokenInfo[token.type];
6334 if (info &&
6335 (info.hide ||
6336 (typeof info.channel !== "undefined" && channel !== info.channel))) {
6337 return this.get(channel);
6338 } else {
6339 return token.type;
6340 }
6341 },
6342 LA: function(index) {
6343 var total = index,
6344 tt;
6345 if (index > 0) {
6346 if (index > 5) {
6347 throw new Error("Too much lookahead.");
6348 }
6349 while (total) {
6350 tt = this.get();
6351 total--;
6352 }
6353 while (total < index) {
6354 this.unget();
6355 total++;
6356 }
6357 } else if (index < 0) {
6358
6359 if (this._lt[this._ltIndex + index]) {
6360 tt = this._lt[this._ltIndex + index].type;
6361 } else {
6362 throw new Error("Too much lookbehind.");
6363 }
6364
6365 } else {
6366 tt = this._token.type;
6367 }
6368
6369 return tt;
6370
6371 },
6372 LT: function(index) {
6373 this.LA(index);
6374 return this._lt[this._ltIndex + index - 1];
6375 },
6376 peek: function() {
6377 return this.LA(1);
6378 },
6379 token: function() {
6380 return this._token;
6381 },
6382 tokenName: function(tokenType) {
6383 if (tokenType < 0 || tokenType > this._tokenData.length) {
6384 return "UNKNOWN_TOKEN";
6385 } else {
6386 return this._tokenData[tokenType].name;
6387 }
6388 },
6389 tokenType: function(tokenName) {
6390 return this._tokenData[tokenName] || -1;
6391 },
6392 unget: function() {
6393 if (this._ltIndexCache.length) {
6394 this._ltIndex -= this._ltIndexCache.pop();//--;
6395 this._token = this._lt[this._ltIndex - 1];
6396 } else {
6397 throw new Error("Too much lookahead.");
6398 }
6399 }
6400
6401 };
6402
6403
6404 },{"./StringReader":24,"./SyntaxError":25}],28:[function(require,module,exports){
6405 "use strict";
6406
6407 module.exports = {
6408 StringReader : require("./StringReader"),
6409 SyntaxError : require("./SyntaxError"),
6410 SyntaxUnit : require("./SyntaxUnit"),
6411 EventTarget : require("./EventTarget"),
6412 TokenStreamBase : require("./TokenStreamBase")
6413 };
6414
6415 },{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],"parserlib":[function(require,module,exports){
6416 "use strict";
6417
6418 module.exports = {
6419 css : require("./css"),
6420 util : require("./util")
6421 };
6422
6423 },{"./css":22,"./util":28}]},{},[]);
6424
6425 return require('parserlib');
6426 })();
6427 var clone = (function() {
6428 'use strict';
6429
6430 function _instanceof(obj, type) {
6431 return type != null && obj instanceof type;
6432 }
6433
6434 var nativeMap;
6435 try {
6436 nativeMap = Map;
6437 } catch(_) {
6438 nativeMap = function() {};
6439 }
6440
6441 var nativeSet;
6442 try {
6443 nativeSet = Set;
6444 } catch(_) {
6445 nativeSet = function() {};
6446 }
6447
6448 var nativePromise;
6449 try {
6450 nativePromise = Promise;
6451 } catch(_) {
6452 nativePromise = function() {};
6453 }
6454 function clone(parent, circular, depth, prototype, includeNonEnumerable) {
6455 if (typeof circular === 'object') {
6456 depth = circular.depth;
6457 prototype = circular.prototype;
6458 includeNonEnumerable = circular.includeNonEnumerable;
6459 circular = circular.circular;
6460 }
6461 var allParents = [];
6462 var allChildren = [];
6463
6464 var useBuffer = typeof Buffer != 'undefined';
6465
6466 if (typeof circular == 'undefined')
6467 circular = true;
6468
6469 if (typeof depth == 'undefined')
6470 depth = Infinity;
6471 function _clone(parent, depth) {
6472 if (parent === null)
6473 return null;
6474
6475 if (depth === 0)
6476 return parent;
6477
6478 var child;
6479 var proto;
6480 if (typeof parent != 'object') {
6481 return parent;
6482 }
6483
6484 if (_instanceof(parent, nativeMap)) {
6485 child = new nativeMap();
6486 } else if (_instanceof(parent, nativeSet)) {
6487 child = new nativeSet();
6488 } else if (_instanceof(parent, nativePromise)) {
6489 child = new nativePromise(function (resolve, reject) {
6490 parent.then(function(value) {
6491 resolve(_clone(value, depth - 1));
6492 }, function(err) {
6493 reject(_clone(err, depth - 1));
6494 });
6495 });
6496 } else if (clone.__isArray(parent)) {
6497 child = [];
6498 } else if (clone.__isRegExp(parent)) {
6499 child = new RegExp(parent.source, __getRegExpFlags(parent));
6500 if (parent.lastIndex) child.lastIndex = parent.lastIndex;
6501 } else if (clone.__isDate(parent)) {
6502 child = new Date(parent.getTime());
6503 } else if (useBuffer && Buffer.isBuffer(parent)) {
6504 if (Buffer.allocUnsafe) {
6505 child = Buffer.allocUnsafe(parent.length);
6506 } else {
6507 child = new Buffer(parent.length);
6508 }
6509 parent.copy(child);
6510 return child;
6511 } else if (_instanceof(parent, Error)) {
6512 child = Object.create(parent);
6513 } else {
6514 if (typeof prototype == 'undefined') {
6515 proto = Object.getPrototypeOf(parent);
6516 child = Object.create(proto);
6517 }
6518 else {
6519 child = Object.create(prototype);
6520 proto = prototype;
6521 }
6522 }
6523
6524 if (circular) {
6525 var index = allParents.indexOf(parent);
6526
6527 if (index != -1) {
6528 return allChildren[index];
6529 }
6530 allParents.push(parent);
6531 allChildren.push(child);
6532 }
6533
6534 if (_instanceof(parent, nativeMap)) {
6535 parent.forEach(function(value, key) {
6536 var keyChild = _clone(key, depth - 1);
6537 var valueChild = _clone(value, depth - 1);
6538 child.set(keyChild, valueChild);
6539 });
6540 }
6541 if (_instanceof(parent, nativeSet)) {
6542 parent.forEach(function(value) {
6543 var entryChild = _clone(value, depth - 1);
6544 child.add(entryChild);
6545 });
6546 }
6547
6548 for (var i in parent) {
6549 var attrs;
6550 if (proto) {
6551 attrs = Object.getOwnPropertyDescriptor(proto, i);
6552 }
6553
6554 if (attrs && attrs.set == null) {
6555 continue;
6556 }
6557 child[i] = _clone(parent[i], depth - 1);
6558 }
6559
6560 if (Object.getOwnPropertySymbols) {
6561 var symbols = Object.getOwnPropertySymbols(parent);
6562 for (var i = 0; i < symbols.length; i++) {
6563 var symbol = symbols[i];
6564 var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
6565 if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
6566 continue;
6567 }
6568 child[symbol] = _clone(parent[symbol], depth - 1);
6569 if (!descriptor.enumerable) {
6570 Object.defineProperty(child, symbol, {
6571 enumerable: false
6572 });
6573 }
6574 }
6575 }
6576
6577 if (includeNonEnumerable) {
6578 var allPropertyNames = Object.getOwnPropertyNames(parent);
6579 for (var i = 0; i < allPropertyNames.length; i++) {
6580 var propertyName = allPropertyNames[i];
6581 var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
6582 if (descriptor && descriptor.enumerable) {
6583 continue;
6584 }
6585 child[propertyName] = _clone(parent[propertyName], depth - 1);
6586 Object.defineProperty(child, propertyName, {
6587 enumerable: false
6588 });
6589 }
6590 }
6591
6592 return child;
6593 }
6594
6595 return _clone(parent, depth);
6596 }
6597 clone.clonePrototype = function clonePrototype(parent) {
6598 if (parent === null)
6599 return null;
6600
6601 var c = function () {};
6602 c.prototype = parent;
6603 return new c();
6604 };
6605
6606 function __objToStr(o) {
6607 return Object.prototype.toString.call(o);
6608 }
6609 clone.__objToStr = __objToStr;
6610
6611 function __isDate(o) {
6612 return typeof o === 'object' && __objToStr(o) === '[object Date]';
6613 }
6614 clone.__isDate = __isDate;
6615
6616 function __isArray(o) {
6617 return typeof o === 'object' && __objToStr(o) === '[object Array]';
6618 }
6619 clone.__isArray = __isArray;
6620
6621 function __isRegExp(o) {
6622 return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
6623 }
6624 clone.__isRegExp = __isRegExp;
6625
6626 function __getRegExpFlags(re) {
6627 var flags = '';
6628 if (re.global) flags += 'g';
6629 if (re.ignoreCase) flags += 'i';
6630 if (re.multiline) flags += 'm';
6631 return flags;
6632 }
6633 clone.__getRegExpFlags = __getRegExpFlags;
6634
6635 return clone;
6636 })();
6637
6638 if (typeof module === 'object' && module.exports) {
6639 module.exports = clone;
6640 }
6641
6642 var CSSLint = (function() {
6643 "use strict";
6644
6645 var rules = [],
6646 formatters = [],
6647 embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
6648 api = new parserlib.util.EventTarget();
6649
6650 api.version = "1.0.5";
6651 api.addRule = function(rule) {
6652 rules.push(rule);
6653 rules[rule.id] = rule;
6654 };
6655 api.clearRules = function() {
6656 rules = [];
6657 };
6658 api.getRules = function() {
6659 return [].concat(rules).sort(function(a, b) {
6660 return a.id > b.id ? 1 : 0;
6661 });
6662 };
6663 api.getRuleset = function() {
6664 var ruleset = {},
6665 i = 0,
6666 len = rules.length;
6667
6668 while (i < len) {
6669 ruleset[rules[i++].id] = 1; // by default, everything is a warning
6670 }
6671
6672 return ruleset;
6673 };
6674 function applyEmbeddedRuleset(text, ruleset) {
6675 var valueMap,
6676 embedded = text && text.match(embeddedRuleset),
6677 rules = embedded && embedded[1];
6678
6679 if (rules) {
6680 valueMap = {
6681 "true": 2, // true is error
6682 "": 1, // blank is warning
6683 "false": 0, // false is ignore
6684
6685 "2": 2, // explicit error
6686 "1": 1, // explicit warning
6687 "0": 0 // explicit ignore
6688 };
6689
6690 rules.toLowerCase().split(",").forEach(function(rule) {
6691 var pair = rule.split(":"),
6692 property = pair[0] || "",
6693 value = pair[1] || "";
6694
6695 ruleset[property.trim()] = valueMap[value.trim()];
6696 });
6697 }
6698
6699 return ruleset;
6700 }
6701 api.addFormatter = function(formatter) {
6702 formatters[formatter.id] = formatter;
6703 };
6704 api.getFormatter = function(formatId) {
6705 return formatters[formatId];
6706 };
6707 api.format = function(results, filename, formatId, options) {
6708 var formatter = api.getFormatter(formatId),
6709 result = null;
6710
6711 if (formatter) {
6712 result = formatter.startFormat();
6713 result += formatter.formatResults(results, filename, options || {});
6714 result += formatter.endFormat();
6715 }
6716
6717 return result;
6718 };
6719 api.hasFormat = function(formatId) {
6720 return formatters.hasOwnProperty(formatId);
6721 };
6722 api.verify = function(text, ruleset) {
6723
6724 var i = 0,
6725 reporter,
6726 lines,
6727 allow = {},
6728 ignore = [],
6729 report,
6730 parser = new parserlib.css.Parser({
6731 starHack: true,
6732 ieFilters: true,
6733 underscoreHack: true,
6734 strict: false
6735 });
6736 lines = text.replace(/\n\r?/g, "$split$").split("$split$");
6737 CSSLint.Util.forEach(lines, function (line, lineno) {
6738 var allowLine = line && line.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),
6739 allowRules = allowLine && allowLine[1],
6740 allowRuleset = {};
6741
6742 if (allowRules) {
6743 allowRules.toLowerCase().split(",").forEach(function(allowRule) {
6744 allowRuleset[allowRule.trim()] = true;
6745 });
6746 if (Object.keys(allowRuleset).length > 0) {
6747 allow[lineno + 1] = allowRuleset;
6748 }
6749 }
6750 });
6751
6752 var ignoreStart = null,
6753 ignoreEnd = null;
6754 CSSLint.Util.forEach(lines, function (line, lineno) {
6755 if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
6756 ignoreStart = lineno;
6757 }
6758
6759 if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
6760 ignoreEnd = lineno;
6761 }
6762
6763 if (ignoreStart !== null && ignoreEnd !== null) {
6764 ignore.push([ignoreStart, ignoreEnd]);
6765 ignoreStart = ignoreEnd = null;
6766 }
6767 });
6768 if (ignoreStart !== null) {
6769 ignore.push([ignoreStart, lines.length]);
6770 }
6771
6772 if (!ruleset) {
6773 ruleset = api.getRuleset();
6774 }
6775
6776 if (embeddedRuleset.test(text)) {
6777 ruleset = clone(ruleset);
6778 ruleset = applyEmbeddedRuleset(text, ruleset);
6779 }
6780
6781 reporter = new Reporter(lines, ruleset, allow, ignore);
6782
6783 ruleset.errors = 2; // always report parsing errors as errors
6784 for (i in ruleset) {
6785 if (ruleset.hasOwnProperty(i) && ruleset[i]) {
6786 if (rules[i]) {
6787 rules[i].init(parser, reporter);
6788 }
6789 }
6790 }
6791 try {
6792 parser.parse(text);
6793 } catch (ex) {
6794 reporter.error("Fatal error, cannot continue: " + ex.message, ex.line, ex.col, {});
6795 }
6796
6797 report = {
6798 messages : reporter.messages,
6799 stats : reporter.stats,
6800 ruleset : reporter.ruleset,
6801 allow : reporter.allow,
6802 ignore : reporter.ignore
6803 };
6804 report.messages.sort(function (a, b) {
6805 if (a.rollup && !b.rollup) {
6806 return 1;
6807 } else if (!a.rollup && b.rollup) {
6808 return -1;
6809 } else {
6810 return a.line - b.line;
6811 }
6812 });
6813
6814 return report;
6815 };
6816
6817 return api;
6818
6819 })();
6820 function Reporter(lines, ruleset, allow, ignore) {
6821 "use strict";
6822 this.messages = [];
6823 this.stats = [];
6824 this.lines = lines;
6825 this.ruleset = ruleset;
6826 this.allow = allow;
6827 if (!this.allow) {
6828 this.allow = {};
6829 }
6830 this.ignore = ignore;
6831 if (!this.ignore) {
6832 this.ignore = [];
6833 }
6834 }
6835
6836 Reporter.prototype = {
6837 constructor: Reporter,
6838 error: function(message, line, col, rule) {
6839 "use strict";
6840 this.messages.push({
6841 type : "error",
6842 line : line,
6843 col : col,
6844 message : message,
6845 evidence: this.lines[line-1],
6846 rule : rule || {}
6847 });
6848 },
6849 warn: function(message, line, col, rule) {
6850 "use strict";
6851 this.report(message, line, col, rule);
6852 },
6853 report: function(message, line, col, rule) {
6854 "use strict";
6855 if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) {
6856 return;
6857 }
6858
6859 if (this.isIgnored(line)) {
6860 return;
6861 }
6862
6863 this.messages.push({
6864 type : this.ruleset[rule.id] === 2 ? "error" : "warning",
6865 line : line,
6866 col : col,
6867 message : message,
6868 evidence: this.lines[line-1],
6869 rule : rule
6870 });
6871 },
6872 info: function(message, line, col, rule) {
6873 "use strict";
6874 this.messages.push({
6875 type : "info",
6876 line : line,
6877 col : col,
6878 message : message,
6879 evidence: this.lines[line-1],
6880 rule : rule
6881 });
6882 },
6883 rollupError: function(message, rule) {
6884 "use strict";
6885 this.messages.push({
6886 type : "error",
6887 rollup : true,
6888 message : message,
6889 rule : rule
6890 });
6891 },
6892 rollupWarn: function(message, rule) {
6893 "use strict";
6894 this.messages.push({
6895 type : "warning",
6896 rollup : true,
6897 message : message,
6898 rule : rule
6899 });
6900 },
6901 stat: function(name, value) {
6902 "use strict";
6903 this.stats[name] = value;
6904 },
6905 isIgnored: function(line) {
6906 "use strict";
6907 var ignore = false;
6908 CSSLint.Util.forEach(this.ignore, function (range) {
6909 if (range[0] <= line && line <= range[1]) {
6910 ignore = true;
6911 }
6912 });
6913 return ignore;
6914 }
6915 };
6916 CSSLint._Reporter = Reporter;
6917 CSSLint.Util = {
6918 mix: function(receiver, supplier) {
6919 "use strict";
6920 var prop;
6921
6922 for (prop in supplier) {
6923 if (supplier.hasOwnProperty(prop)) {
6924 receiver[prop] = supplier[prop];
6925 }
6926 }
6927
6928 return prop;
6929 },
6930 indexOf: function(values, value) {
6931 "use strict";
6932 if (values.indexOf) {
6933 return values.indexOf(value);
6934 } else {
6935 for (var i=0, len=values.length; i < len; i++) {
6936 if (values[i] === value) {
6937 return i;
6938 }
6939 }
6940 return -1;
6941 }
6942 },
6943 forEach: function(values, func) {
6944 "use strict";
6945 if (values.forEach) {
6946 return values.forEach(func);
6947 } else {
6948 for (var i=0, len=values.length; i < len; i++) {
6949 func(values[i], i, values);
6950 }
6951 }
6952 }
6953 };
6954 CSSLint.addRule({
6955 id: "box-model",
6956 name: "Beware of broken box size",
6957 desc: "Don't use width or height when using padding or border.",
6958 url: "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",
6959 browsers: "All",
6960 init: function(parser, reporter) {
6961 "use strict";
6962 var rule = this,
6963 widthProperties = {
6964 border: 1,
6965 "border-left": 1,
6966 "border-right": 1,
6967 padding: 1,
6968 "padding-left": 1,
6969 "padding-right": 1
6970 },
6971 heightProperties = {
6972 border: 1,
6973 "border-bottom": 1,
6974 "border-top": 1,
6975 padding: 1,
6976 "padding-bottom": 1,
6977 "padding-top": 1
6978 },
6979 properties,
6980 boxSizing = false;
6981
6982 function startRule() {
6983 properties = {};
6984 boxSizing = false;
6985 }
6986
6987 function endRule() {
6988 var prop, value;
6989
6990 if (!boxSizing) {
6991 if (properties.height) {
6992 for (prop in heightProperties) {
6993 if (heightProperties.hasOwnProperty(prop) && properties[prop]) {
6994 value = properties[prop].value;
6995 if (!(prop === "padding" && value.parts.length === 2 && value.parts[0].value === 0)) {
6996 reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
6997 }
6998 }
6999 }
7000 }
7001
7002 if (properties.width) {
7003 for (prop in widthProperties) {
7004 if (widthProperties.hasOwnProperty(prop) && properties[prop]) {
7005 value = properties[prop].value;
7006
7007 if (!(prop === "padding" && value.parts.length === 2 && value.parts[1].value === 0)) {
7008 reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
7009 }
7010 }
7011 }
7012 }
7013 }
7014 }
7015
7016 parser.addListener("startrule", startRule);
7017 parser.addListener("startfontface", startRule);
7018 parser.addListener("startpage", startRule);
7019 parser.addListener("startpagemargin", startRule);
7020 parser.addListener("startkeyframerule", startRule);
7021 parser.addListener("startviewport", startRule);
7022
7023 parser.addListener("property", function(event) {
7024 var name = event.property.text.toLowerCase();
7025
7026 if (heightProperties[name] || widthProperties[name]) {
7027 if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
7028 properties[name] = {
7029 line: event.property.line,
7030 col: event.property.col,
7031 value: event.value
7032 };
7033 }
7034 } else {
7035 if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
7036 properties[name] = 1;
7037 } else if (name === "box-sizing") {
7038 boxSizing = true;
7039 }
7040 }
7041
7042 });
7043
7044 parser.addListener("endrule", endRule);
7045 parser.addListener("endfontface", endRule);
7046 parser.addListener("endpage", endRule);
7047 parser.addListener("endpagemargin", endRule);
7048 parser.addListener("endkeyframerule", endRule);
7049 parser.addListener("endviewport", endRule);
7050 }
7051
7052 });
7053
7054 CSSLint.addRule({
7055 id: "bulletproof-font-face",
7056 name: "Use the bulletproof @font-face syntax",
7057 desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
7058 url: "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",
7059 browsers: "All",
7060 init: function(parser, reporter) {
7061 "use strict";
7062 var rule = this,
7063 fontFaceRule = false,
7064 firstSrc = true,
7065 ruleFailed = false,
7066 line, col;
7067 parser.addListener("startfontface", function() {
7068 fontFaceRule = true;
7069 });
7070
7071 parser.addListener("property", function(event) {
7072 if (!fontFaceRule) {
7073 return;
7074 }
7075
7076 var propertyName = event.property.toString().toLowerCase(),
7077 value = event.value.toString();
7078 line = event.line;
7079 col = event.col;
7080 if (propertyName === "src") {
7081 var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
7082 if (!value.match(regex) && firstSrc) {
7083 ruleFailed = true;
7084 firstSrc = false;
7085 } else if (value.match(regex) && !firstSrc) {
7086 ruleFailed = false;
7087 }
7088 }
7089
7090
7091 });
7092 parser.addListener("endfontface", function() {
7093 fontFaceRule = false;
7094
7095 if (ruleFailed) {
7096 reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.", line, col, rule);
7097 }
7098 });
7099 }
7100 });
7101
7102 CSSLint.addRule({
7103 id: "compatible-vendor-prefixes",
7104 name: "Require compatible vendor prefixes",
7105 desc: "Include all compatible vendor prefixes to reach a wider range of users.",
7106 url: "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",
7107 browsers: "All",
7108 init: function (parser, reporter) {
7109 "use strict";
7110 var rule = this,
7111 compatiblePrefixes,
7112 properties,
7113 prop,
7114 variations,
7115 prefixed,
7116 i,
7117 len,
7118 inKeyFrame = false,
7119 arrayPush = Array.prototype.push,
7120 applyTo = [];
7121 compatiblePrefixes = {
7122 "animation" : "webkit",
7123 "animation-delay" : "webkit",
7124 "animation-direction" : "webkit",
7125 "animation-duration" : "webkit",
7126 "animation-fill-mode" : "webkit",
7127 "animation-iteration-count" : "webkit",
7128 "animation-name" : "webkit",
7129 "animation-play-state" : "webkit",
7130 "animation-timing-function" : "webkit",
7131 "appearance" : "webkit moz",
7132 "border-end" : "webkit moz",
7133 "border-end-color" : "webkit moz",
7134 "border-end-style" : "webkit moz",
7135 "border-end-width" : "webkit moz",
7136 "border-image" : "webkit moz o",
7137 "border-radius" : "webkit",
7138 "border-start" : "webkit moz",
7139 "border-start-color" : "webkit moz",
7140 "border-start-style" : "webkit moz",
7141 "border-start-width" : "webkit moz",
7142 "box-align" : "webkit moz",
7143 "box-direction" : "webkit moz",
7144 "box-flex" : "webkit moz",
7145 "box-lines" : "webkit",
7146 "box-ordinal-group" : "webkit moz",
7147 "box-orient" : "webkit moz",
7148 "box-pack" : "webkit moz",
7149 "box-sizing" : "",
7150 "box-shadow" : "",
7151 "column-count" : "webkit moz ms",
7152 "column-gap" : "webkit moz ms",
7153 "column-rule" : "webkit moz ms",
7154 "column-rule-color" : "webkit moz ms",
7155 "column-rule-style" : "webkit moz ms",
7156 "column-rule-width" : "webkit moz ms",
7157 "column-width" : "webkit moz ms",
7158 "flex" : "webkit ms",
7159 "flex-basis" : "webkit",
7160 "flex-direction" : "webkit ms",
7161 "flex-flow" : "webkit",
7162 "flex-grow" : "webkit",
7163 "flex-shrink" : "webkit",
7164 "hyphens" : "epub moz",
7165 "line-break" : "webkit ms",
7166 "margin-end" : "webkit moz",
7167 "margin-start" : "webkit moz",
7168 "marquee-speed" : "webkit wap",
7169 "marquee-style" : "webkit wap",
7170 "padding-end" : "webkit moz",
7171 "padding-start" : "webkit moz",
7172 "tab-size" : "moz o",
7173 "text-size-adjust" : "webkit ms",
7174 "transform" : "webkit ms",
7175 "transform-origin" : "webkit ms",
7176 "transition" : "",
7177 "transition-delay" : "",
7178 "transition-duration" : "",
7179 "transition-property" : "",
7180 "transition-timing-function" : "",
7181 "user-modify" : "webkit moz",
7182 "user-select" : "webkit moz ms",
7183 "word-break" : "epub ms",
7184 "writing-mode" : "epub ms"
7185 };
7186
7187
7188 for (prop in compatiblePrefixes) {
7189 if (compatiblePrefixes.hasOwnProperty(prop)) {
7190 variations = [];
7191 prefixed = compatiblePrefixes[prop].split(" ");
7192 for (i = 0, len = prefixed.length; i < len; i++) {
7193 variations.push("-" + prefixed[i] + "-" + prop);
7194 }
7195 compatiblePrefixes[prop] = variations;
7196 arrayPush.apply(applyTo, variations);
7197 }
7198 }
7199
7200 parser.addListener("startrule", function () {
7201 properties = [];
7202 });
7203
7204 parser.addListener("startkeyframes", function (event) {
7205 inKeyFrame = event.prefix || true;
7206 });
7207
7208 parser.addListener("endkeyframes", function () {
7209 inKeyFrame = false;
7210 });
7211
7212 parser.addListener("property", function (event) {
7213 var name = event.property;
7214 if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
7215 if (!inKeyFrame || typeof inKeyFrame !== "string" ||
7216 name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
7217 properties.push(name);
7218 }
7219 }
7220 });
7221
7222 parser.addListener("endrule", function () {
7223 if (!properties.length) {
7224 return;
7225 }
7226
7227 var propertyGroups = {},
7228 i,
7229 len,
7230 name,
7231 prop,
7232 variations,
7233 value,
7234 full,
7235 actual,
7236 item,
7237 propertiesSpecified;
7238
7239 for (i = 0, len = properties.length; i < len; i++) {
7240 name = properties[i];
7241
7242 for (prop in compatiblePrefixes) {
7243 if (compatiblePrefixes.hasOwnProperty(prop)) {
7244 variations = compatiblePrefixes[prop];
7245 if (CSSLint.Util.indexOf(variations, name.text) > -1) {
7246 if (!propertyGroups[prop]) {
7247 propertyGroups[prop] = {
7248 full: variations.slice(0),
7249 actual: [],
7250 actualNodes: []
7251 };
7252 }
7253 if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
7254 propertyGroups[prop].actual.push(name.text);
7255 propertyGroups[prop].actualNodes.push(name);
7256 }
7257 }
7258 }
7259 }
7260 }
7261
7262 for (prop in propertyGroups) {
7263 if (propertyGroups.hasOwnProperty(prop)) {
7264 value = propertyGroups[prop];
7265 full = value.full;
7266 actual = value.actual;
7267
7268 if (full.length > actual.length) {
7269 for (i = 0, len = full.length; i < len; i++) {
7270 item = full[i];
7271 if (CSSLint.Util.indexOf(actual, item) === -1) {
7272 propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length === 2) ? actual.join(" and ") : actual.join(", ");
7273 reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
7274 }
7275 }
7276
7277 }
7278 }
7279 }
7280 });
7281 }
7282 });
7283
7284 CSSLint.addRule({
7285 id: "display-property-grouping",
7286 name: "Require properties appropriate for display",
7287 desc: "Certain properties shouldn't be used with certain display property values.",
7288 url: "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",
7289 browsers: "All",
7290 init: function(parser, reporter) {
7291 "use strict";
7292 var rule = this;
7293
7294 var propertiesToCheck = {
7295 display: 1,
7296 "float": "none",
7297 height: 1,
7298 width: 1,
7299 margin: 1,
7300 "margin-left": 1,
7301 "margin-right": 1,
7302 "margin-bottom": 1,
7303 "margin-top": 1,
7304 padding: 1,
7305 "padding-left": 1,
7306 "padding-right": 1,
7307 "padding-bottom": 1,
7308 "padding-top": 1,
7309 "vertical-align": 1
7310 },
7311 properties;
7312
7313 function reportProperty(name, display, msg) {
7314 if (properties[name]) {
7315 if (typeof propertiesToCheck[name] !== "string" || properties[name].value.toLowerCase() !== propertiesToCheck[name]) {
7316 reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
7317 }
7318 }
7319 }
7320
7321 function startRule() {
7322 properties = {};
7323 }
7324
7325 function endRule() {
7326
7327 var display = properties.display ? properties.display.value : null;
7328 if (display) {
7329 switch (display) {
7330
7331 case "inline":
7332 reportProperty("height", display);
7333 reportProperty("width", display);
7334 reportProperty("margin", display);
7335 reportProperty("margin-top", display);
7336 reportProperty("margin-bottom", display);
7337 reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
7338 break;
7339
7340 case "block":
7341 reportProperty("vertical-align", display);
7342 break;
7343
7344 case "inline-block":
7345 reportProperty("float", display);
7346 break;
7347
7348 default:
7349 if (display.indexOf("table-") === 0) {
7350 reportProperty("margin", display);
7351 reportProperty("margin-left", display);
7352 reportProperty("margin-right", display);
7353 reportProperty("margin-top", display);
7354 reportProperty("margin-bottom", display);
7355 reportProperty("float", display);
7356 }
7357 }
7358 }
7359
7360 }
7361
7362 parser.addListener("startrule", startRule);
7363 parser.addListener("startfontface", startRule);
7364 parser.addListener("startkeyframerule", startRule);
7365 parser.addListener("startpagemargin", startRule);
7366 parser.addListener("startpage", startRule);
7367 parser.addListener("startviewport", startRule);
7368
7369 parser.addListener("property", function(event) {
7370 var name = event.property.text.toLowerCase();
7371
7372 if (propertiesToCheck[name]) {
7373 properties[name] = {
7374 value: event.value.text,
7375 line: event.property.line,
7376 col: event.property.col
7377 };
7378 }
7379 });
7380
7381 parser.addListener("endrule", endRule);
7382 parser.addListener("endfontface", endRule);
7383 parser.addListener("endkeyframerule", endRule);
7384 parser.addListener("endpagemargin", endRule);
7385 parser.addListener("endpage", endRule);
7386 parser.addListener("endviewport", endRule);
7387
7388 }
7389
7390 });
7391
7392 CSSLint.addRule({
7393 id: "duplicate-background-images",
7394 name: "Disallow duplicate background images",
7395 desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
7396 url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",
7397 browsers: "All",
7398 init: function(parser, reporter) {
7399 "use strict";
7400 var rule = this,
7401 stack = {};
7402
7403 parser.addListener("property", function(event) {
7404 var name = event.property.text,
7405 value = event.value,
7406 i, len;
7407
7408 if (name.match(/background/i)) {
7409 for (i=0, len=value.parts.length; i < len; i++) {
7410 if (value.parts[i].type === "uri") {
7411 if (typeof stack[value.parts[i].uri] === "undefined") {
7412 stack[value.parts[i].uri] = event;
7413 } else {
7414 reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
7415 }
7416 }
7417 }
7418 }
7419 });
7420 }
7421 });
7422
7423 CSSLint.addRule({
7424 id: "duplicate-properties",
7425 name: "Disallow duplicate properties",
7426 desc: "Duplicate properties must appear one after the other.",
7427 url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",
7428 browsers: "All",
7429 init: function(parser, reporter) {
7430 "use strict";
7431 var rule = this,
7432 properties,
7433 lastProperty;
7434
7435 function startRule() {
7436 properties = {};
7437 }
7438
7439 parser.addListener("startrule", startRule);
7440 parser.addListener("startfontface", startRule);
7441 parser.addListener("startpage", startRule);
7442 parser.addListener("startpagemargin", startRule);
7443 parser.addListener("startkeyframerule", startRule);
7444 parser.addListener("startviewport", startRule);
7445
7446 parser.addListener("property", function(event) {
7447 var property = event.property,
7448 name = property.text.toLowerCase();
7449
7450 if (properties[name] && (lastProperty !== name || properties[name] === event.value.text)) {
7451 reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
7452 }
7453
7454 properties[name] = event.value.text;
7455 lastProperty = name;
7456
7457 });
7458
7459
7460 }
7461
7462 });
7463
7464 CSSLint.addRule({
7465 id: "empty-rules",
7466 name: "Disallow empty rules",
7467 desc: "Rules without any properties specified should be removed.",
7468 url: "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",
7469 browsers: "All",
7470 init: function(parser, reporter) {
7471 "use strict";
7472 var rule = this,
7473 count = 0;
7474
7475 parser.addListener("startrule", function() {
7476 count=0;
7477 });
7478
7479 parser.addListener("property", function() {
7480 count++;
7481 });
7482
7483 parser.addListener("endrule", function(event) {
7484 var selectors = event.selectors;
7485
7486 if (count === 0) {
7487 reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
7488 }
7489 });
7490 }
7491
7492 });
7493
7494 CSSLint.addRule({
7495 id: "errors",
7496 name: "Parsing Errors",
7497 desc: "This rule looks for recoverable syntax errors.",
7498 browsers: "All",
7499 init: function(parser, reporter) {
7500 "use strict";
7501 var rule = this;
7502
7503 parser.addListener("error", function(event) {
7504 reporter.error(event.message, event.line, event.col, rule);
7505 });
7506
7507 }
7508
7509 });
7510
7511 CSSLint.addRule({
7512 id: "floats",
7513 name: "Disallow too many floats",
7514 desc: "This rule tests if the float property is used too many times",
7515 url: "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",
7516 browsers: "All",
7517 init: function(parser, reporter) {
7518 "use strict";
7519 var rule = this;
7520 var count = 0;
7521 parser.addListener("property", function(event) {
7522 if (!reporter.isIgnored(event.property.line)) {
7523 if (event.property.text.toLowerCase() === "float" &&
7524 event.value.text.toLowerCase() !== "none") {
7525 count++;
7526 }
7527 }
7528 });
7529 parser.addListener("endstylesheet", function() {
7530 reporter.stat("floats", count);
7531 if (count >= 10) {
7532 reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
7533 }
7534 });
7535 }
7536
7537 });
7538
7539 CSSLint.addRule({
7540 id: "font-faces",
7541 name: "Don't use too many web fonts",
7542 desc: "Too many different web fonts in the same stylesheet.",
7543 url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",
7544 browsers: "All",
7545 init: function(parser, reporter) {
7546 "use strict";
7547 var rule = this,
7548 count = 0;
7549
7550
7551 parser.addListener("startfontface", function(event) {
7552 if (!reporter.isIgnored(event.line)) {
7553 count++;
7554 }
7555 });
7556
7557 parser.addListener("endstylesheet", function() {
7558 if (count > 5) {
7559 reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
7560 }
7561 });
7562 }
7563
7564 });
7565
7566 CSSLint.addRule({
7567 id: "font-sizes",
7568 name: "Disallow too many font sizes",
7569 desc: "Checks the number of font-size declarations.",
7570 url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
7571 browsers: "All",
7572 init: function(parser, reporter) {
7573 "use strict";
7574 var rule = this,
7575 count = 0;
7576 parser.addListener("property", function(event) {
7577 if (!reporter.isIgnored(event.property.line)) {
7578 if (event.property.toString() === "font-size") {
7579 count++;
7580 }
7581 }
7582 });
7583 parser.addListener("endstylesheet", function() {
7584 reporter.stat("font-sizes", count);
7585 if (count >= 10) {
7586 reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
7587 }
7588 });
7589 }
7590
7591 });
7592
7593 CSSLint.addRule({
7594 id: "gradients",
7595 name: "Require all gradient definitions",
7596 desc: "When using a vendor-prefixed gradient, make sure to use them all.",
7597 url: "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",
7598 browsers: "All",
7599 init: function(parser, reporter) {
7600 "use strict";
7601 var rule = this,
7602 gradients;
7603
7604 parser.addListener("startrule", function() {
7605 gradients = {
7606 moz: 0,
7607 webkit: 0,
7608 oldWebkit: 0,
7609 o: 0
7610 };
7611 });
7612
7613 parser.addListener("property", function(event) {
7614
7615 if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)) {
7616 gradients[RegExp.$1] = 1;
7617 } else if (/\-webkit\-gradient/i.test(event.value)) {
7618 gradients.oldWebkit = 1;
7619 }
7620
7621 });
7622
7623 parser.addListener("endrule", function(event) {
7624 var missing = [];
7625
7626 if (!gradients.moz) {
7627 missing.push("Firefox 3.6+");
7628 }
7629
7630 if (!gradients.webkit) {
7631 missing.push("Webkit (Safari 5+, Chrome)");
7632 }
7633
7634 if (!gradients.oldWebkit) {
7635 missing.push("Old Webkit (Safari 4+, Chrome)");
7636 }
7637
7638 if (!gradients.o) {
7639 missing.push("Opera 11.1+");
7640 }
7641
7642 if (missing.length && missing.length < 4) {
7643 reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
7644 }
7645
7646 });
7647
7648 }
7649
7650 });
7651
7652 CSSLint.addRule({
7653 id: "ids",
7654 name: "Disallow IDs in selectors",
7655 desc: "Selectors should not contain IDs.",
7656 url: "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",
7657 browsers: "All",
7658 init: function(parser, reporter) {
7659 "use strict";
7660 var rule = this;
7661 parser.addListener("startrule", function(event) {
7662 var selectors = event.selectors,
7663 selector,
7664 part,
7665 modifier,
7666 idCount,
7667 i, j, k;
7668
7669 for (i=0; i < selectors.length; i++) {
7670 selector = selectors[i];
7671 idCount = 0;
7672
7673 for (j=0; j < selector.parts.length; j++) {
7674 part = selector.parts[j];
7675 if (part.type === parser.SELECTOR_PART_TYPE) {
7676 for (k=0; k < part.modifiers.length; k++) {
7677 modifier = part.modifiers[k];
7678 if (modifier.type === "id") {
7679 idCount++;
7680 }
7681 }
7682 }
7683 }
7684
7685 if (idCount === 1) {
7686 reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
7687 } else if (idCount > 1) {
7688 reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
7689 }
7690 }
7691
7692 });
7693 }
7694
7695 });
7696
7697 CSSLint.addRule({
7698 id: "import-ie-limit",
7699 name: "@import limit on IE6-IE9",
7700 desc: "IE6-9 supports up to 31 @import per stylesheet",
7701 browsers: "IE6, IE7, IE8, IE9",
7702 init: function(parser, reporter) {
7703 "use strict";
7704 var rule = this,
7705 MAX_IMPORT_COUNT = 31,
7706 count = 0;
7707
7708 function startPage() {
7709 count = 0;
7710 }
7711
7712 parser.addListener("startpage", startPage);
7713
7714 parser.addListener("import", function() {
7715 count++;
7716 });
7717
7718 parser.addListener("endstylesheet", function() {
7719 if (count > MAX_IMPORT_COUNT) {
7720 reporter.rollupError(
7721 "Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
7722 rule
7723 );
7724 }
7725 });
7726 }
7727
7728 });
7729
7730 CSSLint.addRule({
7731 id: "import",
7732 name: "Disallow @import",
7733 desc: "Don't use @import, use <link> instead.",
7734 url: "https://github.com/CSSLint/csslint/wiki/Disallow-%40import",
7735 browsers: "All",
7736 init: function(parser, reporter) {
7737 "use strict";
7738 var rule = this;
7739
7740 parser.addListener("import", function(event) {
7741 reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
7742 });
7743
7744 }
7745
7746 });
7747
7748 CSSLint.addRule({
7749 id: "important",
7750 name: "Disallow !important",
7751 desc: "Be careful when using !important declaration",
7752 url: "https://github.com/CSSLint/csslint/wiki/Disallow-%21important",
7753 browsers: "All",
7754 init: function(parser, reporter) {
7755 "use strict";
7756 var rule = this,
7757 count = 0;
7758 parser.addListener("property", function(event) {
7759 if (!reporter.isIgnored(event.line)) {
7760 if (event.important === true) {
7761 count++;
7762 reporter.report("Use of !important", event.line, event.col, rule);
7763 }
7764 }
7765 });
7766 parser.addListener("endstylesheet", function() {
7767 reporter.stat("important", count);
7768 if (count >= 10) {
7769 reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
7770 }
7771 });
7772 }
7773
7774 });
7775
7776 CSSLint.addRule({
7777 id: "known-properties",
7778 name: "Require use of known properties",
7779 desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
7780 url: "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",
7781 browsers: "All",
7782 init: function(parser, reporter) {
7783 "use strict";
7784 var rule = this;
7785
7786 parser.addListener("property", function(event) {
7787 if (event.invalid) {
7788 reporter.report(event.invalid.message, event.line, event.col, rule);
7789 }
7790
7791 });
7792 }
7793
7794 });
7795
7796 CSSLint.addRule({
7797 id: "order-alphabetical",
7798 name: "Alphabetical order",
7799 desc: "Assure properties are in alphabetical order",
7800 browsers: "All",
7801 init: function(parser, reporter) {
7802 "use strict";
7803 var rule = this,
7804 properties;
7805
7806 var startRule = function () {
7807 properties = [];
7808 };
7809
7810 var endRule = function(event) {
7811 var currentProperties = properties.join(","),
7812 expectedProperties = properties.sort().join(",");
7813
7814 if (currentProperties !== expectedProperties) {
7815 reporter.report("Rule doesn't have all its properties in alphabetical order.", event.line, event.col, rule);
7816 }
7817 };
7818
7819 parser.addListener("startrule", startRule);
7820 parser.addListener("startfontface", startRule);
7821 parser.addListener("startpage", startRule);
7822 parser.addListener("startpagemargin", startRule);
7823 parser.addListener("startkeyframerule", startRule);
7824 parser.addListener("startviewport", startRule);
7825
7826 parser.addListener("property", function(event) {
7827 var name = event.property.text,
7828 lowerCasePrefixLessName = name.toLowerCase().replace(/^-.*?-/, "");
7829
7830 properties.push(lowerCasePrefixLessName);
7831 });
7832
7833 parser.addListener("endrule", endRule);
7834 parser.addListener("endfontface", endRule);
7835 parser.addListener("endpage", endRule);
7836 parser.addListener("endpagemargin", endRule);
7837 parser.addListener("endkeyframerule", endRule);
7838 parser.addListener("endviewport", endRule);
7839 }
7840
7841 });
7842
7843 CSSLint.addRule({
7844 id: "outline-none",
7845 name: "Disallow outline: none",
7846 desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
7847 url: "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",
7848 browsers: "All",
7849 tags: ["Accessibility"],
7850 init: function(parser, reporter) {
7851 "use strict";
7852 var rule = this,
7853 lastRule;
7854
7855 function startRule(event) {
7856 if (event.selectors) {
7857 lastRule = {
7858 line: event.line,
7859 col: event.col,
7860 selectors: event.selectors,
7861 propCount: 0,
7862 outline: false
7863 };
7864 } else {
7865 lastRule = null;
7866 }
7867 }
7868
7869 function endRule() {
7870 if (lastRule) {
7871 if (lastRule.outline) {
7872 if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") === -1) {
7873 reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
7874 } else if (lastRule.propCount === 1) {
7875 reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
7876 }
7877 }
7878 }
7879 }
7880
7881 parser.addListener("startrule", startRule);
7882 parser.addListener("startfontface", startRule);
7883 parser.addListener("startpage", startRule);
7884 parser.addListener("startpagemargin", startRule);
7885 parser.addListener("startkeyframerule", startRule);
7886 parser.addListener("startviewport", startRule);
7887
7888 parser.addListener("property", function(event) {
7889 var name = event.property.text.toLowerCase(),
7890 value = event.value;
7891
7892 if (lastRule) {
7893 lastRule.propCount++;
7894 if (name === "outline" && (value.toString() === "none" || value.toString() === "0")) {
7895 lastRule.outline = true;
7896 }
7897 }
7898
7899 });
7900
7901 parser.addListener("endrule", endRule);
7902 parser.addListener("endfontface", endRule);
7903 parser.addListener("endpage", endRule);
7904 parser.addListener("endpagemargin", endRule);
7905 parser.addListener("endkeyframerule", endRule);
7906 parser.addListener("endviewport", endRule);
7907
7908 }
7909
7910 });
7911
7912 CSSLint.addRule({
7913 id: "overqualified-elements",
7914 name: "Disallow overqualified elements",
7915 desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
7916 url: "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",
7917 browsers: "All",
7918 init: function(parser, reporter) {
7919 "use strict";
7920 var rule = this,
7921 classes = {};
7922
7923 parser.addListener("startrule", function(event) {
7924 var selectors = event.selectors,
7925 selector,
7926 part,
7927 modifier,
7928 i, j, k;
7929
7930 for (i=0; i < selectors.length; i++) {
7931 selector = selectors[i];
7932
7933 for (j=0; j < selector.parts.length; j++) {
7934 part = selector.parts[j];
7935 if (part.type === parser.SELECTOR_PART_TYPE) {
7936 for (k=0; k < part.modifiers.length; k++) {
7937 modifier = part.modifiers[k];
7938 if (part.elementName && modifier.type === "id") {
7939 reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
7940 } else if (modifier.type === "class") {
7941
7942 if (!classes[modifier]) {
7943 classes[modifier] = [];
7944 }
7945 classes[modifier].push({
7946 modifier: modifier,
7947 part: part
7948 });
7949 }
7950 }
7951 }
7952 }
7953 }
7954 });
7955
7956 parser.addListener("endstylesheet", function() {
7957
7958 var prop;
7959 for (prop in classes) {
7960 if (classes.hasOwnProperty(prop)) {
7961 if (classes[prop].length === 1 && classes[prop][0].part.elementName) {
7962 reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
7963 }
7964 }
7965 }
7966 });
7967 }
7968
7969 });
7970
7971 CSSLint.addRule({
7972 id: "regex-selectors",
7973 name: "Disallow selectors that look like regexs",
7974 desc: "Selectors that look like regular expressions are slow and should be avoided.",
7975 url: "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",
7976 browsers: "All",
7977 init: function(parser, reporter) {
7978 "use strict";
7979 var rule = this;
7980
7981 parser.addListener("startrule", function(event) {
7982 var selectors = event.selectors,
7983 selector,
7984 part,
7985 modifier,
7986 i, j, k;
7987
7988 for (i=0; i < selectors.length; i++) {
7989 selector = selectors[i];
7990 for (j=0; j < selector.parts.length; j++) {
7991 part = selector.parts[j];
7992 if (part.type === parser.SELECTOR_PART_TYPE) {
7993 for (k=0; k < part.modifiers.length; k++) {
7994 modifier = part.modifiers[k];
7995 if (modifier.type === "attribute") {
7996 if (/([~\|\^\$\*]=)/.test(modifier)) {
7997 reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
7998 }
7999 }
8000
8001 }
8002 }
8003 }
8004 }
8005 });
8006 }
8007
8008 });
8009
8010 CSSLint.addRule({
8011 id: "rules-count",
8012 name: "Rules Count",
8013 desc: "Track how many rules there are.",
8014 browsers: "All",
8015 init: function(parser, reporter) {
8016 "use strict";
8017 var count = 0;
8018 parser.addListener("startrule", function() {
8019 count++;
8020 });
8021
8022 parser.addListener("endstylesheet", function() {
8023 reporter.stat("rule-count", count);
8024 });
8025 }
8026
8027 });
8028
8029 CSSLint.addRule({
8030 id: "selector-max-approaching",
8031 name: "Warn when approaching the 4095 selector limit for IE",
8032 desc: "Will warn when selector count is >= 3800 selectors.",
8033 browsers: "IE",
8034 init: function(parser, reporter) {
8035 "use strict";
8036 var rule = this, count = 0;
8037
8038 parser.addListener("startrule", function(event) {
8039 count += event.selectors.length;
8040 });
8041
8042 parser.addListener("endstylesheet", function() {
8043 if (count >= 3800) {
8044 reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
8045 }
8046 });
8047 }
8048
8049 });
8050
8051 CSSLint.addRule({
8052 id: "selector-max",
8053 name: "Error when past the 4095 selector limit for IE",
8054 desc: "Will error when selector count is > 4095.",
8055 browsers: "IE",
8056 init: function(parser, reporter) {
8057 "use strict";
8058 var rule = this, count = 0;
8059
8060 parser.addListener("startrule", function(event) {
8061 count += event.selectors.length;
8062 });
8063
8064 parser.addListener("endstylesheet", function() {
8065 if (count > 4095) {
8066 reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
8067 }
8068 });
8069 }
8070
8071 });
8072
8073 CSSLint.addRule({
8074 id: "selector-newline",
8075 name: "Disallow new-line characters in selectors",
8076 desc: "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",
8077 browsers: "All",
8078 init: function(parser, reporter) {
8079 "use strict";
8080 var rule = this;
8081
8082 function startRule(event) {
8083 var i, len, selector, p, n, pLen, part, part2, type, currentLine, nextLine,
8084 selectors = event.selectors;
8085
8086 for (i = 0, len = selectors.length; i < len; i++) {
8087 selector = selectors[i];
8088 for (p = 0, pLen = selector.parts.length; p < pLen; p++) {
8089 for (n = p + 1; n < pLen; n++) {
8090 part = selector.parts[p];
8091 part2 = selector.parts[n];
8092 type = part.type;
8093 currentLine = part.line;
8094 nextLine = part2.line;
8095
8096 if (type === "descendant" && nextLine > currentLine) {
8097 reporter.report("newline character found in selector (forgot a comma?)", currentLine, selectors[i].parts[0].col, rule);
8098 }
8099 }
8100 }
8101
8102 }
8103 }
8104
8105 parser.addListener("startrule", startRule);
8106
8107 }
8108 });
8109
8110 CSSLint.addRule({
8111 id: "shorthand",
8112 name: "Require shorthand properties",
8113 desc: "Use shorthand properties where possible.",
8114 url: "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",
8115 browsers: "All",
8116 init: function(parser, reporter) {
8117 "use strict";
8118 var rule = this,
8119 prop, i, len,
8120 propertiesToCheck = {},
8121 properties,
8122 mapping = {
8123 "margin": [
8124 "margin-top",
8125 "margin-bottom",
8126 "margin-left",
8127 "margin-right"
8128 ],
8129 "padding": [
8130 "padding-top",
8131 "padding-bottom",
8132 "padding-left",
8133 "padding-right"
8134 ]
8135 };
8136 for (prop in mapping) {
8137 if (mapping.hasOwnProperty(prop)) {
8138 for (i=0, len=mapping[prop].length; i < len; i++) {
8139 propertiesToCheck[mapping[prop][i]] = prop;
8140 }
8141 }
8142 }
8143
8144 function startRule() {
8145 properties = {};
8146 }
8147 function endRule(event) {
8148
8149 var prop, i, len, total;
8150 for (prop in mapping) {
8151 if (mapping.hasOwnProperty(prop)) {
8152 total=0;
8153
8154 for (i=0, len=mapping[prop].length; i < len; i++) {
8155 total += properties[mapping[prop][i]] ? 1 : 0;
8156 }
8157
8158 if (total === mapping[prop].length) {
8159 reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
8160 }
8161 }
8162 }
8163 }
8164
8165 parser.addListener("startrule", startRule);
8166 parser.addListener("startfontface", startRule);
8167 parser.addListener("property", function(event) {
8168 var name = event.property.toString().toLowerCase();
8169
8170 if (propertiesToCheck[name]) {
8171 properties[name] = 1;
8172 }
8173 });
8174
8175 parser.addListener("endrule", endRule);
8176 parser.addListener("endfontface", endRule);
8177
8178 }
8179
8180 });
8181
8182 CSSLint.addRule({
8183 id: "star-property-hack",
8184 name: "Disallow properties with a star prefix",
8185 desc: "Checks for the star property hack (targets IE6/7)",
8186 url: "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",
8187 browsers: "All",
8188 init: function(parser, reporter) {
8189 "use strict";
8190 var rule = this;
8191 parser.addListener("property", function(event) {
8192 var property = event.property;
8193
8194 if (property.hack === "*") {
8195 reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
8196 }
8197 });
8198 }
8199 });
8200
8201 CSSLint.addRule({
8202 id: "text-indent",
8203 name: "Disallow negative text-indent",
8204 desc: "Checks for text indent less than -99px",
8205 url: "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",
8206 browsers: "All",
8207 init: function(parser, reporter) {
8208 "use strict";
8209 var rule = this,
8210 textIndent,
8211 direction;
8212
8213
8214 function startRule() {
8215 textIndent = false;
8216 direction = "inherit";
8217 }
8218 function endRule() {
8219 if (textIndent && direction !== "ltr") {
8220 reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
8221 }
8222 }
8223
8224 parser.addListener("startrule", startRule);
8225 parser.addListener("startfontface", startRule);
8226 parser.addListener("property", function(event) {
8227 var name = event.property.toString().toLowerCase(),
8228 value = event.value;
8229
8230 if (name === "text-indent" && value.parts[0].value < -99) {
8231 textIndent = event.property;
8232 } else if (name === "direction" && value.toString() === "ltr") {
8233 direction = "ltr";
8234 }
8235 });
8236
8237 parser.addListener("endrule", endRule);
8238 parser.addListener("endfontface", endRule);
8239
8240 }
8241
8242 });
8243
8244 CSSLint.addRule({
8245 id: "underscore-property-hack",
8246 name: "Disallow properties with an underscore prefix",
8247 desc: "Checks for the underscore property hack (targets IE6)",
8248 url: "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",
8249 browsers: "All",
8250 init: function(parser, reporter) {
8251 "use strict";
8252 var rule = this;
8253 parser.addListener("property", function(event) {
8254 var property = event.property;
8255
8256 if (property.hack === "_") {
8257 reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
8258 }
8259 });
8260 }
8261 });
8262
8263 CSSLint.addRule({
8264 id: "universal-selector",
8265 name: "Disallow universal selector",
8266 desc: "The universal selector (*) is known to be slow.",
8267 url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",
8268 browsers: "All",
8269 init: function(parser, reporter) {
8270 "use strict";
8271 var rule = this;
8272
8273 parser.addListener("startrule", function(event) {
8274 var selectors = event.selectors,
8275 selector,
8276 part,
8277 i;
8278
8279 for (i=0; i < selectors.length; i++) {
8280 selector = selectors[i];
8281
8282 part = selector.parts[selector.parts.length-1];
8283 if (part.elementName === "*") {
8284 reporter.report(rule.desc, part.line, part.col, rule);
8285 }
8286 }
8287 });
8288 }
8289
8290 });
8291
8292 CSSLint.addRule({
8293 id: "unqualified-attributes",
8294 name: "Disallow unqualified attribute selectors",
8295 desc: "Unqualified attribute selectors are known to be slow.",
8296 url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",
8297 browsers: "All",
8298 init: function(parser, reporter) {
8299 "use strict";
8300
8301 var rule = this;
8302
8303 parser.addListener("startrule", function(event) {
8304
8305 var selectors = event.selectors,
8306 selectorContainsClassOrId = false,
8307 selector,
8308 part,
8309 modifier,
8310 i, k;
8311
8312 for (i=0; i < selectors.length; i++) {
8313 selector = selectors[i];
8314
8315 part = selector.parts[selector.parts.length-1];
8316 if (part.type === parser.SELECTOR_PART_TYPE) {
8317 for (k=0; k < part.modifiers.length; k++) {
8318 modifier = part.modifiers[k];
8319
8320 if (modifier.type === "class" || modifier.type === "id") {
8321 selectorContainsClassOrId = true;
8322 break;
8323 }
8324 }
8325
8326 if (!selectorContainsClassOrId) {
8327 for (k=0; k < part.modifiers.length; k++) {
8328 modifier = part.modifiers[k];
8329 if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
8330 reporter.report(rule.desc, part.line, part.col, rule);
8331 }
8332 }
8333 }
8334 }
8335
8336 }
8337 });
8338 }
8339
8340 });
8341
8342 CSSLint.addRule({
8343 id: "vendor-prefix",
8344 name: "Require standard property with vendor prefix",
8345 desc: "When using a vendor-prefixed property, make sure to include the standard one.",
8346 url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",
8347 browsers: "All",
8348 init: function(parser, reporter) {
8349 "use strict";
8350 var rule = this,
8351 properties,
8352 num,
8353 propertiesToCheck = {
8354 "-webkit-border-radius": "border-radius",
8355 "-webkit-border-top-left-radius": "border-top-left-radius",
8356 "-webkit-border-top-right-radius": "border-top-right-radius",
8357 "-webkit-border-bottom-left-radius": "border-bottom-left-radius",
8358 "-webkit-border-bottom-right-radius": "border-bottom-right-radius",
8359
8360 "-o-border-radius": "border-radius",
8361 "-o-border-top-left-radius": "border-top-left-radius",
8362 "-o-border-top-right-radius": "border-top-right-radius",
8363 "-o-border-bottom-left-radius": "border-bottom-left-radius",
8364 "-o-border-bottom-right-radius": "border-bottom-right-radius",
8365
8366 "-moz-border-radius": "border-radius",
8367 "-moz-border-radius-topleft": "border-top-left-radius",
8368 "-moz-border-radius-topright": "border-top-right-radius",
8369 "-moz-border-radius-bottomleft": "border-bottom-left-radius",
8370 "-moz-border-radius-bottomright": "border-bottom-right-radius",
8371
8372 "-moz-column-count": "column-count",
8373 "-webkit-column-count": "column-count",
8374
8375 "-moz-column-gap": "column-gap",
8376 "-webkit-column-gap": "column-gap",
8377
8378 "-moz-column-rule": "column-rule",
8379 "-webkit-column-rule": "column-rule",
8380
8381 "-moz-column-rule-style": "column-rule-style",
8382 "-webkit-column-rule-style": "column-rule-style",
8383
8384 "-moz-column-rule-color": "column-rule-color",
8385 "-webkit-column-rule-color": "column-rule-color",
8386
8387 "-moz-column-rule-width": "column-rule-width",
8388 "-webkit-column-rule-width": "column-rule-width",
8389
8390 "-moz-column-width": "column-width",
8391 "-webkit-column-width": "column-width",
8392
8393 "-webkit-column-span": "column-span",
8394 "-webkit-columns": "columns",
8395
8396 "-moz-box-shadow": "box-shadow",
8397 "-webkit-box-shadow": "box-shadow",
8398
8399 "-moz-transform": "transform",
8400 "-webkit-transform": "transform",
8401 "-o-transform": "transform",
8402 "-ms-transform": "transform",
8403
8404 "-moz-transform-origin": "transform-origin",
8405 "-webkit-transform-origin": "transform-origin",
8406 "-o-transform-origin": "transform-origin",
8407 "-ms-transform-origin": "transform-origin",
8408
8409 "-moz-box-sizing": "box-sizing",
8410 "-webkit-box-sizing": "box-sizing"
8411 };
8412 function startRule() {
8413 properties = {};
8414 num = 1;
8415 }
8416 function endRule() {
8417 var prop,
8418 i,
8419 len,
8420 needed,
8421 actual,
8422 needsStandard = [];
8423
8424 for (prop in properties) {
8425 if (propertiesToCheck[prop]) {
8426 needsStandard.push({
8427 actual: prop,
8428 needed: propertiesToCheck[prop]
8429 });
8430 }
8431 }
8432
8433 for (i=0, len=needsStandard.length; i < len; i++) {
8434 needed = needsStandard[i].needed;
8435 actual = needsStandard[i].actual;
8436
8437 if (!properties[needed]) {
8438 reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
8439 } else {
8440 if (properties[needed][0].pos < properties[actual][0].pos) {
8441 reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
8442 }
8443 }
8444 }
8445
8446 }
8447
8448 parser.addListener("startrule", startRule);
8449 parser.addListener("startfontface", startRule);
8450 parser.addListener("startpage", startRule);
8451 parser.addListener("startpagemargin", startRule);
8452 parser.addListener("startkeyframerule", startRule);
8453 parser.addListener("startviewport", startRule);
8454
8455 parser.addListener("property", function(event) {
8456 var name = event.property.text.toLowerCase();
8457
8458 if (!properties[name]) {
8459 properties[name] = [];
8460 }
8461
8462 properties[name].push({
8463 name: event.property,
8464 value: event.value,
8465 pos: num++
8466 });
8467 });
8468
8469 parser.addListener("endrule", endRule);
8470 parser.addListener("endfontface", endRule);
8471 parser.addListener("endpage", endRule);
8472 parser.addListener("endpagemargin", endRule);
8473 parser.addListener("endkeyframerule", endRule);
8474 parser.addListener("endviewport", endRule);
8475 }
8476
8477 });
8478
8479 CSSLint.addRule({
8480 id: "zero-units",
8481 name: "Disallow units for 0 values",
8482 desc: "You don't need to specify units when a value is 0.",
8483 url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",
8484 browsers: "All",
8485 init: function(parser, reporter) {
8486 "use strict";
8487 var rule = this;
8488 parser.addListener("property", function(event) {
8489 var parts = event.value.parts,
8490 i = 0,
8491 len = parts.length;
8492
8493 while (i < len) {
8494 if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") {
8495 reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
8496 }
8497 i++;
8498 }
8499
8500 });
8501
8502 }
8503
8504 });
8505
8506 (function() {
8507 "use strict";
8508 var xmlEscape = function(str) {
8509 if (!str || str.constructor !== String) {
8510 return "";
8511 }
8512
8513 return str.replace(/["&><]/g, function(match) {
8514 switch (match) {
8515 case "\"":
8516 return "&quot;";
8517 case "&":
8518 return "&amp;";
8519 case "<":
8520 return "&lt;";
8521 case ">":
8522 return "&gt;";
8523 }
8524 });
8525 };
8526
8527 CSSLint.addFormatter({
8528 id: "checkstyle-xml",
8529 name: "Checkstyle XML format",
8530 startFormat: function() {
8531 return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
8532 },
8533 endFormat: function() {
8534 return "</checkstyle>";
8535 },
8536 readError: function(filename, message) {
8537 return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
8538 },
8539 formatResults: function(results, filename/*, options*/) {
8540 var messages = results.messages,
8541 output = [];
8542 var generateSource = function(rule) {
8543 if (!rule || !("name" in rule)) {
8544 return "";
8545 }
8546 return "net.csslint." + rule.name.replace(/\s/g, "");
8547 };
8548
8549
8550 if (messages.length > 0) {
8551 output.push("<file name=\""+filename+"\">");
8552 CSSLint.Util.forEach(messages, function (message) {
8553 if (!message.rollup) {
8554 output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
8555 " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
8556 }
8557 });
8558 output.push("</file>");
8559 }
8560
8561 return output.join("");
8562 }
8563 });
8564
8565 }());
8566
8567 CSSLint.addFormatter({
8568 id: "compact",
8569 name: "Compact, 'porcelain' format",
8570 startFormat: function() {
8571 "use strict";
8572 return "";
8573 },
8574 endFormat: function() {
8575 "use strict";
8576 return "";
8577 },
8578 formatResults: function(results, filename, options) {
8579 "use strict";
8580 var messages = results.messages,
8581 output = "";
8582 options = options || {};
8583 var capitalize = function(str) {
8584 return str.charAt(0).toUpperCase() + str.slice(1);
8585 };
8586
8587 if (messages.length === 0) {
8588 return options.quiet ? "" : filename + ": Lint Free!";
8589 }
8590
8591 CSSLint.Util.forEach(messages, function(message) {
8592 if (message.rollup) {
8593 output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
8594 } else {
8595 output += filename + ": line " + message.line +
8596 ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
8597 }
8598 });
8599
8600 return output;
8601 }
8602 });
8603
8604 CSSLint.addFormatter({
8605 id: "csslint-xml",
8606 name: "CSSLint XML format",
8607 startFormat: function() {
8608 "use strict";
8609 return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
8610 },
8611 endFormat: function() {
8612 "use strict";
8613 return "</csslint>";
8614 },
8615 formatResults: function(results, filename/*, options*/) {
8616 "use strict";
8617 var messages = results.messages,
8618 output = [];
8619 var escapeSpecialCharacters = function(str) {
8620 if (!str || str.constructor !== String) {
8621 return "";
8622 }
8623 return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
8624 };
8625
8626 if (messages.length > 0) {
8627 output.push("<file name=\""+filename+"\">");
8628 CSSLint.Util.forEach(messages, function (message) {
8629 if (message.rollup) {
8630 output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
8631 } else {
8632 output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
8633 " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
8634 }
8635 });
8636 output.push("</file>");
8637 }
8638
8639 return output.join("");
8640 }
8641 });
8642
8643 CSSLint.addFormatter({
8644 id: "json",
8645 name: "JSON",
8646 startFormat: function() {
8647 "use strict";
8648 this.json = [];
8649 return "";
8650 },
8651 endFormat: function() {
8652 "use strict";
8653 var ret = "";
8654 if (this.json.length > 0) {
8655 if (this.json.length === 1) {
8656 ret = JSON.stringify(this.json[0]);
8657 } else {
8658 ret = JSON.stringify(this.json);
8659 }
8660 }
8661 return ret;
8662 },
8663 formatResults: function(results, filename, options) {
8664 "use strict";
8665 if (results.messages.length > 0 || !options.quiet) {
8666 this.json.push({
8667 filename: filename,
8668 messages: results.messages,
8669 stats: results.stats
8670 });
8671 }
8672 return "";
8673 }
8674 });
8675
8676 CSSLint.addFormatter({
8677 id: "junit-xml",
8678 name: "JUNIT XML format",
8679 startFormat: function() {
8680 "use strict";
8681 return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
8682 },
8683 endFormat: function() {
8684 "use strict";
8685 return "</testsuites>";
8686 },
8687 formatResults: function(results, filename/*, options*/) {
8688 "use strict";
8689
8690 var messages = results.messages,
8691 output = [],
8692 tests = {
8693 "error": 0,
8694 "failure": 0
8695 };
8696 var generateSource = function(rule) {
8697 if (!rule || !("name" in rule)) {
8698 return "";
8699 }
8700 return "net.csslint." + rule.name.replace(/\s/g, "");
8701 };
8702 var escapeSpecialCharacters = function(str) {
8703
8704 if (!str || str.constructor !== String) {
8705 return "";
8706 }
8707
8708 return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
8709
8710 };
8711
8712 if (messages.length > 0) {
8713
8714 messages.forEach(function (message) {
8715 var type = message.type === "warning" ? "error" : message.type;
8716 if (!message.rollup) {
8717 output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
8718 output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
8719 output.push("</testcase>");
8720
8721 tests[type] += 1;
8722
8723 }
8724
8725 });
8726
8727 output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
8728 output.push("</testsuite>");
8729
8730 }
8731
8732 return output.join("");
8733
8734 }
8735 });
8736
8737 CSSLint.addFormatter({
8738 id: "lint-xml",
8739 name: "Lint XML format",
8740 startFormat: function() {
8741 "use strict";
8742 return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
8743 },
8744 endFormat: function() {
8745 "use strict";
8746 return "</lint>";
8747 },
8748 formatResults: function(results, filename/*, options*/) {
8749 "use strict";
8750 var messages = results.messages,
8751 output = [];
8752 var escapeSpecialCharacters = function(str) {
8753 if (!str || str.constructor !== String) {
8754 return "";
8755 }
8756 return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
8757 };
8758
8759 if (messages.length > 0) {
8760
8761 output.push("<file name=\""+filename+"\">");
8762 CSSLint.Util.forEach(messages, function (message) {
8763 if (message.rollup) {
8764 output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
8765 } else {
8766 var rule = "";
8767 if (message.rule && message.rule.id) {
8768 rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
8769 }
8770 output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
8771 " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
8772 }
8773 });
8774 output.push("</file>");
8775 }
8776
8777 return output.join("");
8778 }
8779 });
8780
8781 CSSLint.addFormatter({
8782 id: "text",
8783 name: "Plain Text",
8784 startFormat: function() {
8785 "use strict";
8786 return "";
8787 },
8788 endFormat: function() {
8789 "use strict";
8790 return "";
8791 },
8792 formatResults: function(results, filename, options) {
8793 "use strict";
8794 var messages = results.messages,
8795 output = "";
8796 options = options || {};
8797
8798 if (messages.length === 0) {
8799 return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
8800 }
8801
8802 output = "\n\ncsslint: There ";
8803 if (messages.length === 1) {
8804 output += "is 1 problem";
8805 } else {
8806 output += "are " + messages.length + " problems";
8807 }
8808 output += " in " + filename + ".";
8809
8810 var pos = filename.lastIndexOf("/"),
8811 shortFilename = filename;
8812
8813 if (pos === -1) {
8814 pos = filename.lastIndexOf("\\");
8815 }
8816 if (pos > -1) {
8817 shortFilename = filename.substring(pos+1);
8818 }
8819
8820 CSSLint.Util.forEach(messages, function (message, i) {
8821 output = output + "\n\n" + shortFilename;
8822 if (message.rollup) {
8823 output += "\n" + (i+1) + ": " + message.type;
8824 output += "\n" + message.message;
8825 } else {
8826 output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
8827 output += "\n" + message.message;
8828 output += "\n" + message.evidence;
8829 }
8830 });
8831
8832 return output;
8833 }
8834 });
8835
8836 return CSSLint;
8837 })();
8838
8839
8840 module.exports.CSSLint = CSSLint;
8841
8842 });
8843
8844 ace.define("ace/mode/css_worker",[], function(require, exports, module) {
8845 "use strict";
8846
8847 var oop = require("../lib/oop");
8848 var lang = require("../lib/lang");
8849 var Mirror = require("../worker/mirror").Mirror;
8850 var CSSLint = require("./css/csslint").CSSLint;
8851
8852 var Worker = exports.Worker = function(sender) {
8853 Mirror.call(this, sender);
8854 this.setTimeout(400);
8855 this.ruleset = null;
8856 this.setDisabledRules("ids|order-alphabetical");
8857 this.setInfoRules(
8858 "adjoining-classes|zero-units|gradients|box-model|" +
8859 "import|outline-none|vendor-prefix"
8860 );
8861 };
8862
8863 oop.inherits(Worker, Mirror);
8864
8865 (function() {
8866 this.setInfoRules = function(ruleNames) {
8867 if (typeof ruleNames == "string")
8868 ruleNames = ruleNames.split("|");
8869 this.infoRules = lang.arrayToMap(ruleNames);
8870 this.doc.getValue() && this.deferredUpdate.schedule(100);
8871 };
8872
8873 this.setDisabledRules = function(ruleNames) {
8874 if (!ruleNames) {
8875 this.ruleset = null;
8876 } else {
8877 if (typeof ruleNames == "string")
8878 ruleNames = ruleNames.split("|");
8879 var all = {};
8880
8881 CSSLint.getRules().forEach(function(x){
8882 all[x.id] = true;
8883 });
8884 ruleNames.forEach(function(x) {
8885 delete all[x];
8886 });
8887
8888 this.ruleset = all;
8889 }
8890 this.doc.getValue() && this.deferredUpdate.schedule(100);
8891 };
8892
8893 this.onUpdate = function() {
8894 var value = this.doc.getValue();
8895 if (!value)
8896 return this.sender.emit("annotate", []);
8897 var infoRules = this.infoRules;
8898
8899 var result = CSSLint.verify(value, this.ruleset);
8900 this.sender.emit("annotate", result.messages.map(function(msg) {
8901 return {
8902 row: msg.line - 1,
8903 column: msg.col - 1,
8904 text: msg.message,
8905 type: infoRules[msg.rule.id] ? "info" : msg.type,
8906 rule: msg.rule.name
8907 };
8908 }));
8909 };
8910
8911 }).call(Worker.prototype);
8912
8913 });