diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-06-26 15:00:12 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-06-26 15:00:12 +0000 |
commit | 2e9e28395eb8c832d9d0b4c943aa243a1aaf00af (patch) | |
tree | a173c5fb2ba20374067d17b8ff77cba9ffccabf7 /src | |
parent | f87fc9dbb774906dd8c2db4d6094e14b0667fa74 (diff) | |
download | libcss-2e9e28395eb8c832d9d0b4c943aa243a1aaf00af.tar.gz libcss-2e9e28395eb8c832d9d0b4c943aa243a1aaf00af.tar.bz2 |
Make selection ignore selectors generated by rules in inactive @media blocks.
svn path=/trunk/libcss/; revision=8015
Diffstat (limited to 'src')
-rw-r--r-- | src/select/select.c | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/src/select/select.c b/src/select/select.c index 453289c..e6e9116 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -569,9 +569,28 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, /* Process any matching selectors */ while (*selectors != NULL) { - error = match_selector_chain(ctx, *selectors, state); - if (error != CSS_OK) - goto cleanup; + css_rule *rule; + bool process = true; + + /* Ignore any selectors contained in rules which are a child + * of an @media block that doesn't match the current media + * requirements. */ + for (rule = (*selectors)->rule; + rule->ptype != CSS_RULE_PARENT_STYLESHEET; + rule = rule->parent) { + if (rule->type == CSS_RULE_MEDIA && + (((css_rule_media *) rule)->media & + state->media) == 0) { + process = false; + break; + } + } + + if (process) { + error = match_selector_chain(ctx, *selectors, state); + if (error != CSS_OK) + goto cleanup; + } error = css_selector_hash_iterate(sheet->selectors, selectors, &selectors); @@ -587,9 +606,28 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, /* Process any matching selectors */ while (*selectors != NULL) { - error = match_selector_chain(ctx, *selectors, state); - if (error != CSS_OK) - goto cleanup; + css_rule *rule; + bool process = true; + + /* Ignore any selectors contained in rules which are a child + * of an @media block that doesn't match the current media + * requirements. */ + for (rule = (*selectors)->rule; + rule->ptype != CSS_RULE_PARENT_STYLESHEET; + rule = rule->parent) { + if (rule->type == CSS_RULE_MEDIA && + (((css_rule_media *) rule)->media & + state->media) == 0) { + process = false; + break; + } + } + + if (process) { + error = match_selector_chain(ctx, *selectors, state); + if (error != CSS_OK) + goto cleanup; + } error = css_selector_hash_iterate(sheet->selectors, selectors, &selectors); |