1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

CSS: Count nested blocks when skipping.

When skipping "@media print { #foo {bar: baz} pre {white-space: normal} }",
the previous code would look for the first "{" and then the first "}", and
fail to skip the "pre" rule.  Seen at support.microsoft.com.

I originally posted this change as part of attachment 383 to bug 722.
This commit is contained in:
Kalle Olavi Niemitalo 2007-07-11 17:16:19 +03:00 committed by Kalle Olavi Niemitalo
parent 9c1873a517
commit 64da6774c2

View File

@ -90,12 +90,23 @@ ride_on:
}
}
static void
skip_css_block(struct scanner *scanner)
{
if (skip_css_tokens(scanner, '{')) {
const int preclimit = get_css_precedence('}');
int depth = 1;
struct scanner_token *token = get_scanner_token(scanner);
/* TODO: We should handle support for skipping blocks better like "{ { } }"
* will be handled correctly. --jonas */
#define skip_css_block(scanner) \
if (skip_css_tokens(scanner, '{')) skip_css_tokens(scanner, '}');
while (token && token->precedence <= preclimit && depth > 0) {
if (token->type == '{')
++depth;
else if (token->type == '}')
--depth;
token = get_next_scanner_token(scanner);
}
}
}
/* Atrules grammer:
*