#include <libgen.h>
+#if defined(CHXJ_TEST)
+#undef ap_regex_t
+#undef ap_regmatch_t
+#endif
+
#undef list_insert
#undef list_remove
#define list_insert(node, point) do { \
static int s_is_already_imported(struct css_already_import_stack *imported_stack_head, const char *url);
static css_stylesheet_t *s_merge_stylesheet(apr_pool_t *pool, css_stylesheet_t *old_stylesheet, css_stylesheet_t *new_stylesheet);
static void s_copy_already_import_stack(apr_pool_t *pool, struct css_already_import_stack *base, struct css_already_import_stack *imported_stack);
+static css_selector_t *s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesheet_t *stylesheet, const char *pattern_str1, const char *pattern_str2, Node *node);
+static void s_get_tag_and_class_and_id(Doc *doc, Node *node, char **tag_name, char **class_name, char **id);
+static char *s_cmp_now_node_vs_current_style(Doc *doc, request_rec *r, apr_pool_t *pool, char *src, ap_regex_t *pattern4, Node *node);
/**
* Data is acquired from url specified by using libserf.
/**
* find selector engine.
- * @param r request_rec
- * @param pool pool
+ * @param doc Doc structure.
* @param stylesheet Retrieval object.
- * @param tag_name tag name.
- * @param class_name class name.
- * @param id id.
+ * @param node this node.
* @return css_selector_t if any. null if not found.
*
*/
css_selector_t *
-chxj_css_find_selector(request_rec *r, apr_pool_t *pool, css_stylesheet_t *stylesheet, const char *tag_name, const char *class_name, const char *id)
+chxj_css_find_selector(Doc *doc, css_stylesheet_t *stylesheet, Node *node)
{
+ request_rec *r = doc->r;
+ apr_pool_t *pool = doc->pool;
css_selector_t *sel = NULL;
css_selector_t *cur = NULL;
+ css_selector_t *tail = NULL;
+ char *tag_name = NULL;
+ char *class_name = NULL;
+ char *id = NULL;
+ Attr *attr;
DBG(r, "start chxj_css_find_selector()");
- for (cur = stylesheet->selector_head.next; cur != &stylesheet->selector_head; cur = cur->next) {
- DBG(r, "cur->name:[%s]", cur->name);
+
+ s_get_tag_and_class_and_id(doc, node, &tag_name, &class_name, &id);
+
+ if (! tag_name || strcasecmp("ROOT", tag_name) == 0) {
+ ERR(r, "%s:%d tag_name is null", APLOG_MARK);
+ return NULL;
+ }
+ char *pattern_str1 = NULL;
+ char *pattern_str2 = NULL;
+ if (class_name && id) {
+ pattern_str1 = apr_psprintf(pool,
+ "^((%s|\\*)(\\.%s)?(#%s)?|(\\*|)\\.%s(#%s)?|(\\*|)(\\.%s)?#%s)$",
+ tag_name,
+ class_name,
+ id,
+ class_name,
+ id,
+ class_name,
+ id);
+ pattern_str2 = apr_psprintf(pool,
+ ".*([ >+])((%s|\\*)(\\.%s)?(#%s)?|(\\*|)\\.%s(#%s)?|(\\*|)(\\.%s)?#%s)$",
+ tag_name,
+ class_name,
+ id,
+ class_name,
+ id,
+ class_name,
+ id);
+ sel = s_search_selector_regexp(doc, r, pool, stylesheet, pattern_str1, pattern_str2, node);
+ if (sel) {
+ DBG(r, "end chxj_css_find_selector()");
+ return sel;
+ }
+ }
+ else if (id) {
+ pattern_str1 = apr_psprintf(pool,
+ "^((%s|\\*)(#%s)?|(\\*|)(#%s)?|(\\*|)#%s)$",
+ tag_name,
+ id,
+ id,
+ id);
+ pattern_str2 = apr_psprintf(pool,
+ ".*([ >+])((%s|\\*)(#%s)?|(\\*|)(#%s)?|(\\*|)#%s)$",
+ tag_name,
+ id,
+ id,
+ id);
+ sel = s_search_selector_regexp(doc, r, pool, stylesheet, pattern_str1, pattern_str2, node);
+ if (sel) {
+ DBG(r, "end chxj_css_find_selector()");
+ return sel;
+ }
}
+ else if (class_name) {
+ pattern_str1 = apr_psprintf(pool,
+ "^((%s|\\*)(\\.%s)?|(\\*|)\\.%s|(\\*|)(\\.%s))$",
+ tag_name,
+ class_name,
+ class_name,
+ class_name);
+ pattern_str2 = apr_psprintf(pool,
+ ".*([ >+])((%s|\\*)(\\.%s)?|(\\*|)\\.%s|(\\*|)(\\.%s)?)$",
+ tag_name,
+ class_name,
+ class_name,
+ class_name);
+ sel = s_search_selector_regexp(doc, r, pool, stylesheet, pattern_str1, pattern_str2, node);
+ if (sel) {
+ DBG(r, "end chxj_css_find_selector()");
+ return sel;
+ }
+ }
+ else {
+ pattern_str1 = apr_psprintf(pool,
+ "^(%s|\\*)$",
+ tag_name);
+ pattern_str2 = apr_psprintf(pool,
+ ".*([ >+])(%s|\\*)$",
+ tag_name);
+ sel = s_search_selector_regexp(doc, r, pool, stylesheet, pattern_str1, pattern_str2, node);
+ if (sel) {
+ DBG(r, "end chxj_css_find_selector()");
+ return sel;
+ }
+ }
+
DBG(r, "end chxj_css_find_selector()");
return sel;
}
/* STATIC */
/* */
/*===========================================================================*/
+static css_selector_t *
+s_search_selector_regexp(Doc *doc, request_rec *r, apr_pool_t *pool, css_stylesheet_t *stylesheet, const char *pattern_str1, const char *pattern_str2, Node *node)
+{
+ Node *node_sv = node;
+ css_selector_t *tail;
+ css_selector_t *cur;
+ DBG(r, "pattern1:[%s]", pattern_str1);
+ DBG(r, "pattern2:[%s]", pattern_str2);
+ ap_regex_t *pattern1 = chxj_ap_pregcomp(pool, pattern_str1, AP_REG_EXTENDED|AP_REG_ICASE);
+ ap_regex_t *pattern2 = chxj_ap_pregcomp(pool, pattern_str2, AP_REG_EXTENDED|AP_REG_ICASE);
+ ap_regex_t *pattern3 = chxj_ap_pregcomp(pool, "^.*([>+ ])([^>+ ]+?)$", AP_REG_EXTENDED|AP_REG_ICASE);
+ ap_regex_t *pattern4 = chxj_ap_pregcomp(pool, "^([^.#]+?)(\\.[^#]+?)?(#.+?)?$", AP_REG_EXTENDED|AP_REG_ICASE);
+
+ tail = (css_selector_t *)((apr_size_t)stylesheet->selector_head.ref - (apr_size_t)APR_OFFSETOF(css_selector_t, next));
+ for (cur = tail;
+ cur != &stylesheet->selector_head;
+ cur = (css_selector_t *)((apr_size_t)cur->ref - (apr_size_t)APR_OFFSETOF(css_selector_t, next))) {
+ ap_regmatch_t match[256];
+ DBG(r, "cur->name:[%s]", cur->name);
+ if (chxj_ap_regexec(pattern1, cur->name, pattern1->re_nsub + 1, match, 0) == 0) {
+ DBG(r, "match(independent of)");
+ return cur;
+ }
+ else
+ if (chxj_ap_regexec(pattern2, cur->name, pattern2->re_nsub + 1, match, 0) == 0) {
+ DBG(r, "match(depend on) [%s]", cur->name);
+ char *src = apr_pstrdup(pool, cur->name);
+ char *one = chxj_ap_pregsub(pool, "$1",src, pattern2->re_nsub + 1, match);
+ int loop = 0;
+ do {
+ DBG(r, "start do while");
+ node = node->parent;
+ *strrchr(src, *one) = 0;
+ switch (*one) {
+ case '>': /* Child selectors */
+ DBG(r, "child selectors");
+ if (chxj_ap_regexec(pattern3, src, pattern3->re_nsub + 1, match, 0) == 0) {
+ DBG(r, "has any parent");
+ one = chxj_ap_pregsub(pool, "$1",src, pattern3->re_nsub + 1, match);
+ char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, strrchr(src, *one)+1, pattern4, node);
+ if (ret) {
+ DBG(r, "continue do while");
+ loop = 1;
+ }
+ }
+ else {
+ DBG(r, "parent:[%x]", node);
+ DBG(r, "parent->name:[%s] src:[%s]", node->name, src);
+ char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, src, pattern4, node);
+ if (ret) return ret;
+ loop = 0;
+ }
+ break;
+ case '+': /* Adjacent sibling selectors */
+ loop = 0;
+ break;
+ case ' ': /* Descendant selectors */
+ DBG(r, "descendant selectors");
+ if (chxj_ap_regexec(pattern3, src, pattern3->re_nsub + 1, match, 0) == 0) {
+ DBG(r, "has any parent");
+ one = chxj_ap_pregsub(pool, "$1",src, pattern3->re_nsub + 1, match);
+ for (; node; node = node->parent) {
+ if (strcasecmp(node->name, "ROOT") == 0) {
+ DBG(r, "unmatch");
+ loop = 0;
+ break;
+ }
+ char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, strrchr(src, *one)+1, pattern4, node);
+ if (ret) {
+ DBG(r, "continue do while");
+ loop = 1;
+ break;
+ }
+ }
+ }
+ else {
+ DBG(r, "parent:[%x]", node);
+ DBG(r, "parent->name:[%s] src:[%s]", node->name, src);
+ for (; node; node = node->parent) {
+ if (strcasecmp(node->name, "ROOT") == 0) {
+ DBG(r, "unmatch");
+ loop = 0;
+ break;
+ }
+ char *ret = s_cmp_now_node_vs_current_style(doc, r, pool, src, pattern4, node);
+ if (ret) return ret;
+ }
+ }
+ break;
+ default:
+ loop = 0;
+ DBG(r, "unmatch(unknown separator)");
+ }
+ } while(loop);
+ node = node_sv;
+ }
+ DBG(r, "unmatch [%s]", cur->name);
+ }
+ chxj_ap_pregfree(pool, pattern1);
+ chxj_ap_pregfree(pool, pattern2);
+ return NULL;
+}
static css_stylesheet_t *
s_chxj_css_parse_from_uri(request_rec *r, apr_pool_t *pool, struct css_already_import_stack *imported_stack, css_stylesheet_t *old_stylesheet, const char *uri)
{
}
}
+static void
+s_get_tag_and_class_and_id(Doc *doc, Node *node, char **tag_name, char **class_name, char **id)
+{
+ Attr *attr;
+ *tag_name = node->name;
+ for (attr = qs_get_attr(doc, node); attr; attr = qs_get_next_attr(doc,attr)) {
+ char *name = qs_get_attr_name(doc,attr);
+ char *value = qs_get_attr_value(doc,attr);
+ if (STRCASEEQ('c','C', "class", name)) {
+ if (*value != 0) {
+ *class_name = value;
+ }
+ }
+ else
+ if (STRCASEEQ('i','I', "id", name)) {
+ if (*value != 0) {
+ *id = value;
+ }
+ }
+ if (*id && *class_name) break;
+ }
+}
+
+static char *
+s_cmp_now_node_vs_current_style(Doc *doc, request_rec *r, apr_pool_t *pool, char *src, ap_regex_t *pattern4, Node *node)
+{
+ ap_regmatch_t match[256];
+ if (chxj_ap_regexec(pattern4, src, pattern4->re_nsub + 1, match, 0) == 0) {
+ char *tag_name = chxj_ap_pregsub(pool, "$1", src, pattern4->re_nsub + 1, match);
+ char *class_name = chxj_ap_pregsub(pool, "$2", src, pattern4->re_nsub + 1, match);
+ char *id_name = chxj_ap_pregsub(pool, "$3", src, pattern4->re_nsub + 1, match);
+ DBG(r, "tag:[%s] class:[%s] id:[%s]", tag_name, class_name, id_name);
+ if (!node) {
+ DBG(r, "unmatch(parent is null)");
+ return NULL;
+ }
+ char *node_tag_name = NULL;
+ char *node_class_name = NULL;
+ char *node_id_name = NULL;
+ s_get_tag_and_class_and_id(doc, node, &node_tag_name, &node_class_name, &node_id_name);
+ if (strcasecmp(node_tag_name, tag_name) == 0 || strcmp("*", tag_name) == 0) {
+ if (class_name && *class_name != 0) {
+ if (strcasecmp(node_class_name, &class_name[1]) != 0) {
+ DBG(r, "unmatch (class) node:[%s] style:[%s]", node_class_name, &class_name[1]);
+ return NULL;
+ }
+ }
+ if (id_name && *id_name != 0) {
+ if (strcasecmp(node_id_name, &id_name[1]) != 0) {
+ DBG(r, "unmatch (id)");
+ return NULL;
+ }
+ }
+ DBG(r, "match");
+ return src;
+ }
+ DBG(r, "unmatch(tag) tag:[%s] vs [%s]", tag_name, node_tag_name);
+ }
+ return NULL;
+}
+
#if 0
css_stylesheet_t *
chxj_css_parse_from_style_tag(apr_pool_t *pool, css_stylesheet_t *old_stylesheet, const char *style_value)
#include "chxj_url_encode.c"
#include "chxj_apache.c"
#include "chxj_str_util.c"
+#include "qs_malloc.c"
+#include "qs_parse_string.c"
+#include "qs_log.c"
+#include "qs_parse_tag.c"
+#include "qs_parse_attr.c"
+#include "qs_ignore_sp.c"
void test_chxj_css_parse_from_uri_006();
void test_chxj_css_parse_from_uri_007();
void test_chxj_css_parse_from_uri_008();
-void test_chxj_css_parse_from_uri_009();
+
+/* chxj_css_find_selector */
+void test_chxj_css_find_selector_001();
+void test_chxj_css_find_selector_002();
+void test_chxj_css_find_selector_003();
+void test_chxj_css_find_selector_004();
+void test_chxj_css_find_selector_005();
+void test_chxj_css_find_selector_006();
+void test_chxj_css_find_selector_007();
+void test_chxj_css_find_selector_unmatch_pattern_001();
+void test_chxj_css_find_selector_unmatch_pattern_002();
+void test_chxj_css_find_selector_unmatch_pattern_003();
+/* E > F */
+void test_chxj_css_find_selector_p_001();
+void test_chxj_css_find_selector_p_002();
+void test_chxj_css_find_selector_p_003();
+void test_chxj_css_find_selector_p_004();
+void test_chxj_css_find_selector_p_005();
+void test_chxj_css_find_selector_p_006();
+void test_chxj_css_find_selector_p_007();
+void test_chxj_css_find_selector_p_008();
+void test_chxj_css_find_selector_p_009();
+
+/* E F */
+void test_chxj_css_find_selector_des_001();
+void test_chxj_css_find_selector_des_002();
+void test_chxj_css_find_selector_des_003();
+void test_chxj_css_find_selector_des_004();
+void test_chxj_css_find_selector_des_005();
/* pend */
int
CU_add_test(css_suite, "test css 006", test_chxj_css_parse_from_uri_006);
CU_add_test(css_suite, "test css 007", test_chxj_css_parse_from_uri_007);
CU_add_test(css_suite, "test css 008", test_chxj_css_parse_from_uri_008);
- CU_add_test(css_suite, "test css 009", test_chxj_css_parse_from_uri_009);
+ CU_add_test(css_suite, "test css find_selector 001", test_chxj_css_find_selector_001);
+ CU_add_test(css_suite, "test css find_selector 002", test_chxj_css_find_selector_002);
+ CU_add_test(css_suite, "test css find_selector 003", test_chxj_css_find_selector_003);
+ CU_add_test(css_suite, "test css find_selector 004", test_chxj_css_find_selector_004);
+ CU_add_test(css_suite, "test css find_selector 005", test_chxj_css_find_selector_005);
+ CU_add_test(css_suite, "test css find_selector 006", test_chxj_css_find_selector_006);
+ CU_add_test(css_suite, "test css find_selector 007", test_chxj_css_find_selector_007);
+ CU_add_test(css_suite, "test css find_selector unmatch 001", test_chxj_css_find_selector_unmatch_pattern_001);
+ CU_add_test(css_suite, "test css find_selector unmatch 002", test_chxj_css_find_selector_unmatch_pattern_002);
+ CU_add_test(css_suite, "test css find_selector unmatch 003", test_chxj_css_find_selector_unmatch_pattern_003);
+ CU_add_test(css_suite, "test css find_selector with '>' 001", test_chxj_css_find_selector_p_001);
+ CU_add_test(css_suite, "test css find_selector with '>' 002", test_chxj_css_find_selector_p_002);
+ CU_add_test(css_suite, "test css find_selector with '>' 003", test_chxj_css_find_selector_p_003);
+ CU_add_test(css_suite, "test css find_selector with '>' 004", test_chxj_css_find_selector_p_004);
+ CU_add_test(css_suite, "test css find_selector with '>' 005", test_chxj_css_find_selector_p_005);
+ CU_add_test(css_suite, "test css find_selector with '>' 006", test_chxj_css_find_selector_p_006);
+ CU_add_test(css_suite, "test css find_selector with '>' 007", test_chxj_css_find_selector_p_007);
+ CU_add_test(css_suite, "test css find_selector with '>' 008", test_chxj_css_find_selector_p_008);
+ CU_add_test(css_suite, "test css find_selector with '>' 009", test_chxj_css_find_selector_p_009);
+
+ CU_add_test(css_suite, "test css find_selector with ' ' 001", test_chxj_css_find_selector_des_001);
+ CU_add_test(css_suite, "test css find_selector with ' ' 002", test_chxj_css_find_selector_des_002);
+ CU_add_test(css_suite, "test css find_selector with ' ' 003", test_chxj_css_find_selector_des_003);
+ CU_add_test(css_suite, "test css find_selector with ' ' 004", test_chxj_css_find_selector_des_004);
+ CU_add_test(css_suite, "test css find_selector with ' ' 005", test_chxj_css_find_selector_des_005);
/* aend */
CU_basic_run_tests();
}
-
+/*===========================================================================*/
+/* */
+/* chxj_css_find_selector */
+/* */
+/*===========================================================================*/
char *test_chxj_serf_get009(request_rec *r, apr_pool_t *ppool, const char *uri_path)
{
- static char *css = "html { display: none }";
+ static char *css = "html,body, hr.abc#id1 { display: none }";
return css;
}
-void test_chxj_css_parse_from_uri_009()
+void test_chxj_css_find_selector_001()
{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
css_stylesheet_t *ret;
css_selector_t *sel;
APR_INIT;
chxj_serf_get = test_chxj_serf_get009;
+ fprintf(stderr, "start %s\n", __func__);
+
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+#undef TEST_STRING
+ fprintf(stderr, "end %s\n", __func__);
+}
+
+
+
+char *test_chxj_serf_get010(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, .abc#id1 { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_002()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get010;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+
+char *test_chxj_serf_get011(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, #id1 { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_003()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get011;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+
+char *test_chxj_serf_get012(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, .abc { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_004()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get012;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+char *test_chxj_serf_get013(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, hr.abc { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_005()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get013;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+
+char *test_chxj_serf_get014(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, hr#id1 { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_006()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get014;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+
+char *test_chxj_serf_get015(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_007()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get015;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+
+char *test_chxj_serf_get016(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, li { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_unmatch_pattern_001()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get016;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get017(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, hr.def { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_unmatch_pattern_002()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get017;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get018(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, hr#id2 { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_unmatch_pattern_003()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get018;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+/*===========================================================================*/
+/* E > F */
+/*===========================================================================*/
+char *test_chxj_serf_get019(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, body>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_001()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get019;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get020(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html>body>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_002()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get020;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get021(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html>body>div>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_003()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get021;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get022(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html>body>div>div>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_004()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get022;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get023(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html>body>div.def#id2>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_005()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get023;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get024(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html>body>div.abc#id2>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_006()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get024;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get025(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, body>*.def#id2>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_007()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get025;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get026(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, body.def#id2>*.def#id2>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_008()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get026;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+char *test_chxj_serf_get027(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, body.abc#id2>*.def#id2>hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_p_009()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><hr class=\"abc\" id=\"id1\"></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get027;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get028(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, body hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_des_001()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get028;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get029(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html body hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_des_002()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get029;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get030(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html body.def#id2 hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_des_003()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get030;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get031(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html body.abc#id2 hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_des_004()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get031;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+
+ apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
+
+ ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
+ CU_ASSERT(ret != NULL);
+
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel == NULL);
+ APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
+}
+
+char *test_chxj_serf_get032(request_rec *r, apr_pool_t *ppool, const char *uri_path)
+{
+ static char *css = "html,body, html body.def hr { display: none }";
+
+ return css;
+}
+void test_chxj_css_find_selector_des_005()
+{
+#define TEST_STRING "<html><head></head><body class=\"def\" id=\"id2\"><div class=\"def\" id=\"id2\"><div><hr class=\"abc\" id=\"id1\"></div></div></body></html>"
+ Doc doc;
+ Node *node;
+ Node *tmp_node;
+ Node *node_sv;
+ css_stylesheet_t *ret;
+ css_selector_t *sel;
+ APR_INIT;
+ chxj_serf_get = test_chxj_serf_get032;
+
+ fprintf(stderr, "start %s\n", __func__);
+ doc.r = &r;
+ qs_init_malloc(&doc);
+ qs_init_root_node(&doc);
+ doc.parse_mode = PARSE_MODE_CHTML;
+
+ node_sv = node = qs_parse_string(&doc, TEST_STRING, sizeof(TEST_STRING)-1);
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->next;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
+ tmp_node = node->child;
+ node = tmp_node;
apr_uri_parse(p, "http://localhost:888/abc", &r.parsed_uri); \
ret = chxj_css_parse_from_uri(&r, r.pool, NULL, "/hoge.css");
CU_ASSERT(ret != NULL);
- sel = chxj_css_find_selector(&r, r.pool, ret, "html", NULL, NULL);
+ sel = chxj_css_find_selector(&doc, ret, node);
+ CU_ASSERT(sel != NULL);
APR_TERM;
+ fprintf(stderr, "end %s\n", __func__);
+#undef TEST_STRING
}
/*
* vim:ts=2 et