diff --git a/rcssmin.c b/rcssmin.c index eb28720..716954c 100644 --- a/rcssmin.c +++ b/rcssmin.c @@ -1,5 +1,5 @@ /* - * Copyright 2011 + * Copyright 2011 - 2014 * Andr\xe9 Malo or his licensors, as applicable * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -126,6 +126,26 @@ static const rchar pattern_keyframes[] = { U('K'), U('E'), U('Y'), U('F'), U('R'), U('A'), U('M'), U('E'), U('S') }; +static const rchar pattern_vendor_o[] = { + U('-'), U('o'), U('-'), + U('-'), U('O'), U('-') +}; + +static const rchar pattern_vendor_moz[] = { + U('-'), U('m'), U('o'), U('z'), U('-'), + U('-'), U('M'), U('O'), U('Z'), U('-') +}; + +static const rchar pattern_vendor_webkit[] = { + U('-'), U('w'), U('e'), U('b'), U('k'), U('i'), U('t'), U('-'), + U('-'), U('W'), U('E'), U('B'), U('K'), U('I'), U('T'), U('-') +}; + +static const rchar pattern_vendor_ms[] = { + U('-'), U('m'), U('s'), U('-'), + U('-'), U('M'), U('S'), U('-') +}; + static const rchar pattern_first[] = { U('f'), U('i'), U('r'), U('s'), U('t'), U('-'), U('l'), U('F'), U('I'), U('R'), U('S'), U('T'), U('-'), U('L') @@ -549,15 +569,21 @@ copy_at_group(const rchar **source_, rchar **target_, rcssmin_ctx_t *ctx) target = *target_, \ IMATCH(what, &source, &target, ctx) \ ) +#define CMATCH(what) IMATCH(what, &source, &target, ctx) - if (( !IMATCH(media, &source, &target, ctx) + if (( !CMATCH(media) && !REMATCH(supports) + && !REMATCH(document) && !REMATCH(keyframes) - && !REMATCH(document)) + && !(REMATCH(vendor_webkit) && CMATCH(keyframes)) + && !(REMATCH(vendor_moz) && CMATCH(keyframes)) + && !(REMATCH(vendor_o) && CMATCH(keyframes)) + && !(REMATCH(vendor_ms) && CMATCH(keyframes))) || !(source < ctx->sentinel && target < ctx->tsentinel) || RCSSMIN_IS_NMCHAR(*source)) ABORT; +#undef CMATCH #undef REMATCH ++ctx->at_group; diff --git a/rcssmin.py b/rcssmin.py index afe4532..49371b0 100755 --- a/rcssmin.py +++ b/rcssmin.py @@ -193,8 +193,11 @@ def _make_cssmin(python_only=False): r'|(@(?:' r'[mM][eE][dD][iI][aA]' r'|[sS][uU][pP][pP][oO][rR][tT][sS]' - r'|[kK][eE][yY][fF][rR][aA][mM][eE][sS]' r'|[dD][oO][cC][uU][mM][eE][nN][tT]' + r'|(?:-(?:' + r'[wW][eE][bB][kK][iI][tT]|[mM][oO][zZ]|[oO]|[mM][sS]' + r')-)?' + r'[kK][eE][yY][fF][rR][aA][mM][eE][sS]' r'))(?!%(nmchar)s)' r'|(%(ie7hack)s)(%(space)s*)' r'|(:[fF][iI][rR][sS][tT]-[lL]'