summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-02-09 19:10:47 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-02-09 19:10:47 +0000
commitaead1abef55aa88d19bf8b7b5c30b1b0d0255b0b (patch)
tree190305c308b7b7ca9cd7e0e75fe493fe256672c8
parent600c5449ee6929e3571d956285630fd58da79932 (diff)
downloadlibcss-aead1abef55aa88d19bf8b7b5c30b1b0d0255b0b.tar.gz
libcss-aead1abef55aa88d19bf8b7b5c30b1b0d0255b0b.tar.bz2
Match details
svn path=/trunk/libcss/; revision=6404
-rw-r--r--include/libcss/select.h22
-rw-r--r--src/select/select.c47
2 files changed, 64 insertions, 5 deletions
diff --git a/include/libcss/select.h b/include/libcss/select.h
index f51efe5..1226480 100644
--- a/include/libcss/select.h
+++ b/include/libcss/select.h
@@ -28,6 +28,28 @@ typedef struct css_select_handler {
css_error (*parent_node)(void *pw, void *node, void **parent);
css_error (*sibling_node)(void *pw, void *node, void **sibling);
+
+ css_error (*node_has_class)(void *pw, void *node,
+ const uint8_t *name, size_t len,
+ bool *match);
+ css_error (*node_has_id)(void *pw, void *node,
+ const uint8_t *name, size_t len,
+ bool *match);
+ css_error (*node_has_attribute)(void *pw, void *node,
+ const uint8_t *name, size_t len,
+ bool *match);
+ css_error (*node_has_attribute_equal)(void *pw, void *node,
+ const uint8_t *name, size_t nlen,
+ const uint8_t *value, size_t vlen,
+ bool *match);
+ css_error (*node_has_attribute_dashmatch)(void *pw, void *node,
+ const uint8_t *name, size_t nlen,
+ const uint8_t *value, size_t vlen,
+ bool *match);
+ css_error (*node_has_attribute_includes)(void *pw, void *node,
+ const uint8_t *name, size_t nlen,
+ const uint8_t *value, size_t vlen,
+ bool *match);
} css_select_handler;
css_error css_select_ctx_create(css_alloc alloc, void *pw,
diff --git a/src/select/select.c b/src/select/select.c
index c7748cf..687be85 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -624,13 +624,50 @@ css_error match_detail(css_select_ctx *ctx, void *node,
const css_selector_detail *detail, css_select_state *state,
bool *match)
{
+ css_error error = CSS_OK;
+
UNUSED(ctx);
- UNUSED(node);
- UNUSED(detail);
- UNUSED(state);
- UNUSED(match);
- return CSS_OK;
+ switch (detail->type) {
+ case CSS_SELECTOR_CLASS:
+ error = state->handler->node_has_class(state->pw, node,
+ detail->name->data, detail->name->len,
+ match);
+ break;
+ case CSS_SELECTOR_ID:
+ error = state->handler->node_has_id(state->pw, node,
+ detail->name->data, detail->name->len,
+ match);
+ break;
+ case CSS_SELECTOR_PSEUDO:
+ /** \todo pseudo classes/elements */
+ break;
+ case CSS_SELECTOR_ATTRIBUTE:
+ error = state->handler->node_has_attribute(state->pw, node,
+ detail->name->data, detail->name->len,
+ match);
+ break;
+ case CSS_SELECTOR_ATTRIBUTE_EQUAL:
+ error = state->handler->node_has_attribute_equal(state->pw,
+ node, detail->name->data, detail->name->len,
+ detail->value->data, detail->value->len,
+ match);
+ break;
+ case CSS_SELECTOR_ATTRIBUTE_DASHMATCH:
+ error = state->handler->node_has_attribute_dashmatch(state->pw,
+ node, detail->name->data, detail->name->len,
+ detail->value->data, detail->value->len,
+ match);
+ break;
+ case CSS_SELECTOR_ATTRIBUTE_INCLUDES:
+ error = state->handler->node_has_attribute_includes(state->pw,
+ node, detail->name->data, detail->name->len,
+ detail->value->data, detail->value->len,
+ match);
+ break;
+ }
+
+ return error;
}
css_error cascade_style(css_select_ctx *ctx, css_style *style,