Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/css/Properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var Properties = {
"animation-duration" : { multi: "<time>", comma: true },
"animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
"animation-iteration-count" : { multi: "<number> | infinite", comma: true },
"animation-name" : { multi: "none | <ident>", comma: true },
"animation-name" : { multi: "none | initial | inherit | unset | <single-animation-name>", comma: true },
"animation-play-state" : { multi: "running | paused", comma: true },
"animation-timing-function" : 1,

Expand All @@ -27,29 +27,29 @@ var Properties = {
"-moz-animation-direction" : { multi: "normal | alternate", comma: true },
"-moz-animation-duration" : { multi: "<time>", comma: true },
"-moz-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
"-moz-animation-name" : { multi: "none | <ident>", comma: true },
"-moz-animation-name" : { multi: "none | initial | inherit | unset | <single-animation-name>", comma: true },
"-moz-animation-play-state" : { multi: "running | paused", comma: true },

"-ms-animation-delay" : { multi: "<time>", comma: true },
"-ms-animation-direction" : { multi: "normal | alternate", comma: true },
"-ms-animation-duration" : { multi: "<time>", comma: true },
"-ms-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
"-ms-animation-name" : { multi: "none | <ident>", comma: true },
"-ms-animation-name" : { multi: "none | initial | inherit | unset | <single-animation-name>", comma: true },
"-ms-animation-play-state" : { multi: "running | paused", comma: true },

"-webkit-animation-delay" : { multi: "<time>", comma: true },
"-webkit-animation-direction" : { multi: "normal | alternate", comma: true },
"-webkit-animation-duration" : { multi: "<time>", comma: true },
"-webkit-animation-fill-mode" : { multi: "none | forwards | backwards | both", comma: true },
"-webkit-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
"-webkit-animation-name" : { multi: "none | <ident>", comma: true },
"-webkit-animation-name" : { multi: "none | initial | inherit | unset | <single-animation-name>", comma: true },
"-webkit-animation-play-state" : { multi: "running | paused", comma: true },

"-o-animation-delay" : { multi: "<time>", comma: true },
"-o-animation-direction" : { multi: "normal | alternate", comma: true },
"-o-animation-duration" : { multi: "<time>", comma: true },
"-o-animation-iteration-count" : { multi: "<number> | infinite", comma: true },
"-o-animation-name" : { multi: "none | <ident>", comma: true },
"-o-animation-name" : { multi: "none | initial | inherit | unset | <single-animation-name>", comma: true },
"-o-animation-play-state" : { multi: "running | paused", comma: true },

"appearance" : "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 | none | inherit",
Expand Down Expand Up @@ -315,18 +315,22 @@ var Properties = {
"-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
"float" : "left | right | none | inherit",
"float-offset" : 1,
"font" : 1,
"font-family" : 1,
"font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar | inherit",
"font-family" : "<font-family> | inherit",
"font-feature-settings" : "<feature-tag-value> | normal | inherit",
"font-kerning" : "auto | normal | none | initial | inherit | unset",
"font-size" : "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
"font-size" : "<font-size> | inherit",
"font-size-adjust" : "<number> | none | inherit",
"font-stretch" : "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
"font-style" : "normal | italic | oblique | inherit",
"font-variant" : "normal | small-caps | inherit",
"font-variant-caps" : "normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps",
"font-stretch" : "<font-stretch> | inherit",
"font-style" : "<font-style> | inherit",
"font-variant" : "<font-variant> | normal | none | inherit",
"font-variant-alternates" : "<font-variant-alternates> | normal | inherit",
"font-variant-caps" : "<font-variant-caps> | normal | inherit",
"font-variant-east-asian" : "<font-variant-east-asian> | normal | inherit",
"font-variant-ligatures" : "<font-variant-ligatures> | normal | none | inherit",
"font-variant-numeric" : "<font-variant-numeric> | normal | inherit",
"font-variant-position" : "normal | sub | super | inherit | initial | unset",
"font-weight" : "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
"font-weight" : "<font-weight> | inherit",

//G
"glyph-orientation-horizontal" : "<glyph-angle> | inherit",
Expand Down Expand Up @@ -384,7 +388,7 @@ var Properties = {
//L
"left" : "<margin-width> | inherit",
"letter-spacing" : "<length> | normal | inherit",
"line-height" : "<number> | <length> | <percentage> | normal | inherit",
"line-height" : "<line-height> | inherit",
"line-break" : "auto | loose | normal | strict",
"line-stacking" : 1,
"line-stacking-ruby" : "exclude-ruby | include-ruby",
Expand Down Expand Up @@ -557,7 +561,7 @@ var Properties = {
"white-space-collapse" : 1,
"widows" : "<integer> | inherit",
"width" : "<length> | <percentage> | <content-sizing> | auto | inherit",
"will-change" : { multi: "<ident>", comma: true },
"will-change" : "<will-change> | inherit | initial | unset",
"word-break" : "normal | keep-all | break-all",
"word-spacing" : "<length> | normal | inherit",
"word-wrap" : "normal | break-word",
Expand Down
131 changes: 130 additions & 1 deletion src/css/ValidationTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ ValidationTypes = {
return part.type === "identifier" || part.wasIdent;
},

"<single-animation-name>": function(part) {
return this["<ident>"](part) &&
/^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
!/^(none|unset|initial|inherit)$/i.test(part);
},

"<animateable-feature-name>": function(part) {
return this["<ident>"](part) &&
!/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
},

"<string>": function(part){
return part.type === "string";
},

"<length>": function(part){
if (part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)){
return true;
Expand Down Expand Up @@ -528,12 +543,46 @@ ValidationTypes = {
part, "blur() | brightness() | contrast() | custom() | " +
"drop-shadow() | grayscale() | hue-rotate() | invert() | " +
"opacity() | saturate() | sepia()");
},

"<generic-family>": function(part){
return ValidationTypes.isLiteral(part, "serif | sans-serif | cursive | fantasy | monospace");
},

"<ident-not-generic-family>": function(part){
return this["<ident>"](part) && !this["<generic-family>"](part);
},

"<font-size>": function(part){
var result = this["<absolute-size>"](part) || this["<relative-size>"](part) || this["<length>"](part) || this["<percentage>"](part);
return result;
},

"<font-stretch>": function(part){
return ValidationTypes.isLiteral(part, "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded");
},

"<font-style>": function(part){
return ValidationTypes.isLiteral(part, "normal | italic | oblique");
},

"<font-weight>": function(part){
return ValidationTypes.isLiteral(part, "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900");
},

"<line-height>": function(part){
var result = this["<number>"](part) || this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "normal");
return result;
}
},

complex: {
__proto__: null,

"<animateable-feature>":
// scroll-position | contents | <custom-ident>
Matcher.cast("scroll-position | contents | <animateable-feature-name>"),

"<bg-position>": Matcher.cast("<position>").hash(),

"<bg-size>":
Expand Down Expand Up @@ -622,8 +671,88 @@ ValidationTypes = {
// * inherit
Matcher.alt("none", "inherit", Matcher.cast("<flex-grow>").then(Matcher.cast("<flex-shrink>").question()).oror("<flex-basis>")),

"<font-family>":
// [ <family-name> | <generic-family> ]#
Matcher.cast("<generic-family> | <family-name>").hash(),

"<family-name>":
// <string> | <IDENT>+
Matcher.alt("<string>",
Matcher.seq("<ident-not-generic-family>",
Matcher.cast("<ident>").star())),

"<font-variant-alternates>":
Matcher.oror(// stylistic(<feature-value-name>)
"stylistic()",
"historical-forms",
// styleset(<feature-value-name> #)
"styleset()",
// character-variant(<feature-value-name> #)
"character-variant()",
// swash(<feature-value-name>)
"swash()",
// ornaments(<feature-value-name>)
"ornaments()",
// annotation(<feature-value-name>)
"annotation()"),

"<font-variant-caps>":
Matcher.cast("small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps"),

"<font-variant-css21>":
Matcher.cast("normal | small-caps"),

"<font-variant-ligatures>":
Matcher.oror(// <common-lig-values>
"common-ligatures | no-common-ligatures",
// <discretionary-lig-values>
"discretionary-ligatures | no-discretionary-ligatures",
// <historical-lig-values>
"historical-ligatures | no-historical-ligatures",
// <contextual-alt-values>
"contextual | no-contextual"),

"<font-variant-numeric>":
Matcher.oror(// <numeric-figure-values>
"lining-nums | oldstyle-nums",
// <numeric-spacing-values>
"proportional-nums | tabular-nums",
// <numeric-fraction-values>
"diagonal-fractions | stacked-fractions",
"ordinal",
"slashed-zero"),

"<font-variant-east-asian>":
Matcher.oror(// <east-asian-variant-values>
"jis78 | jis83 | jis90 | jis04 | simplified | traditional",
// <east-asian-width-values>
"full-width | proportional-width",
"ruby"),

"<font-shorthand>":
Matcher.seq(Matcher.oror("<font-style>",
"<font-variant-css21>",
"<font-weight>",
"<font-stretch>").question(),
"<font-size>",
Matcher.seq("/", "<line-height>").question(),
"<font-family>"),

"<text-decoration>":
// none | [ underline || overline || line-through || blink ] | inherit
Matcher.oror("underline", "overline", "line-through", "blink")
Matcher.oror("underline", "overline", "line-through", "blink"),

"<will-change>":
// auto | <animateable-feature>#
Matcher.alt("auto", Matcher.cast("<animateable-feature>").hash())
}
};

// Because this is defined relative to other complex validation types,
// we need to define it *after* the rest of the types are initialized.
ValidationTypes.complex["<font-variant>"] =
Matcher.oror({ expand: "<font-variant-ligatures>" },
{ expand: "<font-variant-alternates>" },
"<font-variant-caps>",
{ expand: "<font-variant-numeric>" },
{ expand: "<font-variant-east-asian>" });
Loading