diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2012-08-26 11:38:40 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2012-08-26 11:38:40 +0100 |
commit | 71d28981207beb72b3ca68a9fa24948615a6a9bd (patch) | |
tree | 8a01fba1e8d7c75de97ae13589cdd07d431a5a3b | |
parent | 18aea52cfc1086999ce2463ccd08c5813341d32f (diff) | |
download | libcss-71d28981207beb72b3ca68a9fa24948615a6a9bd.tar.gz libcss-71d28981207beb72b3ca68a9fa24948615a6a9bd.tar.bz2 |
Skip empty/broken rules early, before we match their selector chains.
-rw-r--r-- | src/select/select.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/select/select.c b/src/select/select.c index 3543dd5..ba35262 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -1379,13 +1379,19 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, selector = _selector_next(node_selectors, id_selectors, class_selectors, n_classes, univ_selectors); - /* Ignore any selectors contained in rules which are a child - * of an @media block that doesn't match the current media - * requirements. */ - if (_rule_applies_to_media(selector->rule, state->media)) { - error = match_selector_chain(ctx, selector, state); - if (error != CSS_OK) - goto cleanup; + /* No bytecode if rule body is empty or wholly invalid -- + * Only interested in rules with bytecode */ + if (((css_rule_selector *) selector->rule)->style != NULL) { + /* Ignore any selectors contained in rules which are a + * child of an @media block that doesn't match the + * current media requirements. */ + if (_rule_applies_to_media(selector->rule, + state->media)) { + error = match_selector_chain(ctx, selector, + state); + if (error != CSS_OK) + goto cleanup; + } } /* Advance to next selector in whichever chain we extracted @@ -1531,10 +1537,6 @@ css_error match_selector_chain(css_select_ctx *ctx, /* If we got here, then the entire selector chain matched, so cascade */ state->current_specificity = selector->specificity; - /* No bytecode if rule body is empty or wholly invalid */ - if (((css_rule_selector *) selector->rule)->style == NULL) - return CSS_OK; - /* Ensure that the appropriate computed style exists */ if (state->results->styles[pseudo] == NULL) { error = css_computed_style_create(ctx->alloc, ctx->pw, |