Skip to content

Commit 7195850

Browse files
committed
Updated parser to the latest
1 parent 955e8cb commit 7195850

File tree

1 file changed

+53
-17
lines changed

1 file changed

+53
-17
lines changed

lib/parserlib.js

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
24+
/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
931931
THE SOFTWARE.
932932
933933
*/
934-
/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
934+
/* Version v0.2.2, Build time: 17-January-2013 10:26:34 */
935935
(function(){
936936
var EventTarget = parserlib.util.EventTarget,
937937
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -1080,7 +1080,36 @@ var Colors = {
10801080
white :"#ffffff",
10811081
whitesmoke :"#f5f5f5",
10821082
yellow :"#ffff00",
1083-
yellowgreen :"#9acd32"
1083+
yellowgreen :"#9acd32",
1084+
//CSS2 system colors http://www.w3.org/TR/css3-color/#css2-system
1085+
activeBorder :"Active window border.",
1086+
activecaption :"Active window caption.",
1087+
appworkspace :"Background color of multiple document interface.",
1088+
background :"Desktop background.",
1089+
buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
1090+
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.",
1091+
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.",
1092+
buttontext :"Text on push buttons.",
1093+
captiontext :"Text in caption, size box, and scrollbar arrow box.",
1094+
graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
1095+
highlight :"Item(s) selected in a control.",
1096+
highlighttext :"Text of item(s) selected in a control.",
1097+
inactiveborder :"Inactive window border.",
1098+
inactivecaption :"Inactive window caption.",
1099+
inactivecaptiontext :"Color of text in an inactive caption.",
1100+
infobackground :"Background color for tooltip controls.",
1101+
infotext :"Text color for tooltip controls.",
1102+
menu :"Menu background.",
1103+
menutext :"Text in menus.",
1104+
scrollbar :"Scroll bar gray area.",
1105+
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.",
1106+
threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
1107+
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.",
1108+
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.",
1109+
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.",
1110+
window :"Window background.",
1111+
windowframe :"Window frame.",
1112+
windowtext :"Text in windows."
10841113
};
10851114
/*global SyntaxUnit, Parser*/
10861115
/**
@@ -1169,7 +1198,7 @@ MediaFeature.prototype.constructor = MediaFeature;
11691198
*/
11701199
function MediaQuery(modifier, mediaType, features, line, col){
11711200

1172-
SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType + " " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
1201+
SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
11731202

11741203
/**
11751204
* The media modifier ("not" or "only")
@@ -1908,18 +1937,21 @@ Parser.prototype = function(){
19081937
});
19091938
},
19101939

1911-
_operator: function(){
1940+
_operator: function(inFunction){
19121941

19131942
/*
1914-
* operator
1943+
* operator (outside function)
19151944
* : '/' S* | ',' S* | /( empty )/
1945+
* operator (inside function)
1946+
* : '/' S* | '+' S* | '*' S* | '-' S* /( empty )/
19161947
* ;
19171948
*/
19181949

19191950
var tokenStream = this._tokenStream,
19201951
token = null;
19211952

1922-
if (tokenStream.match([Tokens.SLASH, Tokens.COMMA])){
1953+
if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
1954+
(inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){
19231955
token = tokenStream.token();
19241956
this._readWhitespace();
19251957
}
@@ -2530,7 +2562,7 @@ Parser.prototype = function(){
25302562
while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
25312563
Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
25322564
Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
2533-
Tokens.RESOLUTION])){
2565+
Tokens.RESOLUTION, Tokens.SLASH])){
25342566

25352567
value += tokenStream.token().value;
25362568
value += this._readWhitespace();
@@ -2706,7 +2738,7 @@ Parser.prototype = function(){
27062738
return result;
27072739
},
27082740

2709-
_expr: function(){
2741+
_expr: function(inFunction){
27102742
/*
27112743
* expr
27122744
* : term [ operator term ]*
@@ -2725,8 +2757,8 @@ Parser.prototype = function(){
27252757
values.push(value);
27262758

27272759
do {
2728-
operator = this._operator();
2729-
2760+
operator = this._operator(inFunction);
2761+
27302762
//if there's an operator, keep building up the value parts
27312763
if (operator){
27322764
values.push(operator);
@@ -2862,7 +2894,7 @@ Parser.prototype = function(){
28622894
if (tokenStream.match(Tokens.FUNCTION)){
28632895
functionText = tokenStream.token().value;
28642896
this._readWhitespace();
2865-
expr = this._expr();
2897+
expr = this._expr(true);
28662898
functionText += expr;
28672899

28682900
//START: Horrible hack in case it's an IE filter
@@ -3476,7 +3508,7 @@ var Properties = {
34763508
"-o-animation-name" : { multi: "none | <ident>", comma: true },
34773509
"-o-animation-play-state" : { multi: "running | paused", comma: true },
34783510

3479-
"appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | 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 | inherit",
3511+
"appearance" : "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | 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 | none | inherit",
34803512
"azimuth" : function (expression) {
34813513
var simple = "<angle> | leftwards | rightwards | inherit",
34823514
direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side",
@@ -3685,7 +3717,7 @@ var Properties = {
36853717

36863718
//D
36873719
"direction" : "ltr | rtl | inherit",
3688-
"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 | box | inline-box | grid | inline-grid | none | inherit",
3720+
"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 | box | inline-box | grid | inline-grid | none | inherit | -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",
36893721
"dominant-baseline" : 1,
36903722
"drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
36913723
"drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
@@ -3888,7 +3920,7 @@ var Properties = {
38883920
"user-select" : "none | text | toggle | element | elements | all | inherit",
38893921

38903922
//V
3891-
"vertical-align" : "<percentage> | <length> | baseline | sub | super | top | text-top | middle | bottom | text-bottom | inherit",
3923+
"vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
38923924
"visibility" : "visible | hidden | collapse | inherit",
38933925
"voice-balance" : 1,
38943926
"voice-duration" : 1,
@@ -3901,7 +3933,7 @@ var Properties = {
39013933
"volume" : 1,
39023934

39033935
//W
3904-
"white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit",
3936+
"white-space" : "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", //http://perishablepress.com/wrapping-content/
39053937
"white-space-collapse" : 1,
39063938
"widows" : "<integer> | inherit",
39073939
"width" : "<length> | <percentage> | auto | inherit" ,
@@ -6061,7 +6093,11 @@ var ValidationTypes = {
60616093
},
60626094

60636095
"<length>": function(part){
6064-
return part.type == "length" || part.type == "number" || part.type == "integer" || part == "0";
6096+
if (part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
6097+
return true;
6098+
}else{
6099+
return part.type == "length" || part.type == "number" || part.type == "integer" || part == "0";
6100+
}
60656101
},
60666102

60676103
"<color>": function(part){

0 commit comments

Comments
 (0)