From 379fe6036ee108ca8ebe0ed2254a98e14960a01d Mon Sep 17 00:00:00 2001 From: konn Date: Tue, 8 Jul 2008 17:22:08 +0000 Subject: [PATCH] * Added ul tag with CSS for au XHTML converter. git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/modchxj/mod_chxj/branches/sandbox@2852 1a406e8e-add9-4483-a2c8-d8cac5b7c224 --- src/chxj_xhtml_mobile_1_0.c | 39 ++- .../test_chxj_xhtml_mobile_1_0.c | 382 ++++++++++++++++++++- 2 files changed, 414 insertions(+), 7 deletions(-) diff --git a/src/chxj_xhtml_mobile_1_0.c b/src/chxj_xhtml_mobile_1_0.c index 0bb3348c..f3276b8c 100644 --- a/src/chxj_xhtml_mobile_1_0.c +++ b/src/chxj_xhtml_mobile_1_0.c @@ -1838,7 +1838,8 @@ s_xhtml_1_0_start_ul_tag(void *pdoc, Node *node) xhtml_t *xhtml = GET_XHTML(pdoc); Doc *doc = xhtml->doc; Attr *attr; - W_L("entryp)) { + css_prop_list_t *style = s_xhtml_1_0_push_and_get_now_style(pdoc, node, attr_style); + if (style) { + css_property_t *list_style_type_prop = chxj_css_get_property_value(doc, style, "list-style-type"); + css_property_t *cur; + for (cur = list_style_type_prop->next; cur != list_style_type_prop; cur = cur->next) { + if (STRCASEEQ('d','D',"disc",cur->value)) { + attr_type = apr_pstrdup(doc->pool, "disc"); + } + else if (STRCASEEQ('c','C',"circle",cur->value)) { + attr_type = apr_pstrdup(doc->pool, "circle"); + } + else if (STRCASEEQ('s','S',"square",cur->value)) { + attr_type = apr_pstrdup(doc->pool, "square"); + } + } + } + } + W_L(""); return xhtml->out; @@ -1875,6 +1903,9 @@ s_xhtml_1_0_end_ul_tag(void *pdoc, Node *UNUSED(child)) Doc *doc = xhtml->doc; W_L(""); + if (IS_CSS_ON(xhtml->entryp)) { + chxj_css_pop_prop_list(xhtml->css_prop_stack); + } return xhtml->out; } diff --git a/test/chxj_xhtml_mobile_1_0/test_chxj_xhtml_mobile_1_0.c b/test/chxj_xhtml_mobile_1_0/test_chxj_xhtml_mobile_1_0.c index 7bd7dd46..384bc7d1 100644 --- a/test/chxj_xhtml_mobile_1_0/test_chxj_xhtml_mobile_1_0.c +++ b/test/chxj_xhtml_mobile_1_0/test_chxj_xhtml_mobile_1_0.c @@ -551,6 +551,16 @@ void test_xhtml_p_tag_with_css_010(); void test_xhtml_p_tag_with_css_011(); void test_xhtml_p_tag_with_css_012(); void test_xhtml_p_tag_with_css_013(); + +void test_xhtml_ul_tag_with_css_001(); +void test_xhtml_ul_tag_with_css_002(); +void test_xhtml_ul_tag_with_css_003(); +void test_xhtml_ul_tag_with_css_004(); +void test_xhtml_ul_tag_with_css_005(); +void test_xhtml_ul_tag_with_css_006(); +void test_xhtml_ul_tag_with_css_007(); +void test_xhtml_ul_tag_with_css_008(); +void test_xhtml_ul_tag_with_css_009(); /* pend */ int @@ -1138,6 +1148,16 @@ main() CU_add_test(xhtml_suite, "test p with css 011", test_xhtml_p_tag_with_css_011); CU_add_test(xhtml_suite, "test p with css 012", test_xhtml_p_tag_with_css_012); CU_add_test(xhtml_suite, "test p with css 013", test_xhtml_p_tag_with_css_013); + + CU_add_test(xhtml_suite, "test ul with css 001", test_xhtml_ul_tag_with_css_001); + CU_add_test(xhtml_suite, "test ul with css 002", test_xhtml_ul_tag_with_css_002); + CU_add_test(xhtml_suite, "test ul with css 003", test_xhtml_ul_tag_with_css_003); + CU_add_test(xhtml_suite, "test ul with css 004", test_xhtml_ul_tag_with_css_004); + CU_add_test(xhtml_suite, "test ul with css 005", test_xhtml_ul_tag_with_css_005); + CU_add_test(xhtml_suite, "test ul with css 006", test_xhtml_ul_tag_with_css_006); + CU_add_test(xhtml_suite, "test ul with css 007", test_xhtml_ul_tag_with_css_007); + CU_add_test(xhtml_suite, "test ul with css 008", test_xhtml_ul_tag_with_css_008); + CU_add_test(xhtml_suite, "test ul with css 009", test_xhtml_ul_tag_with_css_009); /* aend */ CU_basic_run_tests(); @@ -11897,7 +11917,7 @@ void test_xhtml_ul_tag_005() void test_xhtml_ul_tag_006() { #define TEST_STRING "
  • abc
" -#define RESULT_STRING "
  • abc
" +#define RESULT_STRING "
  • abc
" char *ret; char *tmp; device_table spec; @@ -11926,7 +11946,7 @@ void test_xhtml_ul_tag_006() void test_xhtml_ul_tag_007() { #define TEST_STRING "
  • abc
" -#define RESULT_STRING "
  • abc
" +#define RESULT_STRING "
  • abc
" char *ret; char *tmp; device_table spec; @@ -11955,7 +11975,7 @@ void test_xhtml_ul_tag_007() void test_xhtml_ul_tag_008() { #define TEST_STRING "
  • abc
" -#define RESULT_STRING "
  • abc
" +#define RESULT_STRING "
  • abc
" char *ret; char *tmp; device_table spec; @@ -15152,6 +15172,362 @@ void test_xhtml_p_tag_with_css_013() #undef TEST_STRING #undef RESULT_STRING } + + +/*===========================================================================*/ +/* ul tag with CSS */ +/*===========================================================================*/ +char *test_chxj_serf_get014(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "ul { list-style-type: disc }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_xhtml_ul_tag_with_css_001() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get014; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get015(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "ul { list-style-type: circle }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_xhtml_ul_tag_with_css_002() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get015; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +char *test_chxj_serf_get016(request_rec *r, apr_pool_t *ppool, const char *uri_path, int ss, apr_size_t *len) +{ + static char *css = "a:focus { display: none }\n" + "a:link { display: none }\n" + "a { display: none }\n" + "hr { display: none }\n" + "a:visited { display:none }\n" + "ul { list-style-type: square }\n"; + *len = strlen(css); + call_check = 1; + return css; +} +void test_xhtml_ul_tag_with_css_003() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get016; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 1); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_004() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_005() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_006() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_007() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_008() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} +void test_xhtml_ul_tag_with_css_009() +{ +#define TEST_STRING "" \ + "
    あいう
" +#define RESULT_STRING "" \ + "" \ + "
    あいう
" + char *ret; + char *tmp; + device_table spec; + chxjconvrule_entry entry; + cookie_t cookie; + apr_size_t destlen; + APR_INIT; + chxj_serf_get = test_chxj_serf_get013; + call_check = 0; + + COOKIE_INIT(cookie); + + SPEC_INIT(spec); + destlen = sizeof(TEST_STRING)-1; + entry.action |= CONVRULE_CSS_ON_BIT; + + tmp = chxj_encoding(&r, TEST_STRING, &destlen); + ret = chxj_convert_xhtml_mobile_1_0(&r, &spec, tmp, destlen, &destlen, &entry, &cookie); + ret = chxj_rencoding(&r, ret, &destlen); + CU_ASSERT(ret != NULL); + CU_ASSERT(strcmp(RESULT_STRING, ret) == 0); + CU_ASSERT(destlen == sizeof(RESULT_STRING)-1); + CU_ASSERT(call_check == 0); + + APR_TERM; +#undef TEST_STRING +#undef RESULT_STRING +} /* * vim:ts=2 et */ -- 2.11.0